diff options
Diffstat (limited to '')
4149 files changed, 50161 insertions, 19324 deletions
diff --git a/js/src/builtin/Array.cpp b/js/src/builtin/Array.cpp index 2ced07b6b9..868fae8bcf 100644 --- a/js/src/builtin/Array.cpp +++ b/js/src/builtin/Array.cpp @@ -51,6 +51,7 @@ # include "vm/TupleType.h" #endif +#include "builtin/Sorting-inl.h" #include "vm/ArgumentsObject-inl.h" #include "vm/ArrayObject-inl.h" #include "vm/GeckoProfiler-inl.h" @@ -439,7 +440,7 @@ bool js::GetElements(JSContext* cx, HandleObject aobj, uint32_t length, if (aobj->is<TypedArrayObject>()) { Handle<TypedArrayObject*> typedArray = aobj.as<TypedArrayObject>(); if (typedArray->length().valueOr(0) == length) { - return TypedArrayObject::getElements(cx, typedArray, vp); + return TypedArrayObject::getElements(cx, typedArray, length, vp); } } @@ -2180,44 +2181,16 @@ static bool ArraySortWithoutComparator(JSContext* cx, Handle<JSObject*> obj, return true; } -void ArraySortData::init(JSObject* obj, JSObject* comparator, ValueVector&& vec, - uint32_t length, uint32_t denseLen) { - MOZ_ASSERT(!vec.empty(), "must have items to sort"); - MOZ_ASSERT(denseLen <= length); - - obj_ = obj; - comparator_ = comparator; - - this->length = length; - this->denseLen = denseLen; - this->vec = std::move(vec); - - auto getComparatorKind = [](JSContext* cx, JSObject* comparator) { - if (!comparator->is<JSFunction>()) { - return ComparatorKind::Unoptimized; - } - JSFunction* fun = &comparator->as<JSFunction>(); - if (!fun->hasJitEntry() || fun->isClassConstructor()) { - return ComparatorKind::Unoptimized; - } - if (fun->realm() == cx->realm() && fun->nargs() <= ComparatorActualArgs) { - return ComparatorKind::JSSameRealmNoRectifier; - } - return ComparatorKind::JS; - }; - comparatorKind_ = getComparatorKind(cx(), comparator); -} - // This function handles sorting without a comparator function (or with a // trivial comparator function that we can pattern match) by calling // ArraySortWithoutComparator. // // If there's a non-trivial comparator function, it initializes the -// ArraySortData struct for ArraySortData::sortWithComparator. This function -// must be called next to perform the sorting. +// ArraySortData struct for ArraySortData::sortArrayWithComparator. This +// function must be called next to perform the sorting. // -// This is separate from ArraySortData::sortWithComparator because it lets the -// compiler generate better code for ArraySortData::sortWithComparator. +// This is separate from ArraySortData::sortArrayWithComparator because it lets +// the compiler generate better code for ArraySortData::sortArrayWithComparator. // // https://tc39.es/ecma262/#sec-array.prototype.sort // 23.1.3.30 Array.prototype.sort ( comparefn ) @@ -2280,7 +2253,7 @@ static MOZ_ALWAYS_INLINE bool ArraySortPrologue(JSContext* cx, uint32_t len = uint32_t(length); // Merge sort requires extra scratch space. - bool needsScratchSpace = len >= ArraySortData::InsertionSortLimit; + bool needsScratchSpace = len > ArraySortData::InsertionSortMaxLength; Rooted<ArraySortData::ValueVector> vec(cx); if (MOZ_UNLIKELY(!vec.reserve(needsScratchSpace ? (2 * len) : len))) { @@ -2323,13 +2296,13 @@ static MOZ_ALWAYS_INLINE bool ArraySortPrologue(JSContext* cx, } d->init(obj, &comparefn.toObject(), std::move(vec.get()), len, denseLen); - // Continue in ArraySortData::sortWithComparator. + // Continue in ArraySortData::sortArrayWithComparator. MOZ_ASSERT(!*done); return true; } -static ArraySortResult CallComparatorSlow(ArraySortData* d, const Value& x, - const Value& y) { +ArraySortResult js::CallComparatorSlow(ArraySortData* d, const Value& x, + const Value& y) { JSContext* cx = d->cx(); FixedInvokeArgs<2> callArgs(cx); callArgs[0].set(x); @@ -2343,230 +2316,15 @@ static ArraySortResult CallComparatorSlow(ArraySortData* d, const Value& x, return ArraySortResult::Done; } -static MOZ_ALWAYS_INLINE ArraySortResult -MaybeYieldToComparator(ArraySortData* d, const Value& x, const Value& y) { - // https://tc39.es/ecma262/#sec-comparearrayelements - // 23.1.3.30.2 CompareArrayElements ( x, y, comparefn ) - - // Steps 1-2. - if (x.isUndefined()) { - d->setComparatorReturnValue(Int32Value(y.isUndefined() ? 0 : 1)); - return ArraySortResult::Done; - } - - // Step 3. - if (y.isUndefined()) { - d->setComparatorReturnValue(Int32Value(-1)); - return ArraySortResult::Done; - } - - // Step 4. Yield to the JIT trampoline (or js::array_sort) if the comparator - // is a JS function we can call more efficiently from JIT code. - auto kind = d->comparatorKind(); - if (MOZ_LIKELY(kind != ArraySortData::ComparatorKind::Unoptimized)) { - d->setComparatorArgs(x, y); - return (kind == ArraySortData::ComparatorKind::JSSameRealmNoRectifier) - ? ArraySortResult::CallJSSameRealmNoRectifier - : ArraySortResult::CallJS; - } - return CallComparatorSlow(d, x, y); -} - -static MOZ_ALWAYS_INLINE bool RvalIsLessOrEqual(ArraySortData* data, - bool* lessOrEqual) { - // https://tc39.es/ecma262/#sec-comparearrayelements - // 23.1.3.30.2 CompareArrayElements ( x, y, comparefn ) - - // Fast path for int32 return values. - Value rval = data->comparatorReturnValue(); - if (MOZ_LIKELY(rval.isInt32())) { - *lessOrEqual = rval.toInt32() <= 0; - return true; - } - - // Step 4.a. - Rooted<Value> rvalRoot(data->cx(), rval); - double d; - if (MOZ_UNLIKELY(!ToNumber(data->cx(), rvalRoot, &d))) { - return false; - } - - // Step 4.b-c. - *lessOrEqual = std::isnan(d) ? true : (d <= 0); - return true; -} - -static void CopyValues(Value* out, const Value* list, uint32_t start, - uint32_t end) { - for (uint32_t i = start; i <= end; i++) { - out[i] = list[i]; - } -} - // static -ArraySortResult ArraySortData::sortWithComparator(ArraySortData* d) { - JSContext* cx = d->cx(); - auto& vec = d->vec; - - // This function is like a generator that is called repeatedly from the JIT - // trampoline or js::array_sort. Resume the sorting algorithm where we left - // off before calling the comparator. - switch (d->state) { - case State::Initial: - break; - case State::InsertionSortCall1: - goto insertion_sort_call1; - case State::InsertionSortCall2: - goto insertion_sort_call2; - case State::MergeSortCall1: - goto merge_sort_call1; - case State::MergeSortCall2: - goto merge_sort_call2; - } - - d->list = vec.begin(); - - // Use insertion sort for small arrays. - if (d->denseLen < InsertionSortLimit) { - for (d->i = 1; d->i < d->denseLen; d->i++) { - d->item = vec[d->i]; - d->j = d->i - 1; - do { - { - ArraySortResult res = MaybeYieldToComparator(d, vec[d->j], d->item); - if (res != ArraySortResult::Done) { - d->state = State::InsertionSortCall1; - return res; - } - } - insertion_sort_call1: - bool lessOrEqual; - if (!RvalIsLessOrEqual(d, &lessOrEqual)) { - return ArraySortResult::Failure; - } - if (lessOrEqual) { - break; - } - vec[d->j + 1] = vec[d->j]; - } while (d->j-- > 0); - vec[d->j + 1] = d->item; - } - } else { - static constexpr size_t InitialWindowSize = 4; - - // Use insertion sort for initial ranges. - for (d->start = 0; d->start < d->denseLen - 1; - d->start += InitialWindowSize) { - d->end = - std::min<uint32_t>(d->start + InitialWindowSize - 1, d->denseLen - 1); - for (d->i = d->start + 1; d->i <= d->end; d->i++) { - d->item = vec[d->i]; - d->j = d->i - 1; - do { - { - ArraySortResult res = MaybeYieldToComparator(d, vec[d->j], d->item); - if (res != ArraySortResult::Done) { - d->state = State::InsertionSortCall2; - return res; - } - } - insertion_sort_call2: - bool lessOrEqual; - if (!RvalIsLessOrEqual(d, &lessOrEqual)) { - return ArraySortResult::Failure; - } - if (lessOrEqual) { - break; - } - vec[d->j + 1] = vec[d->j]; - } while (d->j-- > d->start); - vec[d->j + 1] = d->item; - } - } - - // Merge sort. Set d->out to scratch space initially. - d->out = vec.begin() + d->denseLen; - for (d->windowSize = InitialWindowSize; d->windowSize < d->denseLen; - d->windowSize *= 2) { - for (d->start = 0; d->start < d->denseLen; - d->start += 2 * d->windowSize) { - // The midpoint between the two subarrays. - d->mid = d->start + d->windowSize - 1; - - // To keep from going over the edge. - d->end = std::min<uint32_t>(d->start + 2 * d->windowSize - 1, - d->denseLen - 1); - - // Merge comparator-sorted slices list[start..<=mid] and - // list[mid+1..<=end], storing the merged sequence in out[start..<=end]. - - // Skip lopsided runs to avoid doing useless work. - if (d->mid >= d->end) { - CopyValues(d->out, d->list, d->start, d->end); - continue; - } - - // Skip calling the comparator if the sub-list is already sorted. - { - ArraySortResult res = - MaybeYieldToComparator(d, d->list[d->mid], d->list[d->mid + 1]); - if (res != ArraySortResult::Done) { - d->state = State::MergeSortCall1; - return res; - } - } - merge_sort_call1: - bool lessOrEqual; - if (!RvalIsLessOrEqual(d, &lessOrEqual)) { - return ArraySortResult::Failure; - } - if (lessOrEqual) { - CopyValues(d->out, d->list, d->start, d->end); - continue; - } - - d->i = d->start; - d->j = d->mid + 1; - d->k = d->start; - - while (d->i <= d->mid && d->j <= d->end) { - { - ArraySortResult res = - MaybeYieldToComparator(d, d->list[d->i], d->list[d->j]); - if (res != ArraySortResult::Done) { - d->state = State::MergeSortCall2; - return res; - } - } - merge_sort_call2: - bool lessOrEqual; - if (!RvalIsLessOrEqual(d, &lessOrEqual)) { - return ArraySortResult::Failure; - } - d->out[d->k++] = lessOrEqual ? d->list[d->i++] : d->list[d->j++]; - } - - // Empty out any remaining elements. Use local variables to let the - // compiler generate more efficient code. - Value* out = d->out; - Value* list = d->list; - uint32_t k = d->k; - uint32_t mid = d->mid; - uint32_t end = d->end; - for (uint32_t i = d->i; i <= mid; i++) { - out[k++] = list[i]; - } - for (uint32_t j = d->j; j <= end; j++) { - out[k++] = list[j]; - } - } - - // Swap both lists. - std::swap(d->list, d->out); - } +ArraySortResult ArraySortData::sortArrayWithComparator(ArraySortData* d) { + ArraySortResult result = sortWithComparatorShared<ArraySortKind::Array>(d); + if (result != ArraySortResult::Done) { + return result; } // Copy elements to the array. + JSContext* cx = d->cx(); Rooted<JSObject*> obj(cx, d->obj_); if (!SetArrayElements(cx, obj, 0, d->denseLen, d->list)) { return ArraySortResult::Failure; @@ -2600,9 +2358,9 @@ bool js::array_sort(JSContext* cx, unsigned argc, Value* vp) { Rooted<ArraySortData> data(cx, cx); - // On all return paths other than ArraySortWithComparatorLoop returning Done, - // we call freeMallocData to not fail debug assertions. This matches the JIT - // trampoline where we can't rely on C++ destructors. + // On all return paths other than ArraySortData::sortArrayWithComparator + // returning Done, we call freeMallocData to not fail debug assertions. This + // matches the JIT trampoline where we can't rely on C++ destructors. auto freeData = mozilla::MakeScopeExit([&]() { data.get().freeMallocData(); }); @@ -2620,7 +2378,8 @@ bool js::array_sort(JSContext* cx, unsigned argc, Value* vp) { Rooted<Value> rval(cx); while (true) { - ArraySortResult res = ArraySortData::sortWithComparator(data.address()); + ArraySortResult res = + ArraySortData::sortArrayWithComparator(data.address()); switch (res) { case ArraySortResult::Failure: return false; @@ -2666,21 +2425,7 @@ ArraySortResult js::ArraySortFromJit(JSContext* cx, return ArraySortResult::Done; } - return ArraySortData::sortWithComparator(data); -} - -ArraySortData::ArraySortData(JSContext* cx) : cx_(cx) { -#ifdef DEBUG - cx_->liveArraySortDataInstances++; -#endif -} - -void ArraySortData::freeMallocData() { - vec.clearAndFree(); -#ifdef DEBUG - MOZ_ASSERT(cx_->liveArraySortDataInstances > 0); - cx_->liveArraySortDataInstances--; -#endif + return ArraySortData::sortArrayWithComparator(data); } void ArraySortData::trace(JSTracer* trc) { diff --git a/js/src/builtin/Array.h b/js/src/builtin/Array.h index f861505e7b..1a8335f0d4 100644 --- a/js/src/builtin/Array.h +++ b/js/src/builtin/Array.h @@ -15,6 +15,8 @@ namespace js { +enum class ArraySortResult : uint32_t; + namespace jit { class TrampolineNativeFrameLayout; } @@ -172,144 +174,6 @@ extern bool ArrayLengthGetter(JSContext* cx, HandleObject obj, HandleId id, extern bool ArrayLengthSetter(JSContext* cx, HandleObject obj, HandleId id, HandleValue v, ObjectOpResult& result); -// Note: we use uint32_t because the JIT code uses branch32. -enum class ArraySortResult : uint32_t { - Failure, - Done, - CallJS, - CallJSSameRealmNoRectifier -}; - -// We use a JIT trampoline to optimize sorting with a comparator function. The -// trampoline frame has an ArraySortData instance that contains all state used -// by the sorting algorithm. The sorting algorithm is implemented as a C++ -// "generator" that can yield to the trampoline to perform a fast JIT => JIT -// call to the comparator function. When the comparator function returns, the -// trampoline calls back into C++ to resume the sorting algorithm. -// -// ArraySortData stores the JS Values in a js::Vector. To ensure we don't leak -// its memory, we have debug assertions to check that for each C++ constructor -// call we call |freeMallocData| exactly once. C++ code calls |freeMallocData| -// when it's done sorting and the JIT exception handler calls it when unwinding -// the trampoline frame. -class ArraySortData { - public: - enum class ComparatorKind : uint8_t { - Unoptimized, - JS, - JSSameRealmNoRectifier, - }; - - static constexpr size_t ComparatorActualArgs = 2; - - // Insertion sort is used if the length is < InsertionSortLimit. - static constexpr size_t InsertionSortLimit = 24; - - using ValueVector = GCVector<Value, 8, SystemAllocPolicy>; - - protected: // Silence Clang warning about unused private fields. - // Data for the comparator call. These fields must match the JitFrameLayout - // to let us perform efficient calls to the comparator from JIT code. - // This is asserted in the JIT trampoline code. - // callArgs[0] is also used to store the return value of the sort function and - // the comparator. - uintptr_t descriptor_; - JSObject* comparator_ = nullptr; - Value thisv; - Value callArgs[ComparatorActualArgs]; - - private: - ValueVector vec; - Value item; - JSContext* cx_; - JSObject* obj_ = nullptr; - - Value* list; - Value* out; - - // The value of the .length property. - uint32_t length; - - // The number of items to sort. Can be less than |length| if the object has - // holes. - uint32_t denseLen; - - uint32_t windowSize; - uint32_t start; - uint32_t mid; - uint32_t end; - uint32_t i, j, k; - - // The state value determines where we resume in sortWithComparator. - enum class State : uint8_t { - Initial, - InsertionSortCall1, - InsertionSortCall2, - MergeSortCall1, - MergeSortCall2 - }; - State state = State::Initial; - ComparatorKind comparatorKind_; - - // Optional padding to ensure proper alignment of the comparator JIT frame. -#if !defined(JS_64BIT) && !defined(DEBUG) - protected: // Silence Clang warning about unused private field. - size_t padding; -#endif - - public: - explicit ArraySortData(JSContext* cx); - - void MOZ_ALWAYS_INLINE init(JSObject* obj, JSObject* comparator, - ValueVector&& vec, uint32_t length, - uint32_t denseLen); - - JSContext* cx() const { return cx_; } - - JSObject* comparator() const { - MOZ_ASSERT(comparator_); - return comparator_; - } - - Value returnValue() const { return callArgs[0]; } - void setReturnValue(JSObject* obj) { callArgs[0].setObject(*obj); } - - Value comparatorArg(size_t index) { - MOZ_ASSERT(index < ComparatorActualArgs); - return callArgs[index]; - } - Value comparatorThisValue() const { return thisv; } - Value comparatorReturnValue() const { return callArgs[0]; } - void setComparatorArgs(const Value& x, const Value& y) { - callArgs[0] = x; - callArgs[1] = y; - } - void setComparatorReturnValue(const Value& v) { callArgs[0] = v; } - - ComparatorKind comparatorKind() const { return comparatorKind_; } - - static ArraySortResult sortWithComparator(ArraySortData* d); - - void freeMallocData(); - void trace(JSTracer* trc); - - static constexpr int32_t offsetOfDescriptor() { - return offsetof(ArraySortData, descriptor_); - } - static constexpr int32_t offsetOfComparator() { - return offsetof(ArraySortData, comparator_); - } - static constexpr int32_t offsetOfComparatorReturnValue() { - return offsetof(ArraySortData, callArgs[0]); - } - static constexpr int32_t offsetOfComparatorThis() { - return offsetof(ArraySortData, thisv); - } - static constexpr int32_t offsetOfComparatorArgs() { - return offsetof(ArraySortData, callArgs); - } -}; - extern ArraySortResult ArraySortFromJit( JSContext* cx, jit::TrampolineNativeFrameLayout* frame); diff --git a/js/src/builtin/AtomicsObject.cpp b/js/src/builtin/AtomicsObject.cpp index c4a221aab8..232108872c 100644 --- a/js/src/builtin/AtomicsObject.cpp +++ b/js/src/builtin/AtomicsObject.cpp @@ -280,6 +280,7 @@ bool AtomicAccess(JSContext* cx, HandleValue obj, HandleValue index, Op op) { return op(ArrayOps<int64_t>{}, unwrappedTypedArray, intIndex); case Scalar::BigUint64: return op(ArrayOps<uint64_t>{}, unwrappedTypedArray, intIndex); + case Scalar::Float16: case Scalar::Float32: case Scalar::Float64: case Scalar::Uint8Clamped: @@ -931,7 +932,7 @@ FutexThread::WaitResult js::FutexThread::wait( // See explanation below. if (state_ == WaitingInterrupted) { - UnlockGuard<Mutex> unlock(locked); + UnlockGuard unlock(locked); JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_ATOMICS_WAIT_NOT_ALLOWED); return WaitResult::Error; @@ -1032,7 +1033,7 @@ FutexThread::WaitResult js::FutexThread::wait( state_ = WaitingInterrupted; { - UnlockGuard<Mutex> unlock(locked); + UnlockGuard unlock(locked); if (!cx->handleInterrupt()) { return WaitResult::Error; } diff --git a/js/src/builtin/Boolean-inl.h b/js/src/builtin/Boolean-inl.h index dca2de84f5..5463f80b57 100644 --- a/js/src/builtin/Boolean-inl.h +++ b/js/src/builtin/Boolean-inl.h @@ -24,8 +24,7 @@ inline bool EmulatesUndefined(JSObject* obj) { return actual->getClass()->emulatesUndefined(); } -inline bool EmulatesUndefinedCheckFuse(JSObject* obj, - size_t fuseValue) { +inline bool EmulatesUndefinedCheckFuse(JSObject* obj, size_t fuseValue) { // This may be called off the main thread. It's OK not to expose the object // here as it doesn't escape. AutoUnsafeCallWithABI unsafe(UnsafeABIStrictness::AllowPendingExceptions); diff --git a/js/src/builtin/DataViewObject.cpp b/js/src/builtin/DataViewObject.cpp index 425fdce51d..9c3e8edcc6 100644 --- a/js/src/builtin/DataViewObject.cpp +++ b/js/src/builtin/DataViewObject.cpp @@ -27,6 +27,7 @@ #include "util/DifferentialTesting.h" #include "vm/ArrayBufferObject.h" #include "vm/Compartment.h" +#include "vm/Float16.h" #include "vm/GlobalObject.h" #include "vm/Interpreter.h" #include "vm/JSContext.h" @@ -416,6 +417,16 @@ NativeType DataViewObject::read(uint64_t offset, size_t length, return val; } +#ifdef NIGHTLY_BUILD +template <> +float16 DataViewObject::read(uint64_t offset, size_t length, + bool isLittleEndian) { + float16 val{}; + val.val = read<uint16_t>(offset, length, isLittleEndian); + return val; +} +#endif + template uint32_t DataViewObject::read(uint64_t offset, size_t length, bool isLittleEndian); @@ -499,6 +510,19 @@ inline bool WebIDLCast<uint64_t>(JSContext* cx, HandleValue value, return true; } +#ifdef NIGHTLY_BUILD +template <> +inline bool WebIDLCast<float16>(JSContext* cx, HandleValue value, + float16* out) { + double temp; + if (!ToNumber(cx, value, &temp)) { + return false; + } + *out = float16(temp); + return true; +} +#endif + template <> inline bool WebIDLCast<float>(JSContext* cx, HandleValue value, float* out) { double temp; @@ -537,7 +561,11 @@ bool DataViewObject::write(JSContext* cx, Handle<DataViewObject*> obj, // See the comment in ElementSpecific::doubleToNative. if (js::SupportDifferentialTesting() && TypeIsFloatingPoint<NativeType>()) { - value = JS::CanonicalizeNaN(value); + if constexpr (std::is_same_v<NativeType, float16>) { + value = JS::CanonicalizeNaN(value.toDouble()); + } else { + value = JS::CanonicalizeNaN(value); + } } // Step 6. @@ -739,6 +767,28 @@ bool DataViewObject::fun_getBigUint64(JSContext* cx, unsigned argc, Value* vp) { return CallNonGenericMethod<IsDataView, getBigUint64Impl>(cx, args); } +#ifdef NIGHTLY_BUILD +bool DataViewObject::getFloat16Impl(JSContext* cx, const CallArgs& args) { + MOZ_ASSERT(IsDataView(args.thisv())); + + Rooted<DataViewObject*> thisView( + cx, &args.thisv().toObject().as<DataViewObject>()); + + float16 val{}; + if (!read(cx, thisView, args, &val)) { + return false; + } + + args.rval().setDouble(CanonicalizeNaN(val.toDouble())); + return true; +} + +bool DataViewObject::fun_getFloat16(JSContext* cx, unsigned argc, Value* vp) { + CallArgs args = CallArgsFromVp(argc, vp); + return CallNonGenericMethod<IsDataView, getFloat16Impl>(cx, args); +} +#endif + bool DataViewObject::getFloat32Impl(JSContext* cx, const CallArgs& args) { MOZ_ASSERT(IsDataView(args.thisv())); @@ -927,6 +977,26 @@ bool DataViewObject::fun_setBigUint64(JSContext* cx, unsigned argc, Value* vp) { return CallNonGenericMethod<IsDataView, setBigUint64Impl>(cx, args); } +#ifdef NIGHTLY_BUILD +bool DataViewObject::setFloat16Impl(JSContext* cx, const CallArgs& args) { + MOZ_ASSERT(IsDataView(args.thisv())); + + Rooted<DataViewObject*> thisView( + cx, &args.thisv().toObject().as<DataViewObject>()); + + if (!write<float16>(cx, thisView, args)) { + return false; + } + args.rval().setUndefined(); + return true; +} + +bool DataViewObject::fun_setFloat16(JSContext* cx, unsigned argc, Value* vp) { + CallArgs args = CallArgsFromVp(argc, vp); + return CallNonGenericMethod<IsDataView, setFloat16Impl>(cx, args); +} +#endif + bool DataViewObject::setFloat32Impl(JSContext* cx, const CallArgs& args) { MOZ_ASSERT(IsDataView(args.thisv())); @@ -1083,6 +1153,10 @@ const JSFunctionSpec DataViewObject::methods[] = { DataViewGetInt32), JS_INLINABLE_FN("getUint32", DataViewObject::fun_getUint32, 1, 0, DataViewGetUint32), +#ifdef NIGHTLY_BUILD + // TODO: See Bug 1835034 for JIT support for Float16Array + JS_FN("getFloat16", DataViewObject::fun_getFloat16, 1, 0), +#endif JS_INLINABLE_FN("getFloat32", DataViewObject::fun_getFloat32, 1, 0, DataViewGetFloat32), JS_INLINABLE_FN("getFloat64", DataViewObject::fun_getFloat64, 1, 0, @@ -1103,6 +1177,10 @@ const JSFunctionSpec DataViewObject::methods[] = { DataViewSetInt32), JS_INLINABLE_FN("setUint32", DataViewObject::fun_setUint32, 2, 0, DataViewSetUint32), +#ifdef NIGHTLY_BUILD + // TODO: See Bug 1835034 for JIT support for Float16Array + JS_FN("setFloat16", DataViewObject::fun_setFloat16, 2, 0), +#endif JS_INLINABLE_FN("setFloat32", DataViewObject::fun_setFloat32, 2, 0, DataViewSetFloat32), JS_INLINABLE_FN("setFloat64", DataViewObject::fun_setFloat64, 2, 0, diff --git a/js/src/builtin/DataViewObject.h b/js/src/builtin/DataViewObject.h index db134a5696..aa036cf1c6 100644 --- a/js/src/builtin/DataViewObject.h +++ b/js/src/builtin/DataViewObject.h @@ -115,6 +115,9 @@ class DataViewObject : public ArrayBufferViewObject { static bool getBigUint64Impl(JSContext* cx, const CallArgs& args); static bool fun_getBigUint64(JSContext* cx, unsigned argc, Value* vp); + static bool getFloat16Impl(JSContext* cx, const CallArgs& args); + static bool fun_getFloat16(JSContext* cx, unsigned argc, Value* vp); + static bool getFloat32Impl(JSContext* cx, const CallArgs& args); static bool fun_getFloat32(JSContext* cx, unsigned argc, Value* vp); @@ -145,6 +148,9 @@ class DataViewObject : public ArrayBufferViewObject { static bool setBigUint64Impl(JSContext* cx, const CallArgs& args); static bool fun_setBigUint64(JSContext* cx, unsigned argc, Value* vp); + static bool setFloat16Impl(JSContext* cx, const CallArgs& args); + static bool fun_setFloat16(JSContext* cx, unsigned argc, Value* vp); + static bool setFloat32Impl(JSContext* cx, const CallArgs& args); static bool fun_setFloat32(JSContext* cx, unsigned argc, Value* vp); diff --git a/js/src/builtin/Eval.cpp b/js/src/builtin/Eval.cpp index 0cff2486ad..5fffed2140 100644 --- a/js/src/builtin/Eval.cpp +++ b/js/src/builtin/Eval.cpp @@ -70,7 +70,7 @@ static bool IsEvalCacheCandidate(JSScript* script) { /* static */ HashNumber EvalCacheHashPolicy::hash(const EvalCacheLookup& l) { HashNumber hash = HashStringChars(l.str); - return AddToHash(hash, l.callerScript.get(), l.pc); + return AddToHash(hash, l.callerScript, l.pc); } /* static */ @@ -82,13 +82,18 @@ bool EvalCacheHashPolicy::match(const EvalCacheEntry& cacheEntry, cacheEntry.callerScript == l.callerScript && cacheEntry.pc == l.pc; } +void EvalCacheLookup::trace(JSTracer* trc) { + TraceNullableRoot(trc, &str, "EvalCacheLookup::str"); + TraceNullableRoot(trc, &callerScript, "EvalCacheLookup::callerScript"); +} + // Add the script to the eval cache when EvalKernel is finished class EvalScriptGuard { JSContext* cx_; Rooted<JSScript*> script_; /* These fields are only valid if lookup_.str is non-nullptr. */ - EvalCacheLookup lookup_; + Rooted<EvalCacheLookup> lookup_; mozilla::Maybe<DependentAddPtr<EvalCache>> p_; Rooted<JSLinearString*> lookupStr_; @@ -100,12 +105,13 @@ class EvalScriptGuard { ~EvalScriptGuard() { if (script_ && !cx_->isExceptionPending()) { script_->cacheForEval(); - EvalCacheEntry cacheEntry = {lookupStr_, script_, lookup_.callerScript, - lookup_.pc}; - lookup_.str = lookupStr_; - if (lookup_.str && IsEvalCacheCandidate(script_)) { + EvalCacheLookup& lookup = lookup_.get(); + EvalCacheEntry cacheEntry = {lookupStr_, script_, lookup.callerScript, + lookup.pc}; + lookup.str = lookupStr_; + if (lookup.str && IsEvalCacheCandidate(script_)) { // Ignore failure to add cache entry. - if (!p_->add(cx_, cx_->caches().evalCache, lookup_, cacheEntry)) { + if (!p_->add(cx_, cx_->caches().evalCache, lookup, cacheEntry)) { cx_->recoverFromOutOfMemory(); } } @@ -115,13 +121,14 @@ class EvalScriptGuard { void lookupInEvalCache(JSLinearString* str, JSScript* callerScript, jsbytecode* pc) { lookupStr_ = str; - lookup_.str = str; - lookup_.callerScript = callerScript; - lookup_.pc = pc; - p_.emplace(cx_, cx_->caches().evalCache, lookup_); + EvalCacheLookup& lookup = lookup_.get(); + lookup.str = str; + lookup.callerScript = callerScript; + lookup.pc = pc; + p_.emplace(cx_, cx_->caches().evalCache, lookup); if (*p_) { script_ = (*p_)->script; - p_->remove(cx_, cx_->caches().evalCache, lookup_); + p_->remove(cx_, cx_->caches().evalCache, lookup); } } @@ -531,16 +538,11 @@ JS_PUBLIC_API bool JS::IsJSMEnvironment(JSObject* obj) { #ifdef JSGC_HASH_TABLE_CHECKS void RuntimeCaches::checkEvalCacheAfterMinorGC() { - JSContext* cx = TlsContext.get(); - for (auto r = evalCache.all(); !r.empty(); r.popFront()) { - const EvalCacheEntry& entry = r.front(); + gc::CheckTableAfterMovingGC(evalCache, [](const auto& entry) { CheckGCThingAfterMovingGC(entry.str); - EvalCacheLookup lookup(cx); - lookup.str = entry.str; - lookup.callerScript = entry.callerScript; - lookup.pc = entry.pc; - auto ptr = evalCache.lookup(lookup); - MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front()); - } + CheckGCThingAfterMovingGC(entry.script); + CheckGCThingAfterMovingGC(entry.callerScript); + return EvalCacheLookup(entry.str, entry.callerScript, entry.pc); + }); } #endif diff --git a/js/src/builtin/MapObject.cpp b/js/src/builtin/MapObject.cpp index cd4ae7f46a..52f60721ea 100644 --- a/js/src/builtin/MapObject.cpp +++ b/js/src/builtin/MapObject.cpp @@ -1384,7 +1384,6 @@ const JSFunctionSpec SetObject::methods[] = { JS_FN("entries", entries, 0, 0), JS_FN("clear", clear, 0, 0), JS_SELF_HOSTED_FN("forEach", "SetForEach", 2, 0), -#ifdef NIGHTLY_BUILD JS_SELF_HOSTED_FN("union", "SetUnion", 1, 0), JS_SELF_HOSTED_FN("difference", "SetDifference", 1, 0), JS_SELF_HOSTED_FN("intersection", "SetIntersection", 1, 0), @@ -1392,7 +1391,6 @@ const JSFunctionSpec SetObject::methods[] = { JS_SELF_HOSTED_FN("isSubsetOf", "SetIsSubsetOf", 1, 0), JS_SELF_HOSTED_FN("isSupersetOf", "SetIsSupersetOf", 1, 0), JS_SELF_HOSTED_FN("isDisjointFrom", "SetIsDisjointFrom", 1, 0), -#endif JS_FN("values", values, 0, 0), // @@iterator and |keys| re-defined in finishInit so that they have the // same identity as |values|. diff --git a/js/src/builtin/ModuleObject.cpp b/js/src/builtin/ModuleObject.cpp index 0365f744a6..251e8b46ff 100644 --- a/js/src/builtin/ModuleObject.cpp +++ b/js/src/builtin/ModuleObject.cpp @@ -177,6 +177,17 @@ ResolvedBindingObject* ResolvedBindingObject::create( } /////////////////////////////////////////////////////////////////////////// +// ImportAttribute + +ImportAttribute::ImportAttribute(Handle<JSAtom*> key, Handle<JSString*> value) + : key_(key), value_(value) {} + +void ImportAttribute::trace(JSTracer* trc) { + TraceNullableEdge(trc, &key_, "ImportAttribute::key_"); + TraceNullableEdge(trc, &value_, "ImportAttribute::value_"); +} + +/////////////////////////////////////////////////////////////////////////// // ModuleRequestObject /* static */ const JSClass ModuleRequestObject::class_ = { "ModuleRequest", @@ -185,13 +196,15 @@ ResolvedBindingObject* ResolvedBindingObject::create( DEFINE_ATOM_OR_NULL_ACCESSOR_METHOD(ModuleRequestObject, specifier, SpecifierSlot) -ArrayObject* ModuleRequestObject::attributes() const { - JSObject* obj = getReservedSlot(AttributesSlot).toObjectOrNull(); - if (!obj) { - return nullptr; +Span<const ImportAttribute> ModuleRequestObject::attributes() const { + Value value = getReservedSlot(AttributesSlot); + if (value.isNullOrUndefined()) { + return Span<const ImportAttribute>(); } - - return &obj->as<ArrayObject>(); + void* ptr = value.toPrivate(); + MOZ_ASSERT(ptr); + auto* vector = static_cast<ImportAttributeVector*>(ptr); + return *vector; } bool ModuleRequestObject::hasAttributes() const { @@ -208,32 +221,22 @@ bool ModuleRequestObject::getModuleType( return true; } - Rooted<ArrayObject*> attributesArray(cx, moduleRequest->attributes()); - RootedObject attributeObject(cx); - RootedId typeId(cx, NameToId(cx->names().type)); - RootedValue value(cx); - - uint32_t numberOfAttributes = attributesArray->length(); - for (uint32_t i = 0; i < numberOfAttributes; i++) { - attributeObject = &attributesArray->getDenseElement(i).toObject(); - - if (!GetProperty(cx, attributeObject, attributeObject, typeId, &value)) { - continue; - } + for (const ImportAttribute& importAttribute : moduleRequest->attributes()) { + if (importAttribute.key() == cx->names().type) { + int32_t isJsonString; + if (!js::CompareStrings(cx, cx->names().json, importAttribute.value(), + &isJsonString)) { + return false; + } - int32_t isJsonString; - if (!js::CompareStrings(cx, cx->names().json, value.toString(), - &isJsonString)) { - return false; - } + if (isJsonString == 0) { + moduleType = JS::ModuleType::JSON; + return true; + } - if (isJsonString == 0) { - moduleType = JS::ModuleType::JSON; + moduleType = JS::ModuleType::Unknown; return true; } - - moduleType = JS::ModuleType::Unknown; - return true; } moduleType = JS::ModuleType::JavaScript; @@ -248,7 +251,7 @@ bool ModuleRequestObject::isInstance(HandleValue value) { /* static */ ModuleRequestObject* ModuleRequestObject::create( JSContext* cx, Handle<JSAtom*> specifier, - Handle<ArrayObject*> maybeAttributes) { + MutableHandle<UniquePtr<ImportAttributeVector>> maybeAttributes) { ModuleRequestObject* self = NewObjectWithGivenProto<ModuleRequestObject>(cx, nullptr); if (!self) { @@ -256,7 +259,12 @@ ModuleRequestObject* ModuleRequestObject::create( } self->initReservedSlot(SpecifierSlot, StringOrNullValue(specifier)); - self->initReservedSlot(AttributesSlot, ObjectOrNullValue(maybeAttributes)); + + if (maybeAttributes) { + InitReservedSlot(self, AttributesSlot, maybeAttributes.get().release(), + MemoryUse::ModuleImportAttributes); + } + return self; } @@ -1589,39 +1597,28 @@ bool frontend::StencilModuleMetadata::createModuleRequestObjects( ModuleRequestObject* frontend::StencilModuleMetadata::createModuleRequestObject( JSContext* cx, CompilationAtomCache& atomCache, const StencilModuleRequest& request) const { - Rooted<ArrayObject*> assertionArray(cx); - uint32_t numberOfAssertions = request.assertions.length(); - if (numberOfAssertions > 0) { - assertionArray = NewDenseFullyAllocatedArray(cx, numberOfAssertions); - if (!assertionArray) { + uint32_t numberOfAttributes = request.attributes.length(); + + Rooted<UniquePtr<ImportAttributeVector>> attributes(cx); + if (numberOfAttributes > 0) { + attributes = cx->make_unique<ImportAttributeVector>(); + if (!attributes) { + ReportOutOfMemory(cx); return nullptr; } - assertionArray->ensureDenseInitializedLength(0, numberOfAssertions); - - Rooted<PlainObject*> assertionObject(cx); - RootedId assertionKey(cx); - RootedValue assertionValue(cx); - for (uint32_t j = 0; j < numberOfAssertions; ++j) { - assertionObject = NewPlainObject(cx); - if (!assertionObject) { - return nullptr; - } - JSAtom* jsatom = - atomCache.getExistingAtomAt(cx, request.assertions[j].key); - MOZ_ASSERT(jsatom); - assertionKey = AtomToId(jsatom); - - jsatom = atomCache.getExistingAtomAt(cx, request.assertions[j].value); - MOZ_ASSERT(jsatom); - assertionValue = StringValue(jsatom); - - if (!DefineDataProperty(cx, assertionObject, assertionKey, assertionValue, - JSPROP_ENUMERATE)) { - return nullptr; - } + if (!attributes->reserve(numberOfAttributes)) { + ReportOutOfMemory(cx); + return nullptr; + } - assertionArray->initDenseElement(j, ObjectValue(*assertionObject)); + Rooted<JSAtom*> attributeKey(cx); + Rooted<JSAtom*> attributeValue(cx); + for (uint32_t j = 0; j < numberOfAttributes; ++j) { + attributeKey = atomCache.getExistingAtomAt(cx, request.attributes[j].key); + attributeValue = + atomCache.getExistingAtomAt(cx, request.attributes[j].value); + attributes->infallibleEmplaceBack(attributeKey, attributeValue); } } @@ -1629,7 +1626,7 @@ ModuleRequestObject* frontend::StencilModuleMetadata::createModuleRequestObject( atomCache.getExistingAtomAt(cx, request.specifier)); MOZ_ASSERT(specifier); - return ModuleRequestObject::create(cx, specifier, assertionArray); + return ModuleRequestObject::create(cx, specifier, &attributes); } bool frontend::StencilModuleMetadata::createImportEntries( @@ -1796,34 +1793,24 @@ bool frontend::StencilModuleMetadata::initModule( return true; } -bool ModuleBuilder::isAssertionSupported(frontend::TaggedParserAtomIndex key) { - if (!key.isWellKnownAtomId()) { - return false; - } - - return key.toWellKnownAtomId() == WellKnownAtomId::type; -} - -bool ModuleBuilder::processAssertions(frontend::StencilModuleRequest& request, - frontend::ListNode* assertionList) { +bool ModuleBuilder::processAttributes(frontend::StencilModuleRequest& request, + frontend::ListNode* attributeList) { using namespace js::frontend; - for (ParseNode* assertionItem : assertionList->contents()) { - BinaryNode* assertion = &assertionItem->as<BinaryNode>(); - MOZ_ASSERT(assertion->isKind(ParseNodeKind::ImportAttribute)); + for (ParseNode* attributeItem : attributeList->contents()) { + BinaryNode* attribute = &attributeItem->as<BinaryNode>(); + MOZ_ASSERT(attribute->isKind(ParseNodeKind::ImportAttribute)); - auto key = assertion->left()->as<NameNode>().atom(); - auto value = assertion->right()->as<NameNode>().atom(); + auto key = attribute->left()->as<NameNode>().atom(); + auto value = attribute->right()->as<NameNode>().atom(); - if (isAssertionSupported(key)) { - markUsedByStencil(key); - markUsedByStencil(value); + markUsedByStencil(key); + markUsedByStencil(value); - StencilModuleAssertion assertionStencil(key, value); - if (!request.assertions.append(assertionStencil)) { - js::ReportOutOfMemory(fc_); - return false; - } + StencilModuleImportAttribute attributeStencil(key, value); + if (!request.attributes.append(attributeStencil)) { + js::ReportOutOfMemory(fc_); + return false; } } @@ -1844,12 +1831,12 @@ bool ModuleBuilder::processImport(frontend::BinaryNode* importNode) { auto* moduleSpec = &moduleRequest->left()->as<NameNode>(); MOZ_ASSERT(moduleSpec->isKind(ParseNodeKind::StringExpr)); - auto* assertionList = &moduleRequest->right()->as<ListNode>(); - MOZ_ASSERT(assertionList->isKind(ParseNodeKind::ImportAttributeList)); + auto* attributeList = &moduleRequest->right()->as<ListNode>(); + MOZ_ASSERT(attributeList->isKind(ParseNodeKind::ImportAttributeList)); auto specifier = moduleSpec->atom(); MaybeModuleRequestIndex moduleRequestIndex = - appendModuleRequest(specifier, assertionList); + appendModuleRequest(specifier, attributeList); if (!moduleRequestIndex.isSome()) { return false; } @@ -2089,12 +2076,12 @@ bool ModuleBuilder::processExportFrom(frontend::BinaryNode* exportNode) { auto* moduleSpec = &moduleRequest->left()->as<NameNode>(); MOZ_ASSERT(moduleSpec->isKind(ParseNodeKind::StringExpr)); - auto* assertionList = &moduleRequest->right()->as<ListNode>(); - MOZ_ASSERT(assertionList->isKind(ParseNodeKind::ImportAttributeList)); + auto* attributeList = &moduleRequest->right()->as<ListNode>(); + MOZ_ASSERT(attributeList->isKind(ParseNodeKind::ImportAttributeList)); auto specifier = moduleSpec->atom(); MaybeModuleRequestIndex moduleRequestIndex = - appendModuleRequest(specifier, assertionList); + appendModuleRequest(specifier, attributeList); if (!moduleRequestIndex.isSome()) { return false; } @@ -2192,11 +2179,11 @@ bool ModuleBuilder::appendExportEntry( frontend::MaybeModuleRequestIndex ModuleBuilder::appendModuleRequest( frontend::TaggedParserAtomIndex specifier, - frontend::ListNode* assertionList) { + frontend::ListNode* attributeList) { markUsedByStencil(specifier); auto request = frontend::StencilModuleRequest(specifier); - if (!processAssertions(request, assertionList)) { + if (!processAttributes(request, attributeList)) { return MaybeModuleRequestIndex(); } @@ -2304,17 +2291,17 @@ bool ModuleObject::topLevelCapabilityReject(JSContext* cx, return AsyncFunctionThrown(cx, promise, error); } -// https://tc39.es/proposal-import-assertions/#sec-evaluate-import-call +// https://tc39.es/proposal-import-attributes/#sec-evaluate-import-call // NOTE: The caller needs to handle the promise. static bool EvaluateDynamicImportOptions( JSContext* cx, HandleValue optionsArg, - MutableHandle<ArrayObject*> assertionArrayArg) { - // Step 10. If options is not undefined, then. + MutableHandle<ImportAttributeVector> attributesArrayArg) { + // Step 11. If options is not undefined, then if (optionsArg.isUndefined()) { return true; } - // Step 10.a. If Type(options) is not Object, + // Step 11.a. If options is not an Object, then if (!optionsArg.isObject()) { JS_ReportErrorNumberASCII( cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, "import", @@ -2322,114 +2309,124 @@ static bool EvaluateDynamicImportOptions( return false; } - RootedObject assertWrapperObject(cx, &optionsArg.toObject()); - RootedValue assertValue(cx); + RootedObject attributesWrapperObject(cx, &optionsArg.toObject()); + RootedValue attributesValue(cx); - // Step 10.b. Let attributesObj be Completion(Get(options, "with")). + // Step 11.b. Let attributesObj be Completion(Get(options, "with")). RootedId withId(cx, NameToId(cx->names().with)); - if (!GetProperty(cx, assertWrapperObject, assertWrapperObject, withId, - &assertValue)) { + if (!GetProperty(cx, attributesWrapperObject, attributesWrapperObject, withId, + &attributesValue)) { return false; } - if (assertValue.isUndefined() && + // Step 11.d. If the host supports the deprecated assert keyword for import + // attributes and attributesObj is undefined, then + if (attributesValue.isUndefined() && cx->options().importAttributesAssertSyntax()) { - // Step 10.b. Let assertionsObj be Get(options, "assert"). + // Step 11.d.i. Set attributesObj to Completion(Get(options, "assert")). RootedId assertId(cx, NameToId(cx->names().assert_)); - if (!GetProperty(cx, assertWrapperObject, assertWrapperObject, assertId, - &assertValue)) { + if (!GetProperty(cx, attributesWrapperObject, attributesWrapperObject, + assertId, &attributesValue)) { return false; } } - // Step 10.d. If assertionsObj is not undefined. - if (assertValue.isUndefined()) { + // Step 11.e. If attributesObj is not undefined, then + if (attributesValue.isUndefined()) { return true; } - // Step 10.d.i. If Type(assertionsObj) is not Object. - if (!assertValue.isObject()) { + // Step 11.e.i. If attributesObj is not an Object, then + if (!attributesValue.isObject()) { JS_ReportErrorNumberASCII( cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, "import", - "object or undefined", InformalValueTypeName(assertValue)); + "object or undefined", InformalValueTypeName(attributesValue)); return false; } - // Step 10.d.i. Let keys be EnumerableOwnPropertyNames(assertionsObj, key). - RootedObject assertObject(cx, &assertValue.toObject()); - RootedIdVector assertions(cx); - if (!GetPropertyKeys(cx, assertObject, JSITER_OWNONLY, &assertions)) { + // Step 11.e.ii. Let entries be + // Completion(EnumerableOwnProperties(attributesObj, key+value)). + RootedObject attributesObject(cx, &attributesValue.toObject()); + RootedIdVector attributes(cx); + if (!GetPropertyKeys(cx, attributesObject, JSITER_OWNONLY, &attributes)) { return false; } - uint32_t numberOfAssertions = assertions.length(); - if (numberOfAssertions == 0) { + uint32_t numberOfAttributes = attributes.length(); + if (numberOfAttributes == 0) { return true; } - // Step 9 (reordered). Let assertions be a new empty List. - Rooted<ArrayObject*> assertionArray( - cx, NewDenseFullyAllocatedArray(cx, numberOfAssertions)); - if (!assertionArray) { + // Step 10 (reordered). Let attributes be a new empty List. + if (!attributesArrayArg.reserve(numberOfAttributes)) { + ReportOutOfMemory(cx); return false; } - assertionArray->ensureDenseInitializedLength(0, numberOfAssertions); - // Step 10.d.iv. Let supportedAssertions be - // !HostGetSupportedImportAssertions(). - // Note: This should be driven by a host hook, howver the infrastructure of - // said host hook is deeply unclear, and so right now embedders will - // not have the ability to alter or extend the set of supported - // assertion types. - // See https://bugzilla.mozilla.org/show_bug.cgi?id=1840723. - size_t numberOfValidAssertions = 0; + size_t numberOfValidAttributes = 0; - // Step 10.d.v. For each String key of keys, + // Step 11.e.iv. For each element entry of entries, do RootedId key(cx); - for (size_t i = 0; i < numberOfAssertions; i++) { - key = assertions[i]; - - // Step 10.d.v.1. Let value be Get(assertionsObj, key). - RootedValue value(cx); - if (!GetProperty(cx, assertObject, assertObject, key, &value)) { - return false; - } - - // Step 10.d.v.3. If Type(value) is not String, then. - if (!value.isString()) { - JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, - JSMSG_NOT_EXPECTED_TYPE, "import", "string", - InformalValueTypeName(value)); + RootedValue value(cx); + Rooted<JSAtom*> keyAtom(cx); + Rooted<JSString*> valueString(cx); + for (size_t i = 0; i < numberOfAttributes; i++) { + // Step 11.e.ii.iv.1. Let key be ! Get(entry, "0"). + key = attributes[i]; + + // Step 11.e.ii.iv.2. Let value be ! Get(entry, "1"). + if (!GetProperty(cx, attributesObject, attributesObject, key, &value)) { return false; } - // Step 10.d.v.4. If supportedAssertions contains key, then Append { - // [[Key]]: key, [[Value]]: value } to assertions. - // Note: We only currently support the "type" assertion; this will need - // extension - bool supported = key.isAtom() ? key.toAtom() == cx->names().type : false; - if (supported) { - Rooted<PlainObject*> assertionObj(cx, NewPlainObject(cx)); - if (!assertionObj) { + // Step 11.e.ii.iv.3. If key is a String, then + if (key.isString()) { + // Step 11.f (reordered). If AllImportAttributesSupported(attributes) is + // false, then + // + // Note: This should be driven by a host hook + // (HostGetSupportedImportAttributes), however the infrastructure of said + // host hook is deeply unclear, and so right now embedders will not have + // the ability to alter or extend the set of supported attributes. + // See https://bugzilla.mozilla.org/show_bug.cgi?id=1840723. + bool supported = key.isAtom(cx->names().type); + if (!supported) { + UniqueChars printableKey = AtomToPrintableString(cx, key.toAtom()); + if (!printableKey) { + return false; + } + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_IMPORT_ATTRIBUTES_UNSUPPORTED_ATTRIBUTE, + printableKey.get()); return false; } - if (!DefineDataProperty(cx, assertionObj, key, value, JSPROP_ENUMERATE)) { + // Step 10.d.v.3.a. If value is not a String, then + if (!value.isString()) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_NOT_EXPECTED_TYPE, "import", "string", + InformalValueTypeName(value)); return false; } - assertionArray->initDenseElement(numberOfValidAssertions, - ObjectValue(*assertionObj)); - ++numberOfValidAssertions; + // Step 10.d.v.3.b. Append the ImportAttribute Record { [[Key]]: key, + // [[Value]]: value } to attributes. + keyAtom = key.toAtom(); + valueString = value.toString(); + attributesArrayArg.infallibleEmplaceBack(keyAtom, valueString); + ++numberOfValidAttributes; } } - if (numberOfValidAssertions == 0) { + if (numberOfValidAttributes == 0) { return true; } - assertionArray->setLength(numberOfValidAssertions); - assertionArrayArg.set(assertionArray); + // Step 10.g (skipped). Sort attributes according to the lexicographic order + // of their [[Key]] fields, treating the value of each such field as a + // sequence of UTF-16 code unit values. + // + // We only support "type", so we can ignore this. return true; } @@ -2482,16 +2479,32 @@ JSObject* js::StartDynamicModuleImport(JSContext* cx, HandleScript script, return promise; } - Rooted<ArrayObject*> assertionArray(cx); - if (!EvaluateDynamicImportOptions(cx, optionsArg, &assertionArray)) { + Rooted<ImportAttributeVector> tempAttributes(cx); + if (!EvaluateDynamicImportOptions(cx, optionsArg, &tempAttributes)) { if (!RejectPromiseWithPendingError(cx, promise)) { return nullptr; } return promise; } + Rooted<UniquePtr<ImportAttributeVector>> attributes(cx); + if (!tempAttributes.empty()) { + attributes = cx->make_unique<ImportAttributeVector>(); + if (!attributes) { + return nullptr; + } + if (!attributes->reserve(tempAttributes.length())) { + ReportOutOfMemory(cx); + return nullptr; + } + if (!attributes->appendAll(tempAttributes)) { + ReportOutOfMemory(cx); + return nullptr; + } + } + RootedObject moduleRequest( - cx, ModuleRequestObject::create(cx, specifierAtom, assertionArray)); + cx, ModuleRequestObject::create(cx, specifierAtom, &attributes)); if (!moduleRequest) { if (!RejectPromiseWithPendingError(cx, promise)) { return nullptr; @@ -2669,8 +2682,9 @@ static bool OnResolvedDynamicModule(JSContext* cx, unsigned argc, Value* vp) { } Rooted<PromiseObject*> promise(cx, TargetFromHandler<PromiseObject>(args)); + Rooted<UniquePtr<ImportAttributeVector>> attributes(cx); RootedObject moduleRequest( - cx, ModuleRequestObject::create(cx, specifier, nullptr)); + cx, ModuleRequestObject::create(cx, specifier, &attributes)); if (!moduleRequest) { return RejectPromiseWithPendingError(cx, promise); } diff --git a/js/src/builtin/ModuleObject.h b/js/src/builtin/ModuleObject.h index cb74d67c40..3533201675 100644 --- a/js/src/builtin/ModuleObject.h +++ b/js/src/builtin/ModuleObject.h @@ -50,6 +50,21 @@ class ModuleObject; class PromiseObject; class ScriptSourceObject; +class ImportAttribute { + const HeapPtr<JSAtom*> key_; + const HeapPtr<JSString*> value_; + + public: + ImportAttribute(Handle<JSAtom*> key, Handle<JSString*> value); + + JSAtom* key() const { return key_; } + JSString* value() const { return value_; } + + void trace(JSTracer* trc); +}; + +using ImportAttributeVector = GCVector<ImportAttribute, 0, SystemAllocPolicy>; + class ModuleRequestObject : public NativeObject { public: enum { SpecifierSlot = 0, AttributesSlot, SlotCount }; @@ -58,10 +73,10 @@ class ModuleRequestObject : public NativeObject { static bool isInstance(HandleValue value); [[nodiscard]] static ModuleRequestObject* create( JSContext* cx, Handle<JSAtom*> specifier, - Handle<ArrayObject*> maybeAttributes); + MutableHandle<UniquePtr<ImportAttributeVector>> maybeAttributes); JSAtom* specifier() const; - ArrayObject* attributes() const; + mozilla::Span<const ImportAttribute> attributes() const; bool hasAttributes() const; static bool getModuleType(JSContext* cx, const Handle<ModuleRequestObject*> moduleRequest, diff --git a/js/src/builtin/ReflectParse.cpp b/js/src/builtin/ReflectParse.cpp index dde953143e..aa5666f238 100644 --- a/js/src/builtin/ReflectParse.cpp +++ b/js/src/builtin/ReflectParse.cpp @@ -505,7 +505,7 @@ class NodeBuilder { [[nodiscard]] bool debuggerStatement(TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool moduleRequest(HandleValue moduleSpec, - NodeVector& assertions, TokenPos* pos, + NodeVector& attributes, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool importAttribute(HandleValue key, HandleValue value, @@ -1160,10 +1160,10 @@ bool NodeBuilder::yieldExpression(HandleValue arg, YieldKind kind, dst); } -bool NodeBuilder::moduleRequest(HandleValue moduleSpec, NodeVector& assertions, +bool NodeBuilder::moduleRequest(HandleValue moduleSpec, NodeVector& attributes, TokenPos* pos, MutableHandleValue dst) { RootedValue array(cx); - if (!newArray(assertions, &array)) { + if (!newArray(attributes, &array)) { return false; } @@ -1967,12 +1967,12 @@ bool ASTSerializer::exportDeclaration(ParseNode* exportNode, &moduleRequest->as<BinaryNode>().right()->as<ListNode>(); MOZ_ASSERT(attributeList->isKind(ParseNodeKind::ImportAttributeList)); - NodeVector assertions(cx); - if (!importAttributes(attributeList, assertions)) { + NodeVector attributes(cx); + if (!importAttributes(attributeList, attributes)) { return false; } - if (!builder.moduleRequest(moduleSpec, assertions, &exportNode->pn_pos, + if (!builder.moduleRequest(moduleSpec, attributes, &exportNode->pn_pos, &moduleRequestValue)) { return false; } @@ -2030,13 +2030,13 @@ bool ASTSerializer::importAttributes(ListNode* attributeList, return false; } - RootedValue assertion(cx); + RootedValue attribute(cx); if (!builder.importAttribute(key, value, &attributeNode->pn_pos, - &assertion)) { + &attribute)) { return false; } - if (!attributes.append(assertion)) { + if (!attributes.append(attribute)) { return false; } } diff --git a/js/src/builtin/SelfHostingDefines.h b/js/src/builtin/SelfHostingDefines.h index 0f8fd9694d..a781cc1498 100644 --- a/js/src/builtin/SelfHostingDefines.h +++ b/js/src/builtin/SelfHostingDefines.h @@ -119,6 +119,7 @@ #define TYPEDARRAY_KIND_UINT8CLAMPED 8 #define TYPEDARRAY_KIND_BIGINT64 9 #define TYPEDARRAY_KIND_BIGUINT64 10 +#define TYPEDARRAY_KIND_FLOAT16 11 #define WRAP_FOR_VALID_ITERATOR_ITERATOR_SLOT 0 #define WRAP_FOR_VALID_ITERATOR_NEXT_METHOD_SLOT 1 diff --git a/js/src/builtin/Set.js b/js/src/builtin/Set.js index d1d877ba44..1dbd13cf93 100644 --- a/js/src/builtin/Set.js +++ b/js/src/builtin/Set.js @@ -120,7 +120,6 @@ function SetIteratorNext() { return retVal; } -#ifdef NIGHTLY_BUILD // GetSetRecord ( obj ) // // https://tc39.es/proposal-set-methods/#sec-getsetrecord @@ -564,4 +563,3 @@ function SetIsDisjointFrom(other) { // Step 7. return true; } -#endif diff --git a/js/src/builtin/ShadowRealm.cpp b/js/src/builtin/ShadowRealm.cpp index 0f4efcde14..6c76a2b1b3 100644 --- a/js/src/builtin/ShadowRealm.cpp +++ b/js/src/builtin/ShadowRealm.cpp @@ -444,9 +444,9 @@ static JSObject* ShadowRealmImportValue(JSContext* cx, return promise; } - Rooted<ArrayObject*> assertionArray(cx); + Rooted<UniquePtr<ImportAttributeVector>> attributes(cx); Rooted<JSObject*> moduleRequest( - cx, ModuleRequestObject::create(cx, specifierAtom, assertionArray)); + cx, ModuleRequestObject::create(cx, specifierAtom, &attributes)); if (!moduleRequest) { if (!RejectPromiseWithPendingError(cx, promise)) { return nullptr; diff --git a/js/src/builtin/Sorting-inl.h b/js/src/builtin/Sorting-inl.h new file mode 100644 index 0000000000..83217d3e6c --- /dev/null +++ b/js/src/builtin/Sorting-inl.h @@ -0,0 +1,307 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: set ts=8 sts=2 et sw=2 tw=80: + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef builtin_Sorting_inl_h +#define builtin_Sorting_inl_h + +#include "builtin/Sorting.h" + +#include "js/Conversions.h" +#include "vm/JSContext.h" +#include "vm/JSFunction.h" +#include "vm/JSObject.h" + +namespace js { + +void ArraySortData::init(JSObject* obj, JSObject* comparator, ValueVector&& vec, + uint32_t length, uint32_t denseLen) { + MOZ_ASSERT(!vec.empty(), "must have items to sort"); + MOZ_ASSERT(denseLen <= length); + + obj_ = obj; + comparator_ = comparator; + + this->length = length; + this->denseLen = denseLen; + this->vec = std::move(vec); + + auto getComparatorKind = [](JSContext* cx, JSObject* comparator) { + if (!comparator->is<JSFunction>()) { + return ComparatorKind::Unoptimized; + } + JSFunction* fun = &comparator->as<JSFunction>(); + if (!fun->hasJitEntry() || fun->isClassConstructor()) { + return ComparatorKind::Unoptimized; + } + if (fun->realm() == cx->realm() && fun->nargs() <= ComparatorActualArgs) { + return ComparatorKind::JSSameRealmNoRectifier; + } + return ComparatorKind::JS; + }; + comparatorKind_ = getComparatorKind(cx(), comparator); +} + +ArraySortData::ArraySortData(JSContext* cx) : cx_(cx) { +#ifdef DEBUG + cx_->liveArraySortDataInstances++; +#endif +} + +void ArraySortData::freeMallocData() { + vec.clearAndFree(); +#ifdef DEBUG + MOZ_ASSERT(cx_->liveArraySortDataInstances > 0); + cx_->liveArraySortDataInstances--; +#endif +} + +template <ArraySortKind Kind> +static MOZ_ALWAYS_INLINE ArraySortResult +MaybeYieldToComparator(ArraySortData* d, const Value& x, const Value& y) { + if constexpr (Kind == ArraySortKind::Array) { + // https://tc39.es/ecma262/#sec-comparearrayelements + // 23.1.3.30.2 CompareArrayElements ( x, y, comparefn ) + + // Steps 1-2. + if (x.isUndefined()) { + d->setComparatorReturnValue(Int32Value(y.isUndefined() ? 0 : 1)); + return ArraySortResult::Done; + } + + // Step 3. + if (y.isUndefined()) { + d->setComparatorReturnValue(Int32Value(-1)); + return ArraySortResult::Done; + } + } else { + // https://tc39.es/ecma262/#sec-comparetypedarrayelements + // 23.2.4.7 CompareTypedArrayElements ( x, y, comparefn ) + + // Step 1. + MOZ_ASSERT((x.isNumber() && y.isNumber()) || + (x.isBigInt() && y.isBigInt())); + } + + // Yield to the JIT trampoline (or js::array_sort) if the comparator is a JS + // function we can call more efficiently from JIT code. + auto kind = d->comparatorKind(); + if (MOZ_LIKELY(kind != ArraySortData::ComparatorKind::Unoptimized)) { + d->setComparatorArgs(x, y); + return (kind == ArraySortData::ComparatorKind::JSSameRealmNoRectifier) + ? ArraySortResult::CallJSSameRealmNoRectifier + : ArraySortResult::CallJS; + } + return CallComparatorSlow(d, x, y); +} + +static MOZ_ALWAYS_INLINE bool RvalIsLessOrEqual(ArraySortData* data, + bool* lessOrEqual) { + // https://tc39.es/ecma262/#sec-comparearrayelements + // 23.1.3.30.2 CompareArrayElements ( x, y, comparefn ) + // + // https://tc39.es/ecma262/#sec-comparetypedarrayelements + // 23.2.4.7 CompareTypedArrayElements ( x, y, comparefn ) + // + // Note: CompareTypedArrayElements step 2 is identical to CompareArrayElements + // step 4. + + // Fast path for int32 return values. + Value rval = data->comparatorReturnValue(); + if (MOZ_LIKELY(rval.isInt32())) { + *lessOrEqual = rval.toInt32() <= 0; + return true; + } + + // Step 4.a. + Rooted<Value> rvalRoot(data->cx(), rval); + double d; + if (MOZ_UNLIKELY(!ToNumber(data->cx(), rvalRoot, &d))) { + return false; + } + + // Step 4.b-c. + *lessOrEqual = std::isnan(d) ? true : (d <= 0); + return true; +} + +static MOZ_ALWAYS_INLINE void CopyValues(Value* out, const Value* list, + uint32_t start, uint32_t end) { + for (uint32_t i = start; i <= end; i++) { + out[i] = list[i]; + } +} + +// static +template <ArraySortKind Kind> +ArraySortResult ArraySortData::sortWithComparatorShared(ArraySortData* d) { + auto& vec = d->vec; + + // This function is like a generator that is called repeatedly from the JIT + // trampoline or js::array_sort. Resume the sorting algorithm where we left + // off before calling the comparator. + switch (d->state) { + case State::Initial: + break; + case State::InsertionSortCall1: + goto insertion_sort_call1; + case State::InsertionSortCall2: + goto insertion_sort_call2; + case State::MergeSortCall1: + goto merge_sort_call1; + case State::MergeSortCall2: + goto merge_sort_call2; + } + + d->list = vec.begin(); + + // Use insertion sort for small arrays. + if (d->denseLen <= InsertionSortMaxLength) { + for (d->i = 1; d->i < d->denseLen; d->i++) { + d->item = vec[d->i]; + d->j = d->i - 1; + do { + { + ArraySortResult res = + MaybeYieldToComparator<Kind>(d, vec[d->j], d->item); + if (res != ArraySortResult::Done) { + d->state = State::InsertionSortCall1; + return res; + } + } + insertion_sort_call1: + bool lessOrEqual; + if (!RvalIsLessOrEqual(d, &lessOrEqual)) { + return ArraySortResult::Failure; + } + if (lessOrEqual) { + break; + } + vec[d->j + 1] = vec[d->j]; + } while (d->j-- > 0); + vec[d->j + 1] = d->item; + } + } else { + static constexpr size_t InitialWindowSize = 4; + + // Use insertion sort for initial ranges. + for (d->start = 0; d->start < d->denseLen - 1; + d->start += InitialWindowSize) { + d->end = + std::min<uint32_t>(d->start + InitialWindowSize - 1, d->denseLen - 1); + for (d->i = d->start + 1; d->i <= d->end; d->i++) { + d->item = vec[d->i]; + d->j = d->i - 1; + do { + { + ArraySortResult res = + MaybeYieldToComparator<Kind>(d, vec[d->j], d->item); + if (res != ArraySortResult::Done) { + d->state = State::InsertionSortCall2; + return res; + } + } + insertion_sort_call2: + bool lessOrEqual; + if (!RvalIsLessOrEqual(d, &lessOrEqual)) { + return ArraySortResult::Failure; + } + if (lessOrEqual) { + break; + } + vec[d->j + 1] = vec[d->j]; + } while (d->j-- > d->start); + vec[d->j + 1] = d->item; + } + } + + // Merge sort. Set d->out to scratch space initially. + d->out = vec.begin() + d->denseLen; + for (d->windowSize = InitialWindowSize; d->windowSize < d->denseLen; + d->windowSize *= 2) { + for (d->start = 0; d->start < d->denseLen; + d->start += 2 * d->windowSize) { + // The midpoint between the two subarrays. + d->mid = d->start + d->windowSize - 1; + + // To keep from going over the edge. + d->end = std::min<uint32_t>(d->start + 2 * d->windowSize - 1, + d->denseLen - 1); + + // Merge comparator-sorted slices list[start..<=mid] and + // list[mid+1..<=end], storing the merged sequence in out[start..<=end]. + + // Skip lopsided runs to avoid doing useless work. + if (d->mid >= d->end) { + CopyValues(d->out, d->list, d->start, d->end); + continue; + } + + // Skip calling the comparator if the sub-list is already sorted. + { + ArraySortResult res = MaybeYieldToComparator<Kind>( + d, d->list[d->mid], d->list[d->mid + 1]); + if (res != ArraySortResult::Done) { + d->state = State::MergeSortCall1; + return res; + } + } + merge_sort_call1: + bool lessOrEqual; + if (!RvalIsLessOrEqual(d, &lessOrEqual)) { + return ArraySortResult::Failure; + } + if (lessOrEqual) { + CopyValues(d->out, d->list, d->start, d->end); + continue; + } + + d->i = d->start; + d->j = d->mid + 1; + d->k = d->start; + + while (d->i <= d->mid && d->j <= d->end) { + { + ArraySortResult res = + MaybeYieldToComparator<Kind>(d, d->list[d->i], d->list[d->j]); + if (res != ArraySortResult::Done) { + d->state = State::MergeSortCall2; + return res; + } + } + merge_sort_call2: + bool lessOrEqual; + if (!RvalIsLessOrEqual(d, &lessOrEqual)) { + return ArraySortResult::Failure; + } + d->out[d->k++] = lessOrEqual ? d->list[d->i++] : d->list[d->j++]; + } + + // Empty out any remaining elements. Use local variables to let the + // compiler generate more efficient code. + Value* out = d->out; + Value* list = d->list; + uint32_t k = d->k; + uint32_t mid = d->mid; + uint32_t end = d->end; + for (uint32_t i = d->i; i <= mid; i++) { + out[k++] = list[i]; + } + for (uint32_t j = d->j; j <= end; j++) { + out[k++] = list[j]; + } + } + + // Swap both lists. + std::swap(d->list, d->out); + } + } + + return ArraySortResult::Done; +} + +} // namespace js + +#endif /* builtin_Sorting_inl_h */ diff --git a/js/src/builtin/Sorting.h b/js/src/builtin/Sorting.h new file mode 100644 index 0000000000..4d5216c441 --- /dev/null +++ b/js/src/builtin/Sorting.h @@ -0,0 +1,179 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: set ts=8 sts=2 et sw=2 tw=80: + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef builtin_Sorting_h +#define builtin_Sorting_h + +#include "mozilla/Attributes.h" + +#include "js/GCVector.h" +#include "vm/JSObject.h" + +// Code used by Array.prototype.sort and %TypedArray%.prototype.sort to sort +// objects based on a user-defined comparator function. + +namespace js { + +// Note: we use uint32_t because the JIT code uses branch32. +enum class ArraySortResult : uint32_t { + Failure, + Done, + CallJS, + CallJSSameRealmNoRectifier +}; + +enum class ArraySortKind { + Array, + TypedArray, +}; + +// We use a JIT trampoline to optimize sorting with a comparator function. The +// trampoline frame has an ArraySortData instance that contains all state used +// by the sorting algorithm. The sorting algorithm is implemented as a C++ +// "generator" that can yield to the trampoline to perform a fast JIT => JIT +// call to the comparator function. When the comparator function returns, the +// trampoline calls back into C++ to resume the sorting algorithm. +// +// ArraySortData stores the JS Values in a js::Vector. To ensure we don't leak +// its memory, we have debug assertions to check that for each C++ constructor +// call we call |freeMallocData| exactly once. C++ code calls |freeMallocData| +// when it's done sorting and the JIT exception handler calls it when unwinding +// the trampoline frame. +class ArraySortData { + public: + enum class ComparatorKind : uint8_t { + Unoptimized, + JS, + JSSameRealmNoRectifier, + }; + + // Insertion sort is used if the length is <= InsertionSortMaxLength. + static constexpr size_t InsertionSortMaxLength = 8; + + static constexpr size_t ComparatorActualArgs = 2; + + using ValueVector = GCVector<Value, 8, SystemAllocPolicy>; + + protected: // Silence Clang warning about unused private fields. + // Data for the comparator call. These fields must match the JitFrameLayout + // to let us perform efficient calls to the comparator from JIT code. + // This is asserted in the JIT trampoline code. + // callArgs[0] is also used to store the return value of the sort function and + // the comparator. + uintptr_t descriptor_; + JSObject* comparator_ = nullptr; + Value thisv; + Value callArgs[ComparatorActualArgs]; + + private: + ValueVector vec; + Value item; + JSContext* cx_; + JSObject* obj_ = nullptr; + + Value* list; + Value* out; + + // The value of the .length property. + uint32_t length; + + // The number of items to sort. Can be less than |length| if the object has + // holes. + uint32_t denseLen; + + uint32_t windowSize; + uint32_t start; + uint32_t mid; + uint32_t end; + uint32_t i, j, k; + + // The state value determines where we resume in sortWithComparator. + enum class State : uint8_t { + Initial, + InsertionSortCall1, + InsertionSortCall2, + MergeSortCall1, + MergeSortCall2 + }; + State state = State::Initial; + ComparatorKind comparatorKind_; + + // Optional padding to ensure proper alignment of the comparator JIT frame. +#if !defined(JS_64BIT) && !defined(DEBUG) + protected: // Silence Clang warning about unused private field. + size_t padding; +#endif + + private: + // Merge sort requires extra scratch space in the vector. Insertion sort + // should be used for short arrays that fit in the vector's inline storage, to + // avoid extra malloc calls. + static_assert(decltype(vec)::InlineLength <= InsertionSortMaxLength); + + template <ArraySortKind Kind> + static MOZ_ALWAYS_INLINE ArraySortResult + sortWithComparatorShared(ArraySortData* d); + + public: + explicit inline ArraySortData(JSContext* cx); + + void MOZ_ALWAYS_INLINE init(JSObject* obj, JSObject* comparator, + ValueVector&& vec, uint32_t length, + uint32_t denseLen); + + JSContext* cx() const { return cx_; } + + JSObject* comparator() const { + MOZ_ASSERT(comparator_); + return comparator_; + } + + Value returnValue() const { return callArgs[0]; } + void setReturnValue(JSObject* obj) { callArgs[0].setObject(*obj); } + + Value comparatorArg(size_t index) { + MOZ_ASSERT(index < ComparatorActualArgs); + return callArgs[index]; + } + Value comparatorThisValue() const { return thisv; } + Value comparatorReturnValue() const { return callArgs[0]; } + void setComparatorArgs(const Value& x, const Value& y) { + callArgs[0] = x; + callArgs[1] = y; + } + void setComparatorReturnValue(const Value& v) { callArgs[0] = v; } + + ComparatorKind comparatorKind() const { return comparatorKind_; } + + static ArraySortResult sortArrayWithComparator(ArraySortData* d); + static ArraySortResult sortTypedArrayWithComparator(ArraySortData* d); + + inline void freeMallocData(); + void trace(JSTracer* trc); + + static constexpr int32_t offsetOfDescriptor() { + return offsetof(ArraySortData, descriptor_); + } + static constexpr int32_t offsetOfComparator() { + return offsetof(ArraySortData, comparator_); + } + static constexpr int32_t offsetOfComparatorReturnValue() { + return offsetof(ArraySortData, callArgs[0]); + } + static constexpr int32_t offsetOfComparatorThis() { + return offsetof(ArraySortData, thisv); + } + static constexpr int32_t offsetOfComparatorArgs() { + return offsetof(ArraySortData, callArgs); + } +}; + +ArraySortResult CallComparatorSlow(ArraySortData* d, const Value& x, + const Value& y); + +} // namespace js + +#endif /* builtin_Sorting_h */ diff --git a/js/src/builtin/Sorting.js b/js/src/builtin/Sorting.js deleted file mode 100644 index 175b506192..0000000000 --- a/js/src/builtin/Sorting.js +++ /dev/null @@ -1,120 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -// We use varying sorts across the self-hosted codebase. All sorts are -// consolidated here to avoid confusion and re-implementation of existing -// algorithms. - -// For sorting small typed arrays. -function InsertionSort(array, from, to, comparefn) { - var item, swap, i, j; - for (i = from + 1; i <= to; i++) { - item = array[i]; - for (j = i - 1; j >= from; j--) { - swap = array[j]; - if (callContentFunction(comparefn, undefined, swap, item) <= 0) { - break; - } - array[j + 1] = swap; - } - array[j + 1] = item; - } -} - -// A helper function for MergeSortTypedArray. -// -// Merge comparefn-sorted slices list[start..<=mid] and list[mid+1..<=end], -// storing the merged sequence in out[start..<=end]. -function MergeTypedArray(list, out, start, mid, end, comparefn) { - // Skip lopsided runs to avoid doing useless work. - // Skip calling the comparator if the sub-list is already sorted. - if ( - mid >= end || - callContentFunction(comparefn, undefined, list[mid], list[mid + 1]) <= 0 - ) { - for (var i = start; i <= end; i++) { - out[i] = list[i]; - } - return; - } - - var i = start; - var j = mid + 1; - var k = start; - while (i <= mid && j <= end) { - var lvalue = list[i]; - var rvalue = list[j]; - if (callContentFunction(comparefn, undefined, lvalue, rvalue) <= 0) { - out[k++] = lvalue; - i++; - } else { - out[k++] = rvalue; - j++; - } - } - - // Empty out any remaining elements. - while (i <= mid) { - out[k++] = list[i++]; - } - while (j <= end) { - out[k++] = list[j++]; - } -} - -// Iterative, bottom up, mergesort. Optimized version for TypedArrays. -function MergeSortTypedArray(array, len, comparefn) { - assert( - IsPossiblyWrappedTypedArray(array), - "MergeSortTypedArray works only with typed arrays." - ); - - // Use the same TypedArray kind for the buffer. - var C = ConstructorForTypedArray(array); - - var lBuffer = new C(len); - - // Copy all elements into a temporary buffer, so that any modifications - // when calling |comparefn| are ignored. - for (var i = 0; i < len; i++) { - lBuffer[i] = array[i]; - } - - // Insertion sort for small arrays, where "small" is defined by performance - // testing. - if (len < 8) { - InsertionSort(lBuffer, 0, len - 1, comparefn); - - return lBuffer; - } - - // We do all of our allocating up front. - var rBuffer = new C(len); - - // Use insertion sort for the initial ranges. - var windowSize = 4; - for (var start = 0; start < len - 1; start += windowSize) { - var end = std_Math_min(start + windowSize - 1, len - 1); - InsertionSort(lBuffer, start, end, comparefn); - } - - for (; windowSize < len; windowSize = 2 * windowSize) { - for (var start = 0; start < len; start += 2 * windowSize) { - // The midpoint between the two subarrays. - var mid = start + windowSize - 1; - - // To keep from going over the edge. - var end = std_Math_min(start + 2 * windowSize - 1, len - 1); - - MergeTypedArray(lBuffer, rBuffer, start, mid, end, comparefn); - } - - // Swap both lists. - var swap = lBuffer; - lBuffer = rBuffer; - rBuffer = swap; - } - - return lBuffer; -} diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index da7efd2fcc..10115b8699 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -2121,11 +2121,16 @@ static bool WasmDumpIon(JSContext* cx, unsigned argc, Value* vp) { return false; } - args.rval().set(StringValue(out.release(cx))); + JSString* str = out.release(cx); + if (!str) { + ReportOutOfMemory(cx); + return false; + } + args.rval().set(StringValue(str)); return true; } -enum class Flag { Tier2Complete, Deserialized }; +enum class Flag { Tier2Complete, Deserialized, ParsedBranchHints }; static bool WasmReturnFlag(JSContext* cx, unsigned argc, Value* vp, Flag flag) { CallArgs args = CallArgsFromVp(argc, vp); @@ -2150,6 +2155,9 @@ static bool WasmReturnFlag(JSContext* cx, unsigned argc, Value* vp, Flag flag) { case Flag::Deserialized: b = module->module().loggingDeserialized(); break; + case Flag::ParsedBranchHints: + b = module->module().metadata().parsedBranchHints; + break; } args.rval().set(BooleanValue(b)); @@ -2221,6 +2229,12 @@ static bool WasmLoadedFromCache(JSContext* cx, unsigned argc, Value* vp) { return WasmReturnFlag(cx, argc, vp, Flag::Deserialized); } +#ifdef ENABLE_WASM_BRANCH_HINTING +static bool WasmParsedBranchHints(JSContext* cx, unsigned argc, Value* vp) { + return WasmReturnFlag(cx, argc, vp, Flag::ParsedBranchHints); +} +#endif // ENABLE_WASM_BRANCH_HINTING + static bool WasmBuiltinI8VecMul(JSContext* cx, unsigned argc, Value* vp) { if (!wasm::HasSupport(cx)) { JS_ReportErrorASCII(cx, "wasm support unavailable"); @@ -3773,10 +3787,14 @@ static bool NewDependentString(JSContext* cx, unsigned argc, Value* vp) { } if (requiredHeap.isSome()) { - MOZ_ASSERT_IF(*requiredHeap == gc::Heap::Tenured, result->isTenured()); - if ((*requiredHeap == gc::Heap::Default) && result->isTenured()) { - JS_ReportErrorASCII(cx, "nursery string created in tenured heap"); - return false; + if ((*requiredHeap == gc::Heap::Tenured) != result->isTenured()) { + if (result->isTenured()) { + JS_ReportErrorASCII(cx, "nursery string created in tenured heap"); + return false; + } else { + JS_ReportErrorASCII(cx, "tenured string created in nursery heap"); + return false; + } } } @@ -6246,7 +6264,7 @@ void ShapeSnapshot::check(JSContext* cx, const ShapeSnapshot& later) const { if (object_->is<NativeObject>()) { NativeObject* nobj = &object_->as<NativeObject>(); if (nobj->inDictionaryMode()) { - MOZ_RELEASE_ASSERT(shape_ != later.shape_); + MOZ_RELEASE_ASSERT(nobj->shape() != later.shape_); } } return; @@ -9956,6 +9974,14 @@ JS_FOR_WASM_FEATURES(WASM_FEATURE) " Gets the length of a WebAssembly GC array."), #endif // ENABLE_WASM_GC +#ifdef ENABLE_WASM_BRANCH_HINTING + JS_FN_HELP("wasmParsedBranchHints", WasmParsedBranchHints, 1, 0, +"wasmParsedBranchHints(module)", +" Returns a boolean indicating whether a given module has successfully parsed a\n" +" custom branch hinting section."), + +#endif // ENABLE_WASM_BRANCH_HINTING + JS_FN_HELP("largeArrayBufferSupported", LargeArrayBufferSupported, 0, 0, "largeArrayBufferSupported()", " Returns true if array buffers larger than 2GB can be allocated."), diff --git a/js/src/builtin/TypedArray.js b/js/src/builtin/TypedArray.js index 4d5474f6a7..46b81ebedc 100644 --- a/js/src/builtin/TypedArray.js +++ b/js/src/builtin/TypedArray.js @@ -1129,67 +1129,6 @@ function TypedArraySome(callbackfn /*, thisArg*/) { // Inlining this enables inlining of the callback function. SetIsInlinableLargeFunction(TypedArraySome); -// To satisfy step 6.b from TypedArray SortCompare described in 23.2.3.29 the -// user supplied comparefn is wrapped. -function TypedArraySortCompare(comparefn) { - return function(x, y) { - // Step 6.b.i. - var v = +callContentFunction(comparefn, undefined, x, y); - - // Step 6.b.ii. - if (v !== v) { - return 0; - } - - // Step 6.b.iii. - return v; - }; -} - -// ES2019 draft rev 8a16cb8d18660a1106faae693f0f39b9f1a30748 -// 22.2.3.26 %TypedArray%.prototype.sort ( comparefn ) -function TypedArraySort(comparefn) { - // This function is not generic. - - // Step 1. - if (comparefn !== undefined) { - if (!IsCallable(comparefn)) { - ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, comparefn)); - } - } - - // Step 2. - var obj = this; - - // Step 3. - EnsureTypedArrayWithArrayBuffer(obj); - - // Step 4. - var len = PossiblyWrappedTypedArrayLength(obj); - - // Arrays with less than two elements remain unchanged when sorted. - if (len <= 1) { - return obj; - } - - if (comparefn === undefined) { - return TypedArrayNativeSort(obj); - } - - // Steps 5-6. - var wrappedCompareFn = TypedArraySortCompare(comparefn); - - // Step 7. - var sorted = MergeSortTypedArray(obj, len, wrappedCompareFn); - - // Move the sorted elements into the array. - for (var i = 0; i < len; i++) { - obj[i] = sorted[i]; - } - - return obj; -} - // ES2017 draft rev f8a9be8ea4bd97237d176907a1e3080dce20c68f // 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) // ES2017 Intl draft rev 78bbe7d1095f5ff3760ac4017ed366026e4cb276 @@ -2129,10 +2068,11 @@ function TypedArrayWith(index, value) { return A; } -// https://github.com/tc39/proposal-change-array-by-copy -// TypedArray.prototype.toSorted() +// https://tc39.es/ecma262/#sec-%typedarray%.prototype.tosorted +// 23.2.3.33 %TypedArray%.prototype.toSorted ( comparefn ) function TypedArrayToSorted(comparefn) { - // Step 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. + // Step 1. If comparefn is not undefined and IsCallable(comparefn) is false, + // throw a TypeError exception. if (comparefn !== undefined) { if (!IsCallable(comparefn)) { ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, comparefn)); @@ -2145,48 +2085,27 @@ function TypedArrayToSorted(comparefn) { // Step 3. Perform ? ValidateTypedArray(this). EnsureTypedArrayWithArrayBuffer(O); - // Step 4. omitted. Let buffer be obj.[[ViewedArrayBuffer]]. - // FIXME: Draft spec not synched with https://github.com/tc39/ecma262/pull/2723 - - // Step 5. Let len be O.[[ArrayLength]]. + // Step 4. Let len be TypedArrayLength(taRecord). var len = PossiblyWrappedTypedArrayLength(O); - // Arrays with less than two elements remain unchanged when sorted. - if (len <= 1) { - // Step 6. Let A be ? TypedArrayCreateSameType(O, « 𝔽(len) »). - var A = TypedArrayCreateSameType(O, len); + // Step 5. Let A be ? TypedArrayCreateSameType(O, « 𝔽(len) »). + var A = TypedArrayCreateSameType(O, len); - // Steps 7-11. - if (len > 0) { - A[0] = O[0]; - } + // Steps 6-10 not followed exactly; this implementation copies the list and then + // sorts the copy, rather than calling a sort method that copies the list and then + // copying the result again. - // Step 12. - return A; + // Equivalent to steps 9-10. + for (var k = 0; k < len; k++) { + A[k] = O[k]; } - if (comparefn === undefined) { - // Step 6. Let A be ? TypedArrayCreateSameType(O, « 𝔽(len) »). - var A = TypedArrayCreateSameType(O, len); - - // Steps 7-11 not followed exactly; this implementation copies the list and then - // sorts the copy, rather than calling a sort method that copies the list and then - // copying the result again. - - // Equivalent to steps 10-11. - for (var k = 0; k < len; k++) { - A[k] = O[k]; - } - - // Equivalent to steps 7-9 and 12. - return TypedArrayNativeSort(A); + // Arrays with less than two elements remain unchanged when sorted. + if (len > 1) { + // Equivalent to steps 6-8. + callFunction(std_TypedArray_sort, A, comparefn); } - // Steps 7-8. - var wrappedCompareFn = TypedArraySortCompare(comparefn); - - // Steps 6 and 9-12. - // - // MergeSortTypedArray returns a sorted copy - exactly what we need to return. - return MergeSortTypedArray(O, len, wrappedCompareFn); + // Step 11. + return A; } diff --git a/js/src/builtin/temporal/Calendar.cpp b/js/src/builtin/temporal/Calendar.cpp index 8a06877093..573a1740d2 100644 --- a/js/src/builtin/temporal/Calendar.cpp +++ b/js/src/builtin/temporal/Calendar.cpp @@ -137,18 +137,22 @@ static bool IterableToListOfStrings(JSContext* cx, Handle<Value> items, // Step 1. (Not applicable in our implementation.) - // Steps 2-3. + // Step 2. Rooted<Value> nextValue(cx); Rooted<PropertyKey> value(cx); while (true) { + // Step 2.a. bool done; if (!iterator.next(&nextValue, &done)) { return false; } + + // Step 2.b. if (done) { - break; + return true; } + // Step 2.d. (Reordered) if (nextValue.isString()) { if (!PrimitiveValueToId<CanGC>(cx, nextValue, &value)) { return false; @@ -159,15 +163,14 @@ static bool IterableToListOfStrings(JSContext* cx, Handle<Value> items, continue; } + // Step 2.c.1. ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_IGNORE_STACK, nextValue, nullptr, "not a string"); + // Step 2.c.2. iterator.closeThrow(); return false; } - - // Step 4. - return true; } /** @@ -312,7 +315,7 @@ int32_t js::temporal::ToISODayOfYear(const PlainDate& date) { MOZ_ASSERT(ISODateTimeWithinLimits(date)); // Steps 1-5. - auto& [year, month, day] = date; + const auto& [year, month, day] = date; return ::ToISODayOfYear(year, month, day); } @@ -423,7 +426,7 @@ struct YearWeek final { static YearWeek ToISOWeekOfYear(const PlainDate& date) { MOZ_ASSERT(ISODateTimeWithinLimits(date)); - auto& [year, month, day] = date; + const auto& [year, month, day] = date; // TODO: https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system // TODO: https://en.wikipedia.org/wiki/ISO_week_date#Algorithms @@ -1054,6 +1057,88 @@ static bool BuiltinCalendarFields( return true; } +/** + * Temporal.Calendar.prototype.fields ( fields ) + */ +static bool BuiltinCalendarFields(JSContext* cx, Handle<Value> fields, + MutableHandle<Value> result) { + // Step 4. + JS::ForOfIterator iterator(cx); + if (!iterator.init(fields)) { + return false; + } + + // Step 5. + JS::RootedVector<Value> fieldNames(cx); + mozilla::EnumSet<CalendarField> seen; + + // Step 6. + Rooted<Value> nextValue(cx); + Rooted<JSLinearString*> linear(cx); + while (true) { + // Step 6.a. + bool done; + if (!iterator.next(&nextValue, &done)) { + return false; + } + + // Step 6.b. + if (done) { + auto* array = + NewDenseCopiedArray(cx, fieldNames.length(), fieldNames.begin()); + if (!array) { + return false; + } + + result.setObject(*array); + return true; + } + + // Step 6.c. + if (!nextValue.isString()) { + // Step 6.c.1. + ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_IGNORE_STACK, nextValue, + nullptr, "not a string"); + + // Step 6.c.2. + iterator.closeThrow(); + return false; + } + + linear = nextValue.toString()->ensureLinear(cx); + if (!linear) { + return false; + } + + // Step 6.e. (Reordered) + CalendarField field; + if (!ToCalendarField(cx, linear, &field)) { + iterator.closeThrow(); + return false; + } + + // Step 6.d. + if (seen.contains(field)) { + // Step 6.d.1. + if (auto chars = QuoteString(cx, linear, '"')) { + JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_CALENDAR_DUPLICATE_FIELD, + chars.get()); + } + + // Step 6.d.2. + iterator.closeThrow(); + return false; + } + + // Step 6.f. + if (!fieldNames.append(nextValue)) { + return false; + } + seen += field; + } +} + #ifdef DEBUG static bool IsSorted(std::initializer_list<CalendarField> fieldNames) { return std::is_sorted(fieldNames.begin(), fieldNames.end(), @@ -1075,15 +1160,12 @@ bool js::temporal::CalendarFields( MOZ_ASSERT( CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::Fields)); - // FIXME: spec issue - the input is already sorted, let's assert this, too. + // Step 1. MOZ_ASSERT(IsSorted(fieldNames)); - - // FIXME: spec issue - the input shouldn't have duplicate elements. Let's - // assert this, too. MOZ_ASSERT(std::adjacent_find(fieldNames.begin(), fieldNames.end()) == fieldNames.end()); - // Step 1. + // Step 2. auto fields = calendar.fields(); if (!fields) { bool arrayIterationSane; @@ -1098,16 +1180,14 @@ bool js::temporal::CalendarFields( } if (arrayIterationSane) { - // Steps 1.a-b. (Not applicable in our implementation.) - - // Step 1.c. + // Steps 2.a-b. return BuiltinCalendarFields(cx, fieldNames, result.get()); - // Steps 1.d-f. (Not applicable in our implementation.) + // Steps 2.c-e. (Not applicable in our implementation.) } } - // Step 2. (Inlined call to CalendarMethodsRecordCall.) + // Step 3. (Inlined call to CalendarMethodsRecordCall.) auto* array = NewDenseFullyAllocatedArray(cx, fieldNames.size()); if (!array) { @@ -1120,15 +1200,22 @@ bool js::temporal::CalendarFields( array->initDenseElement(i, StringValue(name)); } - Rooted<Value> fieldsFn(cx, ObjectValue(*fields)); - auto thisv = calendar.receiver().toValue(); Rooted<Value> fieldsArray(cx, ObjectValue(*array)); - if (!Call(cx, fieldsFn, thisv, fieldsArray, &fieldsArray)) { - return false; + Rooted<Value> calendarFieldNames(cx); + if (fields) { + Rooted<Value> fieldsFn(cx, ObjectValue(*fields)); + auto thisv = calendar.receiver().toValue(); + if (!Call(cx, fieldsFn, thisv, fieldsArray, &calendarFieldNames)) { + return false; + } + } else { + if (!BuiltinCalendarFields(cx, fieldsArray, &calendarFieldNames)) { + return false; + } } - // Steps 3-4. - if (!IterableToListOfStrings(cx, fieldsArray, result)) { + // Steps 4-5. + if (!IterableToListOfStrings(cx, calendarFieldNames, result)) { return false; } @@ -1184,6 +1271,26 @@ static bool RequireIntegralPositiveNumber(JSContext* cx, Handle<Value> value, return true; } +static bool RequireIntegralNumberOrUndefined(JSContext* cx, Handle<Value> value, + Handle<PropertyName*> name, + MutableHandle<Value> result) { + if (value.isUndefined()) { + result.setUndefined(); + return true; + } + return RequireIntegralNumber(cx, value, name, result); +} + +static bool RequireIntegralPositiveNumberOrUndefined( + JSContext* cx, Handle<Value> value, Handle<PropertyName*> name, + MutableHandle<Value> result) { + if (value.isUndefined()) { + result.setUndefined(); + return true; + } + return RequireIntegralPositiveNumber(cx, value, name, result); +} + static bool RequireString(JSContext* cx, Handle<Value> value, Handle<PropertyName*> name, MutableHandle<Value> result) { @@ -1756,7 +1863,7 @@ static bool CalendarWeekOfYear(JSContext* cx, Handle<CalendarValue> calendar, MutableHandle<Value> result) { // Steps 1-6. return CallCalendarMethod<BuiltinCalendarWeekOfYear, - RequireIntegralPositiveNumber>( + RequireIntegralPositiveNumberOrUndefined>( cx, cx->names().weekOfYear, Calendar_weekOfYear, calendar, dateLike, date, result); } @@ -1821,7 +1928,8 @@ static bool CalendarYearOfWeek(JSContext* cx, Handle<CalendarValue> calendar, const PlainDate& date, MutableHandle<Value> result) { // Steps 1-5. - return CallCalendarMethod<BuiltinCalendarYearOfWeek, RequireIntegralNumber>( + return CallCalendarMethod<BuiltinCalendarYearOfWeek, + RequireIntegralNumberOrUndefined>( cx, cx->names().yearOfWeek, Calendar_yearOfWeek, calendar, dateLike, date, result); } @@ -2482,8 +2590,8 @@ Wrapped<PlainDateObject*> js::temporal::CalendarDateFromFields( } struct RegulatedISOYearMonth final { - double year; - int32_t month; + double year = 0; + int32_t month = 0; }; /** @@ -2492,33 +2600,30 @@ struct RegulatedISOYearMonth final { static bool RegulateISOYearMonth(JSContext* cx, double year, double month, TemporalOverflow overflow, RegulatedISOYearMonth* result) { - // Step 1. MOZ_ASSERT(IsInteger(year)); MOZ_ASSERT(IsInteger(month)); - // Step 2. (Not applicable in our implementation.) - - // Step 3. + // Step 1. if (overflow == TemporalOverflow::Constrain) { - // Step 3.a. + // Step 1.a. month = std::clamp(month, 1.0, 12.0); - // Step 3.b. + // Step 1.b. *result = {year, int32_t(month)}; return true; } - // Step 4.a. + // Step 2.a. MOZ_ASSERT(overflow == TemporalOverflow::Reject); - // Step 4.b. + // Step 2.b. if (month < 1 || month > 12) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TEMPORAL_PLAIN_YEAR_MONTH_INVALID); return false; } - // Step 4.c. + // Step 2.c. *result = {year, int32_t(month)}; return true; } @@ -2850,7 +2955,7 @@ static bool ISOFieldKeysToIgnore(JSContext* cx, const PropertyVector& keys, // Step 2. bool seenMonthOrMonthCode = false; - for (auto& key : keys) { + for (const auto& key : keys) { // Reorder the substeps in order to use |putNew| instead of |put|, because // the former is slightly faster. @@ -2874,7 +2979,7 @@ static bool ISOFieldKeysToIgnore(JSContext* cx, const PropertyVector& keys, } } - // Step 3. + // Steps 3-4. return true; } @@ -3060,7 +3165,7 @@ JSObject* js::temporal::CalendarMergeFields( * Temporal.Calendar.prototype.dateAdd ( date, duration [ , options ] ) */ static bool BuiltinCalendarAdd(JSContext* cx, const PlainDate& date, - const Duration& duration, + const NormalizedDuration& duration, Handle<JSObject*> options, PlainDate* result) { MOZ_ASSERT(IsValidISODate(date)); MOZ_ASSERT(IsValidDuration(duration)); @@ -3076,32 +3181,71 @@ static bool BuiltinCalendarAdd(JSContext* cx, const PlainDate& date, } // Step 8. - TimeDuration balanceResult; - if (!BalanceTimeDuration(cx, duration, TemporalUnit::Day, &balanceResult)) { - return false; - } + const auto& timeDuration = duration.time; // Step 9. - Duration addDuration = {duration.years, duration.months, duration.weeks, - balanceResult.days}; + auto balanceResult = BalanceTimeDuration(timeDuration, TemporalUnit::Day); + + // Step 10. + auto addDuration = DateDuration{ + duration.date.years, + duration.date.months, + duration.date.weeks, + duration.date.days + balanceResult.days, + }; return AddISODate(cx, date, addDuration, overflow, result); } /** * Temporal.Calendar.prototype.dateAdd ( date, duration [ , options ] ) */ +static bool BuiltinCalendarAdd(JSContext* cx, const PlainDate& date, + const DateDuration& duration, + Handle<JSObject*> options, PlainDate* result) { + // Steps 1-6. (Not applicable) + + // Step 8. (Reordered) + auto normalized = CreateNormalizedDurationRecord(duration, {}); + + // Steps 7-10. + return BuiltinCalendarAdd(cx, date, normalized, options, result); +} + +/** + * Temporal.Calendar.prototype.dateAdd ( date, duration [ , options ] ) + */ +static PlainDateObject* BuiltinCalendarAdd(JSContext* cx, const PlainDate& date, + const DateDuration& duration, + Handle<JSObject*> options) { + // Steps 1-10. + PlainDate result; + if (!BuiltinCalendarAdd(cx, date, duration, options, &result)) { + return nullptr; + } + + // Step 11. + Rooted<CalendarValue> calendar(cx, CalendarValue(cx->names().iso8601)); + return CreateTemporalDate(cx, result, calendar); +} + +/** + * Temporal.Calendar.prototype.dateAdd ( date, duration [ , options ] ) + */ static PlainDateObject* BuiltinCalendarAdd(JSContext* cx, const PlainDate& date, const Duration& duration, Handle<JSObject*> options) { // Steps 1-6. (Not applicable) - // Steps 7-9. + // Step 8. (Reordered) + auto normalized = CreateNormalizedDurationRecord(duration); + + // Steps 7-10. PlainDate result; - if (!BuiltinCalendarAdd(cx, date, duration, options, &result)) { + if (!BuiltinCalendarAdd(cx, date, normalized, options, &result)) { return nullptr; } - // Step 10. + // Step 11. Rooted<CalendarValue> calendar(cx, CalendarValue(cx->names().iso8601)); return CreateTemporalDate(cx, result, calendar); } @@ -3188,6 +3332,38 @@ static Wrapped<PlainDateObject*> CalendarDateAdd( */ static Wrapped<PlainDateObject*> CalendarDateAdd( JSContext* cx, Handle<CalendarRecord> calendar, + Handle<Wrapped<PlainDateObject*>> date, const DateDuration& duration, + Handle<JSObject*> options) { + MOZ_ASSERT( + CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateAdd)); + + // Step 1. (Not applicable). + + // Step 3. (Reordered) + if (!calendar.dateAdd()) { + auto* unwrappedDate = date.unwrap(cx); + if (!unwrappedDate) { + return nullptr; + } + auto date = ToPlainDate(unwrappedDate); + + return BuiltinCalendarAdd(cx, date, duration, options); + } + + // Steps 2 and 4-5. + Rooted<DurationObject*> durationObj( + cx, CreateTemporalDuration(cx, duration.toDuration())); + if (!durationObj) { + return nullptr; + } + return CalendarDateAddSlow(cx, calendar, date, durationObj, options); +} + +/** + * CalendarDateAdd ( calendarRec, date, duration [ , options ] ) + */ +static Wrapped<PlainDateObject*> CalendarDateAdd( + JSContext* cx, Handle<CalendarRecord> calendar, Handle<Wrapped<PlainDateObject*>> date, Handle<Wrapped<DurationObject*>> duration, Handle<JSObject*> options) { MOZ_ASSERT( @@ -3221,8 +3397,8 @@ static Wrapped<PlainDateObject*> CalendarDateAdd( */ static bool CalendarDateAdd(JSContext* cx, Handle<CalendarRecord> calendar, Handle<Wrapped<PlainDateObject*>> date, - const Duration& duration, Handle<JSObject*> options, - PlainDate* result) { + const DateDuration& duration, + Handle<JSObject*> options, PlainDate* result) { MOZ_ASSERT( CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateAdd)); @@ -3241,7 +3417,8 @@ static bool CalendarDateAdd(JSContext* cx, Handle<CalendarRecord> calendar, // Steps 2 and 4-5. - Rooted<DurationObject*> durationObj(cx, CreateTemporalDuration(cx, duration)); + Rooted<DurationObject*> durationObj( + cx, CreateTemporalDuration(cx, duration.toDuration())); if (!durationObj) { return false; } @@ -3259,7 +3436,7 @@ static bool CalendarDateAdd(JSContext* cx, Handle<CalendarRecord> calendar, * CalendarDateAdd ( calendarRec, date, duration [ , options ] ) */ static bool CalendarDateAdd(JSContext* cx, Handle<CalendarRecord> calendar, - const PlainDate& date, const Duration& duration, + const PlainDate& date, const DateDuration& duration, Handle<JSObject*> options, PlainDate* result) { MOZ_ASSERT( CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateAdd)); @@ -3279,7 +3456,8 @@ static bool CalendarDateAdd(JSContext* cx, Handle<CalendarRecord> calendar, return false; } - Rooted<DurationObject*> durationObj(cx, CreateTemporalDuration(cx, duration)); + Rooted<DurationObject*> durationObj( + cx, CreateTemporalDuration(cx, duration.toDuration())); if (!durationObj) { return false; } @@ -3311,7 +3489,7 @@ Wrapped<PlainDateObject*> js::temporal::CalendarDateAdd( */ Wrapped<PlainDateObject*> js::temporal::CalendarDateAdd( JSContext* cx, Handle<CalendarRecord> calendar, - Handle<Wrapped<PlainDateObject*>> date, const Duration& duration) { + Handle<Wrapped<PlainDateObject*>> date, const DateDuration& duration) { // Step 1. Handle<JSObject*> options = nullptr; @@ -3352,7 +3530,7 @@ Wrapped<PlainDateObject*> js::temporal::CalendarDateAdd( bool js::temporal::CalendarDateAdd(JSContext* cx, Handle<CalendarRecord> calendar, const PlainDate& date, - const Duration& duration, + const DateDuration& duration, PlainDate* result) { // Step 1. Handle<JSObject*> options = nullptr; @@ -3364,9 +3542,12 @@ bool js::temporal::CalendarDateAdd(JSContext* cx, /** * CalendarDateAdd ( calendarRec, date, duration [ , options ] ) */ -bool js::temporal::CalendarDateAdd( - JSContext* cx, Handle<CalendarRecord> calendar, const PlainDate& date, - const Duration& duration, Handle<JSObject*> options, PlainDate* result) { +bool js::temporal::CalendarDateAdd(JSContext* cx, + Handle<CalendarRecord> calendar, + const PlainDate& date, + const DateDuration& duration, + Handle<JSObject*> options, + PlainDate* result) { // Step 1. (Not applicable) // Steps 2-5. @@ -3379,7 +3560,7 @@ bool js::temporal::CalendarDateAdd( bool js::temporal::CalendarDateAdd(JSContext* cx, Handle<CalendarRecord> calendar, Handle<Wrapped<PlainDateObject*>> date, - const Duration& duration, + const DateDuration& duration, PlainDate* result) { // Step 1. Handle<JSObject*> options = nullptr; @@ -3391,18 +3572,15 @@ bool js::temporal::CalendarDateAdd(JSContext* cx, /** * Temporal.Calendar.prototype.dateUntil ( one, two [ , options ] ) */ -static Duration BuiltinCalendarDateUntil(const PlainDate& one, - const PlainDate& two, - TemporalUnit largestUnit) { +static DateDuration BuiltinCalendarDateUntil(const PlainDate& one, + const PlainDate& two, + TemporalUnit largestUnit) { // Steps 1-3. (Not applicable) // Steps 4-8. (Not applicable) - // Step 9. - auto difference = DifferenceISODate(one, two, largestUnit); - - // Step 10. - return difference.toDuration(); + // Steps 9-10. + return DifferenceISODate(one, two, largestUnit); } /** @@ -3412,7 +3590,7 @@ static bool BuiltinCalendarDateUntil(JSContext* cx, Handle<Wrapped<PlainDateObject*>> one, Handle<Wrapped<PlainDateObject*>> two, TemporalUnit largestUnit, - Duration* result) { + DateDuration* result) { MOZ_ASSERT(largestUnit <= TemporalUnit::Day); auto* unwrappedOne = one.unwrap(cx); @@ -3432,37 +3610,31 @@ static bool BuiltinCalendarDateUntil(JSContext* cx, return true; } -/** - * Temporal.Calendar.prototype.dateUntil ( one, two [ , options ] ) - */ -static bool BuiltinCalendarDateUntil(JSContext* cx, - Handle<Wrapped<PlainDateObject*>> one, - Handle<Wrapped<PlainDateObject*>> two, - Handle<JSObject*> options, - Duration* result) { - // Steps 1-6. (Not applicable) - - // Steps 7-8. - auto largestUnit = TemporalUnit::Day; - if (!GetTemporalUnit(cx, options, TemporalUnitKey::LargestUnit, - TemporalUnitGroup::Date, &largestUnit)) { - return false; - } - - // Steps 9-10. - return BuiltinCalendarDateUntil(cx, one, two, largestUnit, result); -} - static bool CalendarDateUntilSlow(JSContext* cx, Handle<CalendarRecord> calendar, Handle<Wrapped<PlainDateObject*>> one, Handle<Wrapped<PlainDateObject*>> two, - Handle<JSObject*> options, Duration* result) { + TemporalUnit largestUnit, + Handle<JSObject*> maybeOptions, + DateDuration* result) { MOZ_ASSERT( CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateUntil)); MOZ_ASSERT(calendar.receiver().isObject()); MOZ_ASSERT(calendar.dateUntil()); + Rooted<JSObject*> options(cx, maybeOptions); + if (!options) { + options = NewPlainObjectWithProto(cx, nullptr); + if (!options) { + return false; + } + } + + Rooted<Value> value(cx, StringValue(TemporalUnitToString(cx, largestUnit))); + if (!DefineDataProperty(cx, options, cx->names().largestUnit, value)) { + return false; + } + // Step 1. (Inlined call to CalendarMethodsRecordCall.) Rooted<JS::Value> dateUntil(cx, ObjectValue(*calendar.dateUntil())); auto thisv = calendar.receiver().toValue(); @@ -3488,29 +3660,90 @@ static bool CalendarDateUntilSlow(JSContext* cx, } // Step 4. - *result = ToDuration(&rval.toObject().unwrapAs<DurationObject>()); + auto duration = ToDuration(&rval.toObject().unwrapAs<DurationObject>()); + *result = duration.toDateDuration(); return true; } +static bool CalendarDateUntilSlow(JSContext* cx, + Handle<CalendarRecord> calendar, + const PlainDate& one, const PlainDate& two, + TemporalUnit largestUnit, + Handle<JSObject*> maybeOptions, + DateDuration* result) { + Rooted<PlainDateObject*> date1( + cx, CreateTemporalDate(cx, one, calendar.receiver())); + if (!date1) { + return false; + } + + Rooted<PlainDateObject*> date2( + cx, CreateTemporalDate(cx, two, calendar.receiver())); + if (!date2) { + return false; + } + + return CalendarDateUntilSlow(cx, calendar, date1, date2, largestUnit, + maybeOptions, result); +} + /** * CalendarDateUntil ( calendarRec, one, two, options ) */ bool js::temporal::CalendarDateUntil(JSContext* cx, Handle<CalendarRecord> calendar, - Handle<Wrapped<PlainDateObject*>> one, - Handle<Wrapped<PlainDateObject*>> two, + const PlainDate& one, const PlainDate& two, + TemporalUnit largestUnit, + DateDuration* result) { + MOZ_ASSERT( + CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateUntil)); + MOZ_ASSERT(largestUnit <= TemporalUnit::Day); + + // Step 2. (Reordered) + if (!calendar.dateUntil()) { + *result = BuiltinCalendarDateUntil(one, two, largestUnit); + return true; + } + + // Steps 1 and 3-4. + return CalendarDateUntilSlow(cx, calendar, one, two, largestUnit, nullptr, + result); +} + +/** + * CalendarDateUntil ( calendarRec, one, two, options ) + */ +bool js::temporal::CalendarDateUntil(JSContext* cx, + Handle<CalendarRecord> calendar, + const PlainDate& one, const PlainDate& two, + TemporalUnit largestUnit, Handle<PlainObject*> options, - Duration* result) { + DateDuration* result) { MOZ_ASSERT( CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateUntil)); + // As an optimization, our implementation only adds |largestUnit| to the + // options object when taking the slow-path. +#ifdef DEBUG + // The object must be extensible, otherwise we'd need to throw an error when + // attempting to add the "largestUnit" property to a non-extensible object. + MOZ_ASSERT(options->isExtensible()); + + // Similarily, if there's an existing "largestUnit" property, this property + // must be configurable. + auto largestUnitProp = options->lookupPure(cx->names().largestUnit); + MOZ_ASSERT_IF(largestUnitProp, largestUnitProp->configurable()); +#endif + // Step 2. (Reordered) if (!calendar.dateUntil()) { - return BuiltinCalendarDateUntil(cx, one, two, options, result); + *result = BuiltinCalendarDateUntil(one, two, largestUnit); + return true; } // Steps 1 and 3-4. - return CalendarDateUntilSlow(cx, calendar, one, two, options, result); + return CalendarDateUntilSlow(cx, calendar, one, two, largestUnit, options, + result); } /** @@ -3521,7 +3754,7 @@ bool js::temporal::CalendarDateUntil(JSContext* cx, Handle<Wrapped<PlainDateObject*>> one, Handle<Wrapped<PlainDateObject*>> two, TemporalUnit largestUnit, - Duration* result) { + DateDuration* result) { MOZ_ASSERT( CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateUntil)); MOZ_ASSERT(largestUnit <= TemporalUnit::Day); @@ -3531,18 +3764,45 @@ bool js::temporal::CalendarDateUntil(JSContext* cx, return BuiltinCalendarDateUntil(cx, one, two, largestUnit, result); } - Rooted<PlainObject*> untilOptions(cx, NewPlainObjectWithProto(cx, nullptr)); - if (!untilOptions) { - return false; - } + // Steps 1 and 3-4. + return CalendarDateUntilSlow(cx, calendar, one, two, largestUnit, nullptr, + result); +} - Rooted<Value> value(cx, StringValue(TemporalUnitToString(cx, largestUnit))); - if (!DefineDataProperty(cx, untilOptions, cx->names().largestUnit, value)) { - return false; +/** + * CalendarDateUntil ( calendarRec, one, two, options ) + */ +bool js::temporal::CalendarDateUntil(JSContext* cx, + Handle<CalendarRecord> calendar, + Handle<Wrapped<PlainDateObject*>> one, + Handle<Wrapped<PlainDateObject*>> two, + TemporalUnit largestUnit, + Handle<PlainObject*> options, + DateDuration* result) { + MOZ_ASSERT( + CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateUntil)); + + // As an optimization, our implementation only adds |largestUnit| to the + // options object when taking the slow-path. +#ifdef DEBUG + // The object must be extensible, otherwise we'd need to throw an error when + // attempting to add the "largestUnit" property to a non-extensible object. + MOZ_ASSERT(options->isExtensible()); + + // Similarily, if there's an existing "largestUnit" property, this property + // must be configurable. + auto largestUnitProp = options->lookupPure(cx->names().largestUnit); + MOZ_ASSERT_IF(largestUnitProp, largestUnitProp->configurable()); +#endif + + // Step 2. (Reordered) + if (!calendar.dateUntil()) { + return BuiltinCalendarDateUntil(cx, one, two, largestUnit, result); } // Steps 1 and 3-4. - return CalendarDateUntilSlow(cx, calendar, one, two, untilOptions, result); + return CalendarDateUntilSlow(cx, calendar, one, two, largestUnit, options, + result); } /** @@ -3925,7 +4185,7 @@ static bool Calendar_dateAdd(JSContext* cx, const CallArgs& args) { } } - // Steps 7-10. + // Steps 7-11. auto* obj = BuiltinCalendarAdd(cx, date, duration, options); if (!obj) { return false; @@ -3979,10 +4239,11 @@ static bool Calendar_dateUntil(JSContext* cx, const CallArgs& args) { } } - // Steps 9-10. + // Step 9. auto duration = BuiltinCalendarDateUntil(one, two, largestUnit); - auto* obj = CreateTemporalDuration(cx, duration); + // Step 10. + auto* obj = CreateTemporalDuration(cx, duration.toDuration()); if (!obj) { return false; } @@ -4363,76 +4624,8 @@ static bool Calendar_fields(JSContext* cx, const CallArgs& args) { // Step 3. MOZ_ASSERT(IsISO8601Calendar(&args.thisv().toObject().as<CalendarObject>())); - // Step 4. - JS::ForOfIterator iterator(cx); - if (!iterator.init(args.get(0))) { - return false; - } - - // Step 5. - JS::RootedVector<Value> fieldNames(cx); - mozilla::EnumSet<CalendarField> seen; - - // Steps 6-7. - Rooted<Value> nextValue(cx); - Rooted<JSLinearString*> linear(cx); - while (true) { - // Steps 7.a and 7.b.i. - bool done; - if (!iterator.next(&nextValue, &done)) { - return false; - } - if (done) { - break; - } - - // Step 7.b.ii. - if (!nextValue.isString()) { - ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_IGNORE_STACK, nextValue, - nullptr, "not a string"); - iterator.closeThrow(); - return false; - } - - linear = nextValue.toString()->ensureLinear(cx); - if (!linear) { - return false; - } - - // Step 7.b.iv. (Reordered) - CalendarField field; - if (!ToCalendarField(cx, linear, &field)) { - iterator.closeThrow(); - return false; - } - - // Step 7.b.iii. - if (seen.contains(field)) { - if (auto chars = QuoteString(cx, linear, '"')) { - JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, - JSMSG_TEMPORAL_CALENDAR_DUPLICATE_FIELD, - chars.get()); - } - iterator.closeThrow(); - return false; - } - - // Step 7.b.v. - if (!fieldNames.append(nextValue)) { - return false; - } - seen += field; - } - - // Step 8. - auto* array = - NewDenseCopiedArray(cx, fieldNames.length(), fieldNames.begin()); - if (!array) { - return false; - } - - args.rval().setObject(*array); - return true; + // Steps 4-6. + return BuiltinCalendarFields(cx, args.get(0), args.rval()); } /** @@ -4512,18 +4705,14 @@ static bool Calendar_mergeFields(JSContext* cx, const CallArgs& args) { for (size_t i = 0; i < fieldsKeys.length(); i++) { Handle<PropertyKey> key = fieldsKeys[i]; - // Step 12.a. - // FIXME: spec issue - unnecessary initialisation - // https://github.com/tc39/proposal-temporal/issues/2549 - - // Steps 12.b-c. + // Steps 12.a-b. if (overriddenKeys.has(key)) { if (!GetProperty(cx, additionalFieldsCopy, additionalFieldsCopy, key, &propValue)) { return false; } - // Step 12.d. (Reordered) + // Step 12.c. (Reordered) if (propValue.isUndefined()) { // The property can be undefined if the key is "month" or "monthCode". MOZ_ASSERT(key.isAtom(cx->names().month) || @@ -4540,7 +4729,7 @@ static bool Calendar_mergeFields(JSContext* cx, const CallArgs& args) { MOZ_ASSERT(!propValue.isUndefined()); } - // Step 12.d. + // Step 12.c. if (!DefineDataProperty(cx, merged, key, propValue)) { return false; } diff --git a/js/src/builtin/temporal/Calendar.h b/js/src/builtin/temporal/Calendar.h index f80f528d83..dd06c11923 100644 --- a/js/src/builtin/temporal/Calendar.h +++ b/js/src/builtin/temporal/Calendar.h @@ -8,6 +8,7 @@ #define builtin_temporal_Calendar_h #include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" #include "mozilla/EnumSet.h" #include <initializer_list> @@ -49,7 +50,7 @@ class CalendarObject : public NativeObject { * Calendar value, which is either a string containing a canonical calendar * identifier or an object. */ -class CalendarValue final { +class MOZ_STACK_CLASS CalendarValue final { JS::Value value_{}; public: @@ -126,7 +127,7 @@ enum class CalendarMethod { YearMonthFromFields, }; -class CalendarRecord { +class MOZ_STACK_CLASS CalendarRecord final { CalendarValue receiver_; // Null unless non-builtin calendar methods are used. @@ -190,6 +191,7 @@ class CalendarRecord { void trace(JSTracer* trc); }; +struct DateDuration; struct Duration; struct PlainDate; struct PlainDateTime; @@ -199,6 +201,7 @@ class PlainDateTimeObject; class PlainMonthDayObject; class PlainYearMonthObject; enum class CalendarOption; +enum class TemporalOverflow; enum class TemporalUnit; /** @@ -305,7 +308,7 @@ JSObject* CalendarMergeFields(JSContext* cx, */ Wrapped<PlainDateObject*> CalendarDateAdd( JSContext* cx, JS::Handle<CalendarRecord> calendar, - JS::Handle<Wrapped<PlainDateObject*>> date, const Duration& duration); + JS::Handle<Wrapped<PlainDateObject*>> date, const DateDuration& duration); /** * CalendarDateAdd ( calendarRec, date, duration [ , options ] ) @@ -336,14 +339,14 @@ Wrapped<PlainDateObject*> CalendarDateAdd( * CalendarDateAdd ( calendarRec, date, duration [ , options ] ) */ bool CalendarDateAdd(JSContext* cx, JS::Handle<CalendarRecord> calendar, - const PlainDate& date, const Duration& duration, + const PlainDate& date, const DateDuration& duration, PlainDate* result); /** * CalendarDateAdd ( calendarRec, date, duration [ , options ] ) */ bool CalendarDateAdd(JSContext* cx, JS::Handle<CalendarRecord> calendar, - const PlainDate& date, const Duration& duration, + const PlainDate& date, const DateDuration& duration, JS::Handle<JSObject*> options, PlainDate* result); /** @@ -351,7 +354,22 @@ bool CalendarDateAdd(JSContext* cx, JS::Handle<CalendarRecord> calendar, */ bool CalendarDateAdd(JSContext* cx, JS::Handle<CalendarRecord> calendar, JS::Handle<Wrapped<PlainDateObject*>> date, - const Duration& duration, PlainDate* result); + const DateDuration& duration, PlainDate* result); + +/** + * CalendarDateUntil ( calendarRec, one, two, options ) + */ +bool CalendarDateUntil(JSContext* cx, JS::Handle<CalendarRecord> calendar, + const PlainDate& one, const PlainDate& two, + TemporalUnit largestUnit, DateDuration* result); + +/** + * CalendarDateUntil ( calendarRec, one, two, options ) + */ +bool CalendarDateUntil(JSContext* cx, JS::Handle<CalendarRecord> calendar, + const PlainDate& one, const PlainDate& two, + TemporalUnit largestUnit, + JS::Handle<PlainObject*> options, DateDuration* result); /** * CalendarDateUntil ( calendarRec, one, two, options ) @@ -359,7 +377,7 @@ bool CalendarDateAdd(JSContext* cx, JS::Handle<CalendarRecord> calendar, bool CalendarDateUntil(JSContext* cx, JS::Handle<CalendarRecord> calendar, JS::Handle<Wrapped<PlainDateObject*>> one, JS::Handle<Wrapped<PlainDateObject*>> two, - JS::Handle<PlainObject*> options, Duration* result); + TemporalUnit largestUnit, DateDuration* result); /** * CalendarDateUntil ( calendarRec, one, two, options ) @@ -367,7 +385,8 @@ bool CalendarDateUntil(JSContext* cx, JS::Handle<CalendarRecord> calendar, bool CalendarDateUntil(JSContext* cx, JS::Handle<CalendarRecord> calendar, JS::Handle<Wrapped<PlainDateObject*>> one, JS::Handle<Wrapped<PlainDateObject*>> two, - TemporalUnit largestUnit, Duration* result); + TemporalUnit largestUnit, + JS::Handle<PlainObject*> options, DateDuration* result); /** * CalendarYear ( calendar, dateLike ) diff --git a/js/src/builtin/temporal/Duration.cpp b/js/src/builtin/temporal/Duration.cpp index 7e922aa68b..8f336a9a14 100644 --- a/js/src/builtin/temporal/Duration.cpp +++ b/js/src/builtin/temporal/Duration.cpp @@ -7,6 +7,7 @@ #include "builtin/temporal/Duration.h" #include "mozilla/Assertions.h" +#include "mozilla/Casting.h" #include "mozilla/CheckedInt.h" #include "mozilla/EnumSet.h" #include "mozilla/FloatingPoint.h" @@ -26,6 +27,8 @@ #include "builtin/temporal/Calendar.h" #include "builtin/temporal/Instant.h" +#include "builtin/temporal/Int128.h" +#include "builtin/temporal/Int96.h" #include "builtin/temporal/PlainDate.h" #include "builtin/temporal/PlainDateTime.h" #include "builtin/temporal/Temporal.h" @@ -54,7 +57,6 @@ #include "js/RootingAPI.h" #include "js/Value.h" #include "util/StringBuffer.h" -#include "vm/BigIntType.h" #include "vm/BytecodeUtil.h" #include "vm/GlobalObject.h" #include "vm/JSAtomState.h" @@ -81,8 +83,8 @@ static bool IsIntegerOrInfinity(double d) { } static bool IsIntegerOrInfinityDuration(const Duration& duration) { - auto& [years, months, weeks, days, hours, minutes, seconds, milliseconds, - microseconds, nanoseconds] = duration; + const auto& [years, months, weeks, days, hours, minutes, seconds, + milliseconds, microseconds, nanoseconds] = duration; // Integers exceeding the Number range are represented as infinity. @@ -94,8 +96,8 @@ static bool IsIntegerOrInfinityDuration(const Duration& duration) { } static bool IsIntegerDuration(const Duration& duration) { - auto& [years, months, weeks, days, hours, minutes, seconds, milliseconds, - microseconds, nanoseconds] = duration; + const auto& [years, months, weeks, days, hours, minutes, seconds, + milliseconds, microseconds, nanoseconds] = duration; return IsInteger(years) && IsInteger(months) && IsInteger(weeks) && IsInteger(days) && IsInteger(hours) && IsInteger(minutes) && @@ -104,6 +106,12 @@ static bool IsIntegerDuration(const Duration& duration) { } #endif +static constexpr bool IsSafeInteger(int64_t x) { + constexpr int64_t MaxSafeInteger = int64_t(1) << 53; + constexpr int64_t MinSafeInteger = -MaxSafeInteger; + return MinSafeInteger < x && x < MaxSafeInteger; +} + /** * DurationSign ( years, months, weeks, days, hours, minutes, seconds, * milliseconds, microseconds, nanoseconds ) @@ -111,8 +119,8 @@ static bool IsIntegerDuration(const Duration& duration) { int32_t js::temporal::DurationSign(const Duration& duration) { MOZ_ASSERT(IsIntegerOrInfinityDuration(duration)); - auto& [years, months, weeks, days, hours, minutes, seconds, milliseconds, - microseconds, nanoseconds] = duration; + const auto& [years, months, weeks, days, hours, minutes, seconds, + milliseconds, microseconds, nanoseconds] = duration; // Step 1. for (auto v : {years, months, weeks, days, hours, minutes, seconds, @@ -133,14 +141,418 @@ int32_t js::temporal::DurationSign(const Duration& duration) { } /** + * DurationSign ( years, months, weeks, days, hours, minutes, seconds, + * milliseconds, microseconds, nanoseconds ) + */ +int32_t js::temporal::DurationSign(const DateDuration& duration) { + const auto& [years, months, weeks, days] = duration; + + // Step 1. + for (auto v : {years, months, weeks, days}) { + // Step 1.a. + if (v < 0) { + return -1; + } + + // Step 1.b. + if (v > 0) { + return 1; + } + } + + // Step 2. + return 0; +} + +/** + * Normalize a nanoseconds amount into a time duration. + */ +static NormalizedTimeDuration NormalizeNanoseconds(const Int96& nanoseconds) { + // Split into seconds and nanoseconds. + auto [seconds, nanos] = nanoseconds / ToNanoseconds(TemporalUnit::Second); + + return {seconds, nanos}; +} + +/** + * Normalize a nanoseconds amount into a time duration. Return Nothing if the + * value is too large. + */ +static mozilla::Maybe<NormalizedTimeDuration> NormalizeNanoseconds( + double nanoseconds) { + MOZ_ASSERT(IsInteger(nanoseconds)); + + if (auto int96 = Int96::fromInteger(nanoseconds)) { + // The number of normalized seconds must not exceed `2**53 - 1`. + constexpr auto limit = + Int96{uint64_t(1) << 53} * ToNanoseconds(TemporalUnit::Second); + + if (int96->abs() < limit) { + return mozilla::Some(NormalizeNanoseconds(*int96)); + } + } + return mozilla::Nothing(); +} + +/** + * Normalize a microseconds amount into a time duration. + */ +static NormalizedTimeDuration NormalizeMicroseconds(const Int96& microseconds) { + // Split into seconds and microseconds. + auto [seconds, micros] = microseconds / ToMicroseconds(TemporalUnit::Second); + + // Scale microseconds to nanoseconds. + int32_t nanos = micros * int32_t(ToNanoseconds(TemporalUnit::Microsecond)); + + return {seconds, nanos}; +} + +/** + * Normalize a microseconds amount into a time duration. Return Nothing if the + * value is too large. + */ +static mozilla::Maybe<NormalizedTimeDuration> NormalizeMicroseconds( + double microseconds) { + MOZ_ASSERT(IsInteger(microseconds)); + + if (auto int96 = Int96::fromInteger(microseconds)) { + // The number of normalized seconds must not exceed `2**53 - 1`. + constexpr auto limit = + Int96{uint64_t(1) << 53} * ToMicroseconds(TemporalUnit::Second); + + if (int96->abs() < limit) { + return mozilla::Some(NormalizeMicroseconds(*int96)); + } + } + return mozilla::Nothing(); +} + +/** + * Normalize a duration into a time duration. Return Nothing if any duration + * value is too large. + */ +static mozilla::Maybe<NormalizedTimeDuration> NormalizeSeconds( + const Duration& duration) { + do { + auto nanoseconds = NormalizeNanoseconds(duration.nanoseconds); + if (!nanoseconds) { + break; + } + MOZ_ASSERT(IsValidNormalizedTimeDuration(*nanoseconds)); + + auto microseconds = NormalizeMicroseconds(duration.microseconds); + if (!microseconds) { + break; + } + MOZ_ASSERT(IsValidNormalizedTimeDuration(*microseconds)); + + // Overflows for millis/seconds/minutes/hours/days always result in an + // invalid normalized time duration. + + int64_t milliseconds; + if (!mozilla::NumberEqualsInt64(duration.milliseconds, &milliseconds)) { + break; + } + + int64_t seconds; + if (!mozilla::NumberEqualsInt64(duration.seconds, &seconds)) { + break; + } + + int64_t minutes; + if (!mozilla::NumberEqualsInt64(duration.minutes, &minutes)) { + break; + } + + int64_t hours; + if (!mozilla::NumberEqualsInt64(duration.hours, &hours)) { + break; + } + + int64_t days; + if (!mozilla::NumberEqualsInt64(duration.days, &days)) { + break; + } + + // Compute the overall amount of milliseconds. + mozilla::CheckedInt64 millis = days; + millis *= 24; + millis += hours; + millis *= 60; + millis += minutes; + millis *= 60; + millis += seconds; + millis *= 1000; + millis += milliseconds; + if (!millis.isValid()) { + break; + } + + auto milli = NormalizedTimeDuration::fromMilliseconds(millis.value()); + if (!IsValidNormalizedTimeDuration(milli)) { + break; + } + + // Compute the overall time duration. + auto result = milli + *microseconds + *nanoseconds; + if (!IsValidNormalizedTimeDuration(result)) { + break; + } + + return mozilla::Some(result); + } while (false); + + return mozilla::Nothing(); +} + +/** + * Normalize a days amount into a time duration. Return Nothing if the value is + * too large. + */ +static mozilla::Maybe<NormalizedTimeDuration> NormalizeDays(int64_t days) { + do { + // Compute the overall amount of milliseconds. + auto millis = + mozilla::CheckedInt64(days) * ToMilliseconds(TemporalUnit::Day); + if (!millis.isValid()) { + break; + } + + auto result = NormalizedTimeDuration::fromMilliseconds(millis.value()); + if (!IsValidNormalizedTimeDuration(result)) { + break; + } + + return mozilla::Some(result); + } while (false); + + return mozilla::Nothing(); +} + +/** + * NormalizeTimeDuration ( hours, minutes, seconds, milliseconds, microseconds, + * nanoseconds ) + */ +static NormalizedTimeDuration NormalizeTimeDuration( + double hours, double minutes, double seconds, double milliseconds, + double microseconds, double nanoseconds) { + MOZ_ASSERT(IsInteger(hours)); + MOZ_ASSERT(IsInteger(minutes)); + MOZ_ASSERT(IsInteger(seconds)); + MOZ_ASSERT(IsInteger(milliseconds)); + MOZ_ASSERT(IsInteger(microseconds)); + MOZ_ASSERT(IsInteger(nanoseconds)); + + // Steps 1-3. + mozilla::CheckedInt64 millis = int64_t(hours); + millis *= 60; + millis += int64_t(minutes); + millis *= 60; + millis += int64_t(seconds); + millis *= 1000; + millis += int64_t(milliseconds); + MOZ_ASSERT(millis.isValid()); + + auto normalized = NormalizedTimeDuration::fromMilliseconds(millis.value()); + + // Step 4. + auto micros = Int96::fromInteger(microseconds); + MOZ_ASSERT(micros); + + normalized += NormalizeMicroseconds(*micros); + + // Step 5. + auto nanos = Int96::fromInteger(nanoseconds); + MOZ_ASSERT(nanos); + + normalized += NormalizeNanoseconds(*nanos); + + // Step 6. + MOZ_ASSERT(IsValidNormalizedTimeDuration(normalized)); + + // Step 7. + return normalized; +} + +/** + * NormalizeTimeDuration ( hours, minutes, seconds, milliseconds, microseconds, + * nanoseconds ) + */ +NormalizedTimeDuration js::temporal::NormalizeTimeDuration( + int32_t hours, int32_t minutes, int32_t seconds, int32_t milliseconds, + int32_t microseconds, int32_t nanoseconds) { + // Steps 1-3. + mozilla::CheckedInt64 millis = int64_t(hours); + millis *= 60; + millis += int64_t(minutes); + millis *= 60; + millis += int64_t(seconds); + millis *= 1000; + millis += int64_t(milliseconds); + MOZ_ASSERT(millis.isValid()); + + auto normalized = NormalizedTimeDuration::fromMilliseconds(millis.value()); + + // Step 4. + normalized += NormalizeMicroseconds(Int96{microseconds}); + + // Step 5. + normalized += NormalizeNanoseconds(Int96{nanoseconds}); + + // Step 6. + MOZ_ASSERT(IsValidNormalizedTimeDuration(normalized)); + + // Step 7. + return normalized; +} + +/** + * NormalizeTimeDuration ( hours, minutes, seconds, milliseconds, microseconds, + * nanoseconds ) + */ +NormalizedTimeDuration js::temporal::NormalizeTimeDuration( + const Duration& duration) { + MOZ_ASSERT(IsValidDuration(duration)); + + return ::NormalizeTimeDuration(duration.hours, duration.minutes, + duration.seconds, duration.milliseconds, + duration.microseconds, duration.nanoseconds); +} + +/** + * AddNormalizedTimeDuration ( one, two ) + */ +static bool AddNormalizedTimeDuration(JSContext* cx, + const NormalizedTimeDuration& one, + const NormalizedTimeDuration& two, + NormalizedTimeDuration* result) { + MOZ_ASSERT(IsValidNormalizedTimeDuration(one)); + MOZ_ASSERT(IsValidNormalizedTimeDuration(two)); + + // Step 1. + auto sum = one + two; + + // Step 2. + if (!IsValidNormalizedTimeDuration(sum)) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_DURATION_INVALID_NORMALIZED_TIME); + return false; + } + + // Step 3. + *result = sum; + return true; +} + +/** + * SubtractNormalizedTimeDuration ( one, two ) + */ +static bool SubtractNormalizedTimeDuration(JSContext* cx, + const NormalizedTimeDuration& one, + const NormalizedTimeDuration& two, + NormalizedTimeDuration* result) { + MOZ_ASSERT(IsValidNormalizedTimeDuration(one)); + MOZ_ASSERT(IsValidNormalizedTimeDuration(two)); + + // Step 1. + auto sum = one - two; + + // Step 2. + if (!IsValidNormalizedTimeDuration(sum)) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_DURATION_INVALID_NORMALIZED_TIME); + return false; + } + + // Step 3. + *result = sum; + return true; +} + +/** + * Add24HourDaysToNormalizedTimeDuration ( d, days ) + */ +bool js::temporal::Add24HourDaysToNormalizedTimeDuration( + JSContext* cx, const NormalizedTimeDuration& d, int64_t days, + NormalizedTimeDuration* result) { + MOZ_ASSERT(IsValidNormalizedTimeDuration(d)); + + // Step 1. + auto normalizedDays = NormalizeDays(days); + if (!normalizedDays) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_DURATION_INVALID_NORMALIZED_TIME); + return false; + } + + // Step 2. + auto sum = d + *normalizedDays; + if (!IsValidNormalizedTimeDuration(sum)) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_DURATION_INVALID_NORMALIZED_TIME); + return false; + } + + // Step 3. + *result = sum; + return true; +} + +/** + * CombineDateAndNormalizedTimeDuration ( dateDurationRecord, norm ) + */ +bool js::temporal::CombineDateAndNormalizedTimeDuration( + JSContext* cx, const DateDuration& date, const NormalizedTimeDuration& time, + NormalizedDuration* result) { + MOZ_ASSERT(IsValidDuration(date)); + MOZ_ASSERT(IsValidNormalizedTimeDuration(time)); + + // Step 1. + int32_t dateSign = DurationSign(date); + + // Step 2. + int32_t timeSign = NormalizedTimeDurationSign(time); + + // Step 3 + if ((dateSign * timeSign) < 0) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_DURATION_COMBINE_INVALID_SIGN); + return false; + } + + // Step 4. + *result = {date, time}; + return true; +} + +/** + * NormalizedTimeDurationFromEpochNanosecondsDifference ( one, two ) + */ +NormalizedTimeDuration +js::temporal::NormalizedTimeDurationFromEpochNanosecondsDifference( + const Instant& one, const Instant& two) { + MOZ_ASSERT(IsValidEpochInstant(one)); + MOZ_ASSERT(IsValidEpochInstant(two)); + + // Step 1. + auto result = one - two; + + // Step 2. + MOZ_ASSERT(IsValidInstantSpan(result)); + + // Step 3. + return result.to<NormalizedTimeDuration>(); +} + +/** * IsValidDuration ( years, months, weeks, days, hours, minutes, seconds, * milliseconds, microseconds, nanoseconds ) */ bool js::temporal::IsValidDuration(const Duration& duration) { MOZ_ASSERT(IsIntegerOrInfinityDuration(duration)); - auto& [years, months, weeks, days, hours, minutes, seconds, milliseconds, - microseconds, nanoseconds] = duration; + const auto& [years, months, weeks, days, hours, minutes, seconds, + milliseconds, microseconds, nanoseconds] = duration; // Step 1. int32_t sign = DurationSign(duration); @@ -165,9 +577,61 @@ bool js::temporal::IsValidDuration(const Duration& duration) { } // Step 3. + if (std::abs(years) >= double(int64_t(1) << 32)) { + return false; + } + + // Step 4. + if (std::abs(months) >= double(int64_t(1) << 32)) { + return false; + } + + // Step 5. + if (std::abs(weeks) >= double(int64_t(1) << 32)) { + return false; + } + + // Steps 6-8. + if (!NormalizeSeconds(duration)) { + return false; + } + + // Step 9. return true; } +#ifdef DEBUG +/** + * IsValidDuration ( years, months, weeks, days, hours, minutes, seconds, + * milliseconds, microseconds, nanoseconds ) + */ +bool js::temporal::IsValidDuration(const DateDuration& duration) { + return IsValidDuration(duration.toDuration()); +} + +/** + * IsValidDuration ( years, months, weeks, days, hours, minutes, seconds, + * milliseconds, microseconds, nanoseconds ) + */ +bool js::temporal::IsValidDuration(const NormalizedDuration& duration) { + return IsValidDuration(duration.date) && + IsValidNormalizedTimeDuration(duration.time) && + (DurationSign(duration.date) * + NormalizedTimeDurationSign(duration.time) >= + 0); +} +#endif + +static bool ThrowInvalidDurationPart(JSContext* cx, double value, + const char* name, unsigned errorNumber) { + ToCStringBuf cbuf; + const char* numStr = NumberToCString(&cbuf, value); + + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, errorNumber, name, + numStr); + return false; +} + /** * IsValidDuration ( years, months, weeks, days, hours, minutes, seconds, * milliseconds, microseconds, nanoseconds ) @@ -176,36 +640,36 @@ bool js::temporal::ThrowIfInvalidDuration(JSContext* cx, const Duration& duration) { MOZ_ASSERT(IsIntegerOrInfinityDuration(duration)); - auto& [years, months, weeks, days, hours, minutes, seconds, milliseconds, - microseconds, nanoseconds] = duration; + const auto& [years, months, weeks, days, hours, minutes, seconds, + milliseconds, microseconds, nanoseconds] = duration; // Step 1. int32_t sign = DurationSign(duration); - auto report = [&](double v, const char* name, unsigned errorNumber) { - ToCStringBuf cbuf; - const char* numStr = NumberToCString(&cbuf, v); - - JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, errorNumber, name, - numStr); - }; - auto throwIfInvalid = [&](double v, const char* name) { // Step 2.a. if (!std::isfinite(v)) { - report(v, name, JSMSG_TEMPORAL_DURATION_INVALID_NON_FINITE); - return false; + return ThrowInvalidDurationPart( + cx, v, name, JSMSG_TEMPORAL_DURATION_INVALID_NON_FINITE); } // Steps 2.b-c. if ((v < 0 && sign > 0) || (v > 0 && sign < 0)) { - report(v, name, JSMSG_TEMPORAL_DURATION_INVALID_SIGN); - return false; + return ThrowInvalidDurationPart(cx, v, name, + JSMSG_TEMPORAL_DURATION_INVALID_SIGN); } return true; }; + auto throwIfTooLarge = [&](double v, const char* name) { + if (std::abs(v) >= double(int64_t(1) << 32)) { + return ThrowInvalidDurationPart( + cx, v, name, JSMSG_TEMPORAL_DURATION_INVALID_NON_FINITE); + } + return true; + }; + // Step 2. if (!throwIfInvalid(years, "years")) { return false; @@ -238,9 +702,104 @@ bool js::temporal::ThrowIfInvalidDuration(JSContext* cx, return false; } + // Step 3. + if (!throwIfTooLarge(years, "years")) { + return false; + } + + // Step 4. + if (!throwIfTooLarge(months, "months")) { + return false; + } + + // Step 5. + if (!throwIfTooLarge(weeks, "weeks")) { + return false; + } + + // Steps 6-8. + if (!NormalizeSeconds(duration)) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_DURATION_INVALID_NORMALIZED_TIME); + return false; + } + MOZ_ASSERT(IsValidDuration(duration)); + // Step 9. + return true; +} + +/** + * IsValidDuration ( years, months, weeks, days, hours, minutes, seconds, + * milliseconds, microseconds, nanoseconds ) + */ +bool js::temporal::ThrowIfInvalidDuration(JSContext* cx, + const DateDuration& duration) { + const auto& [years, months, weeks, days] = duration; + + // Step 1. + int32_t sign = DurationSign(duration); + + auto throwIfInvalid = [&](int64_t v, const char* name) { + // Step 2.a. (Not applicable) + + // Steps 2.b-c. + if ((v < 0 && sign > 0) || (v > 0 && sign < 0)) { + return ThrowInvalidDurationPart(cx, double(v), name, + JSMSG_TEMPORAL_DURATION_INVALID_SIGN); + } + + return true; + }; + + auto throwIfTooLarge = [&](int64_t v, const char* name) { + if (std::abs(v) >= (int64_t(1) << 32)) { + return ThrowInvalidDurationPart( + cx, double(v), name, JSMSG_TEMPORAL_DURATION_INVALID_NON_FINITE); + } + return true; + }; + + // Step 2. + if (!throwIfInvalid(years, "years")) { + return false; + } + if (!throwIfInvalid(months, "months")) { + return false; + } + if (!throwIfInvalid(weeks, "weeks")) { + return false; + } + if (!throwIfInvalid(days, "days")) { + return false; + } + // Step 3. + if (!throwIfTooLarge(years, "years")) { + return false; + } + + // Step 4. + if (!throwIfTooLarge(months, "months")) { + return false; + } + + // Step 5. + if (!throwIfTooLarge(weeks, "weeks")) { + return false; + } + + // Steps 6-8. + if (std::abs(days) > ((int64_t(1) << 53) / 86400)) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_DURATION_INVALID_NORMALIZED_TIME); + return false; + } + + MOZ_ASSERT(IsValidDuration(duration)); + + // Step 9. return true; } @@ -307,8 +866,8 @@ static TemporalUnit DefaultTemporalLargestUnit(const Duration& duration) { static DurationObject* CreateTemporalDuration(JSContext* cx, const CallArgs& args, const Duration& duration) { - auto& [years, months, weeks, days, hours, minutes, seconds, milliseconds, - microseconds, nanoseconds] = duration; + const auto& [years, months, weeks, days, hours, minutes, seconds, + milliseconds, microseconds, nanoseconds] = duration; // Step 1. if (!ThrowIfInvalidDuration(cx, duration)) { @@ -355,8 +914,8 @@ static DurationObject* CreateTemporalDuration(JSContext* cx, */ DurationObject* js::temporal::CreateTemporalDuration(JSContext* cx, const Duration& duration) { - auto& [years, months, weeks, days, hours, minutes, seconds, milliseconds, - microseconds, nanoseconds] = duration; + const auto& [years, months, weeks, days, hours, minutes, seconds, + milliseconds, microseconds, nanoseconds] = duration; MOZ_ASSERT(IsInteger(years)); MOZ_ASSERT(IsInteger(months)); @@ -621,11 +1180,12 @@ int32_t js::temporal::DaysUntil(const PlainDate& earlier, // Steps 1-2. int32_t epochDaysEarlier = MakeDay(earlier); - MOZ_ASSERT(std::abs(epochDaysEarlier) <= 100'000'000); + MOZ_ASSERT(MinEpochDay <= epochDaysEarlier && + epochDaysEarlier <= MaxEpochDay); // Steps 3-4. int32_t epochDaysLater = MakeDay(later); - MOZ_ASSERT(std::abs(epochDaysLater) <= 100'000'000); + MOZ_ASSERT(MinEpochDay <= epochDaysLater && epochDaysLater <= MaxEpochDay); // Step 5. return epochDaysLater - epochDaysEarlier; @@ -636,7 +1196,7 @@ int32_t js::temporal::DaysUntil(const PlainDate& earlier, */ static bool MoveRelativeDate( JSContext* cx, Handle<CalendarRecord> calendar, - Handle<Wrapped<PlainDateObject*>> relativeTo, const Duration& duration, + Handle<Wrapped<PlainDateObject*>> relativeTo, const DateDuration& duration, MutableHandle<Wrapped<PlainDateObject*>> relativeToResult, int32_t* daysResult) { auto* unwrappedRelativeTo = relativeTo.unwrap(cx); @@ -655,7 +1215,7 @@ static bool MoveRelativeDate( // Step 2. *daysResult = DaysUntil(relativeToDate, later); - MOZ_ASSERT(std::abs(*daysResult) <= 200'000'000); + MOZ_ASSERT(std::abs(*daysResult) <= MaxEpochDaysDuration); // Step 3. return true; @@ -668,7 +1228,7 @@ static bool MoveRelativeDate( static bool MoveRelativeZonedDateTime( JSContext* cx, Handle<ZonedDateTime> zonedDateTime, Handle<CalendarRecord> calendar, Handle<TimeZoneRecord> timeZone, - const Duration& duration, + const DateDuration& duration, mozilla::Maybe<const PlainDateTime&> precalculatedPlainDateTime, MutableHandle<ZonedDateTime> result) { // Step 1. @@ -683,13 +1243,13 @@ static bool MoveRelativeZonedDateTime( Instant intermediateNs; if (precalculatedPlainDateTime) { if (!AddZonedDateTime(cx, zonedDateTime.instant(), timeZone, calendar, - duration.date(), *precalculatedPlainDateTime, + duration, *precalculatedPlainDateTime, &intermediateNs)) { return false; } } else { if (!AddZonedDateTime(cx, zonedDateTime.instant(), timeZone, calendar, - duration.date(), &intermediateNs)) { + duration, &intermediateNs)) { return false; } } @@ -702,235 +1262,27 @@ static bool MoveRelativeZonedDateTime( } /** - * TotalDurationNanoseconds ( hours, minutes, seconds, milliseconds, - * microseconds, nanoseconds ) - */ -static mozilla::Maybe<int64_t> TotalDurationNanoseconds( - const Duration& duration) { - // Our implementation supports |duration.days| to avoid computing |days * 24| - // in the caller, which may not be representable as a double value. - int64_t days; - if (!mozilla::NumberEqualsInt64(duration.days, &days)) { - return mozilla::Nothing(); - } - int64_t hours; - if (!mozilla::NumberEqualsInt64(duration.hours, &hours)) { - return mozilla::Nothing(); - } - mozilla::CheckedInt64 result = days; - result *= 24; - result += hours; - - // Step 1. - int64_t minutes; - if (!mozilla::NumberEqualsInt64(duration.minutes, &minutes)) { - return mozilla::Nothing(); - } - result *= 60; - result += minutes; - - // Step 2. - int64_t seconds; - if (!mozilla::NumberEqualsInt64(duration.seconds, &seconds)) { - return mozilla::Nothing(); - } - result *= 60; - result += seconds; - - // Step 3. - int64_t milliseconds; - if (!mozilla::NumberEqualsInt64(duration.milliseconds, &milliseconds)) { - return mozilla::Nothing(); - } - result *= 1000; - result += milliseconds; - - // Step 4. - int64_t microseconds; - if (!mozilla::NumberEqualsInt64(duration.microseconds, µseconds)) { - return mozilla::Nothing(); - } - result *= 1000; - result += microseconds; - - // Step 5. - int64_t nanoseconds; - if (!mozilla::NumberEqualsInt64(duration.nanoseconds, &nanoseconds)) { - return mozilla::Nothing(); - } - result *= 1000; - result += nanoseconds; - - // Step 5 (Return). - if (!result.isValid()) { - return mozilla::Nothing(); - } - return mozilla::Some(result.value()); -} - -/** - * TotalDurationNanoseconds ( hours, minutes, seconds, milliseconds, - * microseconds, nanoseconds ) - */ -static BigInt* TotalDurationNanosecondsSlow(JSContext* cx, - const Duration& duration) { - // Our implementation supports |duration.days| to avoid computing |days * 24| - // in the caller, which may not be representable as a double value. - Rooted<BigInt*> result(cx, BigInt::createFromDouble(cx, duration.days)); - if (!result) { - return nullptr; - } - - Rooted<BigInt*> temp(cx); - auto multiplyAdd = [&](int32_t factor, double number) { - temp = BigInt::createFromInt64(cx, factor); - if (!temp) { - return false; - } - - result = BigInt::mul(cx, result, temp); - if (!result) { - return false; - } - - temp = BigInt::createFromDouble(cx, number); - if (!temp) { - return false; - } - - result = BigInt::add(cx, result, temp); - return !!result; - }; - - if (!multiplyAdd(24, duration.hours)) { - return nullptr; - } - - // Step 1. - if (!multiplyAdd(60, duration.minutes)) { - return nullptr; - } - - // Step 2. - if (!multiplyAdd(60, duration.seconds)) { - return nullptr; - } - - // Step 3. - if (!multiplyAdd(1000, duration.milliseconds)) { - return nullptr; - } - - // Step 4. - if (!multiplyAdd(1000, duration.microseconds)) { - return nullptr; - } - - // Step 5. - if (!multiplyAdd(1000, duration.nanoseconds)) { - return nullptr; - } - - // Step 5 (Return). - return result; -} - -struct NanosecondsAndDays final { - int32_t days = 0; - int64_t nanoseconds = 0; -}; - -/** - * Split duration into full days and remainding nanoseconds. - */ -static ::NanosecondsAndDays NanosecondsToDays(int64_t nanoseconds) { - constexpr int64_t dayLengthNs = ToNanoseconds(TemporalUnit::Day); - - static_assert(INT64_MAX / dayLengthNs <= INT32_MAX, - "days doesn't exceed INT32_MAX"); - - return {int32_t(nanoseconds / dayLengthNs), nanoseconds % dayLengthNs}; -} - -/** - * Split duration into full days and remainding nanoseconds. - */ -static bool NanosecondsToDaysSlow( - JSContext* cx, Handle<BigInt*> nanoseconds, - MutableHandle<temporal::NanosecondsAndDays> result) { - constexpr int64_t dayLengthNs = ToNanoseconds(TemporalUnit::Day); - - Rooted<BigInt*> dayLength(cx, BigInt::createFromInt64(cx, dayLengthNs)); - if (!dayLength) { - return false; - } - - Rooted<BigInt*> days(cx); - Rooted<BigInt*> nanos(cx); - if (!BigInt::divmod(cx, nanoseconds, dayLength, &days, &nanos)) { - return false; - } - - result.set(temporal::NanosecondsAndDays::from( - days, ToInstantSpan(nanos), InstantSpan::fromNanoseconds(dayLengthNs))); - return true; -} - -/** * Split duration into full days and remainding nanoseconds. */ -static bool NanosecondsToDays( - JSContext* cx, const Duration& duration, - MutableHandle<temporal::NanosecondsAndDays> result) { - if (auto total = TotalDurationNanoseconds(duration.time())) { - auto nanosAndDays = ::NanosecondsToDays(*total); - - result.set(temporal::NanosecondsAndDays::from( - nanosAndDays.days, - InstantSpan::fromNanoseconds(nanosAndDays.nanoseconds), - InstantSpan::fromNanoseconds(ToNanoseconds(TemporalUnit::Day)))); - return true; - } +static NormalizedTimeAndDays NormalizedTimeDurationToDays( + const NormalizedTimeDuration& duration) { + MOZ_ASSERT(IsValidNormalizedTimeDuration(duration)); - Rooted<BigInt*> nanoseconds( - cx, TotalDurationNanosecondsSlow(cx, duration.time())); - if (!nanoseconds) { - return false; + auto [seconds, nanoseconds] = duration; + if (seconds < 0 && nanoseconds > 0) { + seconds += 1; + nanoseconds -= 1'000'000'000; } - return ::NanosecondsToDaysSlow(cx, nanoseconds, result); -} - -/** - * NanosecondsToDays ( nanoseconds, zonedRelativeTo, timeZoneRec [ , - * precalculatedPlainDateTime ] ) - */ -static bool NanosecondsToDays( - JSContext* cx, const Duration& duration, - Handle<ZonedDateTime> zonedRelativeTo, Handle<TimeZoneRecord> timeZone, - MutableHandle<temporal::NanosecondsAndDays> result) { - if (auto total = TotalDurationNanoseconds(duration.time())) { - auto nanoseconds = InstantSpan::fromNanoseconds(*total); - MOZ_ASSERT(IsValidInstantSpan(nanoseconds)); + int64_t days = seconds / ToSeconds(TemporalUnit::Day); + seconds = seconds % ToSeconds(TemporalUnit::Day); - return NanosecondsToDays(cx, nanoseconds, zonedRelativeTo, timeZone, - result); - } + int64_t time = seconds * ToNanoseconds(TemporalUnit::Second) + nanoseconds; - auto* nanoseconds = TotalDurationNanosecondsSlow(cx, duration.time()); - if (!nanoseconds) { - return false; - } + constexpr int64_t dayLength = ToNanoseconds(TemporalUnit::Day); + MOZ_ASSERT(std::abs(time) < dayLength); - // NanosecondsToDays, step 6. - if (!IsValidInstantSpan(nanoseconds)) { - JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, - JSMSG_TEMPORAL_INSTANT_INVALID); - return false; - } - - return NanosecondsToDays(cx, ToInstantSpan(nanoseconds), zonedRelativeTo, - timeZone, result); + return {days, time, dayLength}; } /** @@ -943,14 +1295,28 @@ static TimeDuration CreateTimeDurationRecord(int64_t days, int64_t hours, int64_t microseconds, int64_t nanoseconds) { // Step 1. - MOZ_ASSERT(IsValidDuration({0, 0, 0, double(days), double(hours), - double(minutes), double(seconds), - double(microseconds), double(nanoseconds)})); + MOZ_ASSERT(IsValidDuration( + {0, 0, 0, double(days), double(hours), double(minutes), double(seconds), + double(milliseconds), double(microseconds), double(nanoseconds)})); + + // All values are safe integers, so we don't need to convert to `double` and + // back for the `ℝ(𝔽(x))` conversion. + MOZ_ASSERT(IsSafeInteger(days)); + MOZ_ASSERT(IsSafeInteger(hours)); + MOZ_ASSERT(IsSafeInteger(minutes)); + MOZ_ASSERT(IsSafeInteger(seconds)); + MOZ_ASSERT(IsSafeInteger(milliseconds)); + MOZ_ASSERT(IsSafeInteger(microseconds)); + MOZ_ASSERT(IsSafeInteger(nanoseconds)); // Step 2. return { - double(days), double(hours), double(minutes), - double(seconds), double(milliseconds), double(microseconds), + days, + hours, + minutes, + seconds, + milliseconds, + double(microseconds), double(nanoseconds), }; } @@ -959,647 +1325,372 @@ static TimeDuration CreateTimeDurationRecord(int64_t days, int64_t hours, * CreateTimeDurationRecord ( days, hours, minutes, seconds, milliseconds, * microseconds, nanoseconds ) */ -static TimeDuration CreateTimeDurationRecord(double days, double hours, - double minutes, double seconds, - double milliseconds, - double microseconds, - double nanoseconds) { +static TimeDuration CreateTimeDurationRecord(int64_t milliseconds, + const Int128& microseconds, + const Int128& nanoseconds) { // Step 1. - MOZ_ASSERT(IsValidDuration({0, 0, 0, days, hours, minutes, seconds, - milliseconds, microseconds, nanoseconds})); + MOZ_ASSERT(IsValidDuration({0, 0, 0, 0, 0, 0, 0, double(milliseconds), + double(microseconds), double(nanoseconds)})); // Step 2. - // NB: Adds +0.0 to correctly handle negative zero. return { - days + (+0.0), hours + (+0.0), minutes + (+0.0), - seconds + (+0.0), milliseconds + (+0.0), microseconds + (+0.0), - nanoseconds + (+0.0), + 0, 0, 0, 0, milliseconds, double(microseconds), double(nanoseconds), }; } /** - * BalanceTimeDuration ( days, hours, minutes, seconds, milliseconds, - * microseconds, nanoseconds, largestUnit ) - * - * BalancePossiblyInfiniteTimeDuration ( days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds, largestUnit ) + * BalanceTimeDuration ( norm, largestUnit ) */ -static TimeDuration BalanceTimeDuration(int64_t nanoseconds, - TemporalUnit largestUnit) { - // Step 1. (Handled in caller.) +TimeDuration js::temporal::BalanceTimeDuration( + const NormalizedTimeDuration& duration, TemporalUnit largestUnit) { + MOZ_ASSERT(IsValidNormalizedTimeDuration(duration)); + MOZ_ASSERT(largestUnit <= TemporalUnit::Second, + "fallible fractional seconds units"); - // Step 2. + auto [seconds, nanoseconds] = duration; + + // Negative nanoseconds are represented as the difference to 1'000'000'000. + // Convert these back to their absolute value and adjust the seconds part + // accordingly. + // + // For example the nanoseconds duration |-1n| is represented as the + // duration {seconds: -1, nanoseconds: 999'999'999}. + if (seconds < 0 && nanoseconds > 0) { + seconds += 1; + nanoseconds -= ToNanoseconds(TemporalUnit::Second); + } + + // Step 1. int64_t days = 0; int64_t hours = 0; int64_t minutes = 0; - int64_t seconds = 0; int64_t milliseconds = 0; int64_t microseconds = 0; - // Steps 3-4. (Not applicable in our implementation.) + // Steps 2-3. (Not applicable in our implementation.) // // We don't need to convert to positive numbers, because integer division // truncates and the %-operator has modulo semantics. - // Steps 5-11. + // Steps 4-10. switch (largestUnit) { - // Step 5. + // Step 4. case TemporalUnit::Year: case TemporalUnit::Month: case TemporalUnit::Week: case TemporalUnit::Day: { - // Step 5.a. + // Step 4.a. microseconds = nanoseconds / 1000; - // Step 5.b. + // Step 4.b. nanoseconds = nanoseconds % 1000; - // Step 5.c. + // Step 4.c. milliseconds = microseconds / 1000; - // Step 5.d. + // Step 4.d. microseconds = microseconds % 1000; - // Step 5.e. - seconds = milliseconds / 1000; + // Steps 4.e-f. (Not applicable) + MOZ_ASSERT(std::abs(milliseconds) <= 999); - // Step 5.f. - milliseconds = milliseconds % 1000; - - // Step 5.g. + // Step 4.g. minutes = seconds / 60; - // Step 5.h. + // Step 4.h. seconds = seconds % 60; - // Step 5.i. + // Step 4.i. hours = minutes / 60; - // Step 5.j. + // Step 4.j. minutes = minutes % 60; - // Step 5.k. + // Step 4.k. days = hours / 24; - // Step 5.l. + // Step 4.l. hours = hours % 24; break; } + // Step 5. case TemporalUnit::Hour: { - // Step 6.a. + // Step 5.a. microseconds = nanoseconds / 1000; - // Step 6.b. + // Step 5.b. nanoseconds = nanoseconds % 1000; - // Step 6.c. + // Step 5.c. milliseconds = microseconds / 1000; - // Step 6.d. + // Step 5.d. microseconds = microseconds % 1000; - // Step 6.e. - seconds = milliseconds / 1000; - - // Step 6.f. - milliseconds = milliseconds % 1000; + // Steps 5.e-f. (Not applicable) + MOZ_ASSERT(std::abs(milliseconds) <= 999); - // Step 6.g. + // Step 5.g. minutes = seconds / 60; - // Step 6.h. + // Step 5.h. seconds = seconds % 60; - // Step 6.i. + // Step 5.i. hours = minutes / 60; - // Step 6.j. + // Step 5.j. minutes = minutes % 60; break; } - // Step 7. case TemporalUnit::Minute: { - // Step 7.a. + // Step 6.a. microseconds = nanoseconds / 1000; - // Step 7.b. + // Step 6.b. nanoseconds = nanoseconds % 1000; - // Step 7.c. + // Step 6.c. milliseconds = microseconds / 1000; - // Step 7.d. + // Step 6.d. microseconds = microseconds % 1000; - // Step 7.e. - seconds = milliseconds / 1000; + // Steps 6.e-f. (Not applicable) + MOZ_ASSERT(std::abs(milliseconds) <= 999); - // Step 7.f. - milliseconds = milliseconds % 1000; - - // Step 7.g. + // Step 6.g. minutes = seconds / 60; - // Step 7.h. + // Step 6.h. seconds = seconds % 60; break; } - // Step 8. + // Step 7. case TemporalUnit::Second: { - // Step 8.a. - microseconds = nanoseconds / 1000; - - // Step 8.b. - nanoseconds = nanoseconds % 1000; - - // Step 8.c. - milliseconds = microseconds / 1000; - - // Step 8.d. - microseconds = microseconds % 1000; - - // Step 8.e. - seconds = milliseconds / 1000; - - // Step 8.f. - milliseconds = milliseconds % 1000; - - break; - } - - // Step 9. - case TemporalUnit::Millisecond: { - // Step 9.a. + // Step 7.a. microseconds = nanoseconds / 1000; - // Step 9.b. + // Step 7.b. nanoseconds = nanoseconds % 1000; - // Step 9.c. + // Step 7.c. milliseconds = microseconds / 1000; - // Step 9.d. + // Step 7.d. microseconds = microseconds % 1000; - break; - } - - // Step 10. - case TemporalUnit::Microsecond: { - // Step 10.a. - microseconds = nanoseconds / 1000; - - // Step 10.b. - nanoseconds = nanoseconds % 1000; + // Steps 7.e-f. (Not applicable) + MOZ_ASSERT(std::abs(milliseconds) <= 999); break; } - // Step 11. - case TemporalUnit::Nanosecond: { - // Nothing to do. - break; - } - + case TemporalUnit::Millisecond: + case TemporalUnit::Microsecond: + case TemporalUnit::Nanosecond: case TemporalUnit::Auto: MOZ_CRASH("Unexpected temporal unit"); } - // Step 12. (Not applicable, all values are finite) - - // Step 13. + // Step 11. return CreateTimeDurationRecord(days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds); } /** - * BalancePossiblyInfiniteTimeDuration ( days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds, largestUnit ) + * BalanceTimeDuration ( norm, largestUnit ) */ -static bool BalancePossiblyInfiniteTimeDurationSlow(JSContext* cx, - Handle<BigInt*> nanos, - TemporalUnit largestUnit, - TimeDuration* result) { - // Steps 1-2. (Handled in caller.) - - BigInt* zero = BigInt::zero(cx); - if (!zero) { - return false; - } +bool js::temporal::BalanceTimeDuration(JSContext* cx, + const NormalizedTimeDuration& duration, + TemporalUnit largestUnit, + TimeDuration* result) { + MOZ_ASSERT(IsValidNormalizedTimeDuration(duration)); - // Step 3. - Rooted<BigInt*> days(cx, zero); - Rooted<BigInt*> hours(cx, zero); - Rooted<BigInt*> minutes(cx, zero); - Rooted<BigInt*> seconds(cx, zero); - Rooted<BigInt*> milliseconds(cx, zero); - Rooted<BigInt*> microseconds(cx, zero); - Rooted<BigInt*> nanoseconds(cx, nanos); + auto [seconds, nanoseconds] = duration; - // Steps 4-5. + // Negative nanoseconds are represented as the difference to 1'000'000'000. + // Convert these back to their absolute value and adjust the seconds part + // accordingly. // - // We don't need to convert to positive numbers, because BigInt division - // truncates and BigInt modulo has modulo semantics. - - // Steps 6-12. - Rooted<BigInt*> thousand(cx, BigInt::createFromInt64(cx, 1000)); - if (!thousand) { - return false; + // For example the nanoseconds duration |-1n| is represented as the + // duration {seconds: -1, nanoseconds: 999'999'999}. + if (seconds < 0 && nanoseconds > 0) { + seconds += 1; + nanoseconds -= ToNanoseconds(TemporalUnit::Second); } - Rooted<BigInt*> sixty(cx, BigInt::createFromInt64(cx, 60)); - if (!sixty) { - return false; - } - - Rooted<BigInt*> twentyfour(cx, BigInt::createFromInt64(cx, 24)); - if (!twentyfour) { - return false; - } + // Steps 1-3. (Not applicable in our implementation.) + // + // We don't need to convert to positive numbers, because integer division + // truncates and the %-operator has modulo semantics. + // Steps 4-10. switch (largestUnit) { - // Step 6. + // Steps 4-7. case TemporalUnit::Year: case TemporalUnit::Month: case TemporalUnit::Week: - case TemporalUnit::Day: { - // Steps 6.a-b. - if (!BigInt::divmod(cx, nanoseconds, thousand, µseconds, - &nanoseconds)) { - return false; - } - - // Steps 6.c-d. - if (!BigInt::divmod(cx, microseconds, thousand, &milliseconds, - µseconds)) { - return false; - } - - // Steps 6.e-f. - if (!BigInt::divmod(cx, milliseconds, thousand, &seconds, - &milliseconds)) { - return false; - } - - // Steps 6.g-h. - if (!BigInt::divmod(cx, seconds, sixty, &minutes, &seconds)) { - return false; - } - - // Steps 6.i-j. - if (!BigInt::divmod(cx, minutes, sixty, &hours, &minutes)) { - return false; - } - - // Steps 6.k-l. - if (!BigInt::divmod(cx, hours, twentyfour, &days, &hours)) { - return false; - } - - break; - } + case TemporalUnit::Day: + case TemporalUnit::Hour: + case TemporalUnit::Minute: + case TemporalUnit::Second: + *result = BalanceTimeDuration(duration, largestUnit); + return true; - // Step 7. - case TemporalUnit::Hour: { - // Steps 7.a-b. - if (!BigInt::divmod(cx, nanoseconds, thousand, µseconds, - &nanoseconds)) { - return false; - } + // Step 8. + case TemporalUnit::Millisecond: { + // The number of normalized seconds must not exceed `2**53 - 1`. + constexpr auto limit = + (int64_t(1) << 53) * ToMilliseconds(TemporalUnit::Second); - // Steps 7.c-d. - if (!BigInt::divmod(cx, microseconds, thousand, &milliseconds, - µseconds)) { - return false; - } + // The largest possible milliseconds value whose double representation + // doesn't exceed the normalized seconds limit. + constexpr auto max = int64_t(0x7cff'ffff'ffff'fdff); - // Steps 7.e-f. - if (!BigInt::divmod(cx, milliseconds, thousand, &seconds, - &milliseconds)) { - return false; - } + // Assert |max| is the maximum allowed milliseconds value. + static_assert(double(max) < double(limit)); + static_assert(double(max + 1) >= double(limit)); - // Steps 7.g-h. - if (!BigInt::divmod(cx, seconds, sixty, &minutes, &seconds)) { - return false; - } + static_assert((NormalizedTimeDuration::max().seconds + 1) * + ToMilliseconds(TemporalUnit::Second) <= + INT64_MAX, + "total number duration milliseconds fits into int64"); - // Steps 7.i-j. - if (!BigInt::divmod(cx, minutes, sixty, &hours, &minutes)) { - return false; - } - - break; - } + // Step 8.a. + int64_t microseconds = nanoseconds / 1000; - // Step 8. - case TemporalUnit::Minute: { - // Steps 8.a-b. - if (!BigInt::divmod(cx, nanoseconds, thousand, µseconds, - &nanoseconds)) { - return false; - } + // Step 8.b. + nanoseconds = nanoseconds % 1000; - // Steps 8.c-d. - if (!BigInt::divmod(cx, microseconds, thousand, &milliseconds, - µseconds)) { - return false; - } + // Step 8.c. + int64_t milliseconds = microseconds / 1000; + MOZ_ASSERT(std::abs(milliseconds) <= 999); - // Steps 8.e-f. - if (!BigInt::divmod(cx, milliseconds, thousand, &seconds, - &milliseconds)) { - return false; - } + // Step 8.d. + microseconds = microseconds % 1000; - // Steps 8.g-h. - if (!BigInt::divmod(cx, seconds, sixty, &minutes, &seconds)) { + auto millis = + (seconds * ToMilliseconds(TemporalUnit::Second)) + milliseconds; + if (std::abs(millis) > max) { + JS_ReportErrorNumberASCII( + cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_DURATION_INVALID_NORMALIZED_TIME); return false; } - break; + // Step 11. + *result = CreateTimeDurationRecord(millis, Int128{microseconds}, + Int128{nanoseconds}); + return true; } // Step 9. - case TemporalUnit::Second: { - // Steps 9.a-b. - if (!BigInt::divmod(cx, nanoseconds, thousand, µseconds, - &nanoseconds)) { - return false; - } + case TemporalUnit::Microsecond: { + // The number of normalized seconds must not exceed `2**53 - 1`. + constexpr auto limit = Uint128{int64_t(1) << 53} * + Uint128{ToMicroseconds(TemporalUnit::Second)}; - // Steps 9.c-d. - if (!BigInt::divmod(cx, microseconds, thousand, &milliseconds, - µseconds)) { - return false; - } + // The largest possible microseconds value whose double representation + // doesn't exceed the normalized seconds limit. + constexpr auto max = + (Uint128{0x1e8} << 64) + Uint128{0x47ff'ffff'fff7'ffff}; + static_assert(max < limit); - // Steps 9.e-f. - if (!BigInt::divmod(cx, milliseconds, thousand, &seconds, - &milliseconds)) { - return false; - } + // Assert |max| is the maximum allowed microseconds value. + MOZ_ASSERT(double(max) < double(limit)); + MOZ_ASSERT(double(max + Uint128{1}) >= double(limit)); - break; - } + // Step 9.a. + int64_t microseconds = nanoseconds / 1000; + MOZ_ASSERT(std::abs(microseconds) <= 999'999); - // Step 10. - case TemporalUnit::Millisecond: { - // Steps 10.a-b. - if (!BigInt::divmod(cx, nanoseconds, thousand, µseconds, - &nanoseconds)) { - return false; - } + // Step 9.b. + nanoseconds = nanoseconds % 1000; - // Steps 10.c-d. - if (!BigInt::divmod(cx, microseconds, thousand, &milliseconds, - µseconds)) { + auto micros = + (Int128{seconds} * Int128{ToMicroseconds(TemporalUnit::Second)}) + + Int128{microseconds}; + if (micros.abs() > max) { + JS_ReportErrorNumberASCII( + cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_DURATION_INVALID_NORMALIZED_TIME); return false; } - break; + // Step 11. + *result = CreateTimeDurationRecord(0, micros, Int128{nanoseconds}); + return true; } - // Step 11. - case TemporalUnit::Microsecond: { - // Steps 11.a-b. - if (!BigInt::divmod(cx, nanoseconds, thousand, µseconds, - &nanoseconds)) { + // Step 10. + case TemporalUnit::Nanosecond: { + // The number of normalized seconds must not exceed `2**53 - 1`. + constexpr auto limit = Uint128{int64_t(1) << 53} * + Uint128{ToNanoseconds(TemporalUnit::Second)}; + + // The largest possible nanoseconds value whose double representation + // doesn't exceed the normalized seconds limit. + constexpr auto max = + (Uint128{0x77359} << 64) + Uint128{0x3fff'ffff'dfff'ffff}; + static_assert(max < limit); + + // Assert |max| is the maximum allowed nanoseconds value. + MOZ_ASSERT(double(max) < double(limit)); + MOZ_ASSERT(double(max + Uint128{1}) >= double(limit)); + + MOZ_ASSERT(std::abs(nanoseconds) <= 999'999'999); + + auto nanos = + (Int128{seconds} * Int128{ToNanoseconds(TemporalUnit::Second)}) + + Int128{nanoseconds}; + if (nanos.abs() > max) { + JS_ReportErrorNumberASCII( + cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_DURATION_INVALID_NORMALIZED_TIME); return false; } - break; - } - - // Step 12. - case TemporalUnit::Nanosecond: { - // Nothing to do. - break; - } - - case TemporalUnit::Auto: - MOZ_CRASH("Unexpected temporal unit"); - } - - double daysNumber = BigInt::numberValue(days); - double hoursNumber = BigInt::numberValue(hours); - double minutesNumber = BigInt::numberValue(minutes); - double secondsNumber = BigInt::numberValue(seconds); - double millisecondsNumber = BigInt::numberValue(milliseconds); - double microsecondsNumber = BigInt::numberValue(microseconds); - double nanosecondsNumber = BigInt::numberValue(nanoseconds); - - // Step 13. - for (double v : {daysNumber, hoursNumber, minutesNumber, secondsNumber, - millisecondsNumber, microsecondsNumber, nanosecondsNumber}) { - if (std::isinf(v)) { - *result = { - daysNumber, hoursNumber, minutesNumber, - secondsNumber, millisecondsNumber, microsecondsNumber, - nanosecondsNumber, - }; + // Step 11. + *result = CreateTimeDurationRecord(0, Int128{}, nanos); return true; } - } - - // Step 14. - *result = CreateTimeDurationRecord(daysNumber, hoursNumber, minutesNumber, - secondsNumber, millisecondsNumber, - microsecondsNumber, nanosecondsNumber); - return true; -} - -/** - * BalanceTimeDuration ( days, hours, minutes, seconds, milliseconds, - * microseconds, nanoseconds, largestUnit ) - */ -static bool BalanceTimeDurationSlow(JSContext* cx, Handle<BigInt*> nanoseconds, - TemporalUnit largestUnit, - TimeDuration* result) { - // Step 1. - if (!BalancePossiblyInfiniteTimeDurationSlow(cx, nanoseconds, largestUnit, - result)) { - return false; - } - - // Steps 2-3. - return ThrowIfInvalidDuration(cx, result->toDuration()); -} - -/** - * BalanceTimeDuration ( days, hours, minutes, seconds, milliseconds, - * microseconds, nanoseconds, largestUnit ) - */ -static bool BalanceTimeDuration(JSContext* cx, const Duration& one, - const Duration& two, TemporalUnit largestUnit, - TimeDuration* result) { - MOZ_ASSERT(IsValidDuration(one)); - MOZ_ASSERT(IsValidDuration(two)); - MOZ_ASSERT(largestUnit >= TemporalUnit::Day); - - // Fast-path when we can perform the whole computation with int64 values. - if (auto oneNanoseconds = TotalDurationNanoseconds(one)) { - if (auto twoNanoseconds = TotalDurationNanoseconds(two)) { - mozilla::CheckedInt64 nanoseconds = *oneNanoseconds; - nanoseconds += *twoNanoseconds; - if (nanoseconds.isValid()) { - *result = ::BalanceTimeDuration(nanoseconds.value(), largestUnit); - return true; - } - } - } - - Rooted<BigInt*> oneNanoseconds(cx, TotalDurationNanosecondsSlow(cx, one)); - if (!oneNanoseconds) { - return false; - } - - Rooted<BigInt*> twoNanoseconds(cx, TotalDurationNanosecondsSlow(cx, two)); - if (!twoNanoseconds) { - return false; - } - - Rooted<BigInt*> nanoseconds(cx, - BigInt::add(cx, oneNanoseconds, twoNanoseconds)); - if (!nanoseconds) { - return false; - } - - return BalanceTimeDurationSlow(cx, nanoseconds, largestUnit, result); -} - -/** - * BalanceTimeDuration ( days, hours, minutes, seconds, milliseconds, - * microseconds, nanoseconds, largestUnit ) - */ -static bool BalanceTimeDuration(JSContext* cx, double days, const Duration& one, - const Duration& two, TemporalUnit largestUnit, - TimeDuration* result) { - MOZ_ASSERT(IsInteger(days)); - MOZ_ASSERT(IsValidDuration(one)); - MOZ_ASSERT(IsValidDuration(two)); - - // Fast-path when we can perform the whole computation with int64 values. - if (auto oneNanoseconds = TotalDurationNanoseconds(one)) { - if (auto twoNanoseconds = TotalDurationNanoseconds(two)) { - int64_t intDays; - if (mozilla::NumberEqualsInt64(days, &intDays)) { - mozilla::CheckedInt64 daysNanoseconds = intDays; - daysNanoseconds *= ToNanoseconds(TemporalUnit::Day); - - mozilla::CheckedInt64 nanoseconds = *oneNanoseconds; - nanoseconds += *twoNanoseconds; - nanoseconds += daysNanoseconds; - - if (nanoseconds.isValid()) { - *result = ::BalanceTimeDuration(nanoseconds.value(), largestUnit); - return true; - } - } - } - } - - Rooted<BigInt*> oneNanoseconds(cx, TotalDurationNanosecondsSlow(cx, one)); - if (!oneNanoseconds) { - return false; - } - - Rooted<BigInt*> twoNanoseconds(cx, TotalDurationNanosecondsSlow(cx, two)); - if (!twoNanoseconds) { - return false; - } - - Rooted<BigInt*> nanoseconds(cx, - BigInt::add(cx, oneNanoseconds, twoNanoseconds)); - if (!nanoseconds) { - return false; - } - - if (days) { - Rooted<BigInt*> daysNanoseconds( - cx, TotalDurationNanosecondsSlow(cx, {0, 0, 0, days})); - if (!daysNanoseconds) { - return false; - } - - nanoseconds = BigInt::add(cx, nanoseconds, daysNanoseconds); - if (!nanoseconds) { - return false; - } - } - - return BalanceTimeDurationSlow(cx, nanoseconds, largestUnit, result); -} -/** - * BalancePossiblyInfiniteTimeDuration ( days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds, largestUnit ) - */ -static bool BalancePossiblyInfiniteTimeDuration(JSContext* cx, - const Duration& duration, - TemporalUnit largestUnit, - TimeDuration* result) { - // NB: |duration.days| can have a different sign than the time components. - MOZ_ASSERT(IsValidDuration(duration.time())); - - // Fast-path when we can perform the whole computation with int64 values. - if (auto nanoseconds = TotalDurationNanoseconds(duration)) { - *result = ::BalanceTimeDuration(*nanoseconds, largestUnit); - return true; - } - - // Steps 1-2. - Rooted<BigInt*> nanoseconds(cx, TotalDurationNanosecondsSlow(cx, duration)); - if (!nanoseconds) { - return false; - } - - // Steps 3-14. - return ::BalancePossiblyInfiniteTimeDurationSlow(cx, nanoseconds, largestUnit, - result); -} - -/** - * BalanceTimeDuration ( days, hours, minutes, seconds, milliseconds, - * microseconds, nanoseconds, largestUnit ) - */ -bool js::temporal::BalanceTimeDuration(JSContext* cx, const Duration& duration, - TemporalUnit largestUnit, - TimeDuration* result) { - if (!::BalancePossiblyInfiniteTimeDuration(cx, duration, largestUnit, - result)) { - return false; + case TemporalUnit::Auto: + break; } - return ThrowIfInvalidDuration(cx, result->toDuration()); + MOZ_CRASH("Unexpected temporal unit"); } /** - * BalancePossiblyInfiniteTimeDurationRelative ( days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds, largestUnit, zonedRelativeTo, - * timeZoneRec [ , precalculatedPlainDateTime ] ) + * BalanceTimeDurationRelative ( days, norm, largestUnit, zonedRelativeTo, + * timeZoneRec, precalculatedPlainDateTime ) */ -static bool BalancePossiblyInfiniteTimeDurationRelative( - JSContext* cx, const Duration& duration, TemporalUnit largestUnit, +static bool BalanceTimeDurationRelative( + JSContext* cx, const NormalizedDuration& duration, TemporalUnit largestUnit, Handle<ZonedDateTime> relativeTo, Handle<TimeZoneRecord> timeZone, mozilla::Maybe<const PlainDateTime&> precalculatedPlainDateTime, TimeDuration* result) { - // Step 1. (Not applicable) + MOZ_ASSERT(IsValidDuration(duration)); + + // Step 1. + const auto& startNs = relativeTo.instant(); // Step 2. - auto intermediateNs = relativeTo.instant(); + const auto& startInstant = startNs; // Step 3. - const auto& startInstant = relativeTo.instant(); + auto intermediateNs = startNs; // Step 4. PlainDateTime startDateTime; - if (duration.days != 0) { + if (duration.date.days != 0) { // Step 4.a. if (!precalculatedPlainDateTime) { if (!GetPlainDateTimeFor(cx, timeZone, startInstant, &startDateTime)) { @@ -1612,7 +1703,7 @@ static bool BalancePossiblyInfiniteTimeDurationRelative( // Steps 4.b-c. Rooted<CalendarValue> isoCalendar(cx, CalendarValue(cx->names().iso8601)); if (!AddDaysToZonedDateTime(cx, startInstant, *precalculatedPlainDateTime, - timeZone, isoCalendar, duration.days, + timeZone, isoCalendar, duration.date.days, &intermediateNs)) { return false; } @@ -1620,23 +1711,23 @@ static bool BalancePossiblyInfiniteTimeDurationRelative( // Step 5. Instant endNs; - if (!AddInstant(cx, intermediateNs, duration.time(), &endNs)) { + if (!AddInstant(cx, intermediateNs, duration.time, &endNs)) { return false; } MOZ_ASSERT(IsValidEpochInstant(endNs)); // Step 6. - auto nanoseconds = endNs - relativeTo.instant(); - MOZ_ASSERT(IsValidInstantSpan(nanoseconds)); + auto normalized = + NormalizedTimeDurationFromEpochNanosecondsDifference(endNs, startInstant); // Step 7. - if (nanoseconds == InstantSpan{}) { + if (normalized == NormalizedTimeDuration{}) { *result = {}; return true; } // Steps 8-9. - double days = 0; + int64_t days = 0; if (TemporalUnit::Year <= largestUnit && largestUnit <= TemporalUnit::Day) { // Step 8.a. if (!precalculatedPlainDateTime) { @@ -1648,61 +1739,32 @@ static bool BalancePossiblyInfiniteTimeDurationRelative( } // Step 8.b. - Rooted<temporal::NanosecondsAndDays> nanosAndDays(cx); - if (!NanosecondsToDays(cx, nanoseconds, relativeTo, timeZone, - *precalculatedPlainDateTime, &nanosAndDays)) { + NormalizedTimeAndDays timeAndDays; + if (!NormalizedTimeDurationToDays(cx, normalized, relativeTo, timeZone, + *precalculatedPlainDateTime, + &timeAndDays)) { return false; } - // NB: |days| is passed to CreateTimeDurationRecord, which performs - // |ℝ(𝔽(days))|, so it's safe to convert from BigInt to double here. - // Step 8.c. - days = nanosAndDays.daysNumber(); - MOZ_ASSERT(IsInteger(days)); - - // FIXME: spec issue - `result.[[Nanoseconds]]` not created in all branches - // https://github.com/tc39/proposal-temporal/issues/2616 + days = timeAndDays.days; // Step 8.d. - nanoseconds = nanosAndDays.nanoseconds(); - MOZ_ASSERT_IF(days > 0, nanoseconds >= InstantSpan{}); - MOZ_ASSERT_IF(days < 0, nanoseconds <= InstantSpan{}); + normalized = NormalizedTimeDuration::fromNanoseconds(timeAndDays.time); + MOZ_ASSERT_IF(days > 0, normalized >= NormalizedTimeDuration{}); + MOZ_ASSERT_IF(days < 0, normalized <= NormalizedTimeDuration{}); // Step 8.e. largestUnit = TemporalUnit::Hour; } - // Step 10. (Not applicable in our implementation.) - - // Steps 11-12. + // Step 10. TimeDuration balanceResult; - if (auto nanos = nanoseconds.toNanoseconds(); nanos.isValid()) { - // Step 11. - balanceResult = ::BalanceTimeDuration(nanos.value(), largestUnit); - - // Step 12. - MOZ_ASSERT(IsValidDuration(balanceResult.toDuration())); - } else { - Rooted<BigInt*> ns(cx, ToEpochNanoseconds(cx, nanoseconds)); - if (!ns) { - return false; - } - - // Step 11. - if (!::BalancePossiblyInfiniteTimeDurationSlow(cx, ns, largestUnit, - &balanceResult)) { - return false; - } - - // Step 12. - if (!IsValidDuration(balanceResult.toDuration())) { - *result = balanceResult; - return true; - } + if (!BalanceTimeDuration(cx, normalized, largestUnit, &balanceResult)) { + return false; } - // Step 13. + // Step 11. *result = { days, balanceResult.hours, @@ -1712,99 +1774,44 @@ static bool BalancePossiblyInfiniteTimeDurationRelative( balanceResult.microseconds, balanceResult.nanoseconds, }; + MOZ_ASSERT(IsValidDuration(result->toDuration())); return true; } /** - * BalancePossiblyInfiniteTimeDurationRelative ( days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds, largestUnit, zonedRelativeTo, - * timeZoneRec [ , precalculatedPlainDateTime ] ) - */ -static bool BalancePossiblyInfiniteTimeDurationRelative( - JSContext* cx, const Duration& duration, TemporalUnit largestUnit, - Handle<ZonedDateTime> relativeTo, Handle<TimeZoneRecord> timeZone, - TimeDuration* result) { - return BalancePossiblyInfiniteTimeDurationRelative( - cx, duration, largestUnit, relativeTo, timeZone, mozilla::Nothing(), - result); -} - -/** - * BalanceTimeDurationRelative ( days, hours, minutes, seconds, milliseconds, - * microseconds, nanoseconds, largestUnit, zonedRelativeTo, timeZoneRec, - * precalculatedPlainDateTime ) - */ -static bool BalanceTimeDurationRelative( - JSContext* cx, const Duration& duration, TemporalUnit largestUnit, - Handle<ZonedDateTime> relativeTo, Handle<TimeZoneRecord> timeZone, - mozilla::Maybe<const PlainDateTime&> precalculatedPlainDateTime, - TimeDuration* result) { - // Step 1. - if (!BalancePossiblyInfiniteTimeDurationRelative( - cx, duration, largestUnit, relativeTo, timeZone, - precalculatedPlainDateTime, result)) { - return false; - } - - // Steps 2-3. - return ThrowIfInvalidDuration(cx, result->toDuration()); -} - -/** - * BalanceTimeDuration ( days, hours, minutes, seconds, milliseconds, - * microseconds, nanoseconds, largestUnit ) - */ -bool js::temporal::BalanceTimeDuration(JSContext* cx, - const InstantSpan& nanoseconds, - TemporalUnit largestUnit, - TimeDuration* result) { - MOZ_ASSERT(IsValidInstantSpan(nanoseconds)); - - // Steps 1-3. (Not applicable) - - // Fast-path when we can perform the whole computation with int64 values. - if (auto nanos = nanoseconds.toNanoseconds(); nanos.isValid()) { - *result = ::BalanceTimeDuration(nanos.value(), largestUnit); - return true; - } - - Rooted<BigInt*> nanos(cx, ToEpochNanoseconds(cx, nanoseconds)); - if (!nanos) { - return false; - } - - // Steps 4-16. - return ::BalanceTimeDurationSlow(cx, nanos, largestUnit, result); -} - -/** * CreateDateDurationRecord ( years, months, weeks, days ) */ -static DateDuration CreateDateDurationRecord(double years, double months, - double weeks, double days) { - MOZ_ASSERT(IsValidDuration({years, months, weeks, days})); +static DateDuration CreateDateDurationRecord(int64_t years, int64_t months, + int64_t weeks, int64_t days) { + MOZ_ASSERT(IsValidDuration(Duration{ + double(years), + double(months), + double(weeks), + double(days), + })); return {years, months, weeks, days}; } /** * CreateDateDurationRecord ( years, months, weeks, days ) */ -static bool CreateDateDurationRecord(JSContext* cx, double years, double months, - double weeks, double days, - DateDuration* result) { - if (!ThrowIfInvalidDuration(cx, {years, months, weeks, days})) { +static bool CreateDateDurationRecord(JSContext* cx, int64_t years, + int64_t months, int64_t weeks, + int64_t days, DateDuration* result) { + auto duration = DateDuration{years, months, weeks, days}; + if (!ThrowIfInvalidDuration(cx, duration)) { return false; } - *result = {years, months, weeks, days}; + *result = duration; return true; } -static bool UnbalanceDateDurationRelativeHasEffect(const Duration& duration, +static bool UnbalanceDateDurationRelativeHasEffect(const DateDuration& duration, TemporalUnit largestUnit) { MOZ_ASSERT(largestUnit != TemporalUnit::Auto); - // Steps 2, 3.a-b, 4.a-b, 6-7. + // Steps 2-4. return (largestUnit > TemporalUnit::Year && duration.years != 0) || (largestUnit > TemporalUnit::Month && duration.months != 0) || (largestUnit > TemporalUnit::Week && duration.weeks != 0); @@ -1815,84 +1822,67 @@ static bool UnbalanceDateDurationRelativeHasEffect(const Duration& duration, * plainRelativeTo, calendarRec ) */ static bool UnbalanceDateDurationRelative( - JSContext* cx, const Duration& duration, TemporalUnit largestUnit, + JSContext* cx, const DateDuration& duration, TemporalUnit largestUnit, Handle<Wrapped<PlainDateObject*>> plainRelativeTo, Handle<CalendarRecord> calendar, DateDuration* result) { MOZ_ASSERT(IsValidDuration(duration)); - double years = duration.years; - double months = duration.months; - double weeks = duration.weeks; - double days = duration.days; + auto [years, months, weeks, days] = duration; // Step 1. (Not applicable in our implementation.) - // Steps 2, 3.a, 4.a, and 6. + // Steps 2-4. if (!UnbalanceDateDurationRelativeHasEffect(duration, largestUnit)) { - // Steps 2.a, 3.a, 4.a, and 6. - *result = CreateDateDurationRecord(years, months, weeks, days); + *result = duration; return true; } - // Step 3. - if (largestUnit == TemporalUnit::Month) { - // Step 3.a. (Handled above) - MOZ_ASSERT(years != 0); + // Step 5. + MOZ_ASSERT(largestUnit != TemporalUnit::Year); - // Step 3.b. (Not applicable in our implementation.) + // Step 6. (Not applicable in our implementation.) - // Step 3.c. - MOZ_ASSERT( - CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateAdd)); + // Step 7. + MOZ_ASSERT( + CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateAdd)); - // Step 3.d. + // Step 8. + if (largestUnit == TemporalUnit::Month) { + // Step 8.a. MOZ_ASSERT( CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateUntil)); - // Step 3.e. - auto yearsDuration = Duration{years}; + // Step 8.b. + auto yearsDuration = DateDuration{years}; - // Step 3.f. + // Step 8.c. Rooted<Wrapped<PlainDateObject*>> later( cx, CalendarDateAdd(cx, calendar, plainRelativeTo, yearsDuration)); if (!later) { return false; } - // Steps 3.g-i. - Duration untilResult; + // Steps 8.d-f. + DateDuration untilResult; if (!CalendarDateUntil(cx, calendar, plainRelativeTo, later, TemporalUnit::Month, &untilResult)) { return false; } - // Step 3.j. - double yearsInMonths = untilResult.months; + // Step 8.g. + int64_t yearsInMonths = untilResult.months; - // Step 3.k. - // - // The addition |months + yearsInMonths| can be imprecise, but this is - // safe to ignore, because all values are passed to - // CreateDateDurationRecord, which converts the values to Numbers. + // Step 8.h. return CreateDateDurationRecord(cx, 0, months + yearsInMonths, weeks, days, result); } - // Step 4. + // Step 9. if (largestUnit == TemporalUnit::Week) { - // Step 4.a. (Handled above) - MOZ_ASSERT(years != 0 || months != 0); - - // Step 4.b. (Not applicable in our implementation.) - - // Step 4.c. - MOZ_ASSERT( - CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateAdd)); - - // Step 4.d. - auto yearsMonthsDuration = Duration{years, months}; + // Step 9.a. + auto yearsMonthsDuration = DateDuration{years, months}; - // Step 4.e. + // Step 9.b. auto later = CalendarDateAdd(cx, calendar, plainRelativeTo, yearsMonthsDuration); if (!later) { @@ -1906,35 +1896,20 @@ static bool UnbalanceDateDurationRelative( } auto relativeToDate = ToPlainDate(unwrappedRelativeTo); - // Step 4.f. + // Step 9.c. int32_t yearsMonthsInDays = DaysUntil(relativeToDate, laterDate); - // Step 4.g. - // - // The addition |days + yearsMonthsInDays| can be imprecise, but this is - // safe to ignore, because all values are passed to - // CreateDateDurationRecord, which converts the values to Numbers. + // Step 9.d. return CreateDateDurationRecord(cx, 0, 0, weeks, days + yearsMonthsInDays, result); } - // Step 5. (Not applicable in our implementation.) - - // Step 6. (Handled above) - MOZ_ASSERT(years != 0 || months != 0 || weeks != 0); - - // FIXME: why don't we unconditionally throw an error for missing calendars? - - // Step 7. (Not applicable in our implementation.) - - // Step 8. - MOZ_ASSERT( - CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateAdd)); + // Step 10. (Not applicable in our implementation.) - // Step 9. - auto yearsMonthsWeeksDuration = Duration{years, months, weeks}; + // Step 11. + auto yearsMonthsWeeksDuration = DateDuration{years, months, weeks}; - // Step 10. + // Step 12. auto later = CalendarDateAdd(cx, calendar, plainRelativeTo, yearsMonthsWeeksDuration); if (!later) { @@ -1948,14 +1923,10 @@ static bool UnbalanceDateDurationRelative( } auto relativeToDate = ToPlainDate(unwrappedRelativeTo); - // Step 11. + // Step 13. int32_t yearsMonthsWeeksInDay = DaysUntil(relativeToDate, laterDate); - // Step 12. - // - // The addition |days + yearsMonthsWeeksInDay| can be imprecise, but this is - // safe to ignore, because all values are passed to CreateDateDurationRecord, - // which converts the values to Numbers. + // Step 14. return CreateDateDurationRecord(cx, 0, 0, 0, days + yearsMonthsWeeksInDay, result); } @@ -1965,28 +1936,23 @@ static bool UnbalanceDateDurationRelative( * plainRelativeTo, calendarRec ) */ static bool UnbalanceDateDurationRelative(JSContext* cx, - const Duration& duration, + const DateDuration& duration, TemporalUnit largestUnit, DateDuration* result) { MOZ_ASSERT(IsValidDuration(duration)); - double years = duration.years; - double months = duration.months; - double weeks = duration.weeks; - double days = duration.days; - // Step 1. (Not applicable.) - // Steps 2, 3.a, 4.a, and 6. + // Step 2-4. if (!UnbalanceDateDurationRelativeHasEffect(duration, largestUnit)) { - // Steps 2.a, 3.a, 4.a, and 6. - *result = CreateDateDurationRecord(years, months, weeks, days); + *result = duration; return true; } - // Step 5. (Not applicable.) + // Step 5. + MOZ_ASSERT(largestUnit != TemporalUnit::Year); - // Steps 3.b, 4.b, and 7. + // Steps 6. JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TEMPORAL_DURATION_UNCOMPARABLE, "calendar"); return false; @@ -1997,17 +1963,14 @@ static bool UnbalanceDateDurationRelative(JSContext* cx, * smallestUnit, plainRelativeTo, calendarRec ) */ static bool BalanceDateDurationRelative( - JSContext* cx, const Duration& duration, TemporalUnit largestUnit, + JSContext* cx, const DateDuration& duration, TemporalUnit largestUnit, TemporalUnit smallestUnit, Handle<Wrapped<PlainDateObject*>> plainRelativeTo, Handle<CalendarRecord> calendar, DateDuration* result) { MOZ_ASSERT(IsValidDuration(duration)); MOZ_ASSERT(largestUnit <= smallestUnit); - double years = duration.years; - double months = duration.months; - double weeks = duration.weeks; - double days = duration.days; + auto [years, months, weeks, days] = duration; // FIXME: spec issue - effectful code paths should be more fine-grained // similar to UnbalanceDateDurationRelative. For example: @@ -2023,7 +1986,7 @@ static bool BalanceDateDurationRelative( if (largestUnit > TemporalUnit::Week || (years == 0 && months == 0 && weeks == 0 && days == 0)) { // Step 4.a. - *result = CreateDateDurationRecord(years, months, weeks, days); + *result = duration; return true; } @@ -2045,7 +2008,8 @@ static bool BalanceDateDurationRelative( // Steps 8-9. (Not applicable in our implementation.) - auto untilAddedDate = [&](const Duration& duration, Duration* untilResult) { + auto untilAddedDate = [&](const DateDuration& duration, + DateDuration* untilResult) { Rooted<Wrapped<PlainDateObject*>> later( cx, AddDate(cx, calendar, plainRelativeTo, duration)); if (!later) { @@ -2064,16 +2028,14 @@ static bool BalanceDateDurationRelative( MOZ_ASSERT(days == 0); // Step 10.a.ii. - auto yearsMonthsDuration = Duration{years, months}; + auto yearsMonthsDuration = DateDuration{years, months}; // Steps 10.a.iii-iv. - Duration untilResult; + DateDuration untilResult; if (!untilAddedDate(yearsMonthsDuration, &untilResult)) { return false; } - // FIXME: spec bug - CreateDateDurationRecord is infallible - // Step 10.a.v. *result = CreateDateDurationRecord(untilResult.years, untilResult.months, weeks, 0); @@ -2081,17 +2043,14 @@ static bool BalanceDateDurationRelative( } // Step 10.b. - auto yearsMonthsWeeksDaysDuration = Duration{years, months, weeks, days}; + const auto& yearsMonthsWeeksDaysDuration = duration; // Steps 10.c-d. - Duration untilResult; + DateDuration untilResult; if (!untilAddedDate(yearsMonthsWeeksDaysDuration, &untilResult)) { return false; } - // FIXME: spec bug - CreateDateDurationRecord is infallible - // https://github.com/tc39/proposal-temporal/issues/2750 - // Step 10.e. *result = CreateDateDurationRecord(untilResult.years, untilResult.months, untilResult.weeks, untilResult.days); @@ -2114,17 +2073,14 @@ static bool BalanceDateDurationRelative( } // Step 11.c. - auto monthsWeeksDaysDuration = Duration{0, months, weeks, days}; + const auto& monthsWeeksDaysDuration = duration; // Steps 11.d-e. - Duration untilResult; + DateDuration untilResult; if (!untilAddedDate(monthsWeeksDaysDuration, &untilResult)) { return false; } - // FIXME: spec bug - CreateDateDurationRecord is infallible - // https://github.com/tc39/proposal-temporal/issues/2750 - // Step 11.f. *result = CreateDateDurationRecord(0, untilResult.months, untilResult.weeks, untilResult.days); @@ -2141,17 +2097,14 @@ static bool BalanceDateDurationRelative( MOZ_ASSERT(months == 0); // Step 15. - auto weeksDaysDuration = Duration{0, 0, weeks, days}; + const auto& weeksDaysDuration = duration; // Steps 16-17. - Duration untilResult; + DateDuration untilResult; if (!untilAddedDate(weeksDaysDuration, &untilResult)) { return false; } - // FIXME: spec bug - CreateDateDurationRecord is infallible - // https://github.com/tc39/proposal-temporal/issues/2750 - // Step 18. *result = CreateDateDurationRecord(0, 0, untilResult.weeks, untilResult.days); return true; @@ -2162,7 +2115,7 @@ static bool BalanceDateDurationRelative( * smallestUnit, plainRelativeTo, calendarRec ) */ bool js::temporal::BalanceDateDurationRelative( - JSContext* cx, const Duration& duration, TemporalUnit largestUnit, + JSContext* cx, const DateDuration& duration, TemporalUnit largestUnit, TemporalUnit smallestUnit, Handle<Wrapped<PlainDateObject*>> plainRelativeTo, Handle<CalendarRecord> calendar, DateDuration* result) { @@ -2179,7 +2132,7 @@ bool js::temporal::BalanceDateDurationRelative( * zonedRelativeTo, timeZoneRec [ , precalculatedPlainDateTime ] ) */ static bool AddDuration(JSContext* cx, const Duration& one, const Duration& two, - Duration* duration) { + Duration* result) { MOZ_ASSERT(IsValidDuration(one)); MOZ_ASSERT(IsValidDuration(two)); @@ -2194,7 +2147,13 @@ static bool AddDuration(JSContext* cx, const Duration& one, const Duration& two, // Step 5. auto largestUnit = std::min(largestUnit1, largestUnit2); - // Step 6.a. + // Step 6. + auto normalized1 = NormalizeTimeDuration(one); + + // Step 7. + auto normalized2 = NormalizeTimeDuration(two); + + // Step 8.a. if (largestUnit <= TemporalUnit::Week) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TEMPORAL_DURATION_UNCOMPARABLE, @@ -2202,14 +2161,31 @@ static bool AddDuration(JSContext* cx, const Duration& one, const Duration& two, return false; } - // Step 6.b. - TimeDuration result; - if (!BalanceTimeDuration(cx, one, two, largestUnit, &result)) { + // Step 8.b. + NormalizedTimeDuration normalized; + if (!AddNormalizedTimeDuration(cx, normalized1, normalized2, &normalized)) { + return false; + } + + // Step 8.c. + int64_t days1 = mozilla::AssertedCast<int64_t>(one.days); + int64_t days2 = mozilla::AssertedCast<int64_t>(two.days); + auto totalDays = mozilla::CheckedInt64(days1) + days2; + MOZ_ASSERT(totalDays.isValid(), "adding two duration days can't overflow"); + + if (!Add24HourDaysToNormalizedTimeDuration(cx, normalized, totalDays.value(), + &normalized)) { return false; } - // Steps 6.c. - *duration = result.toDuration(); + // Step 8.d. + TimeDuration balanced; + if (!temporal::BalanceTimeDuration(cx, normalized, largestUnit, &balanced)) { + return false; + } + + // Steps 8.e. + *result = balanced.toDuration(); return true; } @@ -2220,15 +2196,12 @@ static bool AddDuration(JSContext* cx, const Duration& one, const Duration& two, */ static bool AddDuration(JSContext* cx, const Duration& one, const Duration& two, Handle<Wrapped<PlainDateObject*>> plainRelativeTo, - Handle<CalendarRecord> calendar, Duration* duration) { + Handle<CalendarRecord> calendar, Duration* result) { MOZ_ASSERT(IsValidDuration(one)); MOZ_ASSERT(IsValidDuration(two)); // Steps 1-2. (Not applicable) - // FIXME: spec issue - calendarRec is not undefined when plainRelativeTo is - // not undefined. - // Step 3. auto largestUnit1 = DefaultTemporalLargestUnit(one); @@ -2238,66 +2211,75 @@ static bool AddDuration(JSContext* cx, const Duration& one, const Duration& two, // Step 5. auto largestUnit = std::min(largestUnit1, largestUnit2); - // Step 6. (Not applicable) - - // Step 7.a. (Not applicable in our implementation.) + // Step 6. + auto normalized1 = NormalizeTimeDuration(one); - // Step 7.b. - auto dateDuration1 = one.date(); + // Step 7. + auto normalized2 = NormalizeTimeDuration(two); - // Step 7.c. - auto dateDuration2 = two.date(); + // Step 8. (Not applicable) - // FIXME: spec issue - calendarUnitsPresent is unused. + // Step 9.a. (Not applicable in our implementation.) - // Step 7.d. - [[maybe_unused]] bool calendarUnitsPresent = true; + // Step 9.b. + auto dateDuration1 = one.toDateDuration(); - // Step 7.e. - if (dateDuration1.years == 0 && dateDuration1.months == 0 && - dateDuration1.weeks == 0 && dateDuration2.years == 0 && - dateDuration2.months == 0 && dateDuration2.weeks == 0) { - calendarUnitsPresent = false; - } + // Step 9.c. + auto dateDuration2 = two.toDateDuration(); - // Step 7.f. + // Step 9.d. Rooted<Wrapped<PlainDateObject*>> intermediate( cx, AddDate(cx, calendar, plainRelativeTo, dateDuration1)); if (!intermediate) { return false; } - // Step 7.g. + // Step 9.e. Rooted<Wrapped<PlainDateObject*>> end( cx, AddDate(cx, calendar, intermediate, dateDuration2)); if (!end) { return false; } - // Step 7.h. + // Step 9.f. auto dateLargestUnit = std::min(TemporalUnit::Day, largestUnit); - // Steps 7.i-k. - Duration dateDifference; + // Steps 9.g-i. + DateDuration dateDifference; if (!DifferenceDate(cx, calendar, plainRelativeTo, end, dateLargestUnit, &dateDifference)) { return false; } - // Step 7.l. - TimeDuration result; - if (!BalanceTimeDuration(cx, dateDifference.days, one.time(), two.time(), - largestUnit, &result)) { + // Step 9.j. + NormalizedTimeDuration normalized1WithDays; + if (!Add24HourDaysToNormalizedTimeDuration( + cx, normalized1, dateDifference.days, &normalized1WithDays)) { + return false; + } + + // Step 9.k. + NormalizedTimeDuration normalized; + if (!AddNormalizedTimeDuration(cx, normalized1WithDays, normalized2, + &normalized)) { + return false; + } + + // Step 9.l. + TimeDuration balanced; + if (!temporal::BalanceTimeDuration(cx, normalized, largestUnit, &balanced)) { return false; } - // Steps 7.m. - *duration = { - dateDifference.years, dateDifference.months, dateDifference.weeks, - result.days, result.hours, result.minutes, - result.seconds, result.milliseconds, result.microseconds, - result.nanoseconds, + // Steps 9.m. + *result = { + double(dateDifference.years), double(dateDifference.months), + double(dateDifference.weeks), double(balanced.days), + double(balanced.hours), double(balanced.minutes), + double(balanced.seconds), double(balanced.milliseconds), + balanced.microseconds, balanced.nanoseconds, }; + MOZ_ASSERT(IsValidDuration(*result)); return true; } @@ -2323,89 +2305,107 @@ static bool AddDuration( // Step 5. auto largestUnit = std::min(largestUnit1, largestUnit2); - // Steps 6-7. (Not applicable) + // Step 6. + auto normalized1 = NormalizeTimeDuration(one); - // Steps 8-9. (Not applicable in our implementation.) + // Step 7. + auto normalized2 = NormalizeTimeDuration(two); - // FIXME: spec issue - GetPlainDateTimeFor called unnecessarily - // - // clang-format off - // - // 10. If largestUnit is one of "year", "month", "week", or "day", then - // a. If precalculatedPlainDateTime is undefined, then - // i. Let startDateTime be ? GetPlainDateTimeFor(timeZone, zonedRelativeTo.[[Nanoseconds]], calendar). - // b. Else, - // i. Let startDateTime be precalculatedPlainDateTime. - // c. Let intermediateNs be ? AddZonedDateTime(zonedRelativeTo.[[Nanoseconds]], timeZone, calendar, y1, mon1, w1, d1, h1, min1, s1, ms1, mus1, ns1, startDateTime). - // d. Let endNs be ? AddZonedDateTime(intermediateNs, timeZone, calendar, y2, mon2, w2, d2, h2, min2, s2, ms2, mus2, ns2). - // e. Return ? DifferenceZonedDateTime(zonedRelativeTo.[[Nanoseconds]], endNs, timeZone, calendar, largestUnit, OrdinaryObjectCreate(null), startDateTime). - // 11. Let intermediateNs be ? AddInstant(zonedRelativeTo.[[Nanoseconds]], h1, min1, s1, ms1, mus1, ns1). - // 12. Let endNs be ? AddInstant(intermediateNs, h2, min2, s2, ms2, mus2, ns2). - // 13. Let result be DifferenceInstant(zonedRelativeTo.[[Nanoseconds]], endNs, 1, "nanosecond", largestUnit, "halfExpand"). - // 14. Return ! CreateDurationRecord(0, 0, 0, 0, result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]]). - // - // clang-format on + // Steps 8-9. (Not applicable) - // Step 10. + // Steps 10-11. (Not applicable in our implementation.) + + // Step 12. bool startDateTimeNeeded = largestUnit <= TemporalUnit::Day; - // Steps 11-14 and 16. - if (startDateTimeNeeded) { - // Steps 11-12. - PlainDateTime startDateTime; - if (!precalculatedPlainDateTime) { - if (!GetPlainDateTimeFor(cx, timeZone, zonedRelativeTo.instant(), - &startDateTime)) { - return false; - } - } else { - startDateTime = *precalculatedPlainDateTime; - } + // Steps 13-17. + if (!startDateTimeNeeded) { + // Steps 13-14. (Not applicable) - // Step 13. + // Step 15. (Inlined AddZonedDateTime, step 6.) Instant intermediateNs; - if (!AddZonedDateTime(cx, zonedRelativeTo.instant(), timeZone, calendar, - one, startDateTime, &intermediateNs)) { + if (!AddInstant(cx, zonedRelativeTo.instant(), normalized1, + &intermediateNs)) { return false; } MOZ_ASSERT(IsValidEpochInstant(intermediateNs)); - // Step 14. + // Step 16. (Inlined AddZonedDateTime, step 6.) Instant endNs; - if (!AddZonedDateTime(cx, intermediateNs, timeZone, calendar, two, - &endNs)) { + if (!AddInstant(cx, intermediateNs, normalized2, &endNs)) { return false; } MOZ_ASSERT(IsValidEpochInstant(endNs)); - // Step 15. (Not applicable) + // Step 17.a. + auto normalized = NormalizedTimeDurationFromEpochNanosecondsDifference( + endNs, zonedRelativeTo.instant()); - // Step 16. - return DifferenceZonedDateTime(cx, zonedRelativeTo.instant(), endNs, - timeZone, calendar, largestUnit, - startDateTime, result); + // Step 17.b. + TimeDuration balanced; + if (!BalanceTimeDuration(cx, normalized, largestUnit, &balanced)) { + return false; + } + + // Step 17.c. + *result = balanced.toDuration(); + return true; } - // Steps 11-12. (Not applicable) + // Steps 13-14. + PlainDateTime startDateTime; + if (!precalculatedPlainDateTime) { + if (!GetPlainDateTimeFor(cx, timeZone, zonedRelativeTo.instant(), + &startDateTime)) { + return false; + } + } else { + startDateTime = *precalculatedPlainDateTime; + } - // Step 13. (Inlined AddZonedDateTime, step 6.) + // Step 15. + auto norm1 = + CreateNormalizedDurationRecord(one.toDateDuration(), normalized1); Instant intermediateNs; - if (!AddInstant(cx, zonedRelativeTo.instant(), one, &intermediateNs)) { + if (!AddZonedDateTime(cx, zonedRelativeTo.instant(), timeZone, calendar, + norm1, startDateTime, &intermediateNs)) { return false; } MOZ_ASSERT(IsValidEpochInstant(intermediateNs)); - // Step 14. (Inlined AddZonedDateTime, step 6.) + // Step 16. + auto norm2 = + CreateNormalizedDurationRecord(two.toDateDuration(), normalized2); Instant endNs; - if (!AddInstant(cx, intermediateNs, two, &endNs)) { + if (!AddZonedDateTime(cx, intermediateNs, timeZone, calendar, norm2, + &endNs)) { return false; } MOZ_ASSERT(IsValidEpochInstant(endNs)); - // Steps 15.a-b. - return DifferenceInstant(cx, zonedRelativeTo.instant(), endNs, Increment{1}, - TemporalUnit::Nanosecond, largestUnit, - TemporalRoundingMode::HalfExpand, result); + // Step 17. (Not applicable) + + // Step 18. + NormalizedDuration difference; + if (!DifferenceZonedDateTime(cx, zonedRelativeTo.instant(), endNs, timeZone, + calendar, largestUnit, startDateTime, + &difference)) { + return false; + } + + // Step 19. + auto balanced = BalanceTimeDuration(difference.time, TemporalUnit::Hour); + + // Step 20. + *result = { + double(difference.date.years), double(difference.date.months), + double(difference.date.weeks), double(difference.date.days), + double(balanced.hours), double(balanced.minutes), + double(balanced.seconds), double(balanced.milliseconds), + balanced.microseconds, balanced.nanoseconds, + }; + MOZ_ASSERT(IsValidDuration(*result)); + return true; } /** @@ -2421,214 +2421,18 @@ static bool AddDuration(JSContext* cx, const Duration& one, const Duration& two, mozilla::Nothing(), result); } -static bool RoundDuration(JSContext* cx, int64_t totalNanoseconds, - TemporalUnit unit, Increment increment, - TemporalRoundingMode roundingMode, Duration* result) { - MOZ_ASSERT(unit >= TemporalUnit::Hour); - - double rounded; - if (!RoundNumberToIncrement(cx, totalNanoseconds, unit, increment, - roundingMode, &rounded)) { - return false; - } - - double hours = 0; - double minutes = 0; - double seconds = 0; - double milliseconds = 0; - double microseconds = 0; - double nanoseconds = 0; - - switch (unit) { - case TemporalUnit::Auto: - case TemporalUnit::Year: - case TemporalUnit::Week: - case TemporalUnit::Month: - case TemporalUnit::Day: - MOZ_CRASH("Unexpected temporal unit"); - - case TemporalUnit::Hour: - hours = rounded; - break; - case TemporalUnit::Minute: - minutes = rounded; - break; - case TemporalUnit::Second: - seconds = rounded; - break; - case TemporalUnit::Millisecond: - milliseconds = rounded; - break; - case TemporalUnit::Microsecond: - microseconds = rounded; - break; - case TemporalUnit::Nanosecond: - nanoseconds = rounded; - break; - } - - *result = { - 0, 0, 0, 0, hours, minutes, seconds, milliseconds, microseconds, - nanoseconds, - }; - return ThrowIfInvalidDuration(cx, *result); -} - -static bool RoundDuration(JSContext* cx, Handle<BigInt*> totalNanoseconds, - TemporalUnit unit, Increment increment, - TemporalRoundingMode roundingMode, Duration* result) { - MOZ_ASSERT(unit >= TemporalUnit::Hour); - - double rounded; - if (!RoundNumberToIncrement(cx, totalNanoseconds, unit, increment, - roundingMode, &rounded)) { - return false; - } - - double hours = 0; - double minutes = 0; - double seconds = 0; - double milliseconds = 0; - double microseconds = 0; - double nanoseconds = 0; - - switch (unit) { - case TemporalUnit::Auto: - case TemporalUnit::Year: - case TemporalUnit::Week: - case TemporalUnit::Month: - case TemporalUnit::Day: - MOZ_CRASH("Unexpected temporal unit"); - - case TemporalUnit::Hour: - hours = rounded; - break; - case TemporalUnit::Minute: - minutes = rounded; - break; - case TemporalUnit::Second: - seconds = rounded; - break; - case TemporalUnit::Millisecond: - milliseconds = rounded; - break; - case TemporalUnit::Microsecond: - microseconds = rounded; - break; - case TemporalUnit::Nanosecond: - nanoseconds = rounded; - break; - } - - *result = { - 0, 0, 0, 0, hours, minutes, seconds, milliseconds, microseconds, - nanoseconds, - }; - return ThrowIfInvalidDuration(cx, *result); -} - /** - * AdjustRoundedDurationDays ( years, months, weeks, days, hours, minutes, - * seconds, milliseconds, microseconds, nanoseconds, increment, unit, - * roundingMode, zonedRelativeTo, calendarRec, timeZoneRec, - * precalculatedPlainDateTime ) - */ -static bool AdjustRoundedDurationDaysSlow( - JSContext* cx, const Duration& duration, Increment increment, - TemporalUnit unit, TemporalRoundingMode roundingMode, - Handle<ZonedDateTime> zonedRelativeTo, Handle<CalendarRecord> calendar, - Handle<TimeZoneRecord> timeZone, - mozilla::Maybe<const PlainDateTime&> precalculatedPlainDateTime, - InstantSpan dayLength, Duration* result) { - MOZ_ASSERT(IsValidDuration(duration)); - MOZ_ASSERT(IsValidInstantSpan(dayLength)); - - // Step 3. - Rooted<BigInt*> timeRemainderNs( - cx, TotalDurationNanosecondsSlow(cx, duration.time())); - if (!timeRemainderNs) { - return false; - } - - // Steps 4-6. - int32_t direction = timeRemainderNs->sign(); - - // Steps 7-10. (Computed in caller) - - // Step 11. - Rooted<BigInt*> dayLengthNs(cx, ToEpochNanoseconds(cx, dayLength)); - if (!dayLengthNs) { - return false; - } - MOZ_ASSERT(IsValidInstantSpan(dayLengthNs)); - - // Step 12. - Rooted<BigInt*> oneDayLess(cx, BigInt::sub(cx, timeRemainderNs, dayLengthNs)); - if (!oneDayLess) { - return false; - } - - // Step 13. - if ((direction > 0 && oneDayLess->sign() < 0) || - (direction < 0 && oneDayLess->sign() > 0)) { - *result = duration; - return true; - } - - // Step 14. - Duration adjustedDateDuration; - if (!AddDuration(cx, - { - duration.years, - duration.months, - duration.weeks, - duration.days, - }, - {0, 0, 0, double(direction)}, zonedRelativeTo, calendar, - timeZone, precalculatedPlainDateTime, - &adjustedDateDuration)) { - return false; - } - - // Step 15. - Duration roundedTimeDuration; - if (!RoundDuration(cx, oneDayLess, unit, increment, roundingMode, - &roundedTimeDuration)) { - return false; - } - - // Step 16. - TimeDuration adjustedTimeDuration; - if (!BalanceTimeDuration(cx, roundedTimeDuration, TemporalUnit::Hour, - &adjustedTimeDuration)) { - return false; - } - - // Step 17. - *result = { - adjustedDateDuration.years, adjustedDateDuration.months, - adjustedDateDuration.weeks, adjustedDateDuration.days, - adjustedTimeDuration.hours, adjustedTimeDuration.minutes, - adjustedTimeDuration.seconds, adjustedTimeDuration.milliseconds, - adjustedTimeDuration.microseconds, adjustedTimeDuration.nanoseconds, - }; - MOZ_ASSERT(IsValidDuration(*result)); - return true; -} - -/** - * AdjustRoundedDurationDays ( years, months, weeks, days, hours, minutes, - * seconds, milliseconds, microseconds, nanoseconds, increment, unit, - * roundingMode, zonedRelativeTo, calendarRec, timeZoneRec, + * AdjustRoundedDurationDays ( years, months, weeks, days, norm, increment, + * unit, roundingMode, zonedRelativeTo, calendarRec, timeZoneRec, * precalculatedPlainDateTime ) */ static bool AdjustRoundedDurationDays( - JSContext* cx, const Duration& duration, Increment increment, + JSContext* cx, const NormalizedDuration& duration, Increment increment, TemporalUnit unit, TemporalRoundingMode roundingMode, Handle<ZonedDateTime> zonedRelativeTo, Handle<CalendarRecord> calendar, Handle<TimeZoneRecord> timeZone, mozilla::Maybe<const PlainDateTime&> precalculatedPlainDateTime, - Duration* result) { + NormalizedDuration* result) { MOZ_ASSERT(IsValidDuration(duration)); // Step 1. @@ -2644,27 +2448,25 @@ static bool AdjustRoundedDurationDays( // Step 2. MOZ_ASSERT(precalculatedPlainDateTime); - // Steps 4-6. - // - // Step 3 is moved below, so compute |direction| through DurationSign. - int32_t direction = DurationSign(duration.time()); + // Step 3. + int32_t direction = NormalizedTimeDurationSign(duration.time); - // Steps 7-8. + // Steps 4-5. Instant dayStart; if (!AddZonedDateTime(cx, zonedRelativeTo.instant(), timeZone, calendar, - duration.date(), *precalculatedPlainDateTime, + duration.date, *precalculatedPlainDateTime, &dayStart)) { return false; } MOZ_ASSERT(IsValidEpochInstant(dayStart)); - // Step 9. + // Step 6. PlainDateTime dayStartDateTime; if (!GetPlainDateTimeFor(cx, timeZone, dayStart, &dayStartDateTime)) { return false; } - // Step 10. + // Step 7. Instant dayEnd; if (!AddDaysToZonedDateTime(cx, dayStart, dayStartDateTime, timeZone, zonedRelativeTo.calendar(), direction, &dayEnd)) { @@ -2672,153 +2474,74 @@ static bool AdjustRoundedDurationDays( } MOZ_ASSERT(IsValidEpochInstant(dayEnd)); - // Step 11. - auto dayLength = dayEnd - dayStart; - MOZ_ASSERT(IsValidInstantSpan(dayLength)); - - // Step 3. (Reordered) - auto timeRemainderNs = TotalDurationNanoseconds(duration.time()); - if (!timeRemainderNs) { - return AdjustRoundedDurationDaysSlow( - cx, duration, increment, unit, roundingMode, zonedRelativeTo, calendar, - timeZone, precalculatedPlainDateTime, dayLength, result); - } + // Step 8. + auto dayLengthNs = + NormalizedTimeDurationFromEpochNanosecondsDifference(dayEnd, dayStart); + MOZ_ASSERT(IsValidInstantSpan(dayLengthNs.to<InstantSpan>())); - // Step 12. - auto checkedOneDayLess = *timeRemainderNs - dayLength.toNanoseconds(); - if (!checkedOneDayLess.isValid()) { - return AdjustRoundedDurationDaysSlow( - cx, duration, increment, unit, roundingMode, zonedRelativeTo, calendar, - timeZone, precalculatedPlainDateTime, dayLength, result); + // Step 9. + NormalizedTimeDuration oneDayLess; + if (!SubtractNormalizedTimeDuration(cx, duration.time, dayLengthNs, + &oneDayLess)) { + return false; } - auto oneDayLess = checkedOneDayLess.value(); - // Step 13. - if ((direction > 0 && oneDayLess < 0) || (direction < 0 && oneDayLess > 0)) { + // Step 10. + int32_t oneDayLessSign = NormalizedTimeDurationSign(oneDayLess); + if ((direction > 0 && oneDayLessSign < 0) || + (direction < 0 && oneDayLessSign > 0)) { *result = duration; return true; } - // Step 14. + // Step 11. Duration adjustedDateDuration; - if (!AddDuration(cx, - { - duration.years, - duration.months, - duration.weeks, - duration.days, - }, - {0, 0, 0, double(direction)}, zonedRelativeTo, calendar, - timeZone, precalculatedPlainDateTime, - &adjustedDateDuration)) { - return false; - } - - // Step 15. - Duration roundedTimeDuration; - if (!RoundDuration(cx, oneDayLess, unit, increment, roundingMode, - &roundedTimeDuration)) { + if (!AddDuration(cx, duration.date.toDuration(), {0, 0, 0, double(direction)}, + zonedRelativeTo, calendar, timeZone, + precalculatedPlainDateTime, &adjustedDateDuration)) { return false; } - // Step 16. - TimeDuration adjustedTimeDuration; - if (!BalanceTimeDuration(cx, roundedTimeDuration, TemporalUnit::Hour, - &adjustedTimeDuration)) { + // Step 12. + NormalizedTimeDuration roundedTime; + if (!RoundDuration(cx, oneDayLess, increment, unit, roundingMode, + &roundedTime)) { return false; } - // FIXME: spec bug - CreateDurationRecord is fallible because the adjusted - // date and time durations can be have different signs. - // https://github.com/tc39/proposal-temporal/issues/2536 - // - // clang-format off - // - // { - // let calendar = new class extends Temporal.Calendar { - // dateAdd(date, duration, options) { - // console.log(`dateAdd(${date}, ${duration})`); - // if (duration.days === 10) { - // return super.dateAdd(date, duration.negated(), options); - // } - // return super.dateAdd(date, duration, options); - // } - // }("iso8601"); - // - // let zdt = new Temporal.ZonedDateTime(0n, "UTC", calendar); - // - // let d = Temporal.Duration.from({ - // days: 10, - // hours: 25, - // }); - // - // let r = d.round({ - // smallestUnit: "nanoseconds", - // roundingIncrement: 5, - // relativeTo: zdt, - // }); - // console.log(r.toString()); - // } - // - // clang-format on - - // Step 17. - *result = { - adjustedDateDuration.years, adjustedDateDuration.months, - adjustedDateDuration.weeks, adjustedDateDuration.days, - adjustedTimeDuration.hours, adjustedTimeDuration.minutes, - adjustedTimeDuration.seconds, adjustedTimeDuration.milliseconds, - adjustedTimeDuration.microseconds, adjustedTimeDuration.nanoseconds, - }; - return ThrowIfInvalidDuration(cx, *result); + // Step 13. + return CombineDateAndNormalizedTimeDuration( + cx, adjustedDateDuration.toDateDuration(), roundedTime, result); } /** - * AdjustRoundedDurationDays ( years, months, weeks, days, hours, minutes, - * seconds, milliseconds, microseconds, nanoseconds, increment, unit, - * roundingMode, zonedRelativeTo, calendarRec, timeZoneRec, + * AdjustRoundedDurationDays ( years, months, weeks, days, norm, increment, + * unit, roundingMode, zonedRelativeTo, calendarRec, timeZoneRec, * precalculatedPlainDateTime ) */ bool js::temporal::AdjustRoundedDurationDays( - JSContext* cx, const Duration& duration, Increment increment, + JSContext* cx, const NormalizedDuration& duration, Increment increment, TemporalUnit unit, TemporalRoundingMode roundingMode, Handle<ZonedDateTime> zonedRelativeTo, Handle<CalendarRecord> calendar, Handle<TimeZoneRecord> timeZone, - const PlainDateTime& precalculatedPlainDateTime, Duration* result) { + const PlainDateTime& precalculatedPlainDateTime, + NormalizedDuration* result) { return ::AdjustRoundedDurationDays( cx, duration, increment, unit, roundingMode, zonedRelativeTo, calendar, timeZone, mozilla::SomeRef(precalculatedPlainDateTime), result); } -static bool BigIntToStringBuilder(JSContext* cx, Handle<BigInt*> num, - JSStringBuilder& sb) { - MOZ_ASSERT(!num->isNegative()); - - JSLinearString* str = BigInt::toString<CanGC>(cx, num, 10); - if (!str) { - return false; - } - return sb.append(str); -} - static bool NumberToStringBuilder(JSContext* cx, double num, JSStringBuilder& sb) { MOZ_ASSERT(IsInteger(num)); MOZ_ASSERT(num >= 0); + MOZ_ASSERT(num < DOUBLE_INTEGRAL_PRECISION_LIMIT); - if (num < DOUBLE_INTEGRAL_PRECISION_LIMIT) { - ToCStringBuf cbuf; - size_t length; - const char* numStr = NumberToCString(&cbuf, num, &length); - - return sb.append(numStr, length); - } + ToCStringBuf cbuf; + size_t length; + const char* numStr = NumberToCString(&cbuf, num, &length); - Rooted<BigInt*> bi(cx, BigInt::createFromDouble(cx, num)); - if (!bi) { - return false; - } - return BigIntToStringBuilder(cx, bi, sb); + return sb.append(numStr, length); } static Duration AbsoluteDuration(const Duration& duration) { @@ -2853,7 +2576,7 @@ static Duration AbsoluteDuration(const Duration& duration) { } // Steps 1.b-c. - uint32_t k = 100'000'000; + int32_t k = 100'000'000; do { if (!result.append(char('0' + (subSecondNanoseconds / k)))) { return false; @@ -2874,7 +2597,7 @@ static Duration AbsoluteDuration(const Duration& duration) { } // Steps 2.b-c. - uint32_t k = 100'000'000; + int32_t k = 100'000'000; for (uint8_t i = 0; i < precision.value(); i++) { if (!result.append(char('0' + (subSecondNanoseconds / k)))) { return false; @@ -2889,7 +2612,7 @@ static Duration AbsoluteDuration(const Duration& duration) { /** * TemporalDurationToString ( years, months, weeks, days, hours, minutes, - * seconds, milliseconds, microseconds, nanoseconds, precision ) + * normSeconds, precision ) */ static JSString* TemporalDurationToString(JSContext* cx, const Duration& duration, @@ -2897,187 +2620,49 @@ static JSString* TemporalDurationToString(JSContext* cx, MOZ_ASSERT(IsValidDuration(duration)); MOZ_ASSERT(precision != Precision::Minute()); - // Convert to absolute values up front. This is okay to do, because when the - // duration is valid, all components have the same sign. - const auto& [years, months, weeks, days, hours, minutes, seconds, - milliseconds, microseconds, nanoseconds] = - AbsoluteDuration(duration); - // Fast path for zero durations. - if (years == 0 && months == 0 && weeks == 0 && days == 0 && hours == 0 && - minutes == 0 && seconds == 0 && milliseconds == 0 && microseconds == 0 && - nanoseconds == 0 && + if (duration == Duration{} && (precision == Precision::Auto() || precision.value() == 0)) { return NewStringCopyZ<CanGC>(cx, "PT0S"); } - Rooted<BigInt*> totalSecondsBigInt(cx); - double totalSeconds = seconds; - int32_t fraction = 0; - if (milliseconds != 0 || microseconds != 0 || nanoseconds != 0) { - bool imprecise = false; - do { - int64_t sec; - int64_t milli; - int64_t micro; - int64_t nano; - if (!mozilla::NumberEqualsInt64(seconds, &sec) || - !mozilla::NumberEqualsInt64(milliseconds, &milli) || - !mozilla::NumberEqualsInt64(microseconds, µ) || - !mozilla::NumberEqualsInt64(nanoseconds, &nano)) { - imprecise = true; - break; - } - - mozilla::CheckedInt64 intermediate; - - // Step 2. - intermediate = micro; - intermediate += (nano / 1000); - if (!intermediate.isValid()) { - imprecise = true; - break; - } - micro = intermediate.value(); - - // Step 3. - nano %= 1000; - - // Step 4. - intermediate = milli; - intermediate += (micro / 1000); - if (!intermediate.isValid()) { - imprecise = true; - break; - } - milli = intermediate.value(); - - // Step 5. - micro %= 1000; - - // Step 6. - intermediate = sec; - intermediate += (milli / 1000); - if (!intermediate.isValid()) { - imprecise = true; - break; - } - sec = intermediate.value(); - - // Step 7. - milli %= 1000; - - if (sec < int64_t(DOUBLE_INTEGRAL_PRECISION_LIMIT)) { - totalSeconds = double(sec); - } else { - totalSecondsBigInt = BigInt::createFromInt64(cx, sec); - if (!totalSecondsBigInt) { - return nullptr; - } - } - - // These are now all in the range [0, 999]. - MOZ_ASSERT(0 <= milli && milli <= 999); - MOZ_ASSERT(0 <= micro && micro <= 999); - MOZ_ASSERT(0 <= nano && nano <= 999); - - // Step 20.b. (Reordered) - fraction = milli * 1'000'000 + micro * 1'000 + nano; - MOZ_ASSERT(0 <= fraction && fraction < 1'000'000'000); - } while (false); - - // If a result was imprecise, recompute with BigInt to get full precision. - if (imprecise) { - Rooted<BigInt*> secs(cx, BigInt::createFromDouble(cx, seconds)); - if (!secs) { - return nullptr; - } - - Rooted<BigInt*> millis(cx, BigInt::createFromDouble(cx, milliseconds)); - if (!millis) { - return nullptr; - } - - Rooted<BigInt*> micros(cx, BigInt::createFromDouble(cx, microseconds)); - if (!micros) { - return nullptr; - } - - Rooted<BigInt*> nanos(cx, BigInt::createFromDouble(cx, nanoseconds)); - if (!nanos) { - return nullptr; - } - - Rooted<BigInt*> thousand(cx, BigInt::createFromInt64(cx, 1000)); - if (!thousand) { - return nullptr; - } - - // Steps 2-3. - Rooted<BigInt*> quotient(cx); - if (!BigInt::divmod(cx, nanos, thousand, "ient, &nanos)) { - return nullptr; - } - - micros = BigInt::add(cx, micros, quotient); - if (!micros) { - return nullptr; - } - - // Steps 4-5. - if (!BigInt::divmod(cx, micros, thousand, "ient, µs)) { - return nullptr; - } - - millis = BigInt::add(cx, millis, quotient); - if (!millis) { - return nullptr; - } - - // Steps 6-7. - if (!BigInt::divmod(cx, millis, thousand, "ient, &millis)) { - return nullptr; - } - - totalSecondsBigInt = BigInt::add(cx, secs, quotient); - if (!totalSecondsBigInt) { - return nullptr; - } + // Convert to absolute values up front. This is okay to do, because when the + // duration is valid, all components have the same sign. + const auto& [years, months, weeks, days, hours, minutes, seconds, + milliseconds, microseconds, nanoseconds] = + AbsoluteDuration(duration); - // These are now all in the range [0, 999]. - int64_t milli = BigInt::toInt64(millis); - int64_t micro = BigInt::toInt64(micros); - int64_t nano = BigInt::toInt64(nanos); + // Years to seconds parts are all safe integers for valid durations. + MOZ_ASSERT(years < DOUBLE_INTEGRAL_PRECISION_LIMIT); + MOZ_ASSERT(months < DOUBLE_INTEGRAL_PRECISION_LIMIT); + MOZ_ASSERT(weeks < DOUBLE_INTEGRAL_PRECISION_LIMIT); + MOZ_ASSERT(days < DOUBLE_INTEGRAL_PRECISION_LIMIT); + MOZ_ASSERT(hours < DOUBLE_INTEGRAL_PRECISION_LIMIT); + MOZ_ASSERT(minutes < DOUBLE_INTEGRAL_PRECISION_LIMIT); + MOZ_ASSERT(seconds < DOUBLE_INTEGRAL_PRECISION_LIMIT); - MOZ_ASSERT(0 <= milli && milli <= 999); - MOZ_ASSERT(0 <= micro && micro <= 999); - MOZ_ASSERT(0 <= nano && nano <= 999); + auto secondsDuration = NormalizeTimeDuration(0.0, 0.0, seconds, milliseconds, + microseconds, nanoseconds); - // Step 20.b. (Reordered) - fraction = milli * 1'000'000 + micro * 1'000 + nano; - MOZ_ASSERT(0 <= fraction && fraction < 1'000'000'000); - } - } + // Step 1. + int32_t sign = DurationSign(duration); - // Steps 8 and 13. + // Steps 2 and 7. JSStringBuilder result(cx); - // Step 1. (Reordered) - int32_t sign = DurationSign(duration); - - // Step 21. (Reordered) + // Step 13. (Reordered) if (sign < 0) { if (!result.append('-')) { return nullptr; } } - // Step 22. (Reordered) + // Step 14. (Reordered) if (!result.append('P')) { return nullptr; } - // Step 9. + // Step 3. if (years != 0) { if (!NumberToStringBuilder(cx, years, result)) { return nullptr; @@ -3087,7 +2672,7 @@ static JSString* TemporalDurationToString(JSContext* cx, } } - // Step 10. + // Step 4. if (months != 0) { if (!NumberToStringBuilder(cx, months, result)) { return nullptr; @@ -3097,7 +2682,7 @@ static JSString* TemporalDurationToString(JSContext* cx, } } - // Step 11. + // Step 5. if (weeks != 0) { if (!NumberToStringBuilder(cx, weeks, result)) { return nullptr; @@ -3107,7 +2692,7 @@ static JSString* TemporalDurationToString(JSContext* cx, } } - // Step 12. + // Step 6. if (days != 0) { if (!NumberToStringBuilder(cx, days, result)) { return nullptr; @@ -3117,29 +2702,22 @@ static JSString* TemporalDurationToString(JSContext* cx, } } - // Steps 16-17. - bool nonzeroSecondsAndLower = seconds != 0 || milliseconds != 0 || - microseconds != 0 || nanoseconds != 0; - MOZ_ASSERT(nonzeroSecondsAndLower == - (totalSeconds != 0 || - (totalSecondsBigInt && !totalSecondsBigInt->isZero()) || - fraction != 0)); + // Step 7. (Moved above) - // Steps 18-19. + // Steps 10-11. (Reordered) bool zeroMinutesAndHigher = years == 0 && months == 0 && weeks == 0 && days == 0 && hours == 0 && minutes == 0; - // Step 20. (if-condition) - bool hasSecondsPart = nonzeroSecondsAndLower || zeroMinutesAndHigher || - precision != Precision::Auto(); - + // Steps 8-9, 12, and 15. + bool hasSecondsPart = (secondsDuration != NormalizedTimeDuration{}) || + zeroMinutesAndHigher || precision != Precision::Auto(); if (hours != 0 || minutes != 0 || hasSecondsPart) { - // Step 23. (Reordered) + // Step 15. (Reordered) if (!result.append('T')) { return nullptr; } - // Step 14. + // Step 8. if (hours != 0) { if (!NumberToStringBuilder(cx, hours, result)) { return nullptr; @@ -3149,7 +2727,7 @@ static JSString* TemporalDurationToString(JSContext* cx, } } - // Step 15. + // Step 9. if (minutes != 0) { if (!NumberToStringBuilder(cx, minutes, result)) { return nullptr; @@ -3159,34 +2737,29 @@ static JSString* TemporalDurationToString(JSContext* cx, } } - // Step 20. + // Step 12. if (hasSecondsPart) { - // Step 20.a. - if (totalSecondsBigInt) { - if (!BigIntToStringBuilder(cx, totalSecondsBigInt, result)) { - return nullptr; - } - } else { - if (!NumberToStringBuilder(cx, totalSeconds, result)) { - return nullptr; - } + // Step 12.a. + if (!NumberToStringBuilder(cx, double(secondsDuration.seconds), result)) { + return nullptr; } - // Step 20.b. (Moved above) - - // Step 20.c. - if (!FormatFractionalSeconds(result, fraction, precision)) { + // Step 12.b. + if (!FormatFractionalSeconds(result, secondsDuration.nanoseconds, + precision)) { return nullptr; } - // Step 20.d. + // Step 12.c. if (!result.append('S')) { return nullptr; } } } - // Step 24. + // Steps 13-15. (Moved above) + + // Step 16. return result.finishString(); } @@ -3206,9 +2779,6 @@ static bool ToRelativeTemporalObject( // Step 2. if (value.isUndefined()) { - // FIXME: spec issue - switch return record fields for consistency. - // FIXME: spec bug - [[TimeZoneRec]] field not created - plainRelativeTo.set(nullptr); zonedRelativeTo.set(ZonedDateTime{}); timeZoneRecord.set(TimeZoneRecord{}); @@ -3414,20 +2984,20 @@ static bool ToRelativeTemporalObject( bool isUTC; bool hasOffset; int64_t timeZoneOffset; - Rooted<ParsedTimeZone> timeZoneName(cx); + Rooted<ParsedTimeZone> timeZoneAnnotation(cx); Rooted<JSString*> calendarString(cx); if (!ParseTemporalRelativeToString(cx, string, &dateTime, &isUTC, &hasOffset, &timeZoneOffset, - &timeZoneName, &calendarString)) { + &timeZoneAnnotation, &calendarString)) { return false; } // Step 6.c. (Not applicable in our implementation.) // Steps 6.e-f. - if (timeZoneName) { + if (timeZoneAnnotation) { // Step 6.f.i. - if (!ToTemporalTimeZone(cx, timeZoneName, &timeZone)) { + if (!ToTemporalTimeZone(cx, timeZoneAnnotation, &timeZone)) { return false; } @@ -3545,820 +3115,216 @@ static bool CreateCalendarMethodsRecordFromRelativeTo( return true; } -static constexpr bool IsSafeInteger(int64_t x) { - constexpr int64_t MaxSafeInteger = int64_t(1) << 53; - constexpr int64_t MinSafeInteger = -MaxSafeInteger; - return MinSafeInteger < x && x < MaxSafeInteger; -} +struct RoundedDuration final { + NormalizedDuration duration; + double total = 0; +}; -/** - * RoundNumberToIncrement ( x, increment, roundingMode ) - */ -static void TruncateNumber(int64_t numerator, int64_t denominator, - double* quotient, double* total) { - // Computes the quotient and real number value of the rational number - // |numerator / denominator|. - - // Int64 division truncates. - int64_t q = numerator / denominator; - int64_t r = numerator % denominator; - - // The total value is stored as a mathematical number in the draft proposal, - // so we can't convert it to a double without loss of precision. We use two - // different approaches to compute the total value based on the input range. - // - // For example: - // - // When |numerator = 1000001| and |denominator = 60 * 1000|, the exact result - // is |16.66668333...| and the best possible approximation is - // |16.666683333333335070...𝔽|. We can this approximation when casting both - // numerator and denominator to doubles and then performing a double division. - // - // When |numerator = 14400000000000001| and |denominator = 3600000000000|, we - // can't use double division, because |14400000000000001| can't be represented - // as an exact double value. The exact result is |4000.0000000000002777...|. - // - // The best possible approximation is |4000.0000000000004547...𝔽|, which can - // be computed through |q + r / denominator|. - if (::IsSafeInteger(numerator) && ::IsSafeInteger(denominator)) { - *quotient = double(q); - *total = double(numerator) / double(denominator); - } else { - *quotient = double(q); - *total = double(q) + double(r) / double(denominator); - } -} +enum class ComputeRemainder : bool { No, Yes }; /** - * RoundNumberToIncrement ( x, increment, roundingMode ) + * RoundNormalizedTimeDurationToIncrement ( d, increment, roundingMode ) */ -static bool TruncateNumber(JSContext* cx, Handle<BigInt*> numerator, - Handle<BigInt*> denominator, double* quotient, - double* total) { - MOZ_ASSERT(!denominator->isNegative()); - MOZ_ASSERT(!denominator->isZero()); - - // Dividing zero is always zero. - if (numerator->isZero()) { - *quotient = 0; - *total = 0; - return true; - } +static NormalizedTimeDuration RoundNormalizedTimeDurationToIncrement( + const NormalizedTimeDuration& duration, const TemporalUnit unit, + Increment increment, TemporalRoundingMode roundingMode) { + MOZ_ASSERT(IsValidNormalizedTimeDuration(duration)); + MOZ_ASSERT(unit > TemporalUnit::Day); + MOZ_ASSERT(increment <= MaximumTemporalDurationRoundingIncrement(unit)); - int64_t num, denom; - if (BigInt::isInt64(numerator, &num) && - BigInt::isInt64(denominator, &denom)) { - TruncateNumber(num, denom, quotient, total); - return true; - } + int64_t divisor = ToNanoseconds(unit) * increment.value(); + MOZ_ASSERT(divisor > 0); + MOZ_ASSERT(divisor <= ToNanoseconds(TemporalUnit::Day)); - // BigInt division truncates. - Rooted<BigInt*> quot(cx); - Rooted<BigInt*> rem(cx); - if (!BigInt::divmod(cx, numerator, denominator, ", &rem)) { - return false; - } - - double q = BigInt::numberValue(quot); - *quotient = q; - *total = q + BigInt::numberValue(rem) / BigInt::numberValue(denominator); - return true; + auto totalNanoseconds = duration.toNanoseconds(); + auto rounded = + RoundNumberToIncrement(totalNanoseconds, Int128{divisor}, roundingMode); + return NormalizedTimeDuration::fromNanoseconds(rounded); } /** - * RoundNumberToIncrement ( x, increment, roundingMode ) + * RoundNormalizedTimeDurationToIncrement ( d, increment, roundingMode ) */ -static bool TruncateNumber(JSContext* cx, const Duration& toRound, - TemporalUnit unit, double* quotient, double* total) { - MOZ_ASSERT(unit >= TemporalUnit::Day); - - int64_t denominator = ToNanoseconds(unit); - MOZ_ASSERT(denominator > 0); - MOZ_ASSERT(denominator <= 86'400'000'000'000); - - // Fast-path when we can perform the whole computation with int64 values. - if (auto numerator = TotalDurationNanoseconds(toRound)) { - TruncateNumber(*numerator, denominator, quotient, total); - return true; - } - - Rooted<BigInt*> numerator(cx, TotalDurationNanosecondsSlow(cx, toRound)); - if (!numerator) { - return false; - } - - // Division by one has no remainder. - if (denominator == 1) { - double q = BigInt::numberValue(numerator); - *quotient = q; - *total = q; - return true; - } - - Rooted<BigInt*> denom(cx, BigInt::createFromInt64(cx, denominator)); - if (!denom) { - return false; - } +static bool RoundNormalizedTimeDurationToIncrement( + JSContext* cx, const NormalizedTimeDuration& duration, + const TemporalUnit unit, Increment increment, + TemporalRoundingMode roundingMode, NormalizedTimeDuration* result) { + // Step 1. + auto rounded = RoundNormalizedTimeDurationToIncrement( + duration, unit, increment, roundingMode); - // BigInt division truncates. - Rooted<BigInt*> quot(cx); - Rooted<BigInt*> rem(cx); - if (!BigInt::divmod(cx, numerator, denom, ", &rem)) { + // Step 2. + if (!IsValidNormalizedTimeDuration(rounded)) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_DURATION_INVALID_NORMALIZED_TIME); return false; } - double q = BigInt::numberValue(quot); - *quotient = q; - *total = q + BigInt::numberValue(rem) / double(denominator); + // Step 3. + *result = rounded; return true; } /** - * RoundNumberToIncrement ( x, increment, roundingMode ) + * DivideNormalizedTimeDuration ( d, divisor ) */ -static bool RoundNumberToIncrement(JSContext* cx, const Duration& toRound, - TemporalUnit unit, Increment increment, - TemporalRoundingMode roundingMode, - double* result) { - MOZ_ASSERT(unit >= TemporalUnit::Day); - - // Fast-path when we can perform the whole computation with int64 values. - if (auto total = TotalDurationNanoseconds(toRound)) { - return RoundNumberToIncrement(cx, *total, unit, increment, roundingMode, - result); - } +static double TotalNormalizedTimeDuration( + const NormalizedTimeDuration& duration, const TemporalUnit unit) { + MOZ_ASSERT(IsValidNormalizedTimeDuration(duration)); + MOZ_ASSERT(unit > TemporalUnit::Day); - Rooted<BigInt*> totalNs(cx, TotalDurationNanosecondsSlow(cx, toRound)); - if (!totalNs) { - return false; - } - - return RoundNumberToIncrement(cx, totalNs, unit, increment, roundingMode, - result); + auto numerator = duration.toNanoseconds(); + auto denominator = Int128{ToNanoseconds(unit)}; + return FractionToDouble(numerator, denominator); } -struct RoundedDuration final { - Duration duration; - double total = 0; -}; - -enum class ComputeRemainder : bool { No, Yes }; - /** - * RoundDuration ( years, months, weeks, days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds, increment, unit, roundingMode [ , - * plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , timeZoneRec [ , - * precalculatedPlainDateTime ] ] ] ] ] ) + * RoundDuration ( years, months, weeks, days, norm, increment, unit, + * roundingMode [ , plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , + * timeZoneRec [ , precalculatedPlainDateTime ] ] ] ] ] ) */ -static bool RoundDuration(JSContext* cx, const Duration& duration, - Increment increment, TemporalUnit unit, - TemporalRoundingMode roundingMode, - ComputeRemainder computeRemainder, - RoundedDuration* result) { - // The remainder is only needed when called from |Duration_total|. And `total` - // always passes |increment=1| and |roundingMode=trunc|. - MOZ_ASSERT_IF(computeRemainder == ComputeRemainder::Yes, - increment == Increment{1}); - MOZ_ASSERT_IF(computeRemainder == ComputeRemainder::Yes, - roundingMode == TemporalRoundingMode::Trunc); +NormalizedTimeDuration js::temporal::RoundDuration( + const NormalizedTimeDuration& duration, Increment increment, + TemporalUnit unit, TemporalRoundingMode roundingMode) { + MOZ_ASSERT(IsValidNormalizedTimeDuration(duration)); + MOZ_ASSERT(unit > TemporalUnit::Day); - auto [years, months, weeks, days, hours, minutes, seconds, milliseconds, - microseconds, nanoseconds] = duration; + // Steps 1-12. (Not applicable) - // Steps 1-5. (Not applicable.) - - // Step 6. - if (unit <= TemporalUnit::Week) { - JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, - JSMSG_TEMPORAL_DURATION_UNCOMPARABLE, - "relativeTo"); - return false; - } - - // TODO: We could directly return here if unit=nanoseconds and increment=1, - // because in that case this operation is a no-op. This case happens for - // example when calling Temporal.PlainTime.prototype.{since,until} without an - // options object. - // - // But maybe this can be even more efficiently handled in the callers. For - // example when Temporal.PlainTime.prototype.{since,until} is called without - // an options object, we can not only skip the RoundDuration call, but also - // the following BalanceTimeDuration call. - - // Step 7. (Not applicable.) - - // Step 8. (Moved below.) - - // Step 9. (Not applicable.) - - // Steps 10-19. - Duration toRound; - double* roundedTime; - switch (unit) { - case TemporalUnit::Auto: - case TemporalUnit::Year: - case TemporalUnit::Week: - case TemporalUnit::Month: - // Steps 10-12. (Not applicable.) - MOZ_CRASH("Unexpected temporal unit"); - - case TemporalUnit::Day: { - // clang-format off - // - // Relevant steps from the spec algorithm: - // - // 6.a Let nanoseconds be ! TotalDurationNanoseconds(0, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, 0). - // 6.d Let result be ? NanosecondsToDays(nanoseconds, intermediate). - // 6.e Set days to days + result.[[Days]] + result.[[Nanoseconds]] / abs(result.[[DayLength]]). - // ... - // 12.a Let fractionalDays be days. - // 12.b Set days to ? RoundNumberToIncrement(days, increment, roundingMode). - // 12.c Set remainder to fractionalDays - days. - // - // Where `result.[[Days]]` is `the integral part of nanoseconds / dayLengthNs` - // and `result.[[Nanoseconds]]` is `nanoseconds modulo dayLengthNs`. - // With `dayLengthNs = 8.64 × 10^13`. - // - // So we have: - // d + r.days + (r.nanoseconds / len) - // = d + [ns / len] + ((ns % len) / len) - // = d + [ns / len] + ((ns - ([ns / len] × len)) / len) - // = d + [ns / len] + (ns / len) - (([ns / len] × len) / len) - // = d + [ns / len] + (ns / len) - [ns / len] - // = d + (ns / len) - // = ((d × len) / len) + (ns / len) - // = ((d × len) + ns) / len - // - // `((d × len) + ns)` is the result of calling TotalDurationNanoseconds(), - // which means we can use the same code for all time computations in this - // function. - // - // clang-format on - - MOZ_ASSERT(increment <= Increment{1'000'000'000}, - "limited by ToTemporalRoundingIncrement"); - - // Steps 7.a, 7.c, and 13.a-b. - toRound = duration; - roundedTime = &days; - - // Step 7.b. (Not applicable) - - // Steps 7.d-e. - hours = 0; - minutes = 0; - seconds = 0; - milliseconds = 0; - microseconds = 0; - nanoseconds = 0; - break; - } - - case TemporalUnit::Hour: { - MOZ_ASSERT(increment <= Increment{24}, - "limited by MaximumTemporalDurationRoundingIncrement"); - - // Steps 8 and 14.a-c. - toRound = { - 0, - 0, - 0, - 0, - hours, - minutes, - seconds, - milliseconds, - microseconds, - nanoseconds, - }; - roundedTime = &hours; - - // Step 14.d. - minutes = 0; - seconds = 0; - milliseconds = 0; - microseconds = 0; - nanoseconds = 0; - break; - } - - case TemporalUnit::Minute: { - MOZ_ASSERT(increment <= Increment{60}, - "limited by MaximumTemporalDurationRoundingIncrement"); - - // Steps 8 and 15.a-c. - toRound = { - 0, 0, 0, 0, 0, minutes, seconds, milliseconds, microseconds, - nanoseconds, - }; - roundedTime = &minutes; - - // Step 15.d. - seconds = 0; - milliseconds = 0; - microseconds = 0; - nanoseconds = 0; - break; - } - - case TemporalUnit::Second: { - MOZ_ASSERT(increment <= Increment{60}, - "limited by MaximumTemporalDurationRoundingIncrement"); - - // Steps 8 and 16.a-b. - toRound = { - 0, 0, 0, 0, 0, 0, seconds, milliseconds, microseconds, nanoseconds, - }; - roundedTime = &seconds; - - // Step 16.c. - milliseconds = 0; - microseconds = 0; - nanoseconds = 0; - break; - } - - case TemporalUnit::Millisecond: { - MOZ_ASSERT(increment <= Increment{1000}, - "limited by MaximumTemporalDurationRoundingIncrement"); - - // Steps 17.a-c. - toRound = {0, 0, 0, 0, 0, 0, 0, milliseconds, microseconds, nanoseconds}; - roundedTime = &milliseconds; - - // Step 17.d. - microseconds = 0; - nanoseconds = 0; - break; - } - - case TemporalUnit::Microsecond: { - MOZ_ASSERT(increment <= Increment{1000}, - "limited by MaximumTemporalDurationRoundingIncrement"); - - // Steps 18.a-c. - toRound = {0, 0, 0, 0, 0, 0, 0, 0, microseconds, nanoseconds}; - roundedTime = µseconds; - - // Step 18.d. - nanoseconds = 0; - break; - } - - case TemporalUnit::Nanosecond: { - MOZ_ASSERT(increment <= Increment{1000}, - "limited by MaximumTemporalDurationRoundingIncrement"); - - // Step 19.a. (Implicit) - - // Steps 19.b-c. - toRound = {0, 0, 0, 0, 0, 0, 0, 0, 0, nanoseconds}; - roundedTime = &nanoseconds; - break; - } - } + // Steps 13-18. + auto rounded = RoundNormalizedTimeDurationToIncrement( + duration, unit, increment, roundingMode); + MOZ_ASSERT(IsValidNormalizedTimeDuration(rounded)); - // clang-format off - // - // The specification uses mathematical values in its computations, which - // requires to be able to represent decimals with arbitrary precision. To - // avoid having to struggle with decimals, we can transform the steps to work - // on integer values, which we can conveniently represent with BigInts. - // - // As an example here are the transformation steps for "hours", but all other - // units can be handled similarly. - // - // Relevant spec steps: - // - // 8.a Let fractionalSeconds be nanoseconds × 10^9 + microseconds × 10^6 + milliseconds × 10^3 + seconds. - // ... - // 14.a Let fractionalHours be (fractionalSeconds / 60 + minutes) / 60 + hours. - // 14.b Set hours to ? RoundNumberToIncrement(fractionalHours, increment, roundingMode). - // - // And from RoundNumberToIncrement: - // - // 1. Let quotient be x / increment. - // 2-7. Let rounded be op(quotient). - // 8. Return rounded × increment. - // - // With `fractionalHours = (totalNs / nsPerHour)`, the rounding operation - // computes: - // - // op(fractionalHours / increment) × increment - // = op((totalNs / nsPerHour) / increment) × increment - // = op(totalNs / (nsPerHour × increment)) × increment - // - // So when we pass `totalNs` and `nsPerHour` as separate arguments to - // RoundNumberToIncrement, we can avoid any precision losses and instead - // compute with exact values. - // - // clang-format on - - double total = 0; - if (computeRemainder == ComputeRemainder::No) { - if (!RoundNumberToIncrement(cx, toRound, unit, increment, roundingMode, - roundedTime)) { - return false; - } - } else { - // clang-format off - // - // The remainder is only used for Duration.prototype.total(), which calls - // this operation with increment=1 and roundingMode=trunc. - // - // That means the remainder computation is actually just - // `(totalNs % toNanos) / toNanos`, where `totalNs % toNanos` is already - // computed in RoundNumberToIncrement(): - // - // rounded = trunc(totalNs / toNanos) - // = [totalNs / toNanos] - // - // roundedTime = ℝ(𝔽(rounded)) - // - // remainder = (totalNs - (rounded * toNanos)) / toNanos - // = (totalNs - ([totalNs / toNanos] * toNanos)) / toNanos - // = (totalNs % toNanos) / toNanos - // - // When used in Duration.prototype.total(), the overall computed value is - // `[totalNs / toNanos] + (totalNs % toNanos) / toNanos`. - // - // Applying normal math rules would allow to simplify this to: - // - // [totalNs / toNanos] + (totalNs % toNanos) / toNanos - // = [totalNs / toNanos] + (totalNs - [totalNs / toNanos] * toNanos) / toNanos - // = total / toNanos - // - // We can't apply this simplification because it'd introduce double - // precision issues. Instead of that, we use a specialized version of - // RoundNumberToIncrement which directly returns the remainder. The - // remainder `(totalNs % toNanos) / toNanos` is a value near zero, so this - // approach is as exact as possible. (Double numbers near zero can be - // computed more precisely than large numbers with fractional parts.) - // - // clang-format on - - MOZ_ASSERT(increment == Increment{1}); - MOZ_ASSERT(roundingMode == TemporalRoundingMode::Trunc); - - if (!TruncateNumber(cx, toRound, unit, roundedTime, &total)) { - return false; - } - } - - MOZ_ASSERT(years == duration.years); - MOZ_ASSERT(months == duration.months); - MOZ_ASSERT(weeks == duration.weeks); - MOZ_ASSERT(IsIntegerOrInfinity(days)); - - // Step 20. - Duration resultDuration = {years, months, weeks, days, - hours, minutes, seconds, milliseconds, - microseconds, nanoseconds}; - if (!ThrowIfInvalidDuration(cx, resultDuration)) { - return false; - } - - // Step 21. - *result = {resultDuration, total}; - return true; + // Step 19. + return rounded; } /** - * RoundDuration ( years, months, weeks, days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds, increment, unit, roundingMode [ , - * plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , timeZoneRec [ , - * precalculatedPlainDateTime ] ] ] ] ] ) + * RoundDuration ( years, months, weeks, days, norm, increment, unit, + * roundingMode [ , plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , + * timeZoneRec [ , precalculatedPlainDateTime ] ] ] ] ] ) */ -static bool RoundDuration(JSContext* cx, const Duration& duration, - Increment increment, TemporalUnit unit, - TemporalRoundingMode roundingMode, double* result) { - MOZ_ASSERT(IsValidDuration(duration)); - - // Only called from |Duration_total|, which always passes |increment=1| and - // |roundingMode=trunc|. - MOZ_ASSERT(increment == Increment{1}); - MOZ_ASSERT(roundingMode == TemporalRoundingMode::Trunc); +bool js::temporal::RoundDuration(JSContext* cx, + const NormalizedTimeDuration& duration, + Increment increment, TemporalUnit unit, + TemporalRoundingMode roundingMode, + NormalizedTimeDuration* result) { + MOZ_ASSERT(IsValidNormalizedTimeDuration(duration)); + MOZ_ASSERT(unit > TemporalUnit::Day); - RoundedDuration rounded; - if (!::RoundDuration(cx, duration, increment, unit, roundingMode, - ComputeRemainder::Yes, &rounded)) { - return false; - } + // Steps 1-12. (Not applicable) - *result = rounded.total; - return true; + // Steps 13-19. + return RoundNormalizedTimeDurationToIncrement(cx, duration, unit, increment, + roundingMode, result); } -/** - * RoundDuration ( years, months, weeks, days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds, increment, unit, roundingMode [ , - * plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , timeZoneRec [ , - * precalculatedPlainDateTime ] ] ] ] ] ) - */ -static bool RoundDuration(JSContext* cx, const Duration& duration, - Increment increment, TemporalUnit unit, - TemporalRoundingMode roundingMode, Duration* result) { - MOZ_ASSERT(IsValidDuration(duration)); +#ifdef DEBUG +// Valid duration days are smaller than ⌈(2**53) / (24 * 60 * 60)⌉. +static constexpr int64_t MaxDurationDays = (int64_t(1) << 53) / (24 * 60 * 60); - RoundedDuration rounded; - if (!::RoundDuration(cx, duration, increment, unit, roundingMode, - ComputeRemainder::No, &rounded)) { - return false; - } +// Maximum number of days in |FractionalDays|. +static constexpr int64_t MaxFractionalDays = + 2 * MaxDurationDays + 2 * MaxEpochDaysDuration; +#endif - *result = rounded.duration; - return true; -} +struct FractionalDays final { + int64_t days = 0; + int64_t time = 0; + int64_t dayLength = 0; -/** - * RoundDuration ( years, months, weeks, days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds, increment, unit, roundingMode [ , - * plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , timeZoneRec [ , - * precalculatedPlainDateTime ] ] ] ] ] ) - */ -bool js::temporal::RoundDuration(JSContext* cx, const Duration& duration, - Increment increment, TemporalUnit unit, - TemporalRoundingMode roundingMode, - Duration* result) { - MOZ_ASSERT(IsValidDuration(duration)); + FractionalDays() = default; - return ::RoundDuration(cx, duration, increment, unit, roundingMode, result); -} + explicit FractionalDays(int64_t durationDays, + const NormalizedTimeAndDays& timeAndDays) + : days(durationDays + timeAndDays.days), + time(timeAndDays.time), + dayLength(timeAndDays.dayLength) { + MOZ_ASSERT(std::abs(durationDays) <= MaxDurationDays); + MOZ_ASSERT(std::abs(timeAndDays.days) <= MaxDurationDays); + MOZ_ASSERT(std::abs(days) <= MaxFractionalDays); -static mozilla::Maybe<int64_t> DaysFrom( - const temporal::NanosecondsAndDays& nanosAndDays) { - if (auto* days = nanosAndDays.days) { - int64_t daysInt; - if (BigInt::isInt64(days, &daysInt)) { - return mozilla::Some(daysInt); - } - return mozilla::Nothing(); - } - return mozilla::Some(nanosAndDays.daysInt); -} + // NormalizedTimeDurationToDays guarantees that |dayLength| is strictly + // positive and less than 2**53. + MOZ_ASSERT(dayLength > 0); + MOZ_ASSERT(dayLength < int64_t(1) << 53); -static BigInt* DaysFrom(JSContext* cx, - Handle<temporal::NanosecondsAndDays> nanosAndDays) { - if (auto days = nanosAndDays.days()) { - return days; + // NormalizedTimeDurationToDays guarantees that |abs(timeAndDays.time)| is + // less than |timeAndDays.dayLength|. + MOZ_ASSERT(std::abs(time) < dayLength); } - return BigInt::createFromInt64(cx, nanosAndDays.daysInt()); -} - -static bool TruncateDays(JSContext* cx, - Handle<temporal::NanosecondsAndDays> nanosAndDays, - double days, int32_t daysToAdd, double* result) { - do { - int64_t intDays; - if (!mozilla::NumberEqualsInt64(days, &intDays)) { - break; - } - auto nanoDays = DaysFrom(nanosAndDays); - if (!nanoDays) { - break; - } + FractionalDays operator+=(int32_t epochDays) { + MOZ_ASSERT(std::abs(epochDays) <= MaxEpochDaysDuration); + days += epochDays; + MOZ_ASSERT(std::abs(days) <= MaxFractionalDays); + return *this; + } - auto totalDays = mozilla::CheckedInt64(intDays); - totalDays += *nanoDays; - totalDays += daysToAdd; - if (!totalDays.isValid()) { - break; - } + FractionalDays operator-=(int32_t epochDays) { + MOZ_ASSERT(std::abs(epochDays) <= MaxEpochDaysDuration); + days -= epochDays; + MOZ_ASSERT(std::abs(days) <= MaxFractionalDays); + return *this; + } - int64_t truncatedDays = totalDays.value(); - if (nanosAndDays.nanoseconds() > InstantSpan{}) { + int64_t truncate() const { + int64_t truncatedDays = days; + if (time > 0) { // Round toward positive infinity when the integer days are negative and // the fractional part is positive. if (truncatedDays < 0) { truncatedDays += 1; } - } else if (nanosAndDays.nanoseconds() < InstantSpan{}) { + } else if (time < 0) { // Round toward negative infinity when the integer days are positive and // the fractional part is negative. if (truncatedDays > 0) { truncatedDays -= 1; } } - - *result = double(truncatedDays); - return true; - } while (false); - - Rooted<BigInt*> biDays(cx, BigInt::createFromDouble(cx, days)); - if (!biDays) { - return false; - } - - Rooted<BigInt*> biNanoDays(cx, DaysFrom(cx, nanosAndDays)); - if (!biNanoDays) { - return false; - } - - Rooted<BigInt*> biDaysToAdd(cx, BigInt::createFromInt64(cx, daysToAdd)); - if (!biDaysToAdd) { - return false; - } - - Rooted<BigInt*> truncatedDays(cx, BigInt::add(cx, biDays, biNanoDays)); - if (!truncatedDays) { - return false; - } - - truncatedDays = BigInt::add(cx, truncatedDays, biDaysToAdd); - if (!truncatedDays) { - return false; + MOZ_ASSERT(std::abs(truncatedDays) <= MaxFractionalDays + 1); + return truncatedDays; } - if (nanosAndDays.nanoseconds() > InstantSpan{}) { - // Round toward positive infinity when the integer days are negative and - // the fractional part is positive. - if (truncatedDays->isNegative()) { - truncatedDays = BigInt::inc(cx, truncatedDays); - if (!truncatedDays) { - return false; - } - } - } else if (nanosAndDays.nanoseconds() < InstantSpan{}) { - // Round toward negative infinity when the integer days are positive and - // the fractional part is negative. - if (!truncatedDays->isNegative() && !truncatedDays->isZero()) { - truncatedDays = BigInt::dec(cx, truncatedDays); - if (!truncatedDays) { - return false; - } + int32_t sign() const { + if (days != 0) { + return days < 0 ? -1 : 1; } + return time < 0 ? -1 : time > 0 ? 1 : 0; } - - *result = BigInt::numberValue(truncatedDays); - return true; -} - -static bool DaysIsNegative(double days, - Handle<temporal::NanosecondsAndDays> nanosAndDays, - int32_t daysToAdd) { - // Numbers of days between nsMinInstant and nsMaxInstant. - static constexpr int32_t epochDays = 200'000'000; - - MOZ_ASSERT(std::abs(daysToAdd) <= epochDays * 2); - - // We don't need the exact value, so it's safe to convert from BigInt. - double nanoDays = nanosAndDays.daysNumber(); - - // When non-zero |days| and |nanoDays| have oppositive signs, the absolute - // value of |days| is less-or-equal to |epochDays|. That means when adding - // |days + nanoDays| we don't have to worry about a case like: - // - // days = 9007199254740991 and - // nanoDays = 𝔽(-9007199254740993) = -9007199254740992 - // - // ℝ(𝔽(days) + 𝔽(nanoDays)) is -1, whereas the correct result is -2. - MOZ_ASSERT((days <= 0 && nanoDays <= 0) || (days >= 0 && nanoDays >= 0) || - std::abs(days) <= epochDays); - - // This addition can be imprecise, so |daysApproximation| is only an - // approximation of the actual value. - double daysApproximation = days + nanoDays; - - if (std::abs(daysApproximation) <= epochDays * 2) { - int32_t intDays = int32_t(daysApproximation) + daysToAdd; - return intDays < 0 || - (intDays == 0 && nanosAndDays.nanoseconds() < InstantSpan{}); - } - - // |daysApproximation| is too large, adding |daysToAdd| and |daysToSubtract| - // doesn't change the sign. - return daysApproximation < 0; -} - -struct RoundedNumber { - double rounded; - double total; }; -static bool RoundNumberToIncrementSlow( - JSContext* cx, double durationAmount, double amountPassed, - double durationDays, int32_t daysToAdd, - Handle<temporal::NanosecondsAndDays> nanosAndDays, int32_t oneUnitDays, - Increment increment, TemporalRoundingMode roundingMode, - ComputeRemainder computeRemainder, RoundedNumber* result) { - MOZ_ASSERT(nanosAndDays.dayLength() > InstantSpan{}); - MOZ_ASSERT(nanosAndDays.nanoseconds().abs() < nanosAndDays.dayLength().abs()); - MOZ_ASSERT(oneUnitDays != 0); - - Rooted<BigInt*> biAmount(cx, BigInt::createFromDouble(cx, durationAmount)); - if (!biAmount) { - return false; - } - - Rooted<BigInt*> biAmountPassed(cx, - BigInt::createFromDouble(cx, amountPassed)); - if (!biAmountPassed) { - return false; - } +struct Fraction final { + int64_t numerator = 0; + int32_t denominator = 0; - biAmount = BigInt::add(cx, biAmount, biAmountPassed); - if (!biAmount) { - return false; - } + constexpr Fraction() = default; - Rooted<BigInt*> days(cx, BigInt::createFromDouble(cx, durationDays)); - if (!days) { - return false; - } - - Rooted<BigInt*> nanoDays(cx, DaysFrom(cx, nanosAndDays)); - if (!nanoDays) { - return false; - } - - Rooted<BigInt*> biDaysToAdd(cx, BigInt::createFromInt64(cx, daysToAdd)); - if (!biDaysToAdd) { - return false; - } - - days = BigInt::add(cx, days, nanoDays); - if (!days) { - return false; - } - - days = BigInt::add(cx, days, biDaysToAdd); - if (!days) { - return false; - } - - Rooted<BigInt*> nanoseconds( - cx, ToEpochNanoseconds(cx, nanosAndDays.nanoseconds())); - if (!nanoseconds) { - return false; - } - - Rooted<BigInt*> dayLength(cx, - ToEpochNanoseconds(cx, nanosAndDays.dayLength())); - if (!dayLength) { - return false; - } - - Rooted<BigInt*> denominator( - cx, BigInt::createFromInt64(cx, std::abs(oneUnitDays))); - if (!denominator) { - return false; - } - - denominator = BigInt::mul(cx, denominator, dayLength); - if (!denominator) { - return false; - } - - Rooted<BigInt*> totalNanoseconds(cx, BigInt::mul(cx, days, dayLength)); - if (!totalNanoseconds) { - return false; - } - - totalNanoseconds = BigInt::add(cx, totalNanoseconds, nanoseconds); - if (!totalNanoseconds) { - return false; - } - - Rooted<BigInt*> amountNanos(cx, BigInt::mul(cx, biAmount, denominator)); - if (!amountNanos) { - return false; - } - - totalNanoseconds = BigInt::add(cx, totalNanoseconds, amountNanos); - if (!totalNanoseconds) { - return false; + constexpr Fraction(int64_t numerator, int32_t denominator) + : numerator(numerator), denominator(denominator) { + MOZ_ASSERT(denominator > 0); } +}; - double rounded; +struct RoundedNumber final { + Int128 rounded; double total = 0; - if (computeRemainder == ComputeRemainder::No) { - if (!temporal::RoundNumberToIncrement(cx, totalNanoseconds, denominator, - increment, roundingMode, &rounded)) { - return false; - } - } else { - if (!::TruncateNumber(cx, totalNanoseconds, denominator, &rounded, - &total)) { - return false; - } - } - - *result = {rounded, total}; - return true; -} +}; -static bool RoundNumberToIncrement( - JSContext* cx, double durationAmount, double amountPassed, - double durationDays, int32_t daysToAdd, - Handle<temporal::NanosecondsAndDays> nanosAndDays, int32_t oneUnitDays, +static RoundedNumber RoundNumberToIncrement( + const Fraction& fraction, const FractionalDays& fractionalDays, Increment increment, TemporalRoundingMode roundingMode, - ComputeRemainder computeRemainder, RoundedNumber* result) { - MOZ_ASSERT(nanosAndDays.dayLength() > InstantSpan{}); - MOZ_ASSERT(nanosAndDays.nanoseconds().abs() < nanosAndDays.dayLength().abs()); - MOZ_ASSERT(oneUnitDays != 0); - - // TODO(anba): Rename variables. + ComputeRemainder computeRemainder) { + MOZ_ASSERT(std::abs(fraction.numerator) < (int64_t(1) << 32) * 2); + MOZ_ASSERT(fraction.denominator > 0); + MOZ_ASSERT(fraction.denominator <= MaxEpochDaysDuration); + MOZ_ASSERT(std::abs(fractionalDays.days) <= MaxFractionalDays); + MOZ_ASSERT(fractionalDays.dayLength > 0); + MOZ_ASSERT(fractionalDays.dayLength < (int64_t(1) << 53)); + MOZ_ASSERT(std::abs(fractionalDays.time) < fractionalDays.dayLength); + MOZ_ASSERT(increment <= Increment::max()); // clang-format off // @@ -4373,7 +3339,7 @@ static bool RoundNumberToIncrement( // // where days' = days + nanoseconds / dayLength. // - // The fractional part |nanoseconds / dayLength| is from step 4. + // The fractional part |nanoseconds / dayLength| is from step 7. // // The denominator for |fractionalWeeks| is |dayLength * abs(oneWeekDays)|. // @@ -4382,236 +3348,259 @@ static bool RoundNumberToIncrement( // = weeks + days / abs(oneWeekDays) + nanoseconds / (dayLength * abs(oneWeekDays)) // = (weeks * dayLength * abs(oneWeekDays) + days * dayLength + nanoseconds) / (dayLength * abs(oneWeekDays)) // + // Because |abs(nanoseconds / dayLength) < 0|, this operation can be rewritten + // to omit the multiplication by |dayLength| when the rounding conditions are + // appropriately modified to account for the |nanoseconds / dayLength| part. + // This allows to implement rounding using only int64 values. + // + // This optimization is currently only implemented when |nanoseconds| is zero. + // + // Example how to expand this optimization for non-zero |nanoseconds|: + // + // |Round(fraction / increment) * increment| with: + // fraction = numerator / denominator + // numerator = weeks * dayLength * abs(oneWeekDays) + days * dayLength + nanoseconds + // denominator = dayLength * abs(oneWeekDays) + // + // When ignoring the |nanoseconds / dayLength| part, this can be simplified to: + // + // |Round(fraction / increment) * increment| with: + // fraction = numerator / denominator + // numerator = weeks * abs(oneWeekDays) + days + // denominator = abs(oneWeekDays) + // + // Where: + // fraction / increment + // = (numerator / denominator) / increment + // = numerator / (denominator * increment) + // + // And |numerator| and |denominator * increment| both fit into int64. + // + // The "ceiling" operation has to be modified from: + // + // CeilDiv(dividend, divisor) + // quot, rem = dividend / divisor + // return quot + (rem > 0) + // + // To: + // + // CeilDiv(dividend, divisor, fractional) + // quot, rem = dividend / divisor + // return quot + ((rem > 0) || (fractional > 0)) + // + // To properly account for the fractional |nanoseconds| part. Alternatively + // |dividend| can be modified before calling `CeilDiv`. + // // clang-format on - do { - auto nanoseconds = nanosAndDays.nanoseconds().toNanoseconds(); - if (!nanoseconds.isValid()) { - break; - } + if (fractionalDays.time == 0) { + auto [numerator, denominator] = fraction; + int64_t totalDays = fractionalDays.days + denominator * numerator; - auto dayLength = nanosAndDays.dayLength().toNanoseconds(); - if (!dayLength.isValid()) { - break; + if (computeRemainder == ComputeRemainder::Yes) { + constexpr auto rounded = Int128{0}; + double total = FractionToDouble(totalDays, denominator); + return {rounded, total}; } - auto denominator = dayLength * std::abs(oneUnitDays); - if (!denominator.isValid()) { - break; - } - - int64_t intDays; - if (!mozilla::NumberEqualsInt64(durationDays, &intDays)) { - break; - } + auto rounded = + RoundNumberToIncrement(totalDays, denominator, increment, roundingMode); + constexpr double total = 0; + return {rounded, total}; + } - auto nanoDays = DaysFrom(nanosAndDays); - if (!nanoDays) { - break; - } + do { + auto dayLength = mozilla::CheckedInt64(fractionalDays.dayLength); - auto totalDays = mozilla::CheckedInt64(intDays); - totalDays += *nanoDays; - totalDays += daysToAdd; - if (!totalDays.isValid()) { + auto denominator = dayLength * fraction.denominator; + if (!denominator.isValid()) { break; } - auto totalNanoseconds = dayLength * totalDays; - if (!totalNanoseconds.isValid()) { + auto amountNanos = denominator * fraction.numerator; + if (!amountNanos.isValid()) { break; } - totalNanoseconds += nanoseconds; + auto totalNanoseconds = dayLength * fractionalDays.days; + totalNanoseconds += fractionalDays.time; + totalNanoseconds += amountNanos; if (!totalNanoseconds.isValid()) { break; } - int64_t intAmount; - if (!mozilla::NumberEqualsInt64(durationAmount, &intAmount)) { - break; + if (computeRemainder == ComputeRemainder::Yes) { + constexpr auto rounded = Int128{0}; + double total = + FractionToDouble(totalNanoseconds.value(), denominator.value()); + return {rounded, total}; } - int64_t intAmountPassed; - if (!mozilla::NumberEqualsInt64(amountPassed, &intAmountPassed)) { - break; - } - - auto totalAmount = mozilla::CheckedInt64(intAmount) + intAmountPassed; - if (!totalAmount.isValid()) { - break; - } + auto rounded = RoundNumberToIncrement( + totalNanoseconds.value(), denominator.value(), increment, roundingMode); + constexpr double total = 0; + return {rounded, total}; + } while (false); - auto amountNanos = denominator * totalAmount; - if (!amountNanos.isValid()) { - break; - } + // Use int128 when values are too large for int64. Additionally assert all + // values fit into int128. - totalNanoseconds += amountNanos; - if (!totalNanoseconds.isValid()) { - break; - } + // `dayLength` < 2**53 + auto dayLength = Int128{fractionalDays.dayLength}; + MOZ_ASSERT(dayLength < Int128{1} << 53); - double rounded; - double total = 0; - if (computeRemainder == ComputeRemainder::No) { - if (!temporal::RoundNumberToIncrement(cx, totalNanoseconds.value(), - denominator.value(), increment, - roundingMode, &rounded)) { - return false; - } - } else { - TruncateNumber(totalNanoseconds.value(), denominator.value(), &rounded, - &total); - } + // `fraction.denominator` < MaxEpochDaysDuration + // log2(MaxEpochDaysDuration) = ~27.57. + auto denominator = dayLength * Int128{fraction.denominator}; + MOZ_ASSERT(denominator < Int128{1} << (53 + 28)); - *result = {rounded, total}; - return true; - } while (false); + // log2(24*60*60) = ~16.4 and log2(2 * MaxEpochDaysDuration) = ~28.57. + // + // `abs(MaxFractionalDays)` + // = `abs(2 * MaxDurationDays + 2 * MaxEpochDaysDuration)` + // = `abs(2 * 2**(53 - 16) + 2 * MaxEpochDaysDuration)` + // ≤ 2 * 2**37 + 2**29 + // ≤ 2**39 + auto totalDays = Int128{fractionalDays.days}; + MOZ_ASSERT(totalDays.abs() <= Uint128{1} << 39); + + // `abs(fraction.numerator)` ≤ (2**33) + auto totalAmount = Int128{fraction.numerator}; + MOZ_ASSERT(totalAmount.abs() <= Uint128{1} << 33); + + // `denominator` < 2**(53 + 28) + // `abs(totalAmount)` <= 2**33 + // + // `denominator * totalAmount` + // ≤ 2**(53 + 28) * 2**33 + // = 2**(53 + 28 + 33) + // = 2**114 + auto amountNanos = denominator * totalAmount; + MOZ_ASSERT(amountNanos.abs() <= Uint128{1} << 114); + + // `dayLength` < 2**53 + // `totalDays` ≤ 2**39 + // `fractionalDays.time` < `dayLength` < 2**53 + // `amountNanos` ≤ 2**114 + // + // `dayLength * totalDays` + // ≤ 2**(53 + 39) = 2**92 + // + // `dayLength * totalDays + fractionalDays.time` + // ≤ 2**93 + // + // `dayLength * totalDays + fractionalDays.time + amountNanos` + // ≤ 2**115 + auto totalNanoseconds = dayLength * totalDays; + totalNanoseconds += Int128{fractionalDays.time}; + totalNanoseconds += amountNanos; + MOZ_ASSERT(totalNanoseconds.abs() <= Uint128{1} << 115); - return RoundNumberToIncrementSlow( - cx, durationAmount, amountPassed, durationDays, daysToAdd, nanosAndDays, - oneUnitDays, increment, roundingMode, computeRemainder, result); -} + if (computeRemainder == ComputeRemainder::Yes) { + constexpr auto rounded = Int128{0}; + double total = FractionToDouble(totalNanoseconds, denominator); + return {rounded, total}; + } -static bool RoundNumberToIncrement( - JSContext* cx, double durationDays, - Handle<temporal::NanosecondsAndDays> nanosAndDays, Increment increment, - TemporalRoundingMode roundingMode, ComputeRemainder computeRemainder, - RoundedNumber* result) { - constexpr double daysAmount = 0; - constexpr double daysPassed = 0; - constexpr int32_t oneDayDays = 1; - constexpr int32_t daysToAdd = 0; - - return RoundNumberToIncrement(cx, daysAmount, daysPassed, durationDays, - daysToAdd, nanosAndDays, oneDayDays, increment, - roundingMode, computeRemainder, result); + auto rounded = RoundNumberToIncrement(totalNanoseconds, denominator, + increment, roundingMode); + constexpr double total = 0; + return {rounded, total}; } -static bool RoundDurationYear(JSContext* cx, const Duration& duration, - Handle<temporal::NanosecondsAndDays> nanosAndDays, +static bool RoundDurationYear(JSContext* cx, const NormalizedDuration& duration, + FractionalDays fractionalDays, Increment increment, TemporalRoundingMode roundingMode, Handle<Wrapped<PlainDateObject*>> dateRelativeTo, Handle<CalendarRecord> calendar, ComputeRemainder computeRemainder, RoundedDuration* result) { - // Numbers of days between nsMinInstant and nsMaxInstant. - static constexpr int32_t epochDays = 200'000'000; + auto [years, months, weeks, days] = duration.date; - double years = duration.years; - double months = duration.months; - double weeks = duration.weeks; - double days = duration.days; - - // Step 10.a. - Duration yearsDuration = {years}; + // Step 9.a. + auto yearsDuration = DateDuration{years}; - // Step 10.b. + // Step 9.b. auto yearsLater = AddDate(cx, calendar, dateRelativeTo, yearsDuration); if (!yearsLater) { return false; } auto yearsLaterDate = ToPlainDate(&yearsLater.unwrap()); - // Step 10.f. (Reordered) + // Step 9.f. (Reordered) Rooted<Wrapped<PlainDateObject*>> newRelativeTo(cx, yearsLater); - // Step 10.c. - Duration yearsMonthsWeeks = {years, months, weeks}; + // Step 9.c. + auto yearsMonthsWeeks = DateDuration{years, months, weeks}; - // Step 10.d. + // Step 9.d. PlainDate yearsMonthsWeeksLater; if (!AddDate(cx, calendar, dateRelativeTo, yearsMonthsWeeks, &yearsMonthsWeeksLater)) { return false; } - // Step 10.e. + // Step 9.e. int32_t monthsWeeksInDays = DaysUntil(yearsLaterDate, yearsMonthsWeeksLater); - MOZ_ASSERT(std::abs(monthsWeeksInDays) <= epochDays); + MOZ_ASSERT(std::abs(monthsWeeksInDays) <= MaxEpochDaysDuration); - // Step 10.f. (Moved up) + // Step 9.f. (Moved up) - // Step 10.g. - // Our implementation keeps |days| and |monthsWeeksInDays| separate. + // Step 9.g. + fractionalDays += monthsWeeksInDays; // FIXME: spec issue - truncation doesn't match the spec polyfill. // https://github.com/tc39/proposal-temporal/issues/2540 - // Step 10.h. - double truncatedDays; - if (!TruncateDays(cx, nanosAndDays, days, monthsWeeksInDays, - &truncatedDays)) { - return false; - } - - // FIXME: spec bug - truncated days can be infinity: - // - // Temporal.Duration.from({ - // days: Number.MAX_VALUE, - // hours: Number.MAX_VALUE, - // }).round({ - // smallestUnit: "years", - // relativeTo: "1970-01-01", - // }); - if (!IsInteger(truncatedDays)) { - MOZ_ASSERT(std::isinf(truncatedDays)); - JS_ReportErrorASCII(cx, "truncated days is infinity"); - return false; - } - + // Step 9.h. PlainDate isoResult; - if (!AddISODate(cx, yearsLaterDate, {0, 0, 0, truncatedDays}, - TemporalOverflow::Constrain, &isoResult)) { + if (!BalanceISODate(cx, yearsLaterDate, fractionalDays.truncate(), + &isoResult)) { return false; } - // Step 10.i. + // Step 9.i. Rooted<PlainDateObject*> wholeDaysLater( cx, CreateTemporalDate(cx, isoResult, calendar.receiver())); if (!wholeDaysLater) { return false; } - // Steps 10.j-l. - Duration timePassed; + // Steps 9.j-l. + DateDuration timePassed; if (!DifferenceDate(cx, calendar, newRelativeTo, wholeDaysLater, TemporalUnit::Year, &timePassed)) { return false; } - // Step 10.m. - double yearsPassed = timePassed.years; + // Step 9.m. + int64_t yearsPassed = timePassed.years; - // Step 10.n. - // Our implementation keeps |years| and |yearsPassed| separate. + // Step 9.n. + years += yearsPassed; - // Step 10.o. - Duration yearsPassedDuration = {yearsPassed}; + // Step 9.o. + auto yearsPassedDuration = DateDuration{yearsPassed}; - // Steps 10.p-r. + // Steps 9.p-r. int32_t daysPassed; if (!MoveRelativeDate(cx, calendar, newRelativeTo, yearsPassedDuration, &newRelativeTo, &daysPassed)) { return false; } - MOZ_ASSERT(std::abs(daysPassed) <= epochDays); + MOZ_ASSERT(std::abs(daysPassed) <= MaxEpochDaysDuration); - // Step 10.s. - // - // Our implementation keeps |days| and |daysPassed| separate. - int32_t daysToAdd = monthsWeeksInDays - daysPassed; - MOZ_ASSERT(std::abs(daysToAdd) <= epochDays * 2); + // Step 9.s. + fractionalDays -= daysPassed; - // Steps 10.t. - double sign = DaysIsNegative(days, nanosAndDays, daysToAdd) ? -1 : 1; + // Steps 9.t. + int32_t sign = fractionalDays.sign() < 0 ? -1 : 1; - // Step 10.u. - Duration oneYear = {sign}; + // Step 9.u. + auto oneYear = DateDuration{sign}; - // Steps 10.v-w. + // Steps 9.v-w. Rooted<Wrapped<PlainDateObject*>> moveResultIgnored(cx); int32_t oneYearDays; if (!MoveRelativeDate(cx, calendar, newRelativeTo, oneYear, @@ -4619,158 +3608,137 @@ static bool RoundDurationYear(JSContext* cx, const Duration& duration, return false; } - // Step 10.x. + // Step 9.x. if (oneYearDays == 0) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TEMPORAL_INVALID_NUMBER, "days"); return false; } - // Steps 10.y-aa. - RoundedNumber rounded; - if (!RoundNumberToIncrement(cx, years, yearsPassed, days, daysToAdd, - nanosAndDays, oneYearDays, increment, - roundingMode, computeRemainder, &rounded)) { - return false; - } - auto [numYears, total] = rounded; + // Steps 9.y. + auto fractionalYears = Fraction{years, std::abs(oneYearDays)}; - // Step 10.ab. - double numMonths = 0; - double numWeeks = 0; + // Steps 9.z-aa. + auto [numYears, total] = + RoundNumberToIncrement(fractionalYears, fractionalDays, increment, + roundingMode, computeRemainder); - // Step 20. - Duration resultDuration = {numYears, numMonths, numWeeks}; + // Step 9.ab. + int64_t numMonths = 0; + int64_t numWeeks = 0; + + // Step 9.ac. + constexpr auto time = NormalizedTimeDuration{}; + + // Step 19. + if (numYears.abs() >= (Uint128{1} << 32)) { + return ThrowInvalidDurationPart(cx, double(numYears), "years", + JSMSG_TEMPORAL_DURATION_INVALID_NON_FINITE); + } + + auto resultDuration = DateDuration{int64_t(numYears), numMonths, numWeeks}; if (!ThrowIfInvalidDuration(cx, resultDuration)) { return false; } - // Step 21. - *result = {resultDuration, total}; + *result = {{resultDuration, time}, total}; return true; } -static bool RoundDurationMonth( - JSContext* cx, const Duration& duration, - Handle<temporal::NanosecondsAndDays> nanosAndDays, Increment increment, - TemporalRoundingMode roundingMode, - Handle<Wrapped<PlainDateObject*>> dateRelativeTo, - Handle<CalendarRecord> calendar, ComputeRemainder computeRemainder, - RoundedDuration* result) { - // Numbers of days between nsMinInstant and nsMaxInstant. - static constexpr int32_t epochDays = 200'000'000; +static bool RoundDurationMonth(JSContext* cx, + const NormalizedDuration& duration, + FractionalDays fractionalDays, + Increment increment, + TemporalRoundingMode roundingMode, + Handle<Wrapped<PlainDateObject*>> dateRelativeTo, + Handle<CalendarRecord> calendar, + ComputeRemainder computeRemainder, + RoundedDuration* result) { + auto [years, months, weeks, days] = duration.date; - double years = duration.years; - double months = duration.months; - double weeks = duration.weeks; - double days = duration.days; - - // Step 11.a. - Duration yearsMonths = {years, months}; + // Step 10.a. + auto yearsMonths = DateDuration{years, months}; - // Step 11.b. + // Step 10.b. auto yearsMonthsLater = AddDate(cx, calendar, dateRelativeTo, yearsMonths); if (!yearsMonthsLater) { return false; } auto yearsMonthsLaterDate = ToPlainDate(&yearsMonthsLater.unwrap()); - // Step 11.f. (Reordered) + // Step 10.f. (Reordered) Rooted<Wrapped<PlainDateObject*>> newRelativeTo(cx, yearsMonthsLater); - // Step 11.c. - Duration yearsMonthsWeeks = {years, months, weeks}; + // Step 10.c. + auto yearsMonthsWeeks = DateDuration{years, months, weeks}; - // Step 11.d. + // Step 10.d. PlainDate yearsMonthsWeeksLater; if (!AddDate(cx, calendar, dateRelativeTo, yearsMonthsWeeks, &yearsMonthsWeeksLater)) { return false; } - // Step 11.e. + // Step 10.e. int32_t weeksInDays = DaysUntil(yearsMonthsLaterDate, yearsMonthsWeeksLater); - MOZ_ASSERT(std::abs(weeksInDays) <= epochDays); + MOZ_ASSERT(std::abs(weeksInDays) <= MaxEpochDaysDuration); - // Step 11.f. (Moved up) + // Step 10.f. (Moved up) - // Step 11.g. - // Our implementation keeps |days| and |weeksInDays| separate. + // Step 10.g. + fractionalDays += weeksInDays; // FIXME: spec issue - truncation doesn't match the spec polyfill. // https://github.com/tc39/proposal-temporal/issues/2540 - // Step 11.h. - double truncatedDays; - if (!TruncateDays(cx, nanosAndDays, days, weeksInDays, &truncatedDays)) { - return false; - } - - // FIXME: spec bug - truncated days can be infinity: - // - // Temporal.Duration.from({ - // days: Number.MAX_VALUE, - // hours: Number.MAX_VALUE, - // }).round({ - // smallestUnit: "months", - // relativeTo: "1970-01-01", - // }); - if (!IsInteger(truncatedDays)) { - MOZ_ASSERT(std::isinf(truncatedDays)); - JS_ReportErrorASCII(cx, "truncated days is infinity"); - return false; - } - + // Step 10.h. PlainDate isoResult; - if (!AddISODate(cx, yearsMonthsLaterDate, {0, 0, 0, truncatedDays}, - TemporalOverflow::Constrain, &isoResult)) { + if (!BalanceISODate(cx, yearsMonthsLaterDate, fractionalDays.truncate(), + &isoResult)) { return false; } - // Step 11.i. + // Step 10.i. Rooted<PlainDateObject*> wholeDaysLater( cx, CreateTemporalDate(cx, isoResult, calendar.receiver())); if (!wholeDaysLater) { return false; } - // Steps 11.j-l. - Duration timePassed; + // Steps 10.j-l. + DateDuration timePassed; if (!DifferenceDate(cx, calendar, newRelativeTo, wholeDaysLater, TemporalUnit::Month, &timePassed)) { return false; } - // Step 11.m. - double monthsPassed = timePassed.months; + // Step 10.m. + int64_t monthsPassed = timePassed.months; - // Step 11.n. - // Our implementation keeps |months| and |monthsPassed| separate. + // Step 10.n. + months += monthsPassed; - // Step 11.o. - Duration monthsPassedDuration = {0, monthsPassed}; + // Step 10.o. + auto monthsPassedDuration = DateDuration{0, monthsPassed}; - // Steps 11.p-r. + // Steps 10.p-r. int32_t daysPassed; if (!MoveRelativeDate(cx, calendar, newRelativeTo, monthsPassedDuration, &newRelativeTo, &daysPassed)) { return false; } - MOZ_ASSERT(std::abs(daysPassed) <= epochDays); + MOZ_ASSERT(std::abs(daysPassed) <= MaxEpochDaysDuration); - // Step 11.s. - // - // Our implementation keeps |days| and |daysPassed| separate. - int32_t daysToAdd = weeksInDays - daysPassed; - MOZ_ASSERT(std::abs(daysToAdd) <= epochDays * 2); + // Step 10.s. + fractionalDays -= daysPassed; - // Steps 11.t. - double sign = DaysIsNegative(days, nanosAndDays, daysToAdd) ? -1 : 1; + // Steps 10.t. + int32_t sign = fractionalDays.sign() < 0 ? -1 : 1; - // Step 11.u. - Duration oneMonth = {0, sign}; + // Step 10.u. + auto oneMonth = DateDuration{0, sign}; - // Steps 11.v-w. + // Steps 10.v-w. Rooted<Wrapped<PlainDateObject*>> moveResultIgnored(cx); int32_t oneMonthDays; if (!MoveRelativeDate(cx, calendar, newRelativeTo, oneMonth, @@ -4778,51 +3746,51 @@ static bool RoundDurationMonth( return false; } - // Step 11.x. + // Step 10.x. if (oneMonthDays == 0) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TEMPORAL_INVALID_NUMBER, "days"); return false; } - // Steps 11.y-aa. - RoundedNumber rounded; - if (!RoundNumberToIncrement(cx, months, monthsPassed, days, daysToAdd, - nanosAndDays, oneMonthDays, increment, - roundingMode, computeRemainder, &rounded)) { - return false; - } - auto [numMonths, total] = rounded; + // Step 10.y. + auto fractionalMonths = Fraction{months, std::abs(oneMonthDays)}; - // Step 11.ab. - double numWeeks = 0; + // Steps 10.z-aa. + auto [numMonths, total] = + RoundNumberToIncrement(fractionalMonths, fractionalDays, increment, + roundingMode, computeRemainder); - // Step 20. - Duration resultDuration = {years, numMonths, numWeeks}; + // Step 10.ab. + int64_t numWeeks = 0; + + // Step 10.ac. + constexpr auto time = NormalizedTimeDuration{}; + + // Step 19. + if (numMonths.abs() >= (Uint128{1} << 32)) { + return ThrowInvalidDurationPart(cx, double(numMonths), "months", + JSMSG_TEMPORAL_DURATION_INVALID_NON_FINITE); + } + + auto resultDuration = DateDuration{years, int64_t(numMonths), numWeeks}; if (!ThrowIfInvalidDuration(cx, resultDuration)) { return false; } - // Step 21. - *result = {resultDuration, total}; + *result = {{resultDuration, time}, total}; return true; } -static bool RoundDurationWeek(JSContext* cx, const Duration& duration, - Handle<temporal::NanosecondsAndDays> nanosAndDays, +static bool RoundDurationWeek(JSContext* cx, const NormalizedDuration& duration, + FractionalDays fractionalDays, Increment increment, TemporalRoundingMode roundingMode, Handle<Wrapped<PlainDateObject*>> dateRelativeTo, Handle<CalendarRecord> calendar, ComputeRemainder computeRemainder, RoundedDuration* result) { - // Numbers of days between nsMinInstant and nsMaxInstant. - static constexpr int32_t epochDays = 200'000'000; - - double years = duration.years; - double months = duration.months; - double weeks = duration.weeks; - double days = duration.days; + auto [years, months, weeks, days] = duration.date; auto* unwrappedRelativeTo = dateRelativeTo.unwrap(cx); if (!unwrappedRelativeTo) { @@ -4830,78 +3798,55 @@ static bool RoundDurationWeek(JSContext* cx, const Duration& duration, } auto relativeToDate = ToPlainDate(unwrappedRelativeTo); - // Step 12.a - double truncatedDays; - if (!TruncateDays(cx, nanosAndDays, days, 0, &truncatedDays)) { - return false; - } - - // FIXME: spec bug - truncated days can be infinity: - // - // Temporal.Duration.from({ - // days: Number.MAX_VALUE, - // hours: Number.MAX_VALUE, - // }).round({ - // smallestUnit: "weeks", - // relativeTo: "1970-01-01", - // }); - if (!IsInteger(truncatedDays)) { - MOZ_ASSERT(std::isinf(truncatedDays)); - JS_ReportErrorASCII(cx, "truncated days is infinity"); - return false; - } - + // Step 11.a PlainDate isoResult; - if (!AddISODate(cx, relativeToDate, {0, 0, 0, truncatedDays}, - TemporalOverflow::Constrain, &isoResult)) { + if (!BalanceISODate(cx, relativeToDate, fractionalDays.truncate(), + &isoResult)) { return false; } - // Step 12.b. + // Step 11.b. Rooted<PlainDateObject*> wholeDaysLater( cx, CreateTemporalDate(cx, isoResult, calendar.receiver())); if (!wholeDaysLater) { return false; } - // Steps 12.c-e. - Duration timePassed; + // Steps 11.c-e. + DateDuration timePassed; if (!DifferenceDate(cx, calendar, dateRelativeTo, wholeDaysLater, TemporalUnit::Week, &timePassed)) { return false; } - // Step 12.f. - double weeksPassed = timePassed.weeks; + // Step 11.f. + int64_t weeksPassed = timePassed.weeks; - // Step 12.g. - // Our implementation keeps |weeks| and |weeksPassed| separate. + // Step 11.g. + weeks += weeksPassed; - // Step 12.h. - Duration weeksPassedDuration = {0, 0, weeksPassed}; + // Step 11.h. + auto weeksPassedDuration = DateDuration{0, 0, weeksPassed}; - // Steps 12.i-k. + // Steps 11.i-k. Rooted<Wrapped<PlainDateObject*>> newRelativeTo(cx); int32_t daysPassed; if (!MoveRelativeDate(cx, calendar, dateRelativeTo, weeksPassedDuration, &newRelativeTo, &daysPassed)) { return false; } - MOZ_ASSERT(std::abs(daysPassed) <= epochDays); + MOZ_ASSERT(std::abs(daysPassed) <= MaxEpochDaysDuration); - // Step 12.l. - // - // Our implementation keeps |days| and |daysPassed| separate. - int32_t daysToAdd = -daysPassed; - MOZ_ASSERT(std::abs(daysToAdd) <= epochDays); + // Step 11.l. + fractionalDays -= daysPassed; - // Steps 12.m. - double sign = DaysIsNegative(days, nanosAndDays, daysToAdd) ? -1 : 1; + // Steps 11.m. + int32_t sign = fractionalDays.sign() < 0 ? -1 : 1; - // Step 12.n. - Duration oneWeek = {0, 0, sign}; + // Step 11.n. + auto oneWeek = DateDuration{0, 0, sign}; - // Steps 12.o-p. + // Steps 11.o-p. Rooted<Wrapped<PlainDateObject*>> moveResultIgnored(cx); int32_t oneWeekDays; if (!MoveRelativeDate(cx, calendar, newRelativeTo, oneWeek, @@ -4909,71 +3854,157 @@ static bool RoundDurationWeek(JSContext* cx, const Duration& duration, return false; } - // Step 12.q. + // Step 11.q. if (oneWeekDays == 0) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TEMPORAL_INVALID_NUMBER, "days"); return false; } - // Steps 12.r-t. - RoundedNumber rounded; - if (!RoundNumberToIncrement(cx, weeks, weeksPassed, days, daysToAdd, - nanosAndDays, oneWeekDays, increment, - roundingMode, computeRemainder, &rounded)) { - return false; + // Step 11.r. + auto fractionalWeeks = Fraction{weeks, std::abs(oneWeekDays)}; + + // Steps 11.s-t. + auto [numWeeks, total] = + RoundNumberToIncrement(fractionalWeeks, fractionalDays, increment, + roundingMode, computeRemainder); + + // Step 11.u. + constexpr auto time = NormalizedTimeDuration{}; + + // Step 19. + if (numWeeks.abs() >= (Uint128{1} << 32)) { + return ThrowInvalidDurationPart(cx, double(numWeeks), "weeks", + JSMSG_TEMPORAL_DURATION_INVALID_NON_FINITE); } - auto [numWeeks, total] = rounded; - // Step 20. - Duration resultDuration = {years, months, numWeeks}; + auto resultDuration = DateDuration{years, months, int64_t(numWeeks)}; if (!ThrowIfInvalidDuration(cx, resultDuration)) { return false; } - // Step 21. - *result = {resultDuration, total}; + *result = {{resultDuration, time}, total}; return true; } -static bool RoundDurationDay(JSContext* cx, const Duration& duration, - Handle<temporal::NanosecondsAndDays> nanosAndDays, +static bool RoundDurationDay(JSContext* cx, const NormalizedDuration& duration, + const FractionalDays& fractionalDays, Increment increment, TemporalRoundingMode roundingMode, ComputeRemainder computeRemainder, RoundedDuration* result) { - double years = duration.years; - double months = duration.months; - double weeks = duration.weeks; - double days = duration.days; + auto [years, months, weeks, days] = duration.date; + + // Pass zero fraction. + constexpr auto zero = Fraction{0, 1}; + + // Steps 12.a-b. + auto [numDays, total] = RoundNumberToIncrement( + zero, fractionalDays, increment, roundingMode, computeRemainder); - // Steps 13.a-b. - RoundedNumber rounded; - if (!RoundNumberToIncrement(cx, days, nanosAndDays, increment, roundingMode, - computeRemainder, &rounded)) { + MOZ_ASSERT(Int128{INT64_MIN} <= numDays && numDays <= Int128{INT64_MAX}, + "rounded days fits in int64"); + + // Step 12.c. + constexpr auto time = NormalizedTimeDuration{}; + + // Step 19. + auto resultDuration = DateDuration{years, months, weeks, int64_t(numDays)}; + if (!ThrowIfInvalidDuration(cx, resultDuration)) { return false; } - auto [numDays, total] = rounded; - // Step 20. - Duration resultDuration = {years, months, weeks, numDays}; - if (!ThrowIfInvalidDuration(cx, resultDuration)) { + *result = {{resultDuration, time}, total}; + return true; +} + +/** + * RoundDuration ( years, months, weeks, days, norm, increment, unit, + * roundingMode [ , plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , + * timeZoneRec [ , precalculatedPlainDateTime ] ] ] ] ] ) + */ +static bool RoundDuration(JSContext* cx, const NormalizedDuration& duration, + Increment increment, TemporalUnit unit, + TemporalRoundingMode roundingMode, + ComputeRemainder computeRemainder, + RoundedDuration* result) { + MOZ_ASSERT(IsValidNormalizedTimeDuration(duration.time)); + MOZ_ASSERT_IF(unit > TemporalUnit::Day, IsValidDuration(duration.date)); + + // The remainder is only needed when called from |Duration_total|. And `total` + // always passes |increment=1| and |roundingMode=trunc|. + MOZ_ASSERT_IF(computeRemainder == ComputeRemainder::Yes, + increment == Increment{1}); + MOZ_ASSERT_IF(computeRemainder == ComputeRemainder::Yes, + roundingMode == TemporalRoundingMode::Trunc); + + // Steps 1-5. (Not applicable.) + + // Step 6. + if (unit <= TemporalUnit::Week) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_DURATION_UNCOMPARABLE, + "relativeTo"); return false; } - // Step 21. - *result = {resultDuration, total}; + // TODO: We could directly return here if unit=nanoseconds and increment=1, + // because in that case this operation is a no-op. This case happens for + // example when calling Temporal.PlainTime.prototype.{since,until} without an + // options object. + // + // But maybe this can be even more efficiently handled in the callers. For + // example when Temporal.PlainTime.prototype.{since,until} is called without + // an options object, we can not only skip the RoundDuration call, but also + // the following BalanceTimeDuration call. + + // Step 7. (Moved below.) + + // Step 8. (Not applicable.) + + // Steps 9-11. (Not applicable.) + + // Step 12. + if (unit == TemporalUnit::Day) { + // Step 7. + auto timeAndDays = NormalizedTimeDurationToDays(duration.time); + auto fractionalDays = FractionalDays{duration.date.days, timeAndDays}; + + return RoundDurationDay(cx, duration, fractionalDays, increment, + roundingMode, computeRemainder, result); + } + + MOZ_ASSERT(TemporalUnit::Hour <= unit && unit <= TemporalUnit::Nanosecond); + + // Steps 13-18. + auto time = duration.time; + double total = 0; + if (computeRemainder == ComputeRemainder::No) { + if (!RoundNormalizedTimeDurationToIncrement(cx, time, unit, increment, + roundingMode, &time)) { + return false; + } + } else { + MOZ_ASSERT(increment == Increment{1}); + MOZ_ASSERT(roundingMode == TemporalRoundingMode::Trunc); + + total = TotalNormalizedTimeDuration(duration.time, unit); + } + MOZ_ASSERT(IsValidNormalizedTimeDuration(time)); + + // Step 19. + MOZ_ASSERT(IsValidDuration(duration.date)); + *result = {{duration.date, time}, total}; return true; } /** - * RoundDuration ( years, months, weeks, days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds, increment, unit, roundingMode [ , - * plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , timeZoneRec [ , - * precalculatedPlainDateTime ] ] ] ] ] ) + * RoundDuration ( years, months, weeks, days, norm, increment, unit, + * roundingMode [ , plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , + * timeZoneRec [ , precalculatedPlainDateTime ] ] ] ] ] ) */ static bool RoundDuration( - JSContext* cx, const Duration& duration, Increment increment, + JSContext* cx, const NormalizedDuration& duration, Increment increment, TemporalUnit unit, TemporalRoundingMode roundingMode, Handle<Wrapped<PlainDateObject*>> plainRelativeTo, Handle<CalendarRecord> calendar, Handle<ZonedDateTime> zonedRelativeTo, @@ -4982,9 +4013,11 @@ static bool RoundDuration( ComputeRemainder computeRemainder, RoundedDuration* result) { // Note: |duration.days| can have a different sign than the other date // components. The date and time components can have different signs, too. - MOZ_ASSERT( - IsValidDuration({duration.years, duration.months, duration.weeks})); - MOZ_ASSERT(IsValidDuration(duration.time())); + MOZ_ASSERT(IsValidDuration(Duration{double(duration.date.years), + double(duration.date.months), + double(duration.date.weeks)})); + MOZ_ASSERT(IsValidNormalizedTimeDuration(duration.time)); + MOZ_ASSERT_IF(unit > TemporalUnit::Day, IsValidDuration(duration.date)); MOZ_ASSERT(plainRelativeTo || zonedRelativeTo, "Use RoundDuration without relativeTo when plainRelativeTo and " @@ -5040,69 +4073,61 @@ static bool RoundDuration( MOZ_ASSERT(TemporalUnit::Year <= unit && unit <= TemporalUnit::Day); // Steps 7.a-c. - Rooted<temporal::NanosecondsAndDays> nanosAndDays(cx); + FractionalDays fractionalDays; if (zonedRelativeTo) { - // Step 7.b.i. (Reordered) + // Step 7.a.i. Rooted<ZonedDateTime> intermediate(cx); if (!MoveRelativeZonedDateTime(cx, zonedRelativeTo, calendar, timeZone, - duration.date(), precalculatedPlainDateTime, + duration.date, precalculatedPlainDateTime, &intermediate)) { return false; } - // Steps 7.a and 7.b.ii. - if (!NanosecondsToDays(cx, duration, intermediate, timeZone, - &nanosAndDays)) { + // Steps 7.a.ii. + NormalizedTimeAndDays timeAndDays; + if (!NormalizedTimeDurationToDays(cx, duration.time, intermediate, timeZone, + &timeAndDays)) { return false; } - // Step 7.b.iii. (Not applicable in our implementation.) + // Step 7.a.iii. + fractionalDays = FractionalDays{duration.date.days, timeAndDays}; } else { - // Steps 7.a and 7.c. - if (!::NanosecondsToDays(cx, duration, &nanosAndDays)) { - return false; - } + // Step 7.b. + auto timeAndDays = NormalizedTimeDurationToDays(duration.time); + fractionalDays = FractionalDays{duration.date.days, timeAndDays}; } - // NanosecondsToDays guarantees that |abs(nanosAndDays.nanoseconds)| is less - // than |abs(nanosAndDays.dayLength)|. - MOZ_ASSERT(nanosAndDays.nanoseconds().abs() < nanosAndDays.dayLength()); - - // Step 7.d. (Moved below) - - // Step 7.e. (Implicit) + // Step 7.c. (Moved below) // Step 8. (Not applicable) - // Step 9. - // FIXME: spec issue - `total` doesn't need be initialised. - - // Steps 10-21. + // Steps 9-19. switch (unit) { - // Steps 10 and 20-21. + // Steps 9 and 19. case TemporalUnit::Year: - return RoundDurationYear(cx, duration, nanosAndDays, increment, + return RoundDurationYear(cx, duration, fractionalDays, increment, roundingMode, plainRelativeTo, calendar, computeRemainder, result); - // Steps 11 and 20-21. + // Steps 10 and 19. case TemporalUnit::Month: - return RoundDurationMonth(cx, duration, nanosAndDays, increment, + return RoundDurationMonth(cx, duration, fractionalDays, increment, roundingMode, plainRelativeTo, calendar, computeRemainder, result); - // Steps 12 and 20-21. + // Steps 11 and 19. case TemporalUnit::Week: - return RoundDurationWeek(cx, duration, nanosAndDays, increment, + return RoundDurationWeek(cx, duration, fractionalDays, increment, roundingMode, plainRelativeTo, calendar, computeRemainder, result); - // Steps 13 and 20-21. + // Steps 12 and 19. case TemporalUnit::Day: - return RoundDurationDay(cx, duration, nanosAndDays, increment, + return RoundDurationDay(cx, duration, fractionalDays, increment, roundingMode, computeRemainder, result); - // Steps 14-19. (Handled elsewhere) + // Steps 13-18. (Handled elsewhere) case TemporalUnit::Auto: case TemporalUnit::Hour: case TemporalUnit::Minute: @@ -5117,55 +4142,51 @@ static bool RoundDuration( } /** - * RoundDuration ( years, months, weeks, days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds, increment, unit, roundingMode [ , - * plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , timeZoneRec [ , - * precalculatedPlainDateTime ] ] ] ] ] ) + * RoundDuration ( years, months, weeks, days, norm, increment, unit, + * roundingMode [ , plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , + * timeZoneRec [ , precalculatedPlainDateTime ] ] ] ] ] ) */ -static bool RoundDuration( - JSContext* cx, const Duration& duration, Increment increment, +bool js::temporal::RoundDuration( + JSContext* cx, const NormalizedDuration& duration, Increment increment, TemporalUnit unit, TemporalRoundingMode roundingMode, Handle<Wrapped<PlainDateObject*>> plainRelativeTo, - Handle<CalendarRecord> calendar, Handle<ZonedDateTime> zonedRelativeTo, - Handle<TimeZoneRecord> timeZone, - mozilla::Maybe<const PlainDateTime&> precalculatedPlainDateTime, - double* result) { - // Only called from |Duration_total|, which always passes |increment=1| and - // |roundingMode=trunc|. - MOZ_ASSERT(increment == Increment{1}); - MOZ_ASSERT(roundingMode == TemporalRoundingMode::Trunc); + Handle<CalendarRecord> calendar, NormalizedDuration* result) { + MOZ_ASSERT(IsValidDuration(duration)); + Rooted<ZonedDateTime> zonedRelativeTo(cx, ZonedDateTime{}); + Rooted<TimeZoneRecord> timeZone(cx, TimeZoneRecord{}); + mozilla::Maybe<const PlainDateTime&> precalculatedPlainDateTime{}; RoundedDuration rounded; if (!::RoundDuration(cx, duration, increment, unit, roundingMode, plainRelativeTo, calendar, zonedRelativeTo, timeZone, - precalculatedPlainDateTime, ComputeRemainder::Yes, + precalculatedPlainDateTime, ComputeRemainder::No, &rounded)) { return false; } - *result = rounded.total; + *result = rounded.duration; return true; } /** - * RoundDuration ( years, months, weeks, days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds, increment, unit, roundingMode [ , - * plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , timeZoneRec [ , - * precalculatedPlainDateTime ] ] ] ] ] ) + * RoundDuration ( years, months, weeks, days, norm, increment, unit, + * roundingMode [ , plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , + * timeZoneRec [ , precalculatedPlainDateTime ] ] ] ] ] ) */ -static bool RoundDuration( - JSContext* cx, const Duration& duration, Increment increment, +bool js::temporal::RoundDuration( + JSContext* cx, const NormalizedDuration& duration, Increment increment, TemporalUnit unit, TemporalRoundingMode roundingMode, - Handle<Wrapped<PlainDateObject*>> plainRelativeTo, - Handle<CalendarRecord> calendar, Handle<ZonedDateTime> zonedRelativeTo, - Handle<TimeZoneRecord> timeZone, - mozilla::Maybe<const PlainDateTime&> precalculatedPlainDateTime, - Duration* result) { + Handle<PlainDateObject*> plainRelativeTo, Handle<CalendarRecord> calendar, + Handle<ZonedDateTime> zonedRelativeTo, Handle<TimeZoneRecord> timeZone, + const PlainDateTime& precalculatedPlainDateTime, + NormalizedDuration* result) { + MOZ_ASSERT(IsValidDuration(duration)); + RoundedDuration rounded; if (!::RoundDuration(cx, duration, increment, unit, roundingMode, plainRelativeTo, calendar, zonedRelativeTo, timeZone, - precalculatedPlainDateTime, ComputeRemainder::No, - &rounded)) { + mozilla::SomeRef(precalculatedPlainDateTime), + ComputeRemainder::No, &rounded)) { return false; } @@ -5173,46 +4194,6 @@ static bool RoundDuration( return true; } -/** - * RoundDuration ( years, months, weeks, days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds, increment, unit, roundingMode [ , - * plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , timeZoneRec [ , - * precalculatedPlainDateTime ] ] ] ] ] ) - */ -bool js::temporal::RoundDuration( - JSContext* cx, const Duration& duration, Increment increment, - TemporalUnit unit, TemporalRoundingMode roundingMode, - Handle<Wrapped<PlainDateObject*>> plainRelativeTo, - Handle<CalendarRecord> calendar, Duration* result) { - MOZ_ASSERT(IsValidDuration(duration)); - - Rooted<ZonedDateTime> zonedRelativeTo(cx, ZonedDateTime{}); - Rooted<TimeZoneRecord> timeZone(cx, TimeZoneRecord{}); - mozilla::Maybe<const PlainDateTime&> precalculatedPlainDateTime{}; - return ::RoundDuration(cx, duration, increment, unit, roundingMode, - plainRelativeTo, calendar, zonedRelativeTo, timeZone, - precalculatedPlainDateTime, result); -} - -/** - * RoundDuration ( years, months, weeks, days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds, increment, unit, roundingMode [ , - * plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , timeZoneRec [ , - * precalculatedPlainDateTime ] ] ] ] ] ) - */ -bool js::temporal::RoundDuration( - JSContext* cx, const Duration& duration, Increment increment, - TemporalUnit unit, TemporalRoundingMode roundingMode, - Handle<PlainDateObject*> plainRelativeTo, Handle<CalendarRecord> calendar, - Handle<ZonedDateTime> zonedRelativeTo, Handle<TimeZoneRecord> timeZone, - const PlainDateTime& precalculatedPlainDateTime, Duration* result) { - MOZ_ASSERT(IsValidDuration(duration)); - - return ::RoundDuration(cx, duration, increment, unit, roundingMode, - plainRelativeTo, calendar, zonedRelativeTo, timeZone, - mozilla::SomeRef(precalculatedPlainDateTime), result); -} - enum class DurationOperation { Add, Subtract }; /** @@ -5441,40 +4422,32 @@ static bool Duration_compare(JSContext* cx, unsigned argc, Value* vp) { return false; } - Rooted<Wrapped<PlainDateObject*>> plainRelativeTo(cx); - Rooted<ZonedDateTime> zonedRelativeTo(cx); - Rooted<TimeZoneRecord> timeZone(cx); + // Step 3. + Rooted<JSObject*> options(cx); if (args.hasDefined(2)) { - // Step 3. - Rooted<JSObject*> options( - cx, RequireObjectArg(cx, "options", "compare", args[2])); + options = RequireObjectArg(cx, "options", "compare", args[2]); if (!options) { return false; } + } - // Step 4. - if (one == two) { - args.rval().setInt32(0); - return true; - } + // Step 4. + if (one == two) { + args.rval().setInt32(0); + return true; + } - // Steps 5-8. + // Steps 5-8. + Rooted<Wrapped<PlainDateObject*>> plainRelativeTo(cx); + Rooted<ZonedDateTime> zonedRelativeTo(cx); + Rooted<TimeZoneRecord> timeZone(cx); + if (options) { if (!ToRelativeTemporalObject(cx, options, &plainRelativeTo, &zonedRelativeTo, &timeZone)) { return false; } MOZ_ASSERT(!plainRelativeTo || !zonedRelativeTo); MOZ_ASSERT_IF(zonedRelativeTo, timeZone.receiver()); - } else { - // Step 3. (Not applicable in our implementation.) - - // Step 4. - if (one == two) { - args.rval().setInt32(0); - return true; - } - - // Steps 5-8. (Not applicable in our implementation.) } // Steps 9-10. @@ -5498,7 +4471,7 @@ static bool Duration_compare(JSContext* cx, unsigned argc, Value* vp) { if (zonedRelativeTo && (calendarUnitsPresent || one.days != 0 || two.days != 0)) { // Step 12.a. - auto instant = zonedRelativeTo.instant(); + const auto& instant = zonedRelativeTo.instant(); // Step 12.b. PlainDateTime dateTime; @@ -5507,59 +4480,65 @@ static bool Duration_compare(JSContext* cx, unsigned argc, Value* vp) { } // Step 12.c. + auto normalized1 = CreateNormalizedDurationRecord(one); + + // Step 12.d. + auto normalized2 = CreateNormalizedDurationRecord(two); + + // Step 12.e. Instant after1; - if (!AddZonedDateTime(cx, instant, timeZone, calendar, one, dateTime, - &after1)) { + if (!AddZonedDateTime(cx, instant, timeZone, calendar, normalized1, + dateTime, &after1)) { return false; } - // Step 12.d. + // Step 12.f. Instant after2; - if (!AddZonedDateTime(cx, instant, timeZone, calendar, two, dateTime, - &after2)) { + if (!AddZonedDateTime(cx, instant, timeZone, calendar, normalized2, + dateTime, &after2)) { return false; } - // Steps 12.e-g. + // Steps 12.g-i. args.rval().setInt32(after1 < after2 ? -1 : after1 > after2 ? 1 : 0); return true; } // Steps 13-14. - double days1, days2; + int64_t days1, days2; if (calendarUnitsPresent) { // FIXME: spec issue - directly throw an error if plainRelativeTo is undef. // Step 13.a. DateDuration unbalanceResult1; if (plainRelativeTo) { - if (!UnbalanceDateDurationRelative(cx, one, TemporalUnit::Day, - plainRelativeTo, calendar, - &unbalanceResult1)) { + if (!UnbalanceDateDurationRelative(cx, one.toDateDuration(), + TemporalUnit::Day, plainRelativeTo, + calendar, &unbalanceResult1)) { return false; } } else { - if (!UnbalanceDateDurationRelative(cx, one, TemporalUnit::Day, - &unbalanceResult1)) { + if (!UnbalanceDateDurationRelative( + cx, one.toDateDuration(), TemporalUnit::Day, &unbalanceResult1)) { return false; } - MOZ_ASSERT(one.date() == unbalanceResult1.toDuration()); + MOZ_ASSERT(one.toDateDuration() == unbalanceResult1); } // Step 13.b. DateDuration unbalanceResult2; if (plainRelativeTo) { - if (!UnbalanceDateDurationRelative(cx, two, TemporalUnit::Day, - plainRelativeTo, calendar, - &unbalanceResult2)) { + if (!UnbalanceDateDurationRelative(cx, two.toDateDuration(), + TemporalUnit::Day, plainRelativeTo, + calendar, &unbalanceResult2)) { return false; } } else { - if (!UnbalanceDateDurationRelative(cx, two, TemporalUnit::Day, - &unbalanceResult2)) { + if (!UnbalanceDateDurationRelative( + cx, two.toDateDuration(), TemporalUnit::Day, &unbalanceResult2)) { return false; } - MOZ_ASSERT(two.date() == unbalanceResult2.toDuration()); + MOZ_ASSERT(two.toDateDuration() == unbalanceResult2); } // Step 13.c. @@ -5569,74 +4548,32 @@ static bool Duration_compare(JSContext* cx, unsigned argc, Value* vp) { days2 = unbalanceResult2.days; } else { // Step 14.a. - days1 = one.days; + days1 = mozilla::AssertedCast<int64_t>(one.days); // Step 14.b. - days2 = two.days; + days2 = mozilla::AssertedCast<int64_t>(two.days); } - // Note: duration units can be arbitrary doubles, so we need to use BigInts - // Test case: - // - // Temporal.Duration.compare({ - // milliseconds: 10000000000000, microseconds: 4, nanoseconds: 95 - // }, { - // nanoseconds:10000000000000004000 - // }) - // - // This must return -1, but would return 0 when |double| is used. - // - // Note: BigInt(10000000000000004000) is 10000000000000004096n - - Duration oneTotal = { - 0, - 0, - 0, - days1, - one.hours, - one.minutes, - one.seconds, - one.milliseconds, - one.microseconds, - one.nanoseconds, - }; - Duration twoTotal = { - 0, - 0, - 0, - days2, - two.hours, - two.minutes, - two.seconds, - two.milliseconds, - two.microseconds, - two.nanoseconds, - }; - - // Steps 15-21. - // - // Fast path when the total duration amount fits into an int64. - if (auto ns1 = TotalDurationNanoseconds(oneTotal)) { - if (auto ns2 = TotalDurationNanoseconds(twoTotal)) { - args.rval().setInt32(*ns1 < *ns2 ? -1 : *ns1 > *ns2 ? 1 : 0); - return true; - } - } + // Step 15. + auto normalized1 = NormalizeTimeDuration(one); - // Steps 15 and 17. - Rooted<BigInt*> ns1(cx, TotalDurationNanosecondsSlow(cx, oneTotal)); - if (!ns1) { + // Step 16. + if (!Add24HourDaysToNormalizedTimeDuration(cx, normalized1, days1, + &normalized1)) { return false; } - // Steps 16 and 18. - auto* ns2 = TotalDurationNanosecondsSlow(cx, twoTotal); - if (!ns2) { + // Step 17. + auto normalized2 = NormalizeTimeDuration(two); + + // Step 18. + if (!Add24HourDaysToNormalizedTimeDuration(cx, normalized2, days2, + &normalized2)) { return false; } - // Step 19-21. - args.rval().setInt32(BigInt::compare(ns1, ns2)); + // Step 19. + args.rval().setInt32(CompareNormalizedTimeDuration(normalized1, normalized2)); return true; } @@ -5834,10 +4771,10 @@ static bool Duration_nanoseconds(JSContext* cx, unsigned argc, Value* vp) { * get Temporal.Duration.prototype.sign */ static bool Duration_sign(JSContext* cx, const CallArgs& args) { + auto duration = ToDuration(&args.thisv().toObject().as<DurationObject>()); + // Step 3. - auto* duration = &args.thisv().toObject().as<DurationObject>(); - int32_t sign = DurationSign(ToDuration(duration)); - args.rval().setInt32(sign); + args.rval().setInt32(DurationSign(duration)); return true; } @@ -5854,12 +4791,10 @@ static bool Duration_sign(JSContext* cx, unsigned argc, Value* vp) { * get Temporal.Duration.prototype.blank */ static bool Duration_blank(JSContext* cx, const CallArgs& args) { - // Step 3. - auto* duration = &args.thisv().toObject().as<DurationObject>(); - int32_t sign = DurationSign(ToDuration(duration)); + auto duration = ToDuration(&args.thisv().toObject().as<DurationObject>()); - // Steps 4-5. - args.rval().setBoolean(sign == 0); + // Steps 3-5. + args.rval().setBoolean(duration == Duration{}); return true; } @@ -5878,10 +4813,8 @@ static bool Duration_blank(JSContext* cx, unsigned argc, Value* vp) { * ToPartialDuration ( temporalDurationLike ) */ static bool Duration_with(JSContext* cx, const CallArgs& args) { - auto* durationObj = &args.thisv().toObject().as<DurationObject>(); - // Absent values default to the corresponding values of |this| object. - auto duration = ToDuration(durationObj); + auto duration = ToDuration(&args.thisv().toObject().as<DurationObject>()); // Steps 3-23. Rooted<JSObject*> temporalDurationLike( @@ -5916,8 +4849,7 @@ static bool Duration_with(JSContext* cx, unsigned argc, Value* vp) { * Temporal.Duration.prototype.negated ( ) */ static bool Duration_negated(JSContext* cx, const CallArgs& args) { - auto* durationObj = &args.thisv().toObject().as<DurationObject>(); - auto duration = ToDuration(durationObj); + auto duration = ToDuration(&args.thisv().toObject().as<DurationObject>()); // Step 3. auto* result = CreateTemporalDuration(cx, duration.negate()); @@ -5942,8 +4874,7 @@ static bool Duration_negated(JSContext* cx, unsigned argc, Value* vp) { * Temporal.Duration.prototype.abs ( ) */ static bool Duration_abs(JSContext* cx, const CallArgs& args) { - auto* durationObj = &args.thisv().toObject().as<DurationObject>(); - auto duration = ToDuration(durationObj); + auto duration = ToDuration(&args.thisv().toObject().as<DurationObject>()); // Step 3. auto* result = CreateTemporalDuration(cx, AbsoluteDuration(duration)); @@ -6002,8 +4933,7 @@ static bool Duration_subtract(JSContext* cx, unsigned argc, Value* vp) { * Temporal.Duration.prototype.round ( roundTo ) */ static bool Duration_round(JSContext* cx, const CallArgs& args) { - auto* durationObj = &args.thisv().toObject().as<DurationObject>(); - auto duration = ToDuration(durationObj); + auto duration = ToDuration(&args.thisv().toObject().as<DurationObject>()); // Step 18. (Reordered) auto existingLargestUnit = DefaultTemporalLargestUnit(duration); @@ -6208,7 +5138,7 @@ static bool Duration_round(JSContext* cx, const CallArgs& args) { PlainDateTime relativeToDateTime; if (zonedRelativeTo && plainDateTimeOrRelativeToWillBeUsed) { // Steps 34.a-b. - auto instant = zonedRelativeTo.instant(); + const auto& instant = zonedRelativeTo.instant(); // Step 34.c. if (!GetPlainDateTimeFor(cx, timeZone, instant, &relativeToDateTime)) { @@ -6240,46 +5170,48 @@ static bool Duration_round(JSContext* cx, const CallArgs& args) { // Step 36. DateDuration unbalanceResult; if (plainRelativeTo) { - if (!UnbalanceDateDurationRelative(cx, duration, largestUnit, - plainRelativeTo, calendar, + if (!UnbalanceDateDurationRelative(cx, duration.toDateDuration(), + largestUnit, plainRelativeTo, calendar, &unbalanceResult)) { return false; } } else { - if (!UnbalanceDateDurationRelative(cx, duration, largestUnit, - &unbalanceResult)) { + if (!UnbalanceDateDurationRelative(cx, duration.toDateDuration(), + largestUnit, &unbalanceResult)) { return false; } - MOZ_ASSERT(duration.date() == unbalanceResult.toDuration()); + MOZ_ASSERT(duration.toDateDuration() == unbalanceResult); } + MOZ_ASSERT(IsValidDuration(unbalanceResult)); // Steps 37-38. - Duration roundInput = { - unbalanceResult.years, unbalanceResult.months, unbalanceResult.weeks, - unbalanceResult.days, duration.hours, duration.minutes, - duration.seconds, duration.milliseconds, duration.microseconds, - duration.nanoseconds, - }; - Duration roundResult; + auto roundInput = + NormalizedDuration{unbalanceResult, NormalizeTimeDuration(duration)}; + RoundedDuration rounded; if (plainRelativeTo || zonedRelativeTo) { if (!::RoundDuration(cx, roundInput, roundingIncrement, smallestUnit, roundingMode, plainRelativeTo, calendar, zonedRelativeTo, timeZone, precalculatedPlainDateTime, - &roundResult)) { + ComputeRemainder::No, &rounded)) { return false; } } else { + MOZ_ASSERT(IsValidDuration(roundInput)); + if (!::RoundDuration(cx, roundInput, roundingIncrement, smallestUnit, - roundingMode, &roundResult)) { + roundingMode, ComputeRemainder::No, &rounded)) { return false; } } - // Steps 39-40. + // Step 39. + auto roundResult = rounded.duration; + + // Steps 40-41. TimeDuration balanceResult; if (zonedRelativeTo) { - // Step 39.a. - Duration adjustResult; + // Step 40.a. + NormalizedDuration adjustResult; if (!AdjustRoundedDurationDays(cx, roundResult, roundingIncrement, smallestUnit, roundingMode, zonedRelativeTo, calendar, timeZone, @@ -6288,46 +5220,51 @@ static bool Duration_round(JSContext* cx, const CallArgs& args) { } roundResult = adjustResult; - // Step 39.b. + // Step 40.b. if (!BalanceTimeDurationRelative( cx, roundResult, largestUnit, zonedRelativeTo, timeZone, precalculatedPlainDateTime, &balanceResult)) { return false; } } else { - // Step 40.a. - if (!BalanceTimeDuration(cx, roundResult, largestUnit, &balanceResult)) { + // Step 41.a. + NormalizedTimeDuration withDays; + if (!Add24HourDaysToNormalizedTimeDuration( + cx, roundResult.time, roundResult.date.days, &withDays)) { + return false; + } + + // Step 41.b. + if (!temporal::BalanceTimeDuration(cx, withDays, largestUnit, + &balanceResult)) { return false; } } - // Step 41. - Duration balanceInput = { - roundResult.years, - roundResult.months, - roundResult.weeks, + // Step 42. + auto balanceInput = DateDuration{ + roundResult.date.years, + roundResult.date.months, + roundResult.date.weeks, balanceResult.days, }; - DateDuration result; + DateDuration dateResult; if (!::BalanceDateDurationRelative(cx, balanceInput, largestUnit, smallestUnit, plainRelativeTo, calendar, - &result)) { + &dateResult)) { return false; } - // Step 42. - auto* obj = CreateTemporalDuration(cx, { - result.years, - result.months, - result.weeks, - result.days, - balanceResult.hours, - balanceResult.minutes, - balanceResult.seconds, - balanceResult.milliseconds, - balanceResult.microseconds, - balanceResult.nanoseconds, - }); + // Step 43. + auto result = Duration{ + double(dateResult.years), double(dateResult.months), + double(dateResult.weeks), double(dateResult.days), + double(balanceResult.hours), double(balanceResult.minutes), + double(balanceResult.seconds), double(balanceResult.milliseconds), + balanceResult.microseconds, balanceResult.nanoseconds, + }; + + auto* obj = CreateTemporalDuration(cx, result); if (!obj) { return false; } @@ -6404,14 +5341,13 @@ static bool Duration_total(JSContext* cx, const CallArgs& args) { // Step 13. bool plainDateTimeOrRelativeToWillBeUsed = - unit <= TemporalUnit::Day || duration.years != 0 || - duration.months != 0 || duration.weeks != 0 || duration.days != 0; + unit <= TemporalUnit::Day || duration.toDateDuration() != DateDuration{}; // Step 14. PlainDateTime relativeToDateTime; if (zonedRelativeTo && plainDateTimeOrRelativeToWillBeUsed) { // Steps 14.a-b. - auto instant = zonedRelativeTo.instant(); + const auto& instant = zonedRelativeTo.instant(); // Step 14.c. if (!GetPlainDateTimeFor(cx, timeZone, instant, &relativeToDateTime)) { @@ -6443,34 +5379,27 @@ static bool Duration_total(JSContext* cx, const CallArgs& args) { // Step 16. DateDuration unbalanceResult; if (plainRelativeTo) { - if (!UnbalanceDateDurationRelative(cx, duration, unit, plainRelativeTo, - calendar, &unbalanceResult)) { + if (!UnbalanceDateDurationRelative(cx, duration.toDateDuration(), unit, + plainRelativeTo, calendar, + &unbalanceResult)) { return false; } } else { - if (!UnbalanceDateDurationRelative(cx, duration, unit, &unbalanceResult)) { + if (!UnbalanceDateDurationRelative(cx, duration.toDateDuration(), unit, + &unbalanceResult)) { return false; } - MOZ_ASSERT(duration.date() == unbalanceResult.toDuration()); + MOZ_ASSERT(duration.toDateDuration() == unbalanceResult); } - Duration balanceInput = { - 0, - 0, - 0, - unbalanceResult.days, - duration.hours, - duration.minutes, - duration.seconds, - duration.milliseconds, - duration.microseconds, - duration.nanoseconds, - }; + // Step 17. + int64_t unbalancedDays = unbalanceResult.days; - // Steps 17-18. - TimeDuration balanceResult; + // Steps 18-19. + int64_t days; + NormalizedTimeDuration normTime; if (zonedRelativeTo) { - // Step 17.a + // Step 18.a Rooted<ZonedDateTime> intermediate(cx); if (!MoveRelativeZonedDateTime( cx, zonedRelativeTo, calendar, timeZone, @@ -6480,63 +5409,131 @@ static bool Duration_total(JSContext* cx, const CallArgs& args) { return false; } - // Step 17.b. - if (!BalancePossiblyInfiniteTimeDurationRelative( - cx, balanceInput, unit, intermediate, timeZone, &balanceResult)) { + // Step 18.b. + auto timeDuration = NormalizeTimeDuration(duration); + + // Step 18.c + const auto& startNs = intermediate.instant(); + + // Step 18.d. + const auto& startInstant = startNs; + + // Step 18.e. + mozilla::Maybe<PlainDateTime> startDateTime{}; + + // Steps 18.f-g. + Instant intermediateNs; + if (unbalancedDays != 0) { + // Step 18.f.i. + PlainDateTime dateTime; + if (!GetPlainDateTimeFor(cx, timeZone, startInstant, &dateTime)) { + return false; + } + startDateTime = mozilla::Some(dateTime); + + // Step 18.f.ii. + Rooted<CalendarValue> isoCalendar(cx, CalendarValue(cx->names().iso8601)); + Instant addResult; + if (!AddDaysToZonedDateTime(cx, startInstant, dateTime, timeZone, + isoCalendar, unbalancedDays, &addResult)) { + return false; + } + + // Step 18.f.iii. + intermediateNs = addResult; + } else { + // Step 18.g. + intermediateNs = startNs; + } + + // Step 18.h. + Instant endNs; + if (!AddInstant(cx, intermediateNs, timeDuration, &endNs)) { return false; } + + // Step 18.i. + auto difference = + NormalizedTimeDurationFromEpochNanosecondsDifference(endNs, startNs); + + // Steps 18.j-k. + // + // Avoid calling NormalizedTimeDurationToDays for a zero time difference. + if (TemporalUnit::Year <= unit && unit <= TemporalUnit::Day && + difference != NormalizedTimeDuration{}) { + // Step 18.j.i. + if (!startDateTime) { + PlainDateTime dateTime; + if (!GetPlainDateTimeFor(cx, timeZone, startInstant, &dateTime)) { + return false; + } + startDateTime = mozilla::Some(dateTime); + } + + // Step 18.j.ii. + NormalizedTimeAndDays timeAndDays; + if (!NormalizedTimeDurationToDays(cx, difference, intermediate, timeZone, + *startDateTime, &timeAndDays)) { + return false; + } + + // Step 18.j.iii. + normTime = NormalizedTimeDuration::fromNanoseconds(timeAndDays.time); + + // Step 18.j.iv. + days = timeAndDays.days; + } else { + // Step 18.k.i. + normTime = difference; + days = 0; + } } else { - // Step 18. - if (!BalancePossiblyInfiniteTimeDuration(cx, balanceInput, unit, - &balanceResult)) { + // Step 19.a. + auto timeDuration = NormalizeTimeDuration(duration); + + // Step 19.b. + if (!Add24HourDaysToNormalizedTimeDuration(cx, timeDuration, unbalancedDays, + &normTime)) { return false; } - } - // Steps 19-20. - for (double v : { - balanceResult.days, - balanceResult.hours, - balanceResult.minutes, - balanceResult.seconds, - balanceResult.milliseconds, - balanceResult.microseconds, - balanceResult.nanoseconds, - }) { - if (std::isinf(v)) { - args.rval().setDouble(v); - return true; - } + // Step 19.c. + days = 0; } - MOZ_ASSERT(IsValidDuration(balanceResult.toDuration())); + MOZ_ASSERT(IsValidNormalizedTimeDuration(normTime)); - // Step 21. (Not applicable in our implementation.) - - // Step 22. - Duration roundInput = { - unbalanceResult.years, unbalanceResult.months, - unbalanceResult.weeks, balanceResult.days, - balanceResult.hours, balanceResult.minutes, - balanceResult.seconds, balanceResult.milliseconds, - balanceResult.microseconds, balanceResult.nanoseconds, + // Step 20. + auto roundInput = NormalizedDuration{ + { + unbalanceResult.years, + unbalanceResult.months, + unbalanceResult.weeks, + days, + }, + normTime, }; - double total; + MOZ_ASSERT_IF(unit > TemporalUnit::Day, IsValidDuration(roundInput.date)); + + RoundedDuration rounded; if (plainRelativeTo || zonedRelativeTo) { if (!::RoundDuration(cx, roundInput, Increment{1}, unit, TemporalRoundingMode::Trunc, plainRelativeTo, calendar, zonedRelativeTo, timeZone, precalculatedPlainDateTime, - &total)) { + ComputeRemainder::Yes, &rounded)) { return false; } } else { + MOZ_ASSERT(IsValidDuration(roundInput)); + if (!::RoundDuration(cx, roundInput, Increment{1}, unit, - TemporalRoundingMode::Trunc, &total)) { + TemporalRoundingMode::Trunc, ComputeRemainder::Yes, + &rounded)) { return false; } } - // Step 23. - args.rval().setNumber(total); + // Step 21. + args.rval().setNumber(rounded.total); return true; } @@ -6605,64 +5602,37 @@ static bool Duration_toString(JSContext* cx, const CallArgs& args) { if (precision.unit != TemporalUnit::Nanosecond || precision.increment != Increment{1}) { // Step 10.a. - auto largestUnit = DefaultTemporalLargestUnit(duration); + auto timeDuration = NormalizeTimeDuration(duration); - // Steps 10.b-c. - auto toRound = Duration{ - 0, - 0, - 0, - 0, - 0, - 0, - duration.seconds, - duration.milliseconds, - duration.microseconds, - duration.nanoseconds, - }; - Duration roundResult; - if (!temporal::RoundDuration(cx, toRound, precision.increment, - precision.unit, roundingMode, &roundResult)) { - return false; - } + // Step 10.b. + auto largestUnit = DefaultTemporalLargestUnit(duration); - // Step 10.d. - auto toBalance = Duration{ - 0, - 0, - 0, - duration.days, - duration.hours, - duration.minutes, - roundResult.seconds, - roundResult.milliseconds, - roundResult.microseconds, - roundResult.nanoseconds, - }; - TimeDuration balanceResult; - if (!BalanceTimeDuration(cx, toBalance, largestUnit, &balanceResult)) { + // Steps 10.c-d. + NormalizedTimeDuration rounded; + if (!RoundDuration(cx, timeDuration, precision.increment, precision.unit, + roundingMode, &rounded)) { return false; } // Step 10.e. + auto balanced = BalanceTimeDuration( + rounded, std::min(largestUnit, TemporalUnit::Second)); + + // Step 10.f. result = { - duration.years, - duration.months, - duration.weeks, - balanceResult.days, - balanceResult.hours, - balanceResult.minutes, - balanceResult.seconds, - balanceResult.milliseconds, - balanceResult.microseconds, - balanceResult.nanoseconds, + duration.years, duration.months, + duration.weeks, duration.days + double(balanced.days), + double(balanced.hours), double(balanced.minutes), + double(balanced.seconds), double(balanced.milliseconds), + balanced.microseconds, balanced.nanoseconds, }; + MOZ_ASSERT(IsValidDuration(duration)); } else { // Step 11. result = duration; } - // Step 12. + // Steps 12-13. JSString* str = TemporalDurationToString(cx, result, precision.precision); if (!str) { return false; @@ -6682,14 +5652,13 @@ static bool Duration_toString(JSContext* cx, unsigned argc, Value* vp) { } /** - * Temporal.Duration.prototype.toJSON ( ) + * Temporal.Duration.prototype.toJSON ( ) */ static bool Duration_toJSON(JSContext* cx, const CallArgs& args) { - auto* duration = &args.thisv().toObject().as<DurationObject>(); + auto duration = ToDuration(&args.thisv().toObject().as<DurationObject>()); - // Step 3. - JSString* str = - TemporalDurationToString(cx, ToDuration(duration), Precision::Auto()); + // Steps 3-4. + JSString* str = TemporalDurationToString(cx, duration, Precision::Auto()); if (!str) { return false; } @@ -6699,7 +5668,7 @@ static bool Duration_toJSON(JSContext* cx, const CallArgs& args) { } /** - * Temporal.Duration.prototype.toJSON ( ) + * Temporal.Duration.prototype.toJSON ( ) */ static bool Duration_toJSON(JSContext* cx, unsigned argc, Value* vp) { // Steps 1-2. @@ -6711,11 +5680,10 @@ static bool Duration_toJSON(JSContext* cx, unsigned argc, Value* vp) { * Temporal.Duration.prototype.toLocaleString ( [ locales [ , options ] ] ) */ static bool Duration_toLocaleString(JSContext* cx, const CallArgs& args) { - auto* duration = &args.thisv().toObject().as<DurationObject>(); + auto duration = ToDuration(&args.thisv().toObject().as<DurationObject>()); - // Step 3. - JSString* str = - TemporalDurationToString(cx, ToDuration(duration), Precision::Auto()); + // Steps 3-4. + JSString* str = TemporalDurationToString(cx, duration, Precision::Auto()); if (!str) { return false; } diff --git a/js/src/builtin/temporal/Duration.h b/js/src/builtin/temporal/Duration.h index 47708458f4..e1aea4d1d4 100644 --- a/js/src/builtin/temporal/Duration.h +++ b/js/src/builtin/temporal/Duration.h @@ -89,11 +89,31 @@ enum class TemporalUnit; int32_t DurationSign(const Duration& duration); /** + * DurationSign ( years, months, weeks, days, hours, minutes, seconds, + * milliseconds, microseconds, nanoseconds ) + */ +int32_t DurationSign(const DateDuration& duration); + +/** * IsValidDuration ( years, months, weeks, days, hours, minutes, seconds, * milliseconds, microseconds, nanoseconds ) */ bool IsValidDuration(const Duration& duration); +#ifdef DEBUG +/** + * IsValidDuration ( years, months, weeks, days, hours, minutes, seconds, + * milliseconds, microseconds, nanoseconds ) + */ +bool IsValidDuration(const DateDuration& duration); + +/** + * IsValidDuration ( years, months, weeks, days, hours, minutes, seconds, + * milliseconds, microseconds, nanoseconds ) + */ +bool IsValidDuration(const NormalizedDuration& duration); +#endif + /** * IsValidDuration ( years, months, weeks, days, hours, minutes, seconds, * milliseconds, microseconds, nanoseconds ) @@ -101,6 +121,135 @@ bool IsValidDuration(const Duration& duration); bool ThrowIfInvalidDuration(JSContext* cx, const Duration& duration); /** + * IsValidDuration ( years, months, weeks, days, hours, minutes, seconds, + * milliseconds, microseconds, nanoseconds ) + */ +bool ThrowIfInvalidDuration(JSContext* cx, const DateDuration& duration); + +/** + * IsValidDuration ( years, months, weeks, days, hours, minutes, seconds, + * milliseconds, microseconds, nanoseconds ) + */ +inline bool IsValidNormalizedTimeDuration( + const NormalizedTimeDuration& duration) { + MOZ_ASSERT(0 <= duration.nanoseconds && duration.nanoseconds <= 999'999'999); + + // Step 4. + // + // The absolute value of the seconds part of normalized time duration must be + // less-or-equal to `2**53 - 1` and the nanoseconds part must be less or equal + // to `999'999'999`. + return NormalizedTimeDuration::min() <= duration && + duration <= NormalizedTimeDuration::max(); +} + +/** + * NormalizeTimeDuration ( hours, minutes, seconds, milliseconds, microseconds, + * nanoseconds ) + */ +NormalizedTimeDuration NormalizeTimeDuration(int32_t hours, int32_t minutes, + int32_t seconds, + int32_t milliseconds, + int32_t microseconds, + int32_t nanoseconds); + +/** + * NormalizeTimeDuration ( hours, minutes, seconds, milliseconds, microseconds, + * nanoseconds ) + */ +NormalizedTimeDuration NormalizeTimeDuration(const Duration& duration); + +/** + * CompareNormalizedTimeDuration ( one, two ) + */ +inline int32_t CompareNormalizedTimeDuration( + const NormalizedTimeDuration& one, const NormalizedTimeDuration& two) { + MOZ_ASSERT(IsValidNormalizedTimeDuration(one)); + MOZ_ASSERT(IsValidNormalizedTimeDuration(two)); + + // Step 1. + if (one > two) { + return 1; + } + + // Step 2. + if (one < two) { + return -1; + } + + // Step 3. + return 0; +} + +/** + * NormalizedTimeDurationSign ( d ) + */ +inline int32_t NormalizedTimeDurationSign(const NormalizedTimeDuration& d) { + MOZ_ASSERT(IsValidNormalizedTimeDuration(d)); + + // Steps 1-3. + return CompareNormalizedTimeDuration(d, NormalizedTimeDuration{}); +} + +/** + * Add24HourDaysToNormalizedTimeDuration ( d, days ) + */ +bool Add24HourDaysToNormalizedTimeDuration(JSContext* cx, + const NormalizedTimeDuration& d, + int64_t days, + NormalizedTimeDuration* result); + +/** + * CreateNormalizedDurationRecord ( years, months, weeks, days, norm ) + */ +inline NormalizedDuration CreateNormalizedDurationRecord( + const DateDuration& date, const NormalizedTimeDuration& time) { + MOZ_ASSERT(IsValidDuration(date)); + MOZ_ASSERT(IsValidNormalizedTimeDuration(time)); +#ifdef DEBUG + int64_t dateValues = date.years | date.months | date.weeks | date.days; + int32_t dateSign = dateValues ? dateValues < 0 ? -1 : 1 : 0; + int32_t timeSign = NormalizedTimeDurationSign(time); + MOZ_ASSERT((dateSign * timeSign) >= 0); +#endif + + return {date, time}; +} + +/** + * CreateNormalizedDurationRecord ( years, months, weeks, days, norm ) + */ +inline NormalizedDuration CreateNormalizedDurationRecord( + const Duration& duration) { + return CreateNormalizedDurationRecord(duration.toDateDuration(), + NormalizeTimeDuration(duration)); +} + +/** + * CombineDateAndNormalizedTimeDuration ( dateDurationRecord, norm ) + */ +bool CombineDateAndNormalizedTimeDuration(JSContext* cx, + const DateDuration& date, + const NormalizedTimeDuration& time, + NormalizedDuration* result); + +/** + * CreateNormalizedDurationRecord ( years, months, weeks, days, norm ) + */ +inline bool CreateNormalizedDurationRecord(JSContext* cx, + const DateDuration& date, + const NormalizedTimeDuration& time, + NormalizedDuration* result) { + return CombineDateAndNormalizedTimeDuration(cx, date, time, result); +} + +/** + * NormalizedTimeDurationFromEpochNanosecondsDifference ( one, two ) + */ +NormalizedTimeDuration NormalizedTimeDurationFromEpochNanosecondsDifference( + const Instant& one, const Instant& two); + +/** * CreateTemporalDuration ( years, months, weeks, days, hours, minutes, seconds, * milliseconds, microseconds, nanoseconds [ , newTarget ] ) */ @@ -126,17 +275,15 @@ bool ToTemporalDurationRecord(JSContext* cx, Duration* result); /** - * BalanceTimeDuration ( days, hours, minutes, seconds, milliseconds, - * microseconds, nanoseconds, largestUnit ) + * BalanceTimeDuration ( norm, largestUnit ) */ -bool BalanceTimeDuration(JSContext* cx, const Duration& duration, - TemporalUnit largestUnit, TimeDuration* result); +TimeDuration BalanceTimeDuration(const NormalizedTimeDuration& duration, + TemporalUnit largestUnit); /** - * BalanceTimeDuration ( days, hours, minutes, seconds, milliseconds, - * microseconds, nanoseconds, largestUnit ) + * BalanceTimeDuration ( norm, largestUnit ) */ -bool BalanceTimeDuration(JSContext* cx, const InstantSpan& nanoseconds, +bool BalanceTimeDuration(JSContext* cx, const NormalizedTimeDuration& duration, TemporalUnit largestUnit, TimeDuration* result); /** @@ -144,61 +291,71 @@ bool BalanceTimeDuration(JSContext* cx, const InstantSpan& nanoseconds, * smallestUnit, plainRelativeTo, calendarRec ) */ bool BalanceDateDurationRelative( - JSContext* cx, const Duration& duration, TemporalUnit largestUnit, + JSContext* cx, const DateDuration& duration, TemporalUnit largestUnit, TemporalUnit smallestUnit, JS::Handle<Wrapped<PlainDateObject*>> plainRelativeTo, JS::Handle<CalendarRecord> calendar, DateDuration* result); /** - * AdjustRoundedDurationDays ( years, months, weeks, days, hours, minutes, - * seconds, milliseconds, microseconds, nanoseconds, increment, unit, - * roundingMode, zonedRelativeTo, calendarRec, timeZoneRec, + * AdjustRoundedDurationDays ( years, months, weeks, days, norm, increment, + * unit, roundingMode, zonedRelativeTo, calendarRec, timeZoneRec, * precalculatedPlainDateTime ) */ -bool AdjustRoundedDurationDays(JSContext* cx, const Duration& duration, +bool AdjustRoundedDurationDays(JSContext* cx, + const NormalizedDuration& duration, Increment increment, TemporalUnit unit, TemporalRoundingMode roundingMode, JS::Handle<ZonedDateTime> relativeTo, JS::Handle<CalendarRecord> calendar, JS::Handle<TimeZoneRecord> timeZone, const PlainDateTime& precalculatedPlainDateTime, - Duration* result); + NormalizedDuration* result); /** - * RoundDuration ( years, months, weeks, days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds, increment, unit, roundingMode [ , - * plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , timeZoneRec [ , - * precalculatedPlainDateTime ] ] ] ] ] ) + * RoundDuration ( years, months, weeks, days, norm, increment, unit, + * roundingMode [ , plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , + * timeZoneRec [ , precalculatedPlainDateTime ] ] ] ] ] ) */ -bool RoundDuration(JSContext* cx, const Duration& duration, Increment increment, - TemporalUnit unit, TemporalRoundingMode roundingMode, - Duration* result); +NormalizedTimeDuration RoundDuration(const NormalizedTimeDuration& duration, + Increment increment, TemporalUnit unit, + TemporalRoundingMode roundingMode); /** - * RoundDuration ( years, months, weeks, days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds, increment, unit, roundingMode [ , - * plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , timeZoneRec [ , - * precalculatedPlainDateTime ] ] ] ] ] ) + * RoundDuration ( years, months, weeks, days, norm, increment, unit, + * roundingMode [ , plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , + * timeZoneRec [ , precalculatedPlainDateTime ] ] ] ] ] ) */ -bool RoundDuration(JSContext* cx, const Duration& duration, Increment increment, - TemporalUnit unit, TemporalRoundingMode roundingMode, +bool RoundDuration(JSContext* cx, const NormalizedTimeDuration& duration, + Increment increment, TemporalUnit unit, + TemporalRoundingMode roundingMode, + NormalizedTimeDuration* result); + +/** + * RoundDuration ( years, months, weeks, days, norm, increment, unit, + * roundingMode [ , plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , + * timeZoneRec [ , precalculatedPlainDateTime ] ] ] ] ] ) + */ +bool RoundDuration(JSContext* cx, const NormalizedDuration& duration, + Increment increment, TemporalUnit unit, + TemporalRoundingMode roundingMode, JS::Handle<Wrapped<PlainDateObject*>> plainRelativeTo, - JS::Handle<CalendarRecord> calendar, Duration* result); + JS::Handle<CalendarRecord> calendar, + NormalizedDuration* result); /** - * RoundDuration ( years, months, weeks, days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds, increment, unit, roundingMode [ , - * plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , timeZoneRec [ , - * precalculatedPlainDateTime ] ] ] ] ] ) + * RoundDuration ( years, months, weeks, days, norm, increment, unit, + * roundingMode [ , plainRelativeTo [ , calendarRec [ , zonedRelativeTo [ , + * timeZoneRec [ , precalculatedPlainDateTime ] ] ] ] ] ) */ -bool RoundDuration(JSContext* cx, const Duration& duration, Increment increment, - TemporalUnit unit, TemporalRoundingMode roundingMode, +bool RoundDuration(JSContext* cx, const NormalizedDuration& duration, + Increment increment, TemporalUnit unit, + TemporalRoundingMode roundingMode, JS::Handle<PlainDateObject*> plainRelativeTo, JS::Handle<CalendarRecord> calendar, JS::Handle<ZonedDateTime> zonedRelativeTo, JS::Handle<TimeZoneRecord> timeZone, const PlainDateTime& precalculatedPlainDateTime, - Duration* result); + NormalizedDuration* result); /** * DaysUntil ( earlier, later ) diff --git a/js/src/builtin/temporal/Instant.cpp b/js/src/builtin/temporal/Instant.cpp index 78fc15f313..8e38f3ad51 100644 --- a/js/src/builtin/temporal/Instant.cpp +++ b/js/src/builtin/temporal/Instant.cpp @@ -7,6 +7,7 @@ #include "builtin/temporal/Instant.h" #include "mozilla/Assertions.h" +#include "mozilla/Casting.h" #include "mozilla/CheckedInt.h" #include "mozilla/FloatingPoint.h" #include "mozilla/Maybe.h" @@ -164,43 +165,18 @@ bool js::temporal::IsValidEpochInstant(const Instant& instant) { return Instant::min() <= instant && instant <= Instant::max(); } -static constexpr auto NanosecondsMaxInstantSpan() { - static_assert(BigInt::DigitBits == 64 || BigInt::DigitBits == 32); - - // ±8.64 × 10^21 is the nanoseconds from epoch limit. - // 2 × 8.64 × 10^21 is 172_80000_00000_00000_00000 or 0x3a8_c02c5ea2_de000000. - // Return the BigInt digits of that number for fast BigInt comparisons. - if constexpr (BigInt::DigitBits == 64) { - return std::array{ - BigInt::Digit(0x3a8), - BigInt::Digit(0xc02c'5ea2'de00'0000), - }; - } else { - return std::array{ - BigInt::Digit(0x3a8), - BigInt::Digit(0xc02c'5ea2), - BigInt::Digit(0xde00'0000), - }; - } -} - +#ifdef DEBUG /** * Validates a nanoseconds amount is at most as large as the difference * between two valid nanoseconds from the epoch instants. - * - * Useful when we want to ensure a BigInt doesn't exceed a certain limit. */ -bool js::temporal::IsValidInstantSpan(const BigInt* nanoseconds) { - static constexpr auto spanLimit = NanosecondsMaxInstantSpan(); - return AbsoluteValueIsLessOrEqual<spanLimit>(nanoseconds); -} - bool js::temporal::IsValidInstantSpan(const InstantSpan& span) { MOZ_ASSERT(0 <= span.nanoseconds && span.nanoseconds <= 999'999'999); // Steps 1-3. return InstantSpan::min() <= span && span <= InstantSpan::max(); } +#endif /** * Return the BigInt as a 96-bit integer. The BigInt digits must not consist of @@ -258,14 +234,6 @@ Instant js::temporal::ToInstant(const BigInt* epochNanoseconds) { return {seconds, nanos}; } -InstantSpan js::temporal::ToInstantSpan(const BigInt* nanoseconds) { - MOZ_ASSERT(IsValidInstantSpan(nanoseconds)); - - auto [seconds, nanos] = - ToInt96(nanoseconds) / ToNanoseconds(TemporalUnit::Second); - return {seconds, nanos}; -} - static BigInt* CreateBigInt(JSContext* cx, const std::array<uint32_t, 3>& digits, bool negative) { @@ -300,9 +268,7 @@ static BigInt* CreateBigInt(JSContext* cx, } } -static BigInt* ToEpochBigInt(JSContext* cx, const InstantSpan& instant) { - MOZ_ASSERT(IsValidInstantSpan(instant)); - +static auto ToBigIntDigits(uint64_t seconds, uint32_t nanoseconds) { // Multiplies two uint32_t values and returns the lower 32-bits. The higher // 32-bits are stored in |high|. auto digitMul = [](uint32_t a, uint32_t b, uint32_t* high) { @@ -321,20 +287,6 @@ static BigInt* ToEpochBigInt(JSContext* cx, const InstantSpan& instant) { constexpr uint32_t secToNanos = ToNanoseconds(TemporalUnit::Second); - uint64_t seconds = std::abs(instant.seconds); - uint32_t nanoseconds = instant.nanoseconds; - - // Negative nanoseconds are represented as the difference to 1'000'000'000. - // Convert these back to their absolute value and adjust the seconds part - // accordingly. - // - // For example the nanoseconds from the epoch value |-1n| is represented as - // the instant {seconds: -1, nanoseconds: 999'999'999}. - if (instant.seconds < 0 && nanoseconds != 0) { - nanoseconds = secToNanos - nanoseconds; - seconds -= 1; - } - // uint32_t digits stored in the same order as BigInt digits, i.e. the least // significant digit is stored at index zero. std::array<uint32_t, 2> multiplicand = {uint32_t(seconds), @@ -362,93 +314,34 @@ static BigInt* ToEpochBigInt(JSContext* cx, const InstantSpan& instant) { MOZ_ASSERT(newCarry == 0); } - return CreateBigInt(cx, accumulator, instant.seconds < 0); -} - -BigInt* js::temporal::ToEpochNanoseconds(JSContext* cx, - const Instant& instant) { - MOZ_ASSERT(IsValidEpochInstant(instant)); - return ::ToEpochBigInt(cx, InstantSpan{instant.seconds, instant.nanoseconds}); -} - -BigInt* js::temporal::ToEpochNanoseconds(JSContext* cx, - const InstantSpan& instant) { - MOZ_ASSERT(IsValidInstantSpan(instant)); - return ::ToEpochBigInt(cx, instant); -} - -/** - * Return an Instant for the input nanoseconds if the input is less-or-equal to - * the maximum instant span. Otherwise returns nothing. - */ -static mozilla::Maybe<InstantSpan> NanosecondsToInstantSpan( - double nanoseconds) { - MOZ_ASSERT(IsInteger(nanoseconds)); - - if (auto int96 = Int96::fromInteger(nanoseconds)) { - constexpr auto maximum = Int96{InstantSpan::max().toSeconds()} * - ToNanoseconds(TemporalUnit::Second); - - // Accept if the value is less-or-equal to the maximum instant span. - if (int96->abs() <= maximum) { - // Split into seconds and nanoseconds. - auto [seconds, nanos] = *int96 / ToNanoseconds(TemporalUnit::Second); - - auto result = InstantSpan{seconds, nanos}; - MOZ_ASSERT(IsValidInstantSpan(result)); - return mozilla::Some(result); - } - } - return mozilla::Nothing(); + return accumulator; } -/** - * Return an Instant for the input microseconds if the input is less-or-equal to - * the maximum instant span. Otherwise returns nothing. - */ -static mozilla::Maybe<InstantSpan> MicrosecondsToInstantSpan( - double microseconds) { - MOZ_ASSERT(IsInteger(microseconds)); +template <typename T> +static BigInt* ToBigInt(JSContext* cx, + const SecondsAndNanoseconds<T>& secondsAndNanoseconds) { + uint64_t seconds = std::abs(secondsAndNanoseconds.seconds); + uint32_t nanoseconds = secondsAndNanoseconds.nanoseconds; - constexpr int64_t spanLimit = InstantSpan::max().toSeconds(); - constexpr int64_t secToMicros = ToNanoseconds(TemporalUnit::Second) / - ToNanoseconds(TemporalUnit::Microsecond); - constexpr int32_t microToNanos = ToNanoseconds(TemporalUnit::Microsecond); - - // Fast path for the common case. - if (microseconds == 0) { - return mozilla::Some(InstantSpan{}); - } - - // Reject if the value is larger than the maximum instant span. - if (std::abs(microseconds) > double(spanLimit) * double(secToMicros)) { - return mozilla::Nothing(); + // Negative nanoseconds are represented as the difference to 1'000'000'000. + // Convert these back to their absolute value and adjust the seconds part + // accordingly. + // + // For example the nanoseconds from the epoch value |-1n| is represented as + // the instant {seconds: -1, nanoseconds: 999'999'999}. + if (secondsAndNanoseconds.seconds < 0 && nanoseconds != 0) { + nanoseconds = ToNanoseconds(TemporalUnit::Second) - nanoseconds; + seconds -= 1; } - // |spanLimit| in microseconds is below UINT64_MAX, so we can use uint64 in - // the following computations. - static_assert(double(spanLimit) * double(secToMicros) <= double(UINT64_MAX)); - - // Use the absolute value and convert it then into uint64_t. - uint64_t absMicros = uint64_t(std::abs(microseconds)); - - // Seconds and remainder are small enough to fit into int64_t resp. int32_t. - int64_t seconds = absMicros / uint64_t(secToMicros); - int32_t remainder = absMicros % uint64_t(secToMicros); - - // Correct the sign of |seconds| and |remainder|, and then constrain - // |remainder| to the range [0, 999'999]. - if (microseconds < 0) { - seconds *= -1; - if (remainder != 0) { - seconds -= 1; - remainder = secToMicros - remainder; - } - } + auto digits = ToBigIntDigits(seconds, nanoseconds); + return CreateBigInt(cx, digits, secondsAndNanoseconds.seconds < 0); +} - InstantSpan result = {seconds, remainder * microToNanos}; - MOZ_ASSERT(IsValidInstantSpan(result)); - return mozilla::Some(result); +BigInt* js::temporal::ToEpochNanoseconds(JSContext* cx, + const Instant& instant) { + MOZ_ASSERT(IsValidEpochInstant(instant)); + return ::ToBigInt(cx, instant); } /** @@ -456,7 +349,7 @@ static mozilla::Maybe<InstantSpan> MicrosecondsToInstantSpan( * microsecond, nanosecond [ , offsetNanoseconds ] ) */ Instant js::temporal::GetUTCEpochNanoseconds(const PlainDateTime& dateTime) { - auto& [date, time] = dateTime; + const auto& [date, time] = dateTime; // Step 1. MOZ_ASSERT(IsValidISODateTime(dateTime)); @@ -579,13 +472,13 @@ Wrapped<InstantObject*> js::temporal::ToTemporalInstant(JSContext* cx, } } - // Steps 1.b-d and 3-6 + // Steps 1.b-d and 3-7 Instant epochNanoseconds; if (!ToTemporalInstant(cx, item, &epochNanoseconds)) { return nullptr; } - // Step 7. + // Step 8. return CreateTemporalInstant(cx, epochNanoseconds); } @@ -635,25 +528,25 @@ bool js::temporal::ToTemporalInstant(JSContext* cx, Handle<Value> item, } MOZ_ASSERT(std::abs(offset) < ToNanoseconds(TemporalUnit::Day)); - // Step 6. (Reordered) + // Steps 5-6. (Reordered) if (!ISODateTimeWithinLimits(dateTime)) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TEMPORAL_INSTANT_INVALID); return false; } - // Step 5. + // Step 4. auto epochNanoseconds = GetUTCEpochNanoseconds(dateTime, InstantSpan::fromNanoseconds(offset)); - // Step 6. + // Step 7. if (!IsValidEpochInstant(epochNanoseconds)) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TEMPORAL_INSTANT_INVALID); return false; } - // Step 7. + // Step 8. *result = epochNanoseconds; return true; } @@ -663,181 +556,75 @@ bool js::temporal::ToTemporalInstant(JSContext* cx, Handle<Value> item, * microseconds, nanoseconds ) */ bool js::temporal::AddInstant(JSContext* cx, const Instant& instant, - const Duration& duration, Instant* result) { + const NormalizedTimeDuration& duration, + Instant* result) { MOZ_ASSERT(IsValidEpochInstant(instant)); - MOZ_ASSERT(IsValidDuration(duration)); - MOZ_ASSERT(duration.years == 0); - MOZ_ASSERT(duration.months == 0); - MOZ_ASSERT(duration.weeks == 0); - MOZ_ASSERT(duration.days == 0); - - do { - auto nanoseconds = NanosecondsToInstantSpan(duration.nanoseconds); - if (!nanoseconds) { - break; - } - MOZ_ASSERT(IsValidInstantSpan(*nanoseconds)); - - auto microseconds = MicrosecondsToInstantSpan(duration.microseconds); - if (!microseconds) { - break; - } - MOZ_ASSERT(IsValidInstantSpan(*microseconds)); - - // Overflows for millis/seconds/minutes/hours always result in an invalid - // instant. - - int64_t milliseconds; - if (!mozilla::NumberEqualsInt64(duration.milliseconds, &milliseconds)) { - break; - } + MOZ_ASSERT(IsValidNormalizedTimeDuration(duration)); - int64_t seconds; - if (!mozilla::NumberEqualsInt64(duration.seconds, &seconds)) { - break; - } + // Step 1. (Inlined AddNormalizedTimeDurationToEpochNanoseconds) + auto r = instant + duration.to<InstantSpan>(); - int64_t minutes; - if (!mozilla::NumberEqualsInt64(duration.minutes, &minutes)) { - break; - } - - int64_t hours; - if (!mozilla::NumberEqualsInt64(duration.hours, &hours)) { - break; - } - - // Compute the overall amount of milliseconds to add. - mozilla::CheckedInt64 millis = hours; - millis *= 60; - millis += minutes; - millis *= 60; - millis += seconds; - millis *= 1000; - millis += milliseconds; - if (!millis.isValid()) { - break; - } - - auto milli = InstantSpan::fromMilliseconds(millis.value()); - if (!IsValidInstantSpan(milli)) { - break; - } - - // Compute the overall instant span. - auto span = milli + *microseconds + *nanoseconds; - if (!IsValidInstantSpan(span)) { - break; - } - - *result = instant + span; - if (IsValidEpochInstant(*result)) { - return true; - } - } while (false); + // Step 2. + if (!IsValidEpochInstant(r)) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_INSTANT_INVALID); + return false; + } - JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, - JSMSG_TEMPORAL_INSTANT_INVALID); - return false; + // Step 3. + *result = r; + return true; } /** - * DifferenceInstant ( ns1, ns2, roundingIncrement, smallestUnit, largestUnit, - * roundingMode ) + * DifferenceInstant ( ns1, ns2, roundingIncrement, smallestUnit, roundingMode ) */ -bool js::temporal::DifferenceInstant(JSContext* cx, const Instant& ns1, - const Instant& ns2, - Increment roundingIncrement, - TemporalUnit smallestUnit, - TemporalUnit largestUnit, - TemporalRoundingMode roundingMode, - Duration* result) { +NormalizedTimeDuration js::temporal::DifferenceInstant( + const Instant& ns1, const Instant& ns2, Increment roundingIncrement, + TemporalUnit smallestUnit, TemporalRoundingMode roundingMode) { MOZ_ASSERT(IsValidEpochInstant(ns1)); MOZ_ASSERT(IsValidEpochInstant(ns2)); - MOZ_ASSERT(largestUnit > TemporalUnit::Day); - MOZ_ASSERT(largestUnit <= smallestUnit); + MOZ_ASSERT(smallestUnit > TemporalUnit::Day); MOZ_ASSERT(roundingIncrement <= MaximumTemporalDurationRoundingIncrement(smallestUnit)); // Step 1. - auto diff = ns2 - ns1; - MOZ_ASSERT(IsValidInstantSpan(diff)); - - // Negative nanoseconds are represented as the difference to 1'000'000'000. - auto [seconds, nanoseconds] = diff; - if (seconds < 0 && nanoseconds != 0) { - seconds += 1; - nanoseconds -= ToNanoseconds(TemporalUnit::Second); - } - - // Steps 2-5. - Duration duration = { - 0, - 0, - 0, - 0, - 0, - 0, - double(seconds), - double((nanoseconds / 1000'000) % 1000), - double((nanoseconds / 1000) % 1000), - double(nanoseconds % 1000), - }; - MOZ_ASSERT(IsValidDuration(duration)); + auto diff = NormalizedTimeDurationFromEpochNanosecondsDifference(ns2, ns1); + MOZ_ASSERT(IsValidInstantSpan(diff.to<InstantSpan>())); - // Step 6. + // Step 2. if (smallestUnit == TemporalUnit::Nanosecond && roundingIncrement == Increment{1}) { - TimeDuration balanced; - if (!BalanceTimeDuration(cx, duration, largestUnit, &balanced)) { - return false; - } - MOZ_ASSERT(balanced.days == 0); - - *result = balanced.toDuration().time(); - return true; - } - - // Steps 7-8. - Duration roundResult; - if (!temporal::RoundDuration(cx, duration, roundingIncrement, smallestUnit, - roundingMode, &roundResult)) { - return false; - } - - // Step 9. - MOZ_ASSERT(roundResult.days == 0); - - // Step 10. - TimeDuration balanced; - if (!BalanceTimeDuration(cx, roundResult, largestUnit, &balanced)) { - return false; + return diff; } - MOZ_ASSERT(balanced.days == 0); - *result = balanced.toDuration().time(); - return true; + // Steps 3-4. + return RoundDuration(diff, roundingIncrement, smallestUnit, roundingMode); } /** * RoundNumberToIncrementAsIfPositive ( x, increment, roundingMode ) */ -static bool RoundNumberToIncrementAsIfPositive( - JSContext* cx, const Instant& x, int64_t increment, - TemporalRoundingMode roundingMode, Instant* result) { +static Instant RoundNumberToIncrementAsIfPositive( + const Instant& x, int64_t increment, TemporalRoundingMode roundingMode) { + MOZ_ASSERT(IsValidEpochInstant(x)); + MOZ_ASSERT(increment > 0); + MOZ_ASSERT(increment <= ToNanoseconds(TemporalUnit::Day)); + // This operation is equivalent to adjusting the rounding mode through // |ToPositiveRoundingMode| and then calling |RoundNumberToIncrement|. - return RoundNumberToIncrement(cx, x, increment, - ToPositiveRoundingMode(roundingMode), result); + auto rounded = RoundNumberToIncrement(x.toNanoseconds(), Int128{increment}, + ToPositiveRoundingMode(roundingMode)); + return Instant::fromNanoseconds(rounded); } /** * RoundTemporalInstant ( ns, increment, unit, roundingMode ) */ -bool js::temporal::RoundTemporalInstant(JSContext* cx, const Instant& ns, - Increment increment, TemporalUnit unit, - TemporalRoundingMode roundingMode, - Instant* result) { +Instant js::temporal::RoundTemporalInstant(const Instant& ns, + Increment increment, + TemporalUnit unit, + TemporalRoundingMode roundingMode) { MOZ_ASSERT(IsValidEpochInstant(ns)); MOZ_ASSERT(increment >= Increment::min()); MOZ_ASSERT(uint64_t(increment.value()) <= ToNanoseconds(TemporalUnit::Day)); @@ -851,7 +638,7 @@ bool js::temporal::RoundTemporalInstant(JSContext* cx, const Instant& ns, // Step 7. return RoundNumberToIncrementAsIfPositive( - cx, ns, increment.value() * toNanoseconds, roundingMode, result); + ns, increment.value() * toNanoseconds, roundingMode); } /** @@ -903,19 +690,23 @@ static bool DifferenceTemporalInstant(JSContext* cx, } // Step 5. - Duration difference; - if (!DifferenceInstant(cx, instant, other, settings.roundingIncrement, - settings.smallestUnit, settings.largestUnit, - settings.roundingMode, &difference)) { + auto difference = + DifferenceInstant(instant, other, settings.roundingIncrement, + settings.smallestUnit, settings.roundingMode); + + // Step 6. + TimeDuration balanced; + if (!BalanceTimeDuration(cx, difference, settings.largestUnit, &balanced)) { return false; } - // Step 6. + // Step 7. + auto duration = balanced.toDuration(); if (operation == TemporalDifference::Since) { - difference = difference.negate(); + duration = duration.negate(); } - auto* obj = CreateTemporalDuration(cx, difference); + auto* obj = CreateTemporalDuration(cx, duration); if (!obj) { return false; } @@ -959,13 +750,15 @@ static bool AddDurationToOrSubtractDurationFromInstant( if (operation == InstantDuration::Subtract) { duration = duration.negate(); } + auto timeDuration = NormalizeTimeDuration(duration); + // Step 8. Instant ns; - if (!AddInstant(cx, epochNanoseconds, duration, &ns)) { + if (!AddInstant(cx, epochNanoseconds, timeDuration, &ns)) { return false; } - // Step 8. + // Step 9. auto* result = CreateTemporalInstant(cx, ns); if (!result) { return false; @@ -1063,7 +856,8 @@ static bool Instant_fromEpochSeconds(JSContext* cx, unsigned argc, Value* vp) { } // Step 5. - auto* result = CreateTemporalInstant(cx, Instant::fromSeconds(epochSeconds)); + int64_t seconds = mozilla::AssertedCast<int64_t>(epochSeconds); + auto* result = CreateTemporalInstant(cx, Instant::fromSeconds(seconds)); if (!result) { return false; } @@ -1106,8 +900,9 @@ static bool Instant_fromEpochMilliseconds(JSContext* cx, unsigned argc, } // Step 5. + int64_t milliseconds = mozilla::AssertedCast<int64_t>(epochMilliseconds); auto* result = - CreateTemporalInstant(cx, Instant::fromMilliseconds(epochMilliseconds)); + CreateTemporalInstant(cx, Instant::fromMilliseconds(milliseconds)); if (!result) { return false; } @@ -1413,7 +1208,7 @@ static bool Instant_round(JSContext* cx, const CallArgs& args) { } // Steps 10-15. - uint64_t maximum = UnitsPerDay(smallestUnit); + int64_t maximum = UnitsPerDay(smallestUnit); // Step 16. if (!ValidateTemporalRoundingIncrement(cx, roundingIncrement, maximum, @@ -1423,11 +1218,8 @@ static bool Instant_round(JSContext* cx, const CallArgs& args) { } // Step 17. - Instant roundedNs; - if (!RoundTemporalInstant(cx, instant, roundingIncrement, smallestUnit, - roundingMode, &roundedNs)) { - return false; - } + auto roundedNs = RoundTemporalInstant(instant, roundingIncrement, + smallestUnit, roundingMode); // Step 18. auto* result = CreateTemporalInstant(cx, roundedNs); @@ -1535,11 +1327,8 @@ static bool Instant_toString(JSContext* cx, const CallArgs& args) { } // Step 12. - Instant ns; - if (!RoundTemporalInstant(cx, instant, precision.increment, precision.unit, - roundingMode, &ns)) { - return false; - } + auto ns = RoundTemporalInstant(instant, precision.increment, precision.unit, + roundingMode); // Step 13. Rooted<InstantObject*> roundedInstant(cx, CreateTemporalInstant(cx, ns)); diff --git a/js/src/builtin/temporal/Instant.h b/js/src/builtin/temporal/Instant.h index edce677d10..9ad7f159db 100644 --- a/js/src/builtin/temporal/Instant.h +++ b/js/src/builtin/temporal/Instant.h @@ -69,15 +69,12 @@ bool IsValidEpochNanoseconds(const JS::BigInt* epochNanoseconds); */ bool IsValidEpochInstant(const Instant& instant); +#ifdef DEBUG /** * Return true if the input is within the valid instant span limits. */ bool IsValidInstantSpan(const InstantSpan& span); - -/** - * Return true if the input is within the valid instant span limits. - */ -bool IsValidInstantSpan(const JS::BigInt* nanoseconds); +#endif /** * Convert a BigInt to an instant. The input must be a valid epoch nanoseconds @@ -86,22 +83,11 @@ bool IsValidInstantSpan(const JS::BigInt* nanoseconds); Instant ToInstant(const JS::BigInt* epochNanoseconds); /** - * Convert a BigInt to an instant span. The input must be a valid epoch - * nanoseconds span value. - */ -InstantSpan ToInstantSpan(const JS::BigInt* nanoseconds); - -/** * Convert an instant to a BigInt. The input must be a valid epoch instant. */ JS::BigInt* ToEpochNanoseconds(JSContext* cx, const Instant& instant); /** - * Convert an instant span to a BigInt. The input must be a valid instant span. - */ -JS::BigInt* ToEpochNanoseconds(JSContext* cx, const InstantSpan& instant); - -/** * ToTemporalInstant ( item ) */ Wrapped<InstantObject*> ToTemporalInstant(JSContext* cx, @@ -134,25 +120,23 @@ Instant GetUTCEpochNanoseconds(const PlainDateTime& dateTime, /** * RoundTemporalInstant ( ns, increment, unit, roundingMode ) */ -bool RoundTemporalInstant(JSContext* cx, const Instant& ns, Increment increment, - TemporalUnit unit, TemporalRoundingMode roundingMode, - Instant* result); +Instant RoundTemporalInstant(const Instant& ns, Increment increment, + TemporalUnit unit, + TemporalRoundingMode roundingMode); /** - * AddInstant ( epochNanoseconds, hours, minutes, seconds, milliseconds, - * microseconds, nanoseconds ) + * AddInstant ( epochNanoseconds, norm ) */ -bool AddInstant(JSContext* cx, const Instant& instant, const Duration& duration, - Instant* result); +bool AddInstant(JSContext* cx, const Instant& instant, + const NormalizedTimeDuration& duration, Instant* result); /** - * DifferenceInstant ( ns1, ns2, roundingIncrement, smallestUnit, largestUnit, - * roundingMode ) + * DifferenceInstant ( ns1, ns2, roundingIncrement, smallestUnit, roundingMode ) */ -bool DifferenceInstant(JSContext* cx, const Instant& ns1, const Instant& ns2, - Increment roundingIncrement, TemporalUnit smallestUnit, - TemporalUnit largestUnit, - TemporalRoundingMode roundingMode, Duration* result); +NormalizedTimeDuration DifferenceInstant(const Instant& ns1, const Instant& ns2, + Increment roundingIncrement, + TemporalUnit smallestUnit, + TemporalRoundingMode roundingMode); } /* namespace js::temporal */ diff --git a/js/src/builtin/temporal/Int128.cpp b/js/src/builtin/temporal/Int128.cpp new file mode 100644 index 0000000000..e712a64be6 --- /dev/null +++ b/js/src/builtin/temporal/Int128.cpp @@ -0,0 +1,161 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: set ts=8 sts=2 et sw=2 tw=80: + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "builtin/temporal/Int128.h" + +#include "mozilla/Assertions.h" +#include "mozilla/Casting.h" +#include "mozilla/FloatingPoint.h" +#include "mozilla/MathAlgorithms.h" + +#include <stdint.h> + +using namespace js; +using namespace js::temporal; + +double Uint128::toDouble(const Uint128& x, bool negative) { + // Simplified version of |BigInt::numberValue()| for DigitBits=64. See the + // comments in |BigInt::numberValue()| for how this code works. + + using Double = mozilla::FloatingPoint<double>; + constexpr uint8_t ExponentShift = Double::kExponentShift; + constexpr uint8_t SignificandWidth = Double::kSignificandWidth; + constexpr unsigned ExponentBias = Double::kExponentBias; + constexpr uint8_t SignShift = Double::kExponentWidth + SignificandWidth; + + constexpr uint64_t MaxIntegralPrecisionDouble = uint64_t(1) + << (SignificandWidth + 1); + + // We compute the final mantissa of the result, shifted upward to the top of + // the `uint64_t` space -- plus an extra bit to detect potential rounding. + constexpr uint8_t BitsNeededForShiftedMantissa = SignificandWidth + 1; + + uint64_t shiftedMantissa = 0; + uint64_t exponent = 0; + + // If the extra bit is set, correctly rounding the result may require + // examining all lower-order bits. Also compute 1) the index of the Digit + // storing the extra bit, and 2) whether bits beneath the extra bit in that + // Digit are nonzero so we can round if needed. + uint64_t bitsBeneathExtraBitInDigitContainingExtraBit = 0; + + if (x.high == 0) { + uint64_t msd = x.low; + + // Fast path for the likely-common case of up to a uint64_t of magnitude not + // exceeding integral precision in IEEE-754. + if (msd <= MaxIntegralPrecisionDouble) { + return negative ? -double(msd) : +double(msd); + } + + const uint8_t msdLeadingZeroes = mozilla::CountLeadingZeroes64(msd); + MOZ_ASSERT(0 <= msdLeadingZeroes && msdLeadingZeroes <= 10, + "leading zeroes is at most 10 when the fast path isn't taken"); + + exponent = 64 - msdLeadingZeroes - 1; + + // Omit the most significant bit: the IEEE-754 format includes this bit + // implicitly for all double-precision integers. + const uint8_t msdIgnoredBits = msdLeadingZeroes + 1; + MOZ_ASSERT(1 <= msdIgnoredBits && msdIgnoredBits <= 11); + + const uint8_t msdIncludedBits = 64 - msdIgnoredBits; + MOZ_ASSERT(53 <= msdIncludedBits && msdIncludedBits <= 63); + MOZ_ASSERT(msdIncludedBits >= BitsNeededForShiftedMantissa); + + // Munge the most significant bits of the number into proper + // position in an IEEE-754 double and go to town. + + // Shift `msd`'s contributed bits upward to remove high-order zeroes and the + // highest set bit (which is implicit in IEEE-754 integral values so must be + // removed) and to add low-order zeroes. (Lower-order garbage bits are + // discarded when `shiftedMantissa` is converted to a real mantissa.) + shiftedMantissa = msd << (64 - msdIncludedBits); + + // Add shifted bits to `shiftedMantissa` until we have a complete mantissa + // and an extra bit. + const uint8_t countOfBitsInDigitBelowExtraBit = + 64 - BitsNeededForShiftedMantissa - msdIgnoredBits; + bitsBeneathExtraBitInDigitContainingExtraBit = + msd & ((uint64_t(1) << countOfBitsInDigitBelowExtraBit) - 1); + } else { + uint64_t msd = x.high; + uint64_t second = x.low; + + uint8_t msdLeadingZeroes = mozilla::CountLeadingZeroes64(msd); + + exponent = 2 * 64 - msdLeadingZeroes - 1; + + // Munge the most significant bits of the number into proper + // position in an IEEE-754 double and go to town. + + // Omit the most significant bit: the IEEE-754 format includes this bit + // implicitly for all double-precision integers. + const uint8_t msdIgnoredBits = msdLeadingZeroes + 1; + const uint8_t msdIncludedBits = 64 - msdIgnoredBits; + + // Shift `msd`'s contributed bits upward to remove high-order zeroes and the + // highest set bit (which is implicit in IEEE-754 integral values so must be + // removed) and to add low-order zeroes. (Lower-order garbage bits are + // discarded when `shiftedMantissa` is converted to a real mantissa.) + shiftedMantissa = msdIncludedBits == 0 ? 0 : msd << (64 - msdIncludedBits); + + // Add shifted bits to `shiftedMantissa` until we have a complete mantissa + // and an extra bit. + if (msdIncludedBits >= BitsNeededForShiftedMantissa) { + const uint8_t countOfBitsInDigitBelowExtraBit = + 64 - BitsNeededForShiftedMantissa - msdIgnoredBits; + bitsBeneathExtraBitInDigitContainingExtraBit = + msd & ((uint64_t(1) << countOfBitsInDigitBelowExtraBit) - 1); + + if (bitsBeneathExtraBitInDigitContainingExtraBit == 0) { + bitsBeneathExtraBitInDigitContainingExtraBit = second; + } + } else { + shiftedMantissa |= second >> msdIncludedBits; + + const uint8_t countOfBitsInSecondDigitBelowExtraBit = + (msdIncludedBits + 64) - BitsNeededForShiftedMantissa; + bitsBeneathExtraBitInDigitContainingExtraBit = + second << (64 - countOfBitsInSecondDigitBelowExtraBit); + } + } + + constexpr uint64_t LeastSignificantBit = uint64_t(1) + << (64 - SignificandWidth); + constexpr uint64_t ExtraBit = LeastSignificantBit >> 1; + + // The extra bit must be set for rounding to change the mantissa. + if ((shiftedMantissa & ExtraBit) != 0) { + bool shouldRoundUp; + if (shiftedMantissa & LeastSignificantBit) { + // If the lowest mantissa bit is set, it doesn't matter what lower bits + // are: nearest-even rounds up regardless. + shouldRoundUp = true; + } else { + // If the lowest mantissa bit is unset, *all* lower bits are relevant. + // All-zero bits below the extra bit situates `x` halfway between two + // values, and the nearest *even* value lies downward. But if any bit + // below the extra bit is set, `x` is closer to the rounded-up value. + shouldRoundUp = bitsBeneathExtraBitInDigitContainingExtraBit != 0; + } + + if (shouldRoundUp) { + // Add one to the significand bits. If they overflow, the exponent must + // also be increased. If *that* overflows, return the correct infinity. + uint64_t before = shiftedMantissa; + shiftedMantissa += ExtraBit; + if (shiftedMantissa < before) { + exponent++; + } + } + } + + uint64_t significandBits = shiftedMantissa >> (64 - SignificandWidth); + uint64_t signBit = uint64_t(negative ? 1 : 0) << SignShift; + uint64_t exponentBits = (exponent + ExponentBias) << ExponentShift; + return mozilla::BitwiseCast<double>(signBit | exponentBits | significandBits); +} diff --git a/js/src/builtin/temporal/Int128.h b/js/src/builtin/temporal/Int128.h new file mode 100644 index 0000000000..b32edb4da5 --- /dev/null +++ b/js/src/builtin/temporal/Int128.h @@ -0,0 +1,742 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: set ts=8 sts=2 et sw=2 tw=80: + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef builtin_temporal_Int128_h +#define builtin_temporal_Int128_h + +#include "mozilla/Assertions.h" +#include "mozilla/EndianUtils.h" +#include "mozilla/MathAlgorithms.h" + +#include <climits> +#include <limits> +#include <stdint.h> +#include <utility> + +namespace js::temporal { + +class Int128; +class Uint128; + +/** + * Unsigned 128-bit integer, implemented as a pair of unsigned 64-bit integers. + * + * Supports all basic arithmetic operators. + */ +class alignas(16) Uint128 final { +#if MOZ_LITTLE_ENDIAN() + uint64_t low = 0; + uint64_t high = 0; +#else + uint64_t high = 0; + uint64_t low = 0; +#endif + + friend class Int128; + + constexpr Uint128(uint64_t low, uint64_t high) : low(low), high(high) {} + + /** + * Return the high double-word of the multiplication of `u * v`. + * + * Based on "Multiply high unsigned" from Hacker's Delight, 2nd edition, + * figure 8-2. + */ + static constexpr uint64_t mulhu(uint64_t u, uint64_t v) { + uint64_t u0 = u & 0xffff'ffff; + uint64_t u1 = u >> 32; + + uint64_t v0 = v & 0xffff'ffff; + uint64_t v1 = v >> 32; + + uint64_t w0 = u0 * v0; + uint64_t t = u1 * v0 + (w0 >> 32); + uint64_t w1 = t & 0xffff'ffff; + uint64_t w2 = t >> 32; + w1 = u0 * v1 + w1; + return u1 * v1 + w2 + (w1 >> 32); + } + + /** + * Based on "Unsigned doubleword division from long division" from + * Hacker's Delight, 2nd edition, figure 9-5. + */ + static constexpr std::pair<Uint128, Uint128> udivdi(const Uint128& u, + const Uint128& v) { + MOZ_ASSERT(v != Uint128{}); + + // If v < 2**64 + if (v.high == 0) { + // If u < 2**64 + if (u.high == 0) { + // Prefer built-in division if possible. + return {Uint128{u.low / v.low, 0}, Uint128{u.low % v.low, 0}}; + } + + // If u/v cannot overflow, just do one division. + if (Uint128{u.high, 0} < v) { + auto [q, r] = divlu(u.high, u.low, v.low); + return {Uint128{q, 0}, Uint128{r, 0}}; + } + + // If u/v would overflow: Break u up into two halves. + + // First quotient digit and first remainder, < v. + auto [q1, r1] = divlu(0, u.high, v.low); + + // Second quotient digit. + auto [q0, r0] = divlu(r1, u.low, v.low); + + // Return quotient and remainder. + return {Uint128{q0, q1}, Uint128{r0, 0}}; + } + + // Here v >= 2**64. + + // 0 <= n <= 63 + auto n = mozilla::CountLeadingZeroes64(v.high); + + // Normalize the divisor so its MSB is 1. + auto v1 = (v << n).high; + + // To ensure no overflow. + auto u1 = u >> 1; + + // Get quotient from divide unsigned instruction. + auto [q1, r1] = divlu(u1.high, u1.low, v1); + + // Undo normalization and division of u by 2. + auto q0 = (Uint128{q1, 0} << n) >> 63; + + // Make q0 correct or too small by 1. + if (q0 != Uint128{0}) { + q0 -= Uint128{1}; + } + + // Now q0 is correct. + auto r0 = u - q0 * v; + if (r0 >= v) { + q0 += Uint128{1}; + r0 -= v; + } + + // Return quotient and remainder. + return {q0, r0}; + } + + /** + * Based on "Divide long unsigned, using fullword division instructions" from + * Hacker's Delight, 2nd edition, figure 9-3. + */ + static constexpr std::pair<uint64_t, uint64_t> divlu(uint64_t u1, uint64_t u0, + uint64_t v) { + // Number base (32 bits). + constexpr uint64_t base = 4294967296; + + // If overflow, set the remainder to an impossible value and return the + // largest possible quotient. + if (u1 >= v) { + return {UINT64_MAX, UINT64_MAX}; + } + + // Shift amount for normalization. (0 <= s <= 63) + int64_t s = mozilla::CountLeadingZeroes64(v); + + // Normalize the divisor. + v = v << s; + + // Normalized divisor digits. + // + // Break divisor up into two 32-bit digits. + uint64_t vn1 = v >> 32; + uint64_t vn0 = uint32_t(v); + + // Dividend digit pairs. + // + // Shift dividend left. + uint64_t un32 = (u1 << s) | ((u0 >> ((64 - s) & 63)) & (-s >> 63)); + uint64_t un10 = u0 << s; + + // Normalized dividend least significant digits. + // + // Break right half of dividend into two digits. + uint64_t un1 = un10 >> 32; + uint64_t un0 = uint32_t(un10); + + // Compute the first quotient digit and its remainder. + uint64_t q1 = un32 / vn1; + uint64_t rhat = un32 - q1 * vn1; + while (q1 >= base || q1 * vn0 > base * rhat + un1) { + q1 -= 1; + rhat += vn1; + if (rhat >= base) { + break; + } + } + + // Multiply and subtract. + uint64_t un21 = un32 * base + un1 - q1 * v; + + // Compute the second quotient digit and its remainder. + uint64_t q0 = un21 / vn1; + rhat = un21 - q0 * vn1; + while (q0 >= base || q0 * vn0 > base * rhat + un0) { + q0 -= 1; + rhat += vn1; + if (rhat >= base) { + break; + } + } + + // Return the quotient and remainder. + uint64_t q = q1 * base + q0; + uint64_t r = (un21 * base + un0 - q0 * v) >> s; + return {q, r}; + } + + static double toDouble(const Uint128& x, bool negative); + + public: + constexpr Uint128() = default; + constexpr Uint128(const Uint128&) = default; + + explicit constexpr Uint128(uint64_t value) + : Uint128(uint64_t(value), uint64_t(0)) {} + + constexpr bool operator==(const Uint128& other) const { + return low == other.low && high == other.high; + } + + constexpr bool operator<(const Uint128& other) const { + if (high == other.high) { + return low < other.low; + } + return high < other.high; + } + + // Other operators are implemented in terms of operator== and operator<. + constexpr bool operator!=(const Uint128& other) const { + return !(*this == other); + } + constexpr bool operator>(const Uint128& other) const { return other < *this; } + constexpr bool operator<=(const Uint128& other) const { + return !(other < *this); + } + constexpr bool operator>=(const Uint128& other) const { + return !(*this < other); + } + + explicit constexpr operator bool() const { return !(*this == Uint128{}); } + + explicit constexpr operator int8_t() const { return int8_t(low); } + explicit constexpr operator int16_t() const { return int16_t(low); } + explicit constexpr operator int32_t() const { return int32_t(low); } + explicit constexpr operator int64_t() const { return int64_t(low); } + + explicit constexpr operator uint8_t() const { return uint8_t(low); } + explicit constexpr operator uint16_t() const { return uint16_t(low); } + explicit constexpr operator uint32_t() const { return uint32_t(low); } + explicit constexpr operator uint64_t() const { return uint64_t(low); } + + explicit constexpr operator Int128() const; + + explicit operator double() const { return toDouble(*this, false); } + + constexpr Uint128 operator+(const Uint128& other) const { + // "§2-16 Double-Length Add/Subtract" from Hacker's Delight, 2nd edition. + Uint128 result; + result.low = low + other.low; + result.high = high + other.high + static_cast<uint64_t>(result.low < low); + return result; + } + + constexpr Uint128 operator-(const Uint128& other) const { + // "§2-16 Double-Length Add/Subtract" from Hacker's Delight, 2nd edition. + Uint128 result; + result.low = low - other.low; + result.high = high - other.high - static_cast<uint64_t>(low < other.low); + return result; + } + + constexpr Uint128 operator*(const Uint128& other) const { + uint64_t w01 = low * other.high; + uint64_t w10 = high * other.low; + uint64_t w00 = mulhu(low, other.low); + + uint64_t w1 = w00 + w10 + w01; + uint64_t w0 = low * other.low; + + return Uint128{w0, w1}; + } + + /** + * Return the quotient and remainder of the division. + */ + constexpr std::pair<Uint128, Uint128> divrem(const Uint128& divisor) const { + return udivdi(*this, divisor); + } + + constexpr Uint128 operator/(const Uint128& other) const { + auto [quot, rem] = divrem(other); + return quot; + } + + constexpr Uint128 operator%(const Uint128& other) const { + auto [quot, rem] = divrem(other); + return rem; + } + + constexpr Uint128 operator<<(int shift) const { + MOZ_ASSERT(0 <= shift && shift <= 127, "undefined shift amount"); + + // Ensure the shift amount is in range. + shift &= 127; + + // "§2-17 Double-Length Shifts" from Hacker's Delight, 2nd edition. + if (shift >= 64) { + uint64_t y0 = 0; + uint64_t y1 = low << (shift - 64); + return Uint128{y0, y1}; + } + uint64_t y0 = low << shift; + uint64_t y1 = (high << shift) | (low >> (64 - shift)); + return Uint128{y0, y1}; + } + + constexpr Uint128 operator>>(int shift) const { + MOZ_ASSERT(0 <= shift && shift <= 127, "undefined shift amount"); + + // Ensure the shift amount is in range. + shift &= 127; + + // "§2-17 Double-Length Shifts" from Hacker's Delight, 2nd edition. + if (shift >= 64) { + uint64_t y0 = high >> (shift - 64); + uint64_t y1 = 0; + return Uint128{y0, y1}; + } + uint64_t y0 = low >> shift | high << (64 - shift); + uint64_t y1 = high >> shift; + return Uint128{y0, y1}; + } + + constexpr Uint128 operator&(const Uint128& other) const { + return Uint128{low & other.low, high & other.high}; + } + + constexpr Uint128 operator|(const Uint128& other) const { + return Uint128{low | other.low, high | other.high}; + } + + constexpr Uint128 operator^(const Uint128& other) const { + return Uint128{low ^ other.low, high ^ other.high}; + } + + constexpr Uint128 operator~() const { return Uint128{~low, ~high}; } + + constexpr Uint128 operator-() const { return Uint128{} - *this; } + + constexpr Uint128 operator+() const { return *this; } + + constexpr Uint128& operator++() { + *this = *this + Uint128{1, 0}; + return *this; + } + + constexpr Uint128 operator++(int) { + auto result = *this; + ++*this; + return result; + } + + constexpr Uint128& operator--() { + *this = *this - Uint128{1, 0}; + return *this; + } + + constexpr Uint128 operator--(int) { + auto result = *this; + --*this; + return result; + } + + constexpr Uint128 operator+=(const Uint128& other) { + *this = *this + other; + return *this; + } + + constexpr Uint128 operator-=(const Uint128& other) { + *this = *this - other; + return *this; + } + + constexpr Uint128 operator*=(const Uint128& other) { + *this = *this * other; + return *this; + } + + constexpr Uint128 operator/=(const Uint128& other) { + *this = *this / other; + return *this; + } + + constexpr Uint128 operator%=(const Uint128& other) { + *this = *this % other; + return *this; + } + + constexpr Uint128 operator&=(const Uint128& other) { + *this = *this & other; + return *this; + } + + constexpr Uint128 operator|=(const Uint128& other) { + *this = *this | other; + return *this; + } + + constexpr Uint128 operator^=(const Uint128& other) { + *this = *this ^ other; + return *this; + } + + constexpr Uint128 operator<<=(int shift) { + *this = *this << shift; + return *this; + } + + constexpr Uint128 operator>>=(int shift) { + *this = *this >> shift; + return *this; + } +}; + +/** + * Signed 128-bit integer, implemented as a pair of unsigned 64-bit integers. + * + * Supports all basic arithmetic operators. + */ +class alignas(16) Int128 final { +#if MOZ_LITTLE_ENDIAN() + uint64_t low = 0; + uint64_t high = 0; +#else + uint64_t high = 0; + uint64_t low = 0; +#endif + + friend class Uint128; + + constexpr Int128(uint64_t low, uint64_t high) : low(low), high(high) {} + + /** + * Based on "Signed doubleword division from unsigned doubleword division" + * from Hacker's Delight, 2nd edition, figure 9-6. + */ + static constexpr std::pair<Int128, Int128> divdi(const Int128& u, + const Int128& v) { + auto [q, r] = Uint128::udivdi(u.abs(), v.abs()); + + // If u and v have different signs, negate q. + // If is negative, negate r. + auto t = static_cast<Uint128>((u ^ v) >> 127); + auto s = static_cast<Uint128>(u >> 127); + return {static_cast<Int128>((q ^ t) - t), static_cast<Int128>((r ^ s) - s)}; + } + + public: + constexpr Int128() = default; + constexpr Int128(const Int128&) = default; + + explicit constexpr Int128(int64_t value) + : Int128(uint64_t(value), uint64_t(value >> 63)) {} + + /** + * Return the quotient and remainder of the division. + */ + constexpr std::pair<Int128, Int128> divrem(const Int128& divisor) const { + return divdi(*this, divisor); + } + + /** + * Return the absolute value of this integer. + */ + constexpr Uint128 abs() const { + if (*this >= Int128{}) { + return Uint128{low, high}; + } + auto neg = -*this; + return Uint128{neg.low, neg.high}; + } + + constexpr bool operator==(const Int128& other) const { + return low == other.low && high == other.high; + } + + constexpr bool operator<(const Int128& other) const { + if (high == other.high) { + return low < other.low; + } + return int64_t(high) < int64_t(other.high); + } + + // Other operators are implemented in terms of operator== and operator<. + constexpr bool operator!=(const Int128& other) const { + return !(*this == other); + } + constexpr bool operator>(const Int128& other) const { return other < *this; } + constexpr bool operator<=(const Int128& other) const { + return !(other < *this); + } + constexpr bool operator>=(const Int128& other) const { + return !(*this < other); + } + + explicit constexpr operator bool() const { return !(*this == Int128{}); } + + explicit constexpr operator int8_t() const { return int8_t(low); } + explicit constexpr operator int16_t() const { return int16_t(low); } + explicit constexpr operator int32_t() const { return int32_t(low); } + explicit constexpr operator int64_t() const { return int64_t(low); } + + explicit constexpr operator uint8_t() const { return uint8_t(low); } + explicit constexpr operator uint16_t() const { return uint16_t(low); } + explicit constexpr operator uint32_t() const { return uint32_t(low); } + explicit constexpr operator uint64_t() const { return uint64_t(low); } + + explicit constexpr operator Uint128() const { return Uint128{low, high}; } + + explicit operator double() const { + return Uint128::toDouble(abs(), *this < Int128{0}); + } + + constexpr Int128 operator+(const Int128& other) const { + return Int128{Uint128{*this} + Uint128{other}}; + } + + constexpr Int128 operator-(const Int128& other) const { + return Int128{Uint128{*this} - Uint128{other}}; + } + + constexpr Int128 operator*(const Int128& other) const { + return Int128{Uint128{*this} * Uint128{other}}; + } + + constexpr Int128 operator/(const Int128& other) const { + auto [quot, rem] = divrem(other); + return quot; + } + + constexpr Int128 operator%(const Int128& other) const { + auto [quot, rem] = divrem(other); + return rem; + } + + constexpr Int128 operator<<(int shift) const { + return Int128{Uint128{*this} << shift}; + } + + constexpr Int128 operator>>(int shift) const { + MOZ_ASSERT(0 <= shift && shift <= 127, "undefined shift amount"); + + // Ensure the shift amount is in range. + shift &= 127; + + // "§2-17 Double-Length Shifts" from Hacker's Delight, 2nd edition. + if (shift >= 64) { + uint64_t y0 = uint64_t(int64_t(high) >> (shift - 64)); + uint64_t y1 = uint64_t(int64_t(high) >> 63); + return Int128{y0, y1}; + } + uint64_t y0 = low >> shift | high << (64 - shift); + uint64_t y1 = uint64_t(int64_t(high) >> shift); + return Int128{y0, y1}; + } + + constexpr Int128 operator&(const Int128& other) const { + return Int128{low & other.low, high & other.high}; + } + + constexpr Int128 operator|(const Int128& other) const { + return Int128{low | other.low, high | other.high}; + } + + constexpr Int128 operator^(const Int128& other) const { + return Int128{low ^ other.low, high ^ other.high}; + } + + constexpr Int128 operator~() const { return Int128{~low, ~high}; } + + constexpr Int128 operator-() const { return Int128{} - *this; } + + constexpr Int128 operator+() const { return *this; } + + constexpr Int128& operator++() { + *this = *this + Int128{1, 0}; + return *this; + } + + constexpr Int128 operator++(int) { + auto result = *this; + ++*this; + return result; + } + + constexpr Int128& operator--() { + *this = *this - Int128{1, 0}; + return *this; + } + + constexpr Int128 operator--(int) { + auto result = *this; + --*this; + return result; + } + + constexpr Int128 operator+=(const Int128& other) { + *this = *this + other; + return *this; + } + + constexpr Int128 operator-=(const Int128& other) { + *this = *this - other; + return *this; + } + + constexpr Int128 operator*=(const Int128& other) { + *this = *this * other; + return *this; + } + + constexpr Int128 operator/=(const Int128& other) { + *this = *this / other; + return *this; + } + + constexpr Int128 operator%=(const Int128& other) { + *this = *this % other; + return *this; + } + + constexpr Int128 operator&=(const Int128& other) { + *this = *this & other; + return *this; + } + + constexpr Int128 operator|=(const Int128& other) { + *this = *this | other; + return *this; + } + + constexpr Int128 operator^=(const Int128& other) { + *this = *this ^ other; + return *this; + } + + constexpr Int128 operator<<=(int shift) { + *this = *this << shift; + return *this; + } + + constexpr Int128 operator>>=(int shift) { + *this = *this >> shift; + return *this; + } +}; + +constexpr Uint128::operator Int128() const { return Int128{low, high}; } + +} /* namespace js::temporal */ + +template <> +class std::numeric_limits<js::temporal::Int128> { + public: + static constexpr bool is_specialized = true; + static constexpr bool is_signed = true; + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_NaN = false; + static constexpr bool has_signaling_NaN = false; + static constexpr std::float_denorm_style has_denorm = std::denorm_absent; + static constexpr bool has_denorm_loss = false; + static constexpr std::float_round_style round_style = std::round_toward_zero; + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = true; + static constexpr int digits = CHAR_BIT * sizeof(js::temporal::Int128) - 1; + static constexpr int digits10 = int(digits * /* std::log10(2) */ 0.30102999); + static constexpr int max_digits10 = 0; + static constexpr int radix = 2; + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; + static constexpr bool traps = true; + static constexpr bool tinyness_before = false; + + static constexpr auto min() noexcept { + return js::temporal::Int128{1} << 127; + } + static constexpr auto lowest() noexcept { return min(); } + static constexpr auto max() noexcept { return ~min(); } + static constexpr auto epsilon() noexcept { return js::temporal::Int128{}; } + static constexpr auto round_error() noexcept { + return js::temporal::Int128{}; + } + static constexpr auto infinity() noexcept { return js::temporal::Int128{}; } + static constexpr auto quiet_NaN() noexcept { return js::temporal::Int128{}; } + static constexpr auto signaling_NaN() noexcept { + return js::temporal::Int128{}; + } + static constexpr auto denorm_min() noexcept { return js::temporal::Int128{}; } +}; + +template <> +class std::numeric_limits<js::temporal::Uint128> { + public: + static constexpr bool is_specialized = true; + static constexpr bool is_signed = false; + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_NaN = false; + static constexpr bool has_signaling_NaN = false; + static constexpr std::float_denorm_style has_denorm = std::denorm_absent; + static constexpr bool has_denorm_loss = false; + static constexpr std::float_round_style round_style = std::round_toward_zero; + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = true; + static constexpr bool is_modulo = true; + static constexpr int digits = CHAR_BIT * sizeof(js::temporal::Uint128); + static constexpr int digits10 = int(digits * /* std::log10(2) */ 0.30102999); + static constexpr int max_digits10 = 0; + static constexpr int radix = 2; + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; + static constexpr bool traps = true; + static constexpr bool tinyness_before = false; + + static constexpr auto min() noexcept { return js::temporal::Uint128{}; } + static constexpr auto lowest() noexcept { return min(); } + static constexpr auto max() noexcept { return ~js::temporal::Uint128{}; } + static constexpr auto epsilon() noexcept { return js::temporal::Uint128{}; } + static constexpr auto round_error() noexcept { + return js::temporal::Uint128{}; + } + static constexpr auto infinity() noexcept { return js::temporal::Uint128{}; } + static constexpr auto quiet_NaN() noexcept { return js::temporal::Uint128{}; } + static constexpr auto signaling_NaN() noexcept { + return js::temporal::Uint128{}; + } + static constexpr auto denorm_min() noexcept { + return js::temporal::Uint128{}; + } +}; + +#endif /* builtin_temporal_Int128_h */ diff --git a/js/src/builtin/temporal/Int96.cpp b/js/src/builtin/temporal/Int96.cpp index 73ea5ce90e..984271566a 100644 --- a/js/src/builtin/temporal/Int96.cpp +++ b/js/src/builtin/temporal/Int96.cpp @@ -39,12 +39,12 @@ mozilla::Maybe<Int96> Int96::fromInteger(double value) { // Inlined version of |BigInt::createFromDouble()| for DigitBits=32. See the // comments in |BigInt::createFromDouble()| for how this code works. - constexpr size_t DigitBits = 32; + constexpr int DigitBits = 32; // The number can't have more than three digits when it's below |maximum|. Int96::Digits digits = {}; - int exponent = mozilla::ExponentComponent(value); + int exponent = int(mozilla::ExponentComponent(value)); MOZ_ASSERT(0 <= exponent && exponent <= 95, "exponent is lower than exponent of 0x1p+96"); @@ -62,7 +62,7 @@ mozilla::Maybe<Int96> Int96::fromInteger(double value) { int msdTopBit = exponent % DigitBits; // First, build the MSD by shifting the mantissa appropriately. - int remainingMantissaBits = Double::kSignificandWidth - msdTopBit; + int remainingMantissaBits = int(Double::kSignificandWidth - msdTopBit); digits[--length] = mantissa >> remainingMantissaBits; // Fill in digits containing mantissa contributions. diff --git a/js/src/builtin/temporal/Int96.h b/js/src/builtin/temporal/Int96.h index dfb0a5c231..36ed359eca 100644 --- a/js/src/builtin/temporal/Int96.h +++ b/js/src/builtin/temporal/Int96.h @@ -133,7 +133,7 @@ class Int96 final { remainder = n % divisor; } - int64_t result = (TwoDigit(quotient[1]) << 32) | quotient[0]; + int64_t result = int64_t((TwoDigit(quotient[1]) << 32) | quotient[0]); if (negative) { result *= -1; if (remainder != 0) { diff --git a/js/src/builtin/temporal/PlainDate.cpp b/js/src/builtin/temporal/PlainDate.cpp index a4ad0e418f..a15d95cdc1 100644 --- a/js/src/builtin/temporal/PlainDate.cpp +++ b/js/src/builtin/temporal/PlainDate.cpp @@ -7,6 +7,7 @@ #include "builtin/temporal/PlainDate.h" #include "mozilla/Assertions.h" +#include "mozilla/Casting.h" #include "mozilla/FloatingPoint.h" #include "mozilla/Maybe.h" @@ -99,20 +100,15 @@ static bool IsValidISODate(T year, T month, T day) { // Step 3. int32_t daysInMonth = js::temporal::ISODaysInMonth(year, int32_t(month)); - // Step 4. - if (day < 1 || day > daysInMonth) { - return false; - } - - // Step 5. - return true; + // Steps 4-5. + return 1 <= day && day <= daysInMonth; } /** * IsValidISODate ( year, month, day ) */ bool js::temporal::IsValidISODate(const PlainDate& date) { - auto& [year, month, day] = date; + const auto& [year, month, day] = date; return ::IsValidISODate(year, month, day); } @@ -170,20 +166,15 @@ static bool ThrowIfInvalidISODate(JSContext* cx, T year, T month, T day) { // Step 3. int32_t daysInMonth = js::temporal::ISODaysInMonth(year, int32_t(month)); - // Step 4. - if (!ThrowIfInvalidDateValue(cx, "day", 1, daysInMonth, day)) { - return false; - } - - // Step 5. - return true; + // Steps 4-5. + return ThrowIfInvalidDateValue(cx, "day", 1, daysInMonth, day); } /** * IsValidISODate ( year, month, day ) */ bool js::temporal::ThrowIfInvalidISODate(JSContext* cx, const PlainDate& date) { - auto& [year, month, day] = date; + const auto& [year, month, day] = date; return ::ThrowIfInvalidISODate(cx, year, month, day); } @@ -201,7 +192,7 @@ bool js::temporal::ThrowIfInvalidISODate(JSContext* cx, double year, * With |overflow = "constrain"|. */ static PlainDate ConstrainISODate(const PlainDate& date) { - auto& [year, month, day] = date; + const auto& [year, month, day] = date; // Step 1.a. int32_t m = std::clamp(month, 1, 12); @@ -316,13 +307,16 @@ static PlainDateObject* CreateTemporalDate(JSContext* cx, const CallArgs& args, } // Step 5. - object->setFixedSlot(PlainDateObject::ISO_YEAR_SLOT, Int32Value(isoYear)); + object->setFixedSlot(PlainDateObject::ISO_YEAR_SLOT, + Int32Value(int32_t(isoYear))); // Step 6. - object->setFixedSlot(PlainDateObject::ISO_MONTH_SLOT, Int32Value(isoMonth)); + object->setFixedSlot(PlainDateObject::ISO_MONTH_SLOT, + Int32Value(int32_t(isoMonth))); // Step 7. - object->setFixedSlot(PlainDateObject::ISO_DAY_SLOT, Int32Value(isoDay)); + object->setFixedSlot(PlainDateObject::ISO_DAY_SLOT, + Int32Value(int32_t(isoDay))); // Step 8. object->setFixedSlot(PlainDateObject::CALENDAR_SLOT, calendar.toValue()); @@ -336,7 +330,7 @@ static PlainDateObject* CreateTemporalDate(JSContext* cx, const CallArgs& args, */ PlainDateObject* js::temporal::CreateTemporalDate( JSContext* cx, const PlainDate& date, Handle<CalendarValue> calendar) { - auto& [isoYear, isoMonth, isoDay] = date; + const auto& [isoYear, isoMonth, isoDay] = date; // Step 1. if (!ThrowIfInvalidISODate(cx, date)) { @@ -602,30 +596,28 @@ bool js::temporal::ToTemporalDate(JSContext* cx, Handle<Value> item, /** * Mathematical Operations, "modulo" notation. */ -static int32_t NonNegativeModulo(double x, int32_t y) { - MOZ_ASSERT(IsInteger(x)); +static int32_t NonNegativeModulo(int64_t x, int32_t y) { MOZ_ASSERT(y > 0); - double r = std::fmod(x, y); - - int32_t result; - MOZ_ALWAYS_TRUE(mozilla::NumberEqualsInt32(r, &result)); - + int32_t result = mozilla::AssertedCast<int32_t>(x % y); return (result < 0) ? (result + y) : result; } struct BalancedYearMonth final { - double year = 0; + int64_t year = 0; int32_t month = 0; }; /** * BalanceISOYearMonth ( year, month ) */ -static BalancedYearMonth BalanceISOYearMonth(double year, double month) { - // Step 1. - MOZ_ASSERT(IsInteger(year)); - MOZ_ASSERT(IsInteger(month)); +static BalancedYearMonth BalanceISOYearMonth(int64_t year, int64_t month) { + MOZ_ASSERT(std::abs(year) < (int64_t(1) << 33), + "year is the addition of plain-date year with duration years"); + MOZ_ASSERT(std::abs(month) < (int64_t(1) << 33), + "month is the addition of plain-date month with duration months"); + + // Step 1. (Not applicable in our implementation.) // Note: If either abs(year) or abs(month) is greater than 2^53 (the double // integral precision limit), the additions resp. subtractions below are @@ -633,18 +625,17 @@ static BalancedYearMonth BalanceISOYearMonth(double year, double month) { // function (AddISODate) will throw an error for large values anyway. // Step 2. - year = year + std::floor((month - 1) / 12); - MOZ_ASSERT(IsInteger(year) || std::isinf(year)); + int64_t balancedYear = year + temporal::FloorDiv(month - 1, 12); // Step 3. - int32_t mon = NonNegativeModulo(month - 1, 12) + 1; - MOZ_ASSERT(1 <= mon && mon <= 12); + int32_t balancedMonth = NonNegativeModulo(month - 1, 12) + 1; + MOZ_ASSERT(1 <= balancedMonth && balancedMonth <= 12); // Step 4. - return {year, mon}; + return {balancedYear, balancedMonth}; } -static bool CanBalanceISOYear(double year) { +static bool CanBalanceISOYear(int64_t year) { // TODO: Export these values somewhere. constexpr int32_t minYear = -271821; constexpr int32_t maxYear = 275760; @@ -654,7 +645,7 @@ static bool CanBalanceISOYear(double year) { return minYear <= year && year <= maxYear; } -static bool CanBalanceISODay(double day) { +static bool CanBalanceISODay(int64_t day) { // The maximum number of seconds from the epoch is 8.64 * 10^12. constexpr int64_t maxInstantSeconds = 8'640'000'000'000; @@ -684,10 +675,9 @@ PlainDate js::temporal::BalanceISODateNew(int32_t year, int32_t month, MOZ_ASSERT(1 <= month && month <= 12); // Steps 1-3. - int64_t ms = MakeDate(year, month, day); + double ms = double(MakeDate(year, month, day)); - // FIXME: spec issue - |ms| can be non-finite - // https://github.com/tc39/proposal-temporal/issues/2315 + // TODO: Add ISODateToEpochDays & friends which handle larger inputs. // TODO: This approach isn't efficient, because MonthFromTime and DayFromTime // both recompute YearFromTime. @@ -700,15 +690,19 @@ PlainDate js::temporal::BalanceISODateNew(int32_t year, int32_t month, /** * BalanceISODate ( year, month, day ) */ -bool js::temporal::BalanceISODate(JSContext* cx, int32_t year, int32_t month, - int64_t day, PlainDate* result) { +bool js::temporal::BalanceISODate(JSContext* cx, const PlainDate& date, + int64_t days, PlainDate* result) { + MOZ_ASSERT(IsValidISODate(date)); + MOZ_ASSERT(ISODateTimeWithinLimits(date)); + + int64_t day = int64_t(date.day) + days; if (!CanBalanceISODay(day)) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TEMPORAL_PLAIN_DATE_INVALID); return false; } - *result = BalanceISODate(year, month, int32_t(day)); + *result = BalanceISODate(date.year, date.month, int32_t(day)); return true; } @@ -725,9 +719,8 @@ PlainDate js::temporal::BalanceISODate(int32_t year, int32_t month, MOZ_ASSERT(1 <= month && month <= 12); MOZ_ASSERT(CanBalanceISODay(day)); - // TODO: BalanceISODate now works using MakeDate + // TODO: BalanceISODate now works using ISODateToEpochDays & friends. // TODO: Can't use JS::MakeDate, because it expects valid month/day values. - // https://github.com/tc39/proposal-temporal/issues/2315 // Step 1. (Not applicable in our implementation.) @@ -811,7 +804,7 @@ PlainDate js::temporal::BalanceISODate(int32_t year, int32_t month, * AddISODate ( year, month, day, years, months, weeks, days, overflow ) */ bool js::temporal::AddISODate(JSContext* cx, const PlainDate& date, - const Duration& duration, + const DateDuration& duration, TemporalOverflow overflow, PlainDate* result) { MOZ_ASSERT(IsValidISODate(date)); MOZ_ASSERT(ISODateTimeWithinLimits(date)); @@ -822,18 +815,11 @@ bool js::temporal::AddISODate(JSContext* cx, const PlainDate& date, // BalanceISODate. MOZ_ASSERT(IsValidDuration(duration)); - // Step 1. - MOZ_ASSERT(IsInteger(duration.years)); - MOZ_ASSERT(IsInteger(duration.months)); - MOZ_ASSERT(IsInteger(duration.weeks)); - MOZ_ASSERT(IsInteger(duration.days)); - - // Step 2. (Not applicable in our implementation.) + // Steps 1-2. (Not applicable in our implementation.) // Step 3. auto yearMonth = BalanceISOYearMonth(date.year + duration.years, date.month + duration.months); - MOZ_ASSERT(IsInteger(yearMonth.year) || std::isinf(yearMonth.year)); MOZ_ASSERT(1 <= yearMonth.month && yearMonth.month <= 12); // FIXME: spec issue? @@ -881,7 +867,7 @@ bool js::temporal::AddISODate(JSContext* cx, const PlainDate& date, // about imprecise number arithmetic here. // Steps 5-6. - double d = regulated.day + (duration.days + duration.weeks * 7); + int64_t d = regulated.day + (duration.days + duration.weeks * 7); // Just as with |yearMonth.year|, also directly throw an error if the |days| // value is too large. @@ -952,65 +938,51 @@ static bool HasYearsMonthsOrWeeks(const Duration& duration) { return duration.years != 0 || duration.months != 0 || duration.weeks != 0; } -static bool AddDate(JSContext* cx, const PlainDate& date, - const Duration& duration, Handle<JSObject*> maybeOptions, - PlainDate* result) { - MOZ_ASSERT(!HasYearsMonthsOrWeeks(duration)); +static bool HasYearsMonthsOrWeeks(const DateDuration& duration) { + return duration.years != 0 || duration.months != 0 || duration.weeks != 0; +} - // Steps 1-3. (Not applicable) +/** + * AddDate ( calendarRec, plainDate, duration [ , options ] ) + */ +static bool AddDate(JSContext* cx, const PlainDate& date, + const NormalizedDuration& duration, + TemporalOverflow overflow, PlainDate* result) { + MOZ_ASSERT(!HasYearsMonthsOrWeeks(duration.date)); + MOZ_ASSERT(IsValidDuration(duration)); - // Step 4. - auto overflow = TemporalOverflow::Constrain; - if (maybeOptions) { - if (!ToTemporalOverflow(cx, maybeOptions, &overflow)) { - return false; - } - } + // Steps 1-4. (Not applicable) - // Step 5. - TimeDuration daysDuration; - if (!BalanceTimeDuration(cx, duration, TemporalUnit::Day, &daysDuration)) { - return false; - } + // Step 5. (Not applicable) + const auto& timeDuration = duration.time; // Step 6. - return AddISODate(cx, date, {0, 0, 0, daysDuration.days}, overflow, result); + int64_t balancedDays = + BalanceTimeDuration(timeDuration, TemporalUnit::Day).days; + int64_t days = duration.date.days + balancedDays; + + // Step 7. + return AddISODate(cx, date, {0, 0, 0, days}, overflow, result); } static bool AddDate(JSContext* cx, Handle<Wrapped<PlainDateObject*>> date, - const Duration& duration, Handle<JSObject*> maybeOptions, - PlainDate* result) { + const NormalizedDuration& duration, + TemporalOverflow overflow, PlainDate* result) { auto* unwrappedDate = date.unwrap(cx); if (!unwrappedDate) { return false; } - return ::AddDate(cx, ToPlainDate(unwrappedDate), duration, maybeOptions, - result); -} - -static PlainDateObject* AddDate(JSContext* cx, Handle<CalendarRecord> calendar, - Handle<Wrapped<PlainDateObject*>> date, - const Duration& duration, - Handle<JSObject*> maybeOptions) { - // Steps 1-3. (Not applicable) - - // Steps 4-6. - PlainDate resultDate; - if (!::AddDate(cx, date, duration, maybeOptions, &resultDate)) { - return nullptr; - } - - // Step 7. - return CreateTemporalDate(cx, resultDate, calendar.receiver()); + return ::AddDate(cx, ToPlainDate(unwrappedDate), duration, overflow, result); } /** * AddDate ( calendarRec, plainDate, duration [ , options ] ) */ -Wrapped<PlainDateObject*> js::temporal::AddDate( - JSContext* cx, Handle<CalendarRecord> calendar, - Handle<Wrapped<PlainDateObject*>> date, const Duration& duration, - Handle<JSObject*> options) { +static Wrapped<PlainDateObject*> AddDate(JSContext* cx, + Handle<CalendarRecord> calendar, + Handle<Wrapped<PlainDateObject*>> date, + const Duration& duration, + Handle<JSObject*> options) { // Step 1. MOZ_ASSERT( CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateAdd)); @@ -1022,8 +994,23 @@ Wrapped<PlainDateObject*> js::temporal::AddDate( return temporal::CalendarDateAdd(cx, calendar, date, duration, options); } - // Steps 4-7. - return ::AddDate(cx, calendar, date, duration, options); + // Step 4. + auto overflow = TemporalOverflow::Constrain; + if (!ToTemporalOverflow(cx, options, &overflow)) { + return nullptr; + } + + // Step 5. + auto normalized = CreateNormalizedDurationRecord(duration); + + // Steps 6-7. + PlainDate resultDate; + if (!::AddDate(cx, date, normalized, overflow, &resultDate)) { + return nullptr; + } + + // Step 8. + return CreateTemporalDate(cx, resultDate, calendar.receiver()); } /** @@ -1031,7 +1018,7 @@ Wrapped<PlainDateObject*> js::temporal::AddDate( */ Wrapped<PlainDateObject*> js::temporal::AddDate( JSContext* cx, Handle<CalendarRecord> calendar, - Handle<Wrapped<PlainDateObject*>> date, const Duration& duration) { + Handle<Wrapped<PlainDateObject*>> date, const DateDuration& duration) { // Step 1. MOZ_ASSERT( CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateAdd)); @@ -1043,8 +1030,20 @@ Wrapped<PlainDateObject*> js::temporal::AddDate( return CalendarDateAdd(cx, calendar, date, duration); } - // Steps 4-7. - return ::AddDate(cx, calendar, date, duration, nullptr); + // Step 4. + auto overflow = TemporalOverflow::Constrain; + + // Step 5. + auto normalized = NormalizedDuration{duration}; + + // Steps 6-7. + PlainDate resultDate; + if (!::AddDate(cx, date, normalized, overflow, &resultDate)) { + return nullptr; + } + + // Step 8. + return CreateTemporalDate(cx, resultDate, calendar.receiver()); } /** @@ -1052,33 +1051,15 @@ Wrapped<PlainDateObject*> js::temporal::AddDate( */ Wrapped<PlainDateObject*> js::temporal::AddDate( JSContext* cx, Handle<CalendarRecord> calendar, - Handle<Wrapped<PlainDateObject*>> date, - Handle<Wrapped<DurationObject*>> durationObj) { - auto* unwrappedDuration = durationObj.unwrap(cx); - if (!unwrappedDuration) { - return nullptr; - } - auto duration = ToDuration(unwrappedDuration); - - // Step 1. - MOZ_ASSERT( - CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateAdd)); - - // Step 2. (Not applicable in our implementation.) - - // Step 3. - if (HasYearsMonthsOrWeeks(duration)) { - return CalendarDateAdd(cx, calendar, date, durationObj); - } - - // Steps 4-7. - return ::AddDate(cx, calendar, date, duration, nullptr); + Handle<Wrapped<PlainDateObject*>> date, const DateDuration& duration, + Handle<JSObject*> options) { + return ::AddDate(cx, calendar, date, duration.toDuration(), options); } /** * AddDate ( calendarRec, plainDate, duration [ , options ] ) */ -Wrapped<PlainDateObject*> js::temporal::AddDate( +static Wrapped<PlainDateObject*> AddDate( JSContext* cx, Handle<CalendarRecord> calendar, Handle<Wrapped<PlainDateObject*>> date, Handle<Wrapped<DurationObject*>> durationObj, Handle<JSObject*> options) { @@ -1099,15 +1080,30 @@ Wrapped<PlainDateObject*> js::temporal::AddDate( return temporal::CalendarDateAdd(cx, calendar, date, durationObj, options); } - // Steps 4-7. - return ::AddDate(cx, calendar, date, duration, options); + // Step 4. + auto overflow = TemporalOverflow::Constrain; + if (!ToTemporalOverflow(cx, options, &overflow)) { + return nullptr; + } + + // Step 5. + auto normalized = CreateNormalizedDurationRecord(duration); + + // Steps 6-7. + PlainDate resultDate; + if (!::AddDate(cx, date, normalized, overflow, &resultDate)) { + return nullptr; + } + + // Step 8. + return CreateTemporalDate(cx, resultDate, calendar.receiver()); } /** * AddDate ( calendarRec, plainDate, duration [ , options ] ) */ bool js::temporal::AddDate(JSContext* cx, Handle<CalendarRecord> calendar, - const PlainDate& date, const Duration& duration, + const PlainDate& date, const DateDuration& duration, Handle<JSObject*> options, PlainDate* result) { // Step 1. MOZ_ASSERT( @@ -1121,8 +1117,17 @@ bool js::temporal::AddDate(JSContext* cx, Handle<CalendarRecord> calendar, result); } - // Steps 4-7. - return ::AddDate(cx, date, duration, options, result); + // Step 4. + auto overflow = TemporalOverflow::Constrain; + if (!ToTemporalOverflow(cx, options, &overflow)) { + return false; + } + + // Step 5. + auto normalized = NormalizedDuration{duration}; + + // Steps 5-8. + return ::AddDate(cx, date, normalized, overflow, result); } /** @@ -1130,7 +1135,7 @@ bool js::temporal::AddDate(JSContext* cx, Handle<CalendarRecord> calendar, */ bool js::temporal::AddDate(JSContext* cx, Handle<CalendarRecord> calendar, Handle<Wrapped<PlainDateObject*>> date, - const Duration& duration, PlainDate* result) { + const DateDuration& duration, PlainDate* result) { // Step 1. MOZ_ASSERT( CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateAdd)); @@ -1142,8 +1147,14 @@ bool js::temporal::AddDate(JSContext* cx, Handle<CalendarRecord> calendar, return CalendarDateAdd(cx, calendar, date, duration, result); } - // Steps 4-7. - return ::AddDate(cx, date, duration, nullptr, result); + // Step 4. + auto overflow = TemporalOverflow::Constrain; + + // Step 5. + auto normalized = NormalizedDuration{duration}; + + // Steps 6-8. + return ::AddDate(cx, date, normalized, overflow, result); } /** @@ -1153,8 +1164,9 @@ bool js::temporal::DifferenceDate(JSContext* cx, Handle<CalendarRecord> calendar, Handle<Wrapped<PlainDateObject*>> one, Handle<Wrapped<PlainDateObject*>> two, + TemporalUnit largestUnit, Handle<PlainObject*> options, - Duration* result) { + DateDuration* result) { auto* unwrappedOne = one.unwrap(cx); if (!unwrappedOne) { return false; @@ -1172,8 +1184,7 @@ bool js::temporal::DifferenceDate(JSContext* cx, // Step 3. MOZ_ASSERT(options->staticPrototype() == nullptr); - // Step 4. - MOZ_ASSERT(options->containsPure(cx->names().largestUnit)); + // Step 4. (Not applicable in our implementation.) // Step 5. if (oneDate == twoDate) { @@ -1182,30 +1193,18 @@ bool js::temporal::DifferenceDate(JSContext* cx, } // Step 6. - Rooted<JS::Value> largestUnit(cx); - if (!GetProperty(cx, options, options, cx->names().largestUnit, - &largestUnit)) { - return false; - } - - if (largestUnit.isString()) { - bool isDay; - if (!EqualStrings(cx, largestUnit.toString(), cx->names().day, &isDay)) { - return false; - } - - if (isDay) { - // Step 6.a. - int32_t days = DaysUntil(oneDate, twoDate); + if (largestUnit == TemporalUnit::Day) { + // Step 6.a. + int32_t days = DaysUntil(oneDate, twoDate); - // Step 6.b. - *result = {0, 0, 0, double(days)}; - return true; - } + // Step 6.b. + *result = {0, 0, 0, days}; + return true; } // Step 7. - return CalendarDateUntil(cx, calendar, one, two, options, result); + return CalendarDateUntil(cx, calendar, one, two, largestUnit, options, + result); } /** @@ -1215,7 +1214,8 @@ bool js::temporal::DifferenceDate(JSContext* cx, Handle<CalendarRecord> calendar, Handle<Wrapped<PlainDateObject*>> one, Handle<Wrapped<PlainDateObject*>> two, - TemporalUnit largestUnit, Duration* result) { + TemporalUnit largestUnit, + DateDuration* result) { auto* unwrappedOne = one.unwrap(cx); if (!unwrappedOne) { return false; @@ -1242,7 +1242,69 @@ bool js::temporal::DifferenceDate(JSContext* cx, int32_t days = DaysUntil(oneDate, twoDate); // Step 6.b. - *result = {0, 0, 0, double(days)}; + *result = {0, 0, 0, days}; + return true; + } + + // Step 7. + return CalendarDateUntil(cx, calendar, one, two, largestUnit, result); +} + +/** + * DifferenceDate ( calendarRec, one, two, options ) + */ +bool js::temporal::DifferenceDate(JSContext* cx, + Handle<CalendarRecord> calendar, + const PlainDate& one, const PlainDate& two, + TemporalUnit largestUnit, + Handle<PlainObject*> options, + DateDuration* result) { + // Steps 1-4. (Not applicable in our implementation.) + + // Step 5. + if (one == two) { + *result = {}; + return true; + } + + // Step 6. + if (largestUnit == TemporalUnit::Day) { + // Step 6.a. + int32_t days = DaysUntil(one, two); + + // Step 6.b. + *result = {0, 0, 0, days}; + return true; + } + + // Step 7. + return CalendarDateUntil(cx, calendar, one, two, largestUnit, options, + result); +} + +/** + * DifferenceDate ( calendarRec, one, two, options ) + */ +bool js::temporal::DifferenceDate(JSContext* cx, + Handle<CalendarRecord> calendar, + const PlainDate& one, const PlainDate& two, + TemporalUnit largestUnit, + DateDuration* result) { + // Steps 1-4. (Not applicable in our implementation.) + + // Step 5. + if (one == two) { + *result = {}; + return true; + } + + // Step 6. + if (largestUnit == TemporalUnit::Day) { + // Step 6.a. + int32_t days = DaysUntil(one, two); + + // Step 6.b. + *result = {0, 0, 0, days}; return true; } @@ -1280,8 +1342,8 @@ int32_t js::temporal::CompareISODate(const PlainDate& one, static DateDuration CreateDateDurationRecord(int32_t years, int32_t months, int32_t weeks, int32_t days) { MOZ_ASSERT(IsValidDuration( - {double(years), double(months), double(weeks), double(days)})); - return {double(years), double(months), double(weeks), double(days)}; + Duration{double(years), double(months), double(weeks), double(days)})); + return {years, months, weeks, days}; } /** @@ -1577,31 +1639,19 @@ static bool DifferenceTemporalPlainDate(JSContext* cx, } // Steps 8-9. - Duration duration; + DateDuration difference; if (resolvedOptions) { - // Step 8. - Rooted<Value> largestUnitValue( - cx, StringValue(TemporalUnitToString(cx, settings.largestUnit))); - if (!DefineDataProperty(cx, resolvedOptions, cx->names().largestUnit, - largestUnitValue)) { - return false; - } - - // Step 9. - Duration result; - if (!DifferenceDate(cx, calendar, temporalDate, other, resolvedOptions, - &result)) { + // Steps 8-9. + if (!DifferenceDate(cx, calendar, temporalDate, other, settings.largestUnit, + resolvedOptions, &difference)) { return false; } - duration = result.date(); } else { // Steps 8-9. - Duration result; if (!DifferenceDate(cx, calendar, temporalDate, other, settings.largestUnit, - &result)) { + &difference)) { return false; } - duration = result.date(); } // Step 10. @@ -1611,8 +1661,8 @@ static bool DifferenceTemporalPlainDate(JSContext* cx, // Step 11. if (!roundingGranularityIsNoop) { // Steps 11.a-b. - Duration roundResult; - if (!temporal::RoundDuration(cx, duration.date(), + NormalizedDuration roundResult; + if (!temporal::RoundDuration(cx, {difference, {}}, settings.roundingIncrement, settings.smallestUnit, settings.roundingMode, temporalDate, calendar, &roundResult)) { @@ -1622,19 +1672,21 @@ static bool DifferenceTemporalPlainDate(JSContext* cx, // Step 11.c. DateDuration balanceResult; if (!temporal::BalanceDateDurationRelative( - cx, roundResult.date(), settings.largestUnit, settings.smallestUnit, + cx, roundResult.date, settings.largestUnit, settings.smallestUnit, temporalDate, calendar, &balanceResult)) { return false; } - duration = balanceResult.toDuration(); + difference = balanceResult; } // Step 12. + auto duration = difference.toDuration(); if (operation == TemporalDifference::Since) { duration = duration.negate(); } + MOZ_ASSERT(IsValidDuration(duration)); - auto* obj = CreateTemporalDuration(cx, duration.date()); + auto* obj = CreateTemporalDuration(cx, duration); if (!obj) { return false; } @@ -2235,14 +2287,14 @@ static bool PlainDate_toPlainDateTime(JSContext* cx, const CallArgs& args) { // Default initialize the time component to all zero. PlainDateTime dateTime = {ToPlainDate(temporalDate), {}}; - // Step 4. (Reordered) + // Step 3. (Inlined ToTemporalTimeOrMidnight) if (args.hasDefined(0)) { if (!ToTemporalTime(cx, args[0], &dateTime.time)) { return false; } } - // Steps 3 and 5. + // Step 4. auto* obj = CreateTemporalDateTime(cx, dateTime, calendar); if (!obj) { return false; @@ -2433,8 +2485,7 @@ static bool PlainDate_subtract(JSContext* cx, const CallArgs& args) { } // Step 7. - auto result = - temporal::AddDate(cx, calendar, temporalDate, negatedDuration, options); + auto result = ::AddDate(cx, calendar, temporalDate, negatedDuration, options); if (!result) { return false; } @@ -2465,13 +2516,11 @@ static bool PlainDate_with(JSContext* cx, const CallArgs& args) { if (!temporalDateLike) { return false; } - - // Step 4. - if (!RejectTemporalLikeObject(cx, temporalDateLike)) { + if (!ThrowIfTemporalLikeObject(cx, temporalDateLike)) { return false; } - // Step 5. + // Step 4. Rooted<PlainObject*> resolvedOptions(cx); if (args.hasDefined(1)) { Rooted<JSObject*> options(cx, @@ -2487,7 +2536,7 @@ static bool PlainDate_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 6. + // Step 5. Rooted<CalendarValue> calendarValue(cx, temporalDate->calendar()); Rooted<CalendarRecord> calendar(cx); if (!CreateCalendarMethodsRecord(cx, calendarValue, @@ -2500,7 +2549,7 @@ static bool PlainDate_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 7. + // Step 6. JS::RootedVector<PropertyKey> fieldNames(cx); if (!CalendarFields(cx, calendar, {CalendarField::Day, CalendarField::Month, @@ -2509,34 +2558,34 @@ static bool PlainDate_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 8. + // Step 7. Rooted<PlainObject*> fields( cx, PrepareTemporalFields(cx, temporalDate, fieldNames)); if (!fields) { return false; } - // Step 9. + // Step 8. Rooted<PlainObject*> partialDate( cx, PreparePartialTemporalFields(cx, temporalDateLike, fieldNames)); if (!partialDate) { return false; } - // Step 10. + // Step 9. Rooted<JSObject*> mergedFields( cx, CalendarMergeFields(cx, calendar, fields, partialDate)); if (!mergedFields) { return false; } - // Step 11. + // Step 10. fields = PrepareTemporalFields(cx, mergedFields, fieldNames); if (!fields) { return false; } - // Step 12. + // Step 11. auto result = temporal::CalendarDateFromFields(cx, calendar, fields, resolvedOptions); if (!result) { @@ -2677,7 +2726,7 @@ static bool PlainDate_toZonedDateTime(JSContext* cx, const CallArgs& args) { // Steps 3-4 Rooted<TimeZoneValue> timeZone(cx); - Rooted<Value> temporalTime(cx); + PlainTime time = {}; if (args.get(0).isObject()) { Rooted<JSObject*> item(cx, &args[0].toObject()); @@ -2686,8 +2735,7 @@ static bool PlainDate_toZonedDateTime(JSContext* cx, const CallArgs& args) { // Step 3.a.i. timeZone.set(TimeZoneValue(item)); - // Step 3.a.ii. - temporalTime.setUndefined(); + // Step 3.a.ii. (Not applicable in our implementation.) } else { // Step 3.b.i. Rooted<Value> timeZoneLike(cx); @@ -2702,8 +2750,7 @@ static bool PlainDate_toZonedDateTime(JSContext* cx, const CallArgs& args) { return false; } - // Step 3.b.ii.2. - temporalTime.setUndefined(); + // Step 3.b.ii.2. (Not applicable in our implementation.) } else { // Step 3.b.iii.1. if (!ToTemporalTimeZone(cx, timeZoneLike, &timeZone)) { @@ -2711,10 +2758,18 @@ static bool PlainDate_toZonedDateTime(JSContext* cx, const CallArgs& args) { } // Step 3.b.iii.2. + Rooted<Value> temporalTime(cx); if (!GetProperty(cx, item, item, cx->names().plainTime, &temporalTime)) { return false; } + + // Step 5. (Inlined ToTemporalTimeOrMidnight) + if (!temporalTime.isUndefined()) { + if (!ToTemporalTime(cx, temporalTime, &time)) { + return false; + } + } } } } else { @@ -2723,19 +2778,12 @@ static bool PlainDate_toZonedDateTime(JSContext* cx, const CallArgs& args) { return false; } - // Step 4.b. - temporalTime.setUndefined(); + // Step 4.b. (Not applicable in our implementation.) } - // Step 6.a. - PlainTime time = {}; - if (!temporalTime.isUndefined()) { - if (!ToTemporalTime(cx, temporalTime, &time)) { - return false; - } - } + // Step 5. (Moved next to step 3.b.iii.2.) - // Steps 5.a and 6.b + // Step 6. Rooted<PlainDateTimeWithCalendar> temporalDateTime(cx); if (!CreateTemporalDateTime(cx, {date, time}, calendar, &temporalDateTime)) { return false; diff --git a/js/src/builtin/temporal/PlainDate.h b/js/src/builtin/temporal/PlainDate.h index 75a3a3f2a1..f8217eb5e0 100644 --- a/js/src/builtin/temporal/PlainDate.h +++ b/js/src/builtin/temporal/PlainDate.h @@ -8,6 +8,7 @@ #define builtin_temporal_PlainDate_h #include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" #include <initializer_list> #include <stdint.h> @@ -60,7 +61,7 @@ class PlainDateObject : public NativeObject { static const ClassSpec classSpec_; }; -class PlainDateWithCalendar { +class MOZ_STACK_CLASS PlainDateWithCalendar final { PlainDate date_; CalendarValue calendar_; @@ -150,9 +151,9 @@ bool RegulateISODate(JSContext* cx, const PlainDate& date, TemporalOverflow overflow, PlainDate* result); struct RegulatedISODate final { - double year; - int32_t month; - int32_t day; + double year = 0; + int32_t month = 0; + int32_t day = 0; }; /** @@ -164,8 +165,9 @@ bool RegulateISODate(JSContext* cx, double year, double month, double day, /** * AddISODate ( year, month, day, years, months, weeks, days, overflow ) */ -bool AddISODate(JSContext* cx, const PlainDate& date, const Duration& duration, - TemporalOverflow overflow, PlainDate* result); +bool AddISODate(JSContext* cx, const PlainDate& date, + const DateDuration& duration, TemporalOverflow overflow, + PlainDate* result); /** * AddDate ( calendarRec, plainDate, duration [ , options ] ) @@ -173,8 +175,7 @@ bool AddISODate(JSContext* cx, const PlainDate& date, const Duration& duration, Wrapped<PlainDateObject*> AddDate(JSContext* cx, JS::Handle<CalendarRecord> calendar, JS::Handle<Wrapped<PlainDateObject*>> date, - const Duration& duration, - JS::Handle<JSObject*> options); + const DateDuration& duration); /** * AddDate ( calendarRec, plainDate, duration [ , options ] ) @@ -182,30 +183,14 @@ Wrapped<PlainDateObject*> AddDate(JSContext* cx, Wrapped<PlainDateObject*> AddDate(JSContext* cx, JS::Handle<CalendarRecord> calendar, JS::Handle<Wrapped<PlainDateObject*>> date, - const Duration& duration); - -/** - * AddDate ( calendarRec, plainDate, duration [ , options ] ) - */ -Wrapped<PlainDateObject*> AddDate( - JSContext* cx, JS::Handle<CalendarRecord> calendar, - JS::Handle<Wrapped<PlainDateObject*>> date, - JS::Handle<Wrapped<DurationObject*>> durationObj, - JS::Handle<JSObject*> options); - -/** - * AddDate ( calendarRec, plainDate, duration [ , options ] ) - */ -Wrapped<PlainDateObject*> AddDate( - JSContext* cx, JS::Handle<CalendarRecord> calendar, - JS::Handle<Wrapped<PlainDateObject*>> date, - JS::Handle<Wrapped<DurationObject*>> durationObj); + const DateDuration& duration, + JS::Handle<JSObject*> options); /** * AddDate ( calendarRec, plainDate, duration [ , options ] ) */ bool AddDate(JSContext* cx, JS::Handle<CalendarRecord> calendar, - const PlainDate& date, const Duration& duration, + const PlainDate& date, const DateDuration& duration, JS::Handle<JSObject*> options, PlainDate* result); /** @@ -213,7 +198,7 @@ bool AddDate(JSContext* cx, JS::Handle<CalendarRecord> calendar, */ bool AddDate(JSContext* cx, JS::Handle<CalendarRecord> calendar, JS::Handle<Wrapped<PlainDateObject*>> date, - const Duration& duration, PlainDate* result); + const DateDuration& duration, PlainDate* result); /** * DifferenceISODate ( y1, m1, d1, y2, m2, d2, largestUnit ) @@ -227,7 +212,8 @@ DateDuration DifferenceISODate(const PlainDate& start, const PlainDate& end, bool DifferenceDate(JSContext* cx, JS::Handle<CalendarRecord> calendar, JS::Handle<Wrapped<PlainDateObject*>> one, JS::Handle<Wrapped<PlainDateObject*>> two, - JS::Handle<PlainObject*> options, Duration* result); + TemporalUnit largestUnit, JS::Handle<PlainObject*> options, + DateDuration* result); /** * DifferenceDate ( calendarRec, one, two, options ) @@ -235,7 +221,22 @@ bool DifferenceDate(JSContext* cx, JS::Handle<CalendarRecord> calendar, bool DifferenceDate(JSContext* cx, JS::Handle<CalendarRecord> calendar, JS::Handle<Wrapped<PlainDateObject*>> one, JS::Handle<Wrapped<PlainDateObject*>> two, - TemporalUnit largestUnit, Duration* result); + TemporalUnit largestUnit, DateDuration* result); + +/** + * DifferenceDate ( calendarRec, one, two, options ) + */ +bool DifferenceDate(JSContext* cx, JS::Handle<CalendarRecord> calendar, + const PlainDate& one, const PlainDate& two, + TemporalUnit largestUnit, JS::Handle<PlainObject*> options, + DateDuration* result); + +/** + * DifferenceDate ( calendarRec, one, two, options ) + */ +bool DifferenceDate(JSContext* cx, JS::Handle<CalendarRecord> calendar, + const PlainDate& one, const PlainDate& two, + TemporalUnit largestUnit, DateDuration* result); /** * CompareISODate ( y1, m1, d1, y2, m2, d2 ) @@ -245,7 +246,7 @@ int32_t CompareISODate(const PlainDate& one, const PlainDate& two); /** * BalanceISODate ( year, month, day ) */ -bool BalanceISODate(JSContext* cx, int32_t year, int32_t month, int64_t day, +bool BalanceISODate(JSContext* cx, const PlainDate& date, int64_t days, PlainDate* result); /** diff --git a/js/src/builtin/temporal/PlainDateTime.cpp b/js/src/builtin/temporal/PlainDateTime.cpp index 8f137cfe43..f4b15422b3 100644 --- a/js/src/builtin/temporal/PlainDateTime.cpp +++ b/js/src/builtin/temporal/PlainDateTime.cpp @@ -178,11 +178,6 @@ static bool ISODateTimeWithinLimits(T year, T month, T day) { // components set to zero. That means the maximum value is exclusive, whereas // the minimum value is inclusive. - // FIXME: spec bug - GetUTCEpochNanoseconds when called with large |year| may - // cause MakeDay to return NaN, which makes MakeDate return NaN, which is - // unexpected in GetUTCEpochNanoseconds, step 4. - // https://github.com/tc39/proposal-temporal/issues/2315 - // Definitely in range. if (minYear < year && year < maxYear) { return true; @@ -229,7 +224,7 @@ bool js::temporal::ISODateTimeWithinLimits(double year, double month, * millisecond, microsecond, nanosecond ) */ bool js::temporal::ISODateTimeWithinLimits(const PlainDateTime& dateTime) { - auto& [date, time] = dateTime; + const auto& [date, time] = dateTime; return ::ISODateTimeWithinLimits(date.year, date.month, date.day, time.hour, time.minute, time.second, time.millisecond, time.microsecond, time.nanosecond); @@ -295,37 +290,39 @@ static PlainDateTimeObject* CreateTemporalDateTime( // Step 6. dateTime->setFixedSlot(PlainDateTimeObject::ISO_YEAR_SLOT, - Int32Value(isoYear)); + Int32Value(int32_t(isoYear))); // Step 7. dateTime->setFixedSlot(PlainDateTimeObject::ISO_MONTH_SLOT, - Int32Value(isoMonth)); + Int32Value(int32_t(isoMonth))); // Step 8. - dateTime->setFixedSlot(PlainDateTimeObject::ISO_DAY_SLOT, Int32Value(isoDay)); + dateTime->setFixedSlot(PlainDateTimeObject::ISO_DAY_SLOT, + Int32Value(int32_t(isoDay))); // Step 9. - dateTime->setFixedSlot(PlainDateTimeObject::ISO_HOUR_SLOT, Int32Value(hour)); + dateTime->setFixedSlot(PlainDateTimeObject::ISO_HOUR_SLOT, + Int32Value(int32_t(hour))); // Step 10. dateTime->setFixedSlot(PlainDateTimeObject::ISO_MINUTE_SLOT, - Int32Value(minute)); + Int32Value(int32_t(minute))); // Step 11. dateTime->setFixedSlot(PlainDateTimeObject::ISO_SECOND_SLOT, - Int32Value(second)); + Int32Value(int32_t(second))); // Step 12. dateTime->setFixedSlot(PlainDateTimeObject::ISO_MILLISECOND_SLOT, - Int32Value(millisecond)); + Int32Value(int32_t(millisecond))); // Step 13. dateTime->setFixedSlot(PlainDateTimeObject::ISO_MICROSECOND_SLOT, - Int32Value(microsecond)); + Int32Value(int32_t(microsecond))); // Step 14. dateTime->setFixedSlot(PlainDateTimeObject::ISO_NANOSECOND_SLOT, - Int32Value(nanosecond)); + Int32Value(int32_t(nanosecond))); // Step 15. dateTime->setFixedSlot(PlainDateTimeObject::CALENDAR_SLOT, @@ -342,9 +339,10 @@ static PlainDateTimeObject* CreateTemporalDateTime( PlainDateTimeObject* js::temporal::CreateTemporalDateTime( JSContext* cx, const PlainDateTime& dateTime, Handle<CalendarValue> calendar) { - auto& [date, time] = dateTime; - auto& [isoYear, isoMonth, isoDay] = date; - auto& [hour, minute, second, millisecond, microsecond, nanosecond] = time; + const auto& [date, time] = dateTime; + const auto& [isoYear, isoMonth, isoDay] = date; + const auto& [hour, minute, second, millisecond, microsecond, nanosecond] = + time; // Steps 1-2. if (!ThrowIfInvalidISODateTime(cx, dateTime)) { @@ -441,7 +439,7 @@ bool js::temporal::InterpretTemporalDateTimeFields( CalendarMethod::DateFromFields)); // Step 3. - TimeRecord timeResult; + TemporalTimeLike timeResult; if (!ToTemporalTimeRecord(cx, fields, &timeResult)) { return false; } @@ -698,7 +696,7 @@ bool js::temporal::ToTemporalDateTime(JSContext* cx, Handle<Value> item, static bool ToTemporalDateTime( JSContext* cx, Handle<Value> item, MutableHandle<PlainDateTimeWithCalendar> result) { - HandleObject options = nullptr; + Handle<JSObject*> options = nullptr; auto* obj = ::ToTemporalDateTime(cx, item, options).unwrapOrNull(); if (!obj) { @@ -734,42 +732,46 @@ static int32_t CompareISODateTime(const PlainDateTime& one, /** * AddDateTime ( year, month, day, hour, minute, second, millisecond, - * microsecond, nanosecond, calendarRec, years, months, weeks, days, hours, - * minutes, seconds, milliseconds, microseconds, nanoseconds, options ) + * microsecond, nanosecond, calendarRec, years, months, weeks, days, norm, + * options ) */ static bool AddDateTime(JSContext* cx, const PlainDateTime& dateTime, Handle<CalendarRecord> calendar, - const Duration& duration, Handle<JSObject*> options, - PlainDateTime* result) { + const NormalizedDuration& duration, + Handle<JSObject*> options, PlainDateTime* result) { MOZ_ASSERT(IsValidDuration(duration)); // Step 1. MOZ_ASSERT(IsValidISODateTime(dateTime)); - MOZ_ASSERT(ISODateTimeWithinLimits(dateTime)); // Step 2. - PlainTime timeResult; - double daysResult; - if (!AddTime(cx, dateTime.time, duration, &timeResult, &daysResult)) { - return false; - } + MOZ_ASSERT(ISODateTimeWithinLimits(dateTime)); // Step 3. - const auto& datePart = dateTime.date; + auto timeResult = AddTime(dateTime.time, duration.time); // Step 4. - Duration dateDuration = {duration.years, duration.months, duration.weeks, - daysResult}; - MOZ_ASSERT(IsValidDuration(duration)); + const auto& datePart = dateTime.date; // Step 5. + auto dateDuration = DateDuration{ + duration.date.years, + duration.date.months, + duration.date.weeks, + duration.date.days + timeResult.days, + }; + if (!ThrowIfInvalidDuration(cx, dateDuration)) { + return false; + } + + // Step 6. PlainDate addedDate; if (!AddDate(cx, calendar, datePart, dateDuration, options, &addedDate)) { return false; } - // Step 6. - *result = {addedDate, timeResult}; + // Step 7. + *result = {addedDate, timeResult.time}; return true; } @@ -782,7 +784,7 @@ static bool DifferenceISODateTime(JSContext* cx, const PlainDateTime& one, Handle<CalendarRecord> calendar, TemporalUnit largestUnit, Handle<PlainObject*> maybeOptions, - Duration* result) { + NormalizedDuration* result) { // Steps 1-2. MOZ_ASSERT(IsValidISODateTime(one)); MOZ_ASSERT(IsValidISODateTime(two)); @@ -795,10 +797,10 @@ static bool DifferenceISODateTime(JSContext* cx, const PlainDateTime& one, CalendarMethodsRecordHasLookedUp(calendar, CalendarMethod::DateUntil)); // Step 4. - auto timeDifference = DifferenceTime(one.time, two.time); + auto timeDuration = DifferenceTime(one.time, two.time); // Step 5. - int32_t timeSign = DurationSign(timeDifference.toDuration()); + int32_t timeSign = NormalizedTimeDurationSign(timeDuration); // Step 6. int32_t dateSign = CompareISODate(two.date, one.date); @@ -813,20 +815,8 @@ static bool DifferenceISODateTime(JSContext* cx, const PlainDateTime& one, adjustedDate.day - timeSign); // Step 8.b. - if (!BalanceTimeDuration(cx, - { - 0, - 0, - 0, - double(-timeSign), - timeDifference.hours, - timeDifference.minutes, - timeDifference.seconds, - timeDifference.milliseconds, - timeDifference.microseconds, - timeDifference.nanoseconds, - }, - largestUnit, &timeDifference)) { + if (!Add24HourDaysToNormalizedTimeDuration(cx, timeDuration, -timeSign, + &timeDuration)) { return false; } } @@ -834,49 +824,26 @@ static bool DifferenceISODateTime(JSContext* cx, const PlainDateTime& one, MOZ_ASSERT(IsValidISODate(adjustedDate)); MOZ_ASSERT(ISODateTimeWithinLimits(adjustedDate)); - // TODO: Avoid allocating CreateTemporalDate. - // Step 9. - Rooted<PlainDateObject*> date1( - cx, CreateTemporalDate(cx, adjustedDate, calendar.receiver())); - if (!date1) { - return false; - } + const auto& date1 = adjustedDate; // Step 10. - Rooted<PlainDateObject*> date2( - cx, CreateTemporalDate(cx, two.date, calendar.receiver())); - if (!date2) { - return false; - } + const auto& date2 = two.date; // Step 11. auto dateLargestUnit = std::min(TemporalUnit::Day, largestUnit); - Duration dateDifference; + DateDuration dateDifference; if (maybeOptions) { - // FIXME: spec issue - this copy is no longer needed, all callers have - // already copied the user input object. - // https://github.com/tc39/proposal-temporal/issues/2525 - // Step 12. - Rooted<PlainObject*> untilOptions(cx, - SnapshotOwnProperties(cx, maybeOptions)); - if (!untilOptions) { - return false; - } + // + // The spec performs an unnecessary copy operation. As an optimization, we + // omit this copy. + auto untilOptions = maybeOptions; - // Step 13. - Rooted<Value> largestUnitValue( - cx, StringValue(TemporalUnitToString(cx, dateLargestUnit))); - if (!DefineDataProperty(cx, untilOptions, cx->names().largestUnit, - largestUnitValue)) { - return false; - } - - // Step 14. - if (!DifferenceDate(cx, calendar, date1, date2, untilOptions, - &dateDifference)) { + // Steps 13-14. + if (!DifferenceDate(cx, calendar, date1, date2, dateLargestUnit, + untilOptions, &dateDifference)) { return false; } } else { @@ -888,82 +855,32 @@ static bool DifferenceISODateTime(JSContext* cx, const PlainDateTime& one, } // Step 15. - TimeDuration balanceResult; - if (!BalanceTimeDuration(cx, - { - 0, - 0, - 0, - dateDifference.days, - timeDifference.hours, - timeDifference.minutes, - timeDifference.seconds, - timeDifference.milliseconds, - timeDifference.microseconds, - timeDifference.nanoseconds, - }, - largestUnit, &balanceResult)) { - return false; - } - - // Step 16. - *result = {dateDifference.years, dateDifference.months, - dateDifference.weeks, balanceResult.days, - balanceResult.hours, balanceResult.minutes, - balanceResult.seconds, balanceResult.milliseconds, - balanceResult.microseconds, balanceResult.nanoseconds}; - MOZ_ASSERT(IsValidDuration(*result)); - return true; -} - -/** - * DifferenceISODateTime ( y1, mon1, d1, h1, min1, s1, ms1, mus1, ns1, y2, mon2, - * d2, h2, min2, s2, ms2, mus2, ns2, calendarRec, largestUnit, options ) - */ -bool js::temporal::DifferenceISODateTime(JSContext* cx, - const PlainDateTime& one, - const PlainDateTime& two, - Handle<CalendarRecord> calendar, - TemporalUnit largestUnit, - Duration* result) { - return ::DifferenceISODateTime(cx, one, two, calendar, largestUnit, nullptr, - result); -} - -/** - * DifferenceISODateTime ( y1, mon1, d1, h1, min1, s1, ms1, mus1, ns1, y2, mon2, - * d2, h2, min2, s2, ms2, mus2, ns2, calendarRec, largestUnit, options ) - */ -bool js::temporal::DifferenceISODateTime( - JSContext* cx, const PlainDateTime& one, const PlainDateTime& two, - Handle<CalendarRecord> calendar, TemporalUnit largestUnit, - Handle<PlainObject*> options, Duration* result) { - return ::DifferenceISODateTime(cx, one, two, calendar, largestUnit, options, - result); + return CreateNormalizedDurationRecord(cx, dateDifference, timeDuration, + result); } /** * RoundISODateTime ( year, month, day, hour, minute, second, millisecond, - * microsecond, nanosecond, increment, unit, roundingMode [ , dayLength ] ) + * microsecond, nanosecond, increment, unit, roundingMode ) */ -static PlainDateTime RoundISODateTime(const PlainDateTime& dateTime, - Increment increment, TemporalUnit unit, - TemporalRoundingMode roundingMode) { +PlainDateTime js::temporal::RoundISODateTime( + const PlainDateTime& dateTime, Increment increment, TemporalUnit unit, + TemporalRoundingMode roundingMode) { const auto& [date, time] = dateTime; // Step 1. MOZ_ASSERT(IsValidISODateTime(dateTime)); - MOZ_ASSERT(ISODateTimeWithinLimits(dateTime)); - // Step 2. (Not applicable in our implementation.) + // Step 2. + MOZ_ASSERT(ISODateTimeWithinLimits(dateTime)); // Step 3. auto roundedTime = RoundTime(time, increment, unit, roundingMode); MOZ_ASSERT(0 <= roundedTime.days && roundedTime.days <= 1); // Step 4. - auto balanceResult = - BalanceISODate(date.year, date.month, date.day + roundedTime.days); + auto balanceResult = BalanceISODate(date.year, date.month, + date.day + int32_t(roundedTime.days)); // Step 5. return {balanceResult, roundedTime.time}; @@ -1049,7 +966,7 @@ static bool DifferenceTemporalPlainDateTime(JSContext* cx, } // Step 10. - Duration diff; + NormalizedDuration diff; if (!::DifferenceISODateTime(cx, dateTime, other, calendar, settings.largestUnit, resolvedOptions, &diff)) { return false; @@ -1060,62 +977,81 @@ static bool DifferenceTemporalPlainDateTime(JSContext* cx, settings.smallestUnit == TemporalUnit::Nanosecond && settings.roundingIncrement == Increment{1}; - // Step 12. - if (roundingGranularityIsNoop) { - if (operation == TemporalDifference::Since) { - diff = diff.negate(); + // Steps 12-13. + DateDuration balancedDate; + TimeDuration balancedTime; + if (!roundingGranularityIsNoop) { + // Step 12.a. + Rooted<PlainDateObject*> relativeTo( + cx, CreateTemporalDate(cx, dateTime.date(), dateTime.calendar())); + if (!relativeTo) { + return false; } - auto* obj = CreateTemporalDuration(cx, diff); - if (!obj) { + // Steps 12.b-c. + NormalizedDuration roundResult; + if (!temporal::RoundDuration(cx, diff, settings.roundingIncrement, + settings.smallestUnit, settings.roundingMode, + relativeTo, calendar, &roundResult)) { return false; } - args.rval().setObject(*obj); - return true; - } + // Step 12.d. + NormalizedTimeDuration withDays; + if (!Add24HourDaysToNormalizedTimeDuration( + cx, roundResult.time, roundResult.date.days, &withDays)) { + return false; + } - // Step 13. - Rooted<PlainDateObject*> relativeTo( - cx, CreateTemporalDate(cx, dateTime.date(), dateTime.calendar())); - if (!relativeTo) { - return false; - } + // Step 12.e. + if (!BalanceTimeDuration(cx, withDays, settings.largestUnit, + &balancedTime)) { + return false; + } - // Steps 14-15. - Duration roundResult; - if (!temporal::RoundDuration(cx, diff, settings.roundingIncrement, - settings.smallestUnit, settings.roundingMode, - relativeTo, calendar, &roundResult)) { - return false; - } + // Step 12.f. + auto toBalance = DateDuration{ + roundResult.date.years, + roundResult.date.months, + roundResult.date.weeks, + balancedTime.days, + }; + if (!temporal::BalanceDateDurationRelative( + cx, toBalance, settings.largestUnit, settings.smallestUnit, + relativeTo, calendar, &balancedDate)) { + return false; + } + } else { + // Step 13.a. + NormalizedTimeDuration withDays; + if (!Add24HourDaysToNormalizedTimeDuration(cx, diff.time, diff.date.days, + &withDays)) { + return false; + } - // Step 16. - TimeDuration result; - if (!BalanceTimeDuration(cx, roundResult, settings.largestUnit, &result)) { - return false; - } + // Step 13.b. + if (!BalanceTimeDuration(cx, withDays, settings.largestUnit, + &balancedTime)) { + return false; + } - // Step 17. - auto toBalance = Duration{ - roundResult.years, - roundResult.months, - roundResult.weeks, - result.days, - }; - DateDuration balanceResult; - if (!temporal::BalanceDateDurationRelative( - cx, toBalance, settings.largestUnit, settings.smallestUnit, - relativeTo, calendar, &balanceResult)) { - return false; + // Step 13.c. + balancedDate = { + diff.date.years, + diff.date.months, + diff.date.weeks, + balancedTime.days, + }; } + MOZ_ASSERT(IsValidDuration(balancedDate)); - // Step 18. + // Step 14. Duration duration = { - balanceResult.years, balanceResult.months, balanceResult.weeks, - balanceResult.days, result.hours, result.minutes, - result.seconds, result.milliseconds, result.microseconds, - result.nanoseconds, + double(balancedDate.years), double(balancedDate.months), + double(balancedDate.weeks), double(balancedDate.days), + double(balancedTime.hours), double(balancedTime.minutes), + double(balancedTime.seconds), double(balancedTime.milliseconds), + balancedTime.microseconds, balancedTime.nanoseconds, }; if (operation == TemporalDifference::Since) { duration = duration.negate(); @@ -1176,16 +1112,18 @@ static bool AddDurationToOrSubtractDurationFromPlainDateTime( if (operation == PlainDateTimeDuration::Subtract) { duration = duration.negate(); } + auto normalized = CreateNormalizedDurationRecord(duration); + // Step 6 PlainDateTime result; - if (!AddDateTime(cx, dateTime, calendar, duration, options, &result)) { + if (!AddDateTime(cx, dateTime, calendar, normalized, options, &result)) { return false; } - // Steps 6-7. + // Steps 7-8. MOZ_ASSERT(IsValidISODateTime(result)); - // Step 8. + // Step 9. auto* obj = CreateTemporalDateTime(cx, result, dateTime.calendar()); if (!obj) { return false; @@ -1824,13 +1762,11 @@ static bool PlainDateTime_with(JSContext* cx, const CallArgs& args) { if (!temporalDateTimeLike) { return false; } - - // Step 4. - if (!RejectTemporalLikeObject(cx, temporalDateTimeLike)) { + if (!ThrowIfTemporalLikeObject(cx, temporalDateTimeLike)) { return false; } - // Step 5. + // Step 4. Rooted<PlainObject*> resolvedOptions(cx); if (args.hasDefined(1)) { Rooted<JSObject*> options(cx, @@ -1846,7 +1782,7 @@ static bool PlainDateTime_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 6. + // Step 5. Rooted<CalendarValue> calendarValue(cx, dateTime->calendar()); Rooted<CalendarRecord> calendar(cx); if (!CreateCalendarMethodsRecord(cx, calendarValue, @@ -1859,7 +1795,7 @@ static bool PlainDateTime_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 7. + // Step 6. JS::RootedVector<PropertyKey> fieldNames(cx); if (!CalendarFields(cx, calendar, {CalendarField::Day, CalendarField::Month, @@ -1868,14 +1804,14 @@ static bool PlainDateTime_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 8. + // Step 7. Rooted<PlainObject*> fields(cx, PrepareTemporalFields(cx, dateTime, fieldNames)); if (!fields) { return false; } - // Steps 9-14. + // Steps 8-13. struct TimeField { using FieldName = ImmutableTenuredPtr<PropertyName*> JSAtomState::*; @@ -1900,7 +1836,7 @@ static bool PlainDateTime_with(JSContext* cx, const CallArgs& args) { } } - // Step 15. + // Step 14. if (!AppendSorted(cx, fieldNames.get(), { TemporalField::Hour, @@ -1913,37 +1849,37 @@ static bool PlainDateTime_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 16. + // Step 15. Rooted<PlainObject*> partialDateTime( cx, PreparePartialTemporalFields(cx, temporalDateTimeLike, fieldNames)); if (!partialDateTime) { return false; } - // Step 17. + // Step 16. Rooted<JSObject*> mergedFields( cx, CalendarMergeFields(cx, calendar, fields, partialDateTime)); if (!mergedFields) { return false; } - // Step 18. + // Step 17. fields = PrepareTemporalFields(cx, mergedFields, fieldNames); if (!fields) { return false; } - // Step 19. + // Step 18. PlainDateTime result; if (!InterpretTemporalDateTimeFields(cx, calendar, fields, resolvedOptions, &result)) { return false; } - // Steps 20-21. + // Steps 19-20. MOZ_ASSERT(IsValidISODateTime(result)); - // Step 22. + // Step 21. auto* obj = CreateTemporalDateTime(cx, result, calendar.receiver()); if (!obj) { return false; @@ -1970,7 +1906,7 @@ static bool PlainDateTime_withPlainTime(JSContext* cx, const CallArgs& args) { auto date = ToPlainDate(temporalDateTime); Rooted<CalendarValue> calendar(cx, temporalDateTime->calendar()); - // Step 4. + // Step 3. (Inlined ToTemporalTimeOrMidnight) PlainTime time = {}; if (args.hasDefined(0)) { if (!ToTemporalTime(cx, args[0], &time)) { @@ -1978,7 +1914,7 @@ static bool PlainDateTime_withPlainTime(JSContext* cx, const CallArgs& args) { } } - // Steps 3 and 5. + // Step 4. auto* obj = CreateTemporalDateTime(cx, {date, time}, calendar); if (!obj) { return false; diff --git a/js/src/builtin/temporal/PlainDateTime.h b/js/src/builtin/temporal/PlainDateTime.h index 3546fca903..1ae80a4508 100644 --- a/js/src/builtin/temporal/PlainDateTime.h +++ b/js/src/builtin/temporal/PlainDateTime.h @@ -8,6 +8,7 @@ #define builtin_temporal_PlainDateTime_h #include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" #include <stdint.h> @@ -104,6 +105,8 @@ inline PlainDateTime ToPlainDateTime(const PlainDateTimeObject* dateTime) { return {ToPlainDate(dateTime), ToPlainTime(dateTime)}; } +class Increment; +enum class TemporalRoundingMode; enum class TemporalUnit; #ifdef DEBUG @@ -170,25 +173,14 @@ bool InterpretTemporalDateTimeFields(JSContext* cx, PlainDateTime* result); /** - * DifferenceISODateTime ( y1, mon1, d1, h1, min1, s1, ms1, mus1, ns1, y2, mon2, - * d2, h2, min2, s2, ms2, mus2, ns2, calendarRec, largestUnit, options ) + * RoundISODateTime ( year, month, day, hour, minute, second, millisecond, + * microsecond, nanosecond, increment, unit, roundingMode ) */ -bool DifferenceISODateTime(JSContext* cx, const PlainDateTime& one, - const PlainDateTime& two, - JS::Handle<CalendarRecord> calendar, - TemporalUnit largestUnit, Duration* result); +PlainDateTime RoundISODateTime(const PlainDateTime& dateTime, + Increment increment, TemporalUnit unit, + TemporalRoundingMode roundingMode); -/** - * DifferenceISODateTime ( y1, mon1, d1, h1, min1, s1, ms1, mus1, ns1, y2, mon2, - * d2, h2, min2, s2, ms2, mus2, ns2, calendarRec, largestUnit, options ) - */ -bool DifferenceISODateTime(JSContext* cx, const PlainDateTime& one, - const PlainDateTime& two, - JS::Handle<CalendarRecord> calendar, - TemporalUnit largestUnit, - JS::Handle<PlainObject*> options, Duration* result); - -class PlainDateTimeWithCalendar { +class MOZ_STACK_CLASS PlainDateTimeWithCalendar final { PlainDateTime dateTime_; CalendarValue calendar_; diff --git a/js/src/builtin/temporal/PlainMonthDay.cpp b/js/src/builtin/temporal/PlainMonthDay.cpp index 0896100a3f..50618a5fb6 100644 --- a/js/src/builtin/temporal/PlainMonthDay.cpp +++ b/js/src/builtin/temporal/PlainMonthDay.cpp @@ -96,16 +96,19 @@ static PlainMonthDayObject* CreateTemporalMonthDay( } // Step 5. - obj->setFixedSlot(PlainMonthDayObject::ISO_MONTH_SLOT, Int32Value(isoMonth)); + obj->setFixedSlot(PlainMonthDayObject::ISO_MONTH_SLOT, + Int32Value(int32_t(isoMonth))); // Step 6. - obj->setFixedSlot(PlainMonthDayObject::ISO_DAY_SLOT, Int32Value(isoDay)); + obj->setFixedSlot(PlainMonthDayObject::ISO_DAY_SLOT, + Int32Value(int32_t(isoDay))); // Step 7. obj->setFixedSlot(PlainMonthDayObject::CALENDAR_SLOT, calendar.toValue()); // Step 8. - obj->setFixedSlot(PlainMonthDayObject::ISO_YEAR_SLOT, Int32Value(isoYear)); + obj->setFixedSlot(PlainMonthDayObject::ISO_YEAR_SLOT, + Int32Value(int32_t(isoYear))); // Step 9. return obj; @@ -117,7 +120,7 @@ static PlainMonthDayObject* CreateTemporalMonthDay( */ PlainMonthDayObject* js::temporal::CreateTemporalMonthDay( JSContext* cx, const PlainDate& date, Handle<CalendarValue> calendar) { - auto& [isoYear, isoMonth, isoDay] = date; + const auto& [isoYear, isoMonth, isoDay] = date; // Step 1. if (!ThrowIfInvalidISODate(cx, date)) { @@ -307,8 +310,6 @@ static Wrapped<PlainMonthDayObject*> ToTemporalMonthDay( return nullptr; } - // FIXME: spec bug - missing call to CreateCalendarMethodsRecord - // Step 13. Rooted<CalendarRecord> calendar(cx); if (!CreateCalendarMethodsRecord(cx, calendarValue, @@ -530,13 +531,11 @@ static bool PlainMonthDay_with(JSContext* cx, const CallArgs& args) { if (!temporalMonthDayLike) { return false; } - - // Step 4. - if (!RejectTemporalLikeObject(cx, temporalMonthDayLike)) { + if (!ThrowIfTemporalLikeObject(cx, temporalMonthDayLike)) { return false; } - // Step 5. + // Step 4. Rooted<PlainObject*> resolvedOptions(cx); if (args.hasDefined(1)) { Rooted<JSObject*> options(cx, @@ -552,7 +551,7 @@ static bool PlainMonthDay_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 6. + // Step 5. Rooted<CalendarRecord> calendar(cx); if (!CreateCalendarMethodsRecord(cx, calendarValue, { @@ -564,7 +563,7 @@ static bool PlainMonthDay_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 7. + // Step 6. JS::RootedVector<PropertyKey> fieldNames(cx); if (!CalendarFields(cx, calendar, {CalendarField::Day, CalendarField::Month, @@ -573,34 +572,34 @@ static bool PlainMonthDay_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 8. + // Step 7. Rooted<PlainObject*> fields(cx, PrepareTemporalFields(cx, monthDay, fieldNames)); if (!fields) { return false; } - // Step 9. + // Step 8. Rooted<PlainObject*> partialMonthDay( cx, PreparePartialTemporalFields(cx, temporalMonthDayLike, fieldNames)); if (!partialMonthDay) { return false; } - // Step 10. + // Step 9. Rooted<JSObject*> mergedFields( cx, CalendarMergeFields(cx, calendar, fields, partialMonthDay)); if (!mergedFields) { return false; } - // Step 11. + // Step 10. fields = PrepareTemporalFields(cx, mergedFields, fieldNames); if (!fields) { return false; } - // Step 12. + // Step 11. auto obj = js::temporal::CalendarMonthDayFromFields(cx, calendar, fields, resolvedOptions); if (!obj) { @@ -836,20 +835,7 @@ static bool PlainMonthDay_toPlainDate(JSContext* cx, const CallArgs& args) { } // Step 12. - Rooted<PlainObject*> options(cx, NewPlainObjectWithProto(cx, nullptr)); - if (!options) { - return false; - } - - // Step 13. - Rooted<Value> overflow(cx, StringValue(cx->names().constrain)); - if (!DefineDataProperty(cx, options, cx->names().overflow, overflow)) { - return false; - } - - // Step 14. - auto obj = js::temporal::CalendarDateFromFields( - cx, calendar, mergedFromConcatenatedFields, options); + auto obj = CalendarDateFromFields(cx, calendar, mergedFromConcatenatedFields); if (!obj) { return false; } diff --git a/js/src/builtin/temporal/PlainTime.cpp b/js/src/builtin/temporal/PlainTime.cpp index bf35b9d93e..c928b06d46 100644 --- a/js/src/builtin/temporal/PlainTime.cpp +++ b/js/src/builtin/temporal/PlainTime.cpp @@ -7,7 +7,6 @@ #include "builtin/temporal/PlainTime.h" #include "mozilla/Assertions.h" -#include "mozilla/CheckedInt.h" #include "mozilla/FloatingPoint.h" #include "mozilla/Maybe.h" @@ -46,7 +45,6 @@ #include "js/PropertySpec.h" #include "js/RootingAPI.h" #include "js/Value.h" -#include "vm/BigIntType.h" #include "vm/BytecodeUtil.h" #include "vm/GlobalObject.h" #include "vm/JSAtomState.h" @@ -121,7 +119,8 @@ static bool IsValidTime(T hour, T minute, T second, T millisecond, * IsValidTime ( hour, minute, second, millisecond, microsecond, nanosecond ) */ bool js::temporal::IsValidTime(const PlainTime& time) { - auto& [hour, minute, second, millisecond, microsecond, nanosecond] = time; + const auto& [hour, minute, second, millisecond, microsecond, nanosecond] = + time; return ::IsValidTime(hour, minute, second, millisecond, microsecond, nanosecond); } @@ -217,7 +216,8 @@ static bool ThrowIfInvalidTime(JSContext* cx, T hour, T minute, T second, * IsValidTime ( hour, minute, second, millisecond, microsecond, nanosecond ) */ bool js::temporal::ThrowIfInvalidTime(JSContext* cx, const PlainTime& time) { - auto& [hour, minute, second, millisecond, microsecond, nanosecond] = time; + const auto& [hour, minute, second, millisecond, microsecond, nanosecond] = + time; return ::ThrowIfInvalidTime(cx, hour, minute, second, millisecond, microsecond, nanosecond); } @@ -261,9 +261,10 @@ static PlainTime ConstrainTime(double hour, double minute, double second, * RegulateTime ( hour, minute, second, millisecond, microsecond, nanosecond, * overflow ) */ -bool js::temporal::RegulateTime(JSContext* cx, const TimeRecord& time, +bool js::temporal::RegulateTime(JSContext* cx, const TemporalTimeLike& time, TemporalOverflow overflow, PlainTime* result) { - auto& [hour, minute, second, millisecond, microsecond, nanosecond] = time; + const auto& [hour, minute, second, millisecond, microsecond, nanosecond] = + time; // Step 1. MOZ_ASSERT(IsInteger(hour)); @@ -334,25 +335,28 @@ static PlainTimeObject* CreateTemporalTime(JSContext* cx, const CallArgs& args, } // Step 4. - object->setFixedSlot(PlainTimeObject::ISO_HOUR_SLOT, Int32Value(hour)); + object->setFixedSlot(PlainTimeObject::ISO_HOUR_SLOT, + Int32Value(int32_t(hour))); // Step 5. - object->setFixedSlot(PlainTimeObject::ISO_MINUTE_SLOT, Int32Value(minute)); + object->setFixedSlot(PlainTimeObject::ISO_MINUTE_SLOT, + Int32Value(int32_t(minute))); // Step 6. - object->setFixedSlot(PlainTimeObject::ISO_SECOND_SLOT, Int32Value(second)); + object->setFixedSlot(PlainTimeObject::ISO_SECOND_SLOT, + Int32Value(int32_t(second))); // Step 7. object->setFixedSlot(PlainTimeObject::ISO_MILLISECOND_SLOT, - Int32Value(millisecond)); + Int32Value(int32_t(millisecond))); // Step 8. object->setFixedSlot(PlainTimeObject::ISO_MICROSECOND_SLOT, - Int32Value(microsecond)); + Int32Value(int32_t(microsecond))); // Step 9. object->setFixedSlot(PlainTimeObject::ISO_NANOSECOND_SLOT, - Int32Value(nanosecond)); + Int32Value(int32_t(nanosecond))); // Step 10. return object; @@ -364,7 +368,8 @@ static PlainTimeObject* CreateTemporalTime(JSContext* cx, const CallArgs& args, */ PlainTimeObject* js::temporal::CreateTemporalTime(JSContext* cx, const PlainTime& time) { - auto& [hour, minute, second, millisecond, microsecond, nanosecond] = time; + const auto& [hour, minute, second, millisecond, microsecond, nanosecond] = + time; // Step 1. if (!ThrowIfInvalidTime(cx, time)) { @@ -403,63 +408,6 @@ PlainTimeObject* js::temporal::CreateTemporalTime(JSContext* cx, } /** - * CreateTimeDurationRecord ( days, hours, minutes, seconds, milliseconds, - * microseconds, nanoseconds ) - */ -static TimeDuration CreateTimeDurationRecord(double days, int32_t hours, - int32_t minutes, int32_t seconds, - int32_t milliseconds, - int32_t microseconds, - int32_t nanoseconds) { - // Step 1. - MOZ_ASSERT(IsValidDuration({0, 0, 0, days, double(hours), double(minutes), - double(seconds), double(microseconds), - double(nanoseconds)})); - - // Step 2. - return { - days, - double(hours), - double(minutes), - double(seconds), - double(milliseconds), - double(microseconds), - double(nanoseconds), - }; -} - -/** - * DurationSign ( years, months, weeks, days, hours, minutes, seconds, - * milliseconds, microseconds, nanoseconds ) - */ -static int32_t DurationSign(int32_t hours, int32_t minutes, int32_t seconds, - int32_t milliseconds, int32_t microseconds, - int32_t nanoseconds) { - // Step 1. (Loop unrolled) - if (hours) { - return hours > 0 ? 1 : -1; - } - if (minutes) { - return minutes > 0 ? 1 : -1; - } - if (seconds) { - return seconds > 0 ? 1 : -1; - } - if (milliseconds) { - return milliseconds > 0 ? 1 : -1; - } - if (microseconds) { - return microseconds > 0 ? 1 : -1; - } - if (nanoseconds) { - return nanoseconds > 0 ? 1 : -1; - } - - // Step 2. - return 0; -} - -/** * BalanceTime ( hour, minute, second, millisecond, microsecond, nanosecond ) */ template <typename IntT> @@ -531,7 +479,7 @@ static BalancedTime BalanceTime(int32_t hour, int32_t minute, int32_t second, BalancedTime js::temporal::BalanceTime(const PlainTime& time, int64_t nanoseconds) { MOZ_ASSERT(IsValidTime(time)); - MOZ_ASSERT(std::abs(nanoseconds) <= 2 * ToNanoseconds(TemporalUnit::Day)); + MOZ_ASSERT(std::abs(nanoseconds) <= ToNanoseconds(TemporalUnit::Day)); return ::BalanceTime<int64_t>(time.hour, time.minute, time.second, time.millisecond, time.microsecond, @@ -541,8 +489,8 @@ BalancedTime js::temporal::BalanceTime(const PlainTime& time, /** * DifferenceTime ( h1, min1, s1, ms1, mus1, ns1, h2, min2, s2, ms2, mus2, ns2 ) */ -TimeDuration js::temporal::DifferenceTime(const PlainTime& time1, - const PlainTime& time2) { +NormalizedTimeDuration js::temporal::DifferenceTime(const PlainTime& time1, + const PlainTime& time2) { MOZ_ASSERT(IsValidTime(time1)); MOZ_ASSERT(IsValidTime(time2)); @@ -565,22 +513,15 @@ TimeDuration js::temporal::DifferenceTime(const PlainTime& time1, int32_t nanoseconds = time2.nanosecond - time1.nanosecond; // Step 7. - int32_t sign = ::DurationSign(hours, minutes, seconds, milliseconds, - microseconds, nanoseconds); + auto result = NormalizeTimeDuration(hours, minutes, seconds, milliseconds, + microseconds, nanoseconds); // Step 8. - auto balanced = ::BalanceTime(hours * sign, minutes * sign, seconds * sign, - milliseconds * sign, microseconds * sign, - nanoseconds * sign); + MOZ_ASSERT(result.abs().toNanoseconds() < + Int128{ToNanoseconds(TemporalUnit::Day)}); // Step 9. - MOZ_ASSERT(balanced.days == 0); - - // Step 10. - return CreateTimeDurationRecord( - 0, balanced.time.hour * sign, balanced.time.minute * sign, - balanced.time.second * sign, balanced.time.millisecond * sign, - balanced.time.microsecond * sign, balanced.time.nanosecond * sign); + return result; } /** @@ -628,7 +569,7 @@ static bool ToTemporalTime(JSContext* cx, Handle<Value> item, } // Step 3.d. - TimeRecord timeResult; + TemporalTimeLike timeResult; if (!ToTemporalTimeRecord(cx, itemObj, &timeResult)) { return false; } @@ -684,218 +625,6 @@ bool js::temporal::ToTemporalTime(JSContext* cx, Handle<Value> item, } /** - * TotalDurationNanoseconds ( hours, minutes, seconds, milliseconds, - * microseconds, nanoseconds ) - */ -static int64_t TotalDurationNanoseconds(const Duration& duration) { - // This function is only called from BalanceTime. The difference between two - // plain times can't exceed the number of nanoseconds in a day. - MOZ_ASSERT(IsValidDuration(duration)); - MOZ_ASSERT(std::abs(duration.hours) <= 24); - MOZ_ASSERT(std::abs(duration.minutes) <= 60); - MOZ_ASSERT(std::abs(duration.seconds) <= 60); - MOZ_ASSERT(std::abs(duration.milliseconds) <= 1000); - MOZ_ASSERT(std::abs(duration.microseconds) <= 1000); - MOZ_ASSERT(std::abs(duration.nanoseconds) <= 1000); - - // Step 1. - auto minutes = int64_t(duration.minutes) + int64_t(duration.hours) * 60; - - // Step 2. - auto seconds = int64_t(duration.seconds) + minutes * 60; - - // Step 3. - auto milliseconds = int64_t(duration.milliseconds) + seconds * 1000; - - // Step 4. - auto microseconds = int64_t(duration.microseconds) + milliseconds * 1000; - - // Steps 5. - return int64_t(duration.nanoseconds) + microseconds * 1000; -} - -/** - * BalanceTimeDuration ( days, hours, minutes, seconds, milliseconds, - * microseconds, nanoseconds, largestUnit [ , relativeTo ] ) - */ -static Duration BalanceTimeDuration(const Duration& duration, - TemporalUnit largestUnit) { - MOZ_ASSERT(IsValidDuration(duration)); - MOZ_ASSERT(largestUnit > TemporalUnit::Day); - - // We only handle time components here. - MOZ_ASSERT(duration.years == 0); - MOZ_ASSERT(duration.months == 0); - MOZ_ASSERT(duration.weeks == 0); - MOZ_ASSERT(duration.days == 0); - - // Step 1. (Not applicable) - - // Step 2. - int64_t nanoseconds = TotalDurationNanoseconds(duration); - MOZ_ASSERT(std::abs(nanoseconds) <= ToNanoseconds(TemporalUnit::Day)); - - // Steps 3-4. (Not applicable) - - // Step 5. - int64_t hours = 0; - int64_t minutes = 0; - int64_t seconds = 0; - int64_t milliseconds = 0; - int64_t microseconds = 0; - - // Step 6. - int32_t sign = nanoseconds < 0 ? -1 : +1; - - // Step 7. - nanoseconds = std::abs(nanoseconds); - - // Steps 8-13. - switch (largestUnit) { - case TemporalUnit::Auto: - case TemporalUnit::Year: - case TemporalUnit::Month: - case TemporalUnit::Week: - case TemporalUnit::Day: - MOZ_CRASH("Unexpected temporal unit"); - - case TemporalUnit::Hour: { - // Step 8. - - // Step 8.a. - microseconds = nanoseconds / 1000; - - // Step 8.b. - nanoseconds = nanoseconds % 1000; - - // Step 8.c. - milliseconds = microseconds / 1000; - - // Step 8.d. - microseconds = microseconds % 1000; - - // Step 8.e. - seconds = milliseconds / 1000; - - // Step 8.f. - milliseconds = milliseconds % 1000; - - // Step 8.g. - minutes = seconds / 60; - - // Step 8.h. - seconds = seconds % 60; - - // Step 8.i. - hours = minutes / 60; - - // Step 8.j. - minutes = minutes % 60; - - break; - } - case TemporalUnit::Minute: { - // Step 9. - - // Step 9.a. - microseconds = nanoseconds / 1000; - - // Step 9.b. - nanoseconds = nanoseconds % 1000; - - // Step 9.c. - milliseconds = microseconds / 1000; - - // Step 9.d. - microseconds = microseconds % 1000; - - // Step 9.e. - seconds = milliseconds / 1000; - - // Step 9.f. - milliseconds = milliseconds % 1000; - - // Step 9.g. - minutes = seconds / 60; - - // Step 9.h. - seconds = seconds % 60; - - break; - } - case TemporalUnit::Second: { - // Step 10. - - // Step 10.a. - microseconds = nanoseconds / 1000; - - // Step 10.b. - nanoseconds = nanoseconds % 1000; - - // Step 10.c. - milliseconds = microseconds / 1000; - - // Step 10.d. - microseconds = microseconds % 1000; - - // Step 10.e. - seconds = milliseconds / 1000; - - // Step 10.f. - milliseconds = milliseconds % 1000; - - break; - } - case TemporalUnit::Millisecond: { - // Step 11. - - // Step 11.a. - microseconds = nanoseconds / 1000; - - // Step 11.b. - nanoseconds = nanoseconds % 1000; - - // Step 11.c. - milliseconds = microseconds / 1000; - - // Step 11.d. - microseconds = microseconds % 1000; - - break; - } - case TemporalUnit::Microsecond: { - // Step 12. - - // Step 12.a. - microseconds = nanoseconds / 1000; - - // Step 12.b. - nanoseconds = nanoseconds % 1000; - - break; - } - case TemporalUnit::Nanosecond: { - // Step 13. - break; - } - } - - // Step 14. - return { - 0, - 0, - 0, - 0, - double(hours * sign), - double(minutes * sign), - double(seconds * sign), - double(milliseconds * sign), - double(microseconds * sign), - double(nanoseconds * sign), - }; -} - -/** * CompareTemporalTime ( h1, min1, s1, ms1, mus1, ns1, h2, min2, s2, ms2, mus2, * ns2 ) */ @@ -940,7 +669,7 @@ int32_t js::temporal::CompareTemporalTime(const PlainTime& one, */ static bool ToTemporalTimeRecord(JSContext* cx, Handle<JSObject*> temporalTimeLike, - TimeRecord* result) { + TemporalTimeLike* result) { // Steps 1 and 3-4. (Not applicable in our implementation.) // Step 2. (Inlined call to PrepareTemporalFields.) @@ -1012,7 +741,7 @@ static bool ToTemporalTimeRecord(JSContext* cx, */ bool js::temporal::ToTemporalTimeRecord(JSContext* cx, Handle<JSObject*> temporalTimeLike, - TimeRecord* result) { + TemporalTimeLike* result) { // Step 3.a. (Set all fields to zero.) *result = {}; @@ -1020,59 +749,6 @@ bool js::temporal::ToTemporalTimeRecord(JSContext* cx, return ::ToTemporalTimeRecord(cx, temporalTimeLike, result); } -/** - * RoundNumberToIncrement ( x, increment, roundingMode ) - */ -static int64_t RoundNumberToIncrement(int64_t x, TemporalUnit unit, - Increment increment, - TemporalRoundingMode roundingMode) { - MOZ_ASSERT(x >= 0); - MOZ_ASSERT(x < ToNanoseconds(TemporalUnit::Day)); - - MOZ_ASSERT(unit >= TemporalUnit::Day); - MOZ_ASSERT_IF(unit == TemporalUnit::Day, increment == Increment{1}); - MOZ_ASSERT_IF(unit > TemporalUnit::Day, - increment <= MaximumTemporalDurationRoundingIncrement(unit)); - - int64_t divisor = ToNanoseconds(unit) * increment.value(); - MOZ_ASSERT(divisor > 0); - MOZ_ASSERT(divisor <= ToNanoseconds(TemporalUnit::Day)); - - // Division by one has no remainder. - if (divisor == 1) { - MOZ_ASSERT(increment == Increment{1}); - return x; - } - - // Steps 1-8. - int64_t rounded = Divide(x, divisor, roundingMode); - - // Step 9. - mozilla::CheckedInt64 result = rounded; - result *= increment.value(); - - MOZ_ASSERT(result.isValid(), "can't overflow when inputs are all in range"); - - return result.value(); -} - -/** - * RoundNumberToIncrement ( x, increment, roundingMode ) - */ -static int64_t RoundNumberToIncrement(int64_t x, int64_t divisor, - Increment increment, - TemporalRoundingMode roundingMode) { - MOZ_ASSERT(x >= 0); - MOZ_ASSERT(x < ToNanoseconds(TemporalUnit::Day)); - MOZ_ASSERT(divisor > 0); - MOZ_ASSERT(increment == Increment{1}, "Rounding increment for 'day' is 1"); - - // Steps 1-2. (Not applicable in our implementation) - - // Steps 3-8. - return Divide(x, divisor, roundingMode); -} - static int64_t TimeToNanos(const PlainTime& time) { // No overflow possible because the input is a valid time. MOZ_ASSERT(IsValidTime(time)); @@ -1090,7 +766,7 @@ static int64_t TimeToNanos(const PlainTime& time) { /** * RoundTime ( hour, minute, second, millisecond, microsecond, nanosecond, - * increment, unit, roundingMode [ , dayLengthNs ] ) + * increment, unit, roundingMode ) */ RoundedTime js::temporal::RoundTime(const PlainTime& time, Increment increment, TemporalUnit unit, @@ -1163,11 +839,15 @@ RoundedTime js::temporal::RoundTime(const PlainTime& time, Increment increment, } // Step 9. - int64_t r = ::RoundNumberToIncrement(TimeToNanos(quantity), unit, increment, - roundingMode); - MOZ_ASSERT(r == int64_t(int32_t(r)), - "no overflow possible due to limited range of arguments"); - *result = r; + int64_t nanos = TimeToNanos(quantity); + MOZ_ASSERT(0 <= nanos && nanos < ToNanoseconds(TemporalUnit::Day)); + + auto r = RoundNumberToIncrement(nanos, ToNanoseconds(unit), increment, + roundingMode); + MOZ_ASSERT(r == Int128{int32_t(r)}, + "can't overflow when inputs are all in range"); + + *result = int32_t(r); // Step 10. if (unit == TemporalUnit::Day) { @@ -1181,471 +861,31 @@ RoundedTime js::temporal::RoundTime(const PlainTime& time, Increment increment, } /** - * RoundTime ( hour, minute, second, millisecond, microsecond, nanosecond, - * increment, unit, roundingMode [ , dayLengthNs ] ) + * AddTime ( hour, minute, second, millisecond, microsecond, nanosecond, norm ) */ -RoundedTime js::temporal::RoundTime(const PlainTime& time, Increment increment, - TemporalUnit unit, - TemporalRoundingMode roundingMode, - const InstantSpan& dayLengthNs) { +AddedTime js::temporal::AddTime(const PlainTime& time, + const NormalizedTimeDuration& duration) { MOZ_ASSERT(IsValidTime(time)); - MOZ_ASSERT(IsValidInstantSpan(dayLengthNs)); - MOZ_ASSERT(dayLengthNs > (InstantSpan{})); + MOZ_ASSERT(IsValidNormalizedTimeDuration(duration)); - if (unit != TemporalUnit::Day) { - return RoundTime(time, increment, unit, roundingMode); + auto [seconds, nanoseconds] = duration; + if (seconds < 0 && nanoseconds > 0) { + seconds += 1; + nanoseconds -= 1'000'000'000; } - - // Step 1. (Not applicable) - - // Step 2. - int64_t quantity = TimeToNanos(time); - MOZ_ASSERT(quantity < ToNanoseconds(TemporalUnit::Day)); - - // Steps 3-8. (Not applicable) - - // Step 9. - int64_t divisor; - if (auto checkedDiv = dayLengthNs.toNanoseconds(); checkedDiv.isValid()) { - divisor = checkedDiv.value(); - } else { - // When the divisor is too large, the expression `quantity / divisor` is a - // value near zero. Substitute |divisor| with an equivalent expression. - // Choose |86'400'000'000'000| which will give a similar result because - // |quantity| is guaranteed to be lower than |86'400'000'000'000|. - divisor = ToNanoseconds(TemporalUnit::Day); - } - MOZ_ASSERT(divisor > 0); - - int64_t result = - ::RoundNumberToIncrement(quantity, divisor, increment, roundingMode); - - // Step 10. - return {result, {0, 0, 0, 0, 0, 0}}; -} - -/** - * AddTime ( hour, minute, second, millisecond, microsecond, nanosecond, hours, - * minutes, seconds, milliseconds, microseconds, nanoseconds ) - */ -static PlainTime AddTime(const PlainTime& time, const Duration& duration) { - MOZ_ASSERT(IsValidTime(time)); - MOZ_ASSERT(IsValidDuration(duration)); - - // Balance the duration so we don't have to worry about imprecise Number - // computations below. - - // Use either int64_t or int32_t below. Assert the total combined amount of - // the units can be expressed in either int64_t or int32_t. - static_assert(1 * UnitsPerDay(TemporalUnit::Nanosecond) > INT32_MAX, - "total combined nanoseconds per day"); - static_assert(2 * UnitsPerDay(TemporalUnit::Microsecond) > INT32_MAX, - "total combined microseconds per day"); - static_assert(3 * UnitsPerDay(TemporalUnit::Millisecond) <= INT32_MAX, - "total combined milliseconds per day"); - static_assert(4 * UnitsPerDay(TemporalUnit::Second) <= INT32_MAX, - "total combined seconds per day"); - static_assert(5 * UnitsPerDay(TemporalUnit::Minute) <= INT32_MAX, - "total combined minutes per day"); - static_assert(6 * UnitsPerDay(TemporalUnit::Hour) <= INT32_MAX, - "total combined hours per day"); - - // We ignore the days overflow in this function, therefore it's possible - // to restrict each unit to units-per-day. - int64_t nanoseconds = int64_t( - std::fmod(duration.nanoseconds, UnitsPerDay(TemporalUnit::Nanosecond))); - int64_t microseconds = int64_t( - std::fmod(duration.microseconds, UnitsPerDay(TemporalUnit::Microsecond))); - int32_t milliseconds = int32_t( - std::fmod(duration.milliseconds, UnitsPerDay(TemporalUnit::Millisecond))); - int32_t seconds = - int32_t(std::fmod(duration.seconds, UnitsPerDay(TemporalUnit::Second))); - int32_t minutes = - int32_t(std::fmod(duration.minutes, UnitsPerDay(TemporalUnit::Minute))); - int32_t hours = - int32_t(std::fmod(duration.hours, UnitsPerDay(TemporalUnit::Hour))); - - // Each unit is now less than the units-per-day. - MOZ_ASSERT(std::abs(nanoseconds) < UnitsPerDay(TemporalUnit::Nanosecond)); - MOZ_ASSERT(std::abs(microseconds) < UnitsPerDay(TemporalUnit::Microsecond)); - MOZ_ASSERT(std::abs(milliseconds) < UnitsPerDay(TemporalUnit::Millisecond)); - MOZ_ASSERT(std::abs(seconds) < UnitsPerDay(TemporalUnit::Second)); - MOZ_ASSERT(std::abs(minutes) < UnitsPerDay(TemporalUnit::Minute)); - MOZ_ASSERT(std::abs(hours) < UnitsPerDay(TemporalUnit::Hour)); - - microseconds += nanoseconds / 1000; - nanoseconds %= 1000; - MOZ_ASSERT(microseconds < 2 * UnitsPerDay(TemporalUnit::Microsecond)); - - milliseconds += microseconds / 1000; - microseconds %= 1000; - MOZ_ASSERT(milliseconds < 3 * UnitsPerDay(TemporalUnit::Millisecond)); - - seconds += milliseconds / 1000; - milliseconds %= 1000; - MOZ_ASSERT(seconds < 4 * UnitsPerDay(TemporalUnit::Second)); - - minutes += seconds / 60; - seconds %= 60; - MOZ_ASSERT(minutes < 5 * UnitsPerDay(TemporalUnit::Minute)); - - hours += minutes / 60; - minutes %= 60; - MOZ_ASSERT(hours < 6 * UnitsPerDay(TemporalUnit::Hour)); - - hours %= 24; - - MOZ_ASSERT(std::abs(hours) <= 23); - MOZ_ASSERT(std::abs(minutes) <= 59); - MOZ_ASSERT(std::abs(seconds) <= 59); - MOZ_ASSERT(std::abs(milliseconds) <= 999); - MOZ_ASSERT(std::abs(microseconds) <= 999); - MOZ_ASSERT(std::abs(nanoseconds) <= 999); + MOZ_ASSERT(std::abs(nanoseconds) <= 999'999'999); // Step 1. - int32_t hour = time.hour + hours; + int64_t second = time.second + seconds; // Step 2. - int32_t minute = time.minute + minutes; + int32_t nanosecond = time.nanosecond + nanoseconds; // Step 3. - int32_t second = time.second + seconds; - - // Step 4. - int32_t millisecond = time.millisecond + milliseconds; - - // Step 5. - int32_t microsecond = time.microsecond + int32_t(microseconds); - - // Step 6. - int32_t nanosecond = time.nanosecond + int32_t(nanoseconds); - - // Step 7. auto balanced = - ::BalanceTime(hour, minute, second, millisecond, microsecond, nanosecond); - return balanced.time; -} - -static BigInt* FloorDiv(JSContext* cx, Handle<BigInt*> dividend, - int32_t divisor) { - MOZ_ASSERT(divisor > 0); - - Rooted<BigInt*> div(cx, BigInt::createFromInt64(cx, divisor)); - if (!div) { - return nullptr; - } - - Rooted<BigInt*> quotient(cx); - Rooted<BigInt*> remainder(cx); - if (!BigInt::divmod(cx, dividend, div, "ient, &remainder)) { - return nullptr; - } - if (remainder->isNegative()) { - return BigInt::dec(cx, quotient); - } - return quotient; -} - -static bool AddTimeDaysSlow(JSContext* cx, const PlainTime& time, - const Duration& duration, double* result) { - MOZ_ASSERT(IsValidTime(time)); - MOZ_ASSERT(IsValidDuration(duration)); - - Rooted<BigInt*> days(cx, BigInt::createFromDouble(cx, duration.days)); - if (!days) { - return false; - } - - Rooted<BigInt*> hours(cx, BigInt::createFromDouble(cx, duration.hours)); - if (!hours) { - return false; - } - - Rooted<BigInt*> minutes(cx, BigInt::createFromDouble(cx, duration.minutes)); - if (!minutes) { - return false; - } - - Rooted<BigInt*> seconds(cx, BigInt::createFromDouble(cx, duration.seconds)); - if (!seconds) { - return false; - } - - Rooted<BigInt*> milliseconds( - cx, BigInt::createFromDouble(cx, duration.milliseconds)); - if (!milliseconds) { - return false; - } - - Rooted<BigInt*> microseconds( - cx, BigInt::createFromDouble(cx, duration.microseconds)); - if (!microseconds) { - return false; - } - - Rooted<BigInt*> nanoseconds( - cx, BigInt::createFromDouble(cx, duration.nanoseconds)); - if (!nanoseconds) { - return false; - } - - auto addWithInt32 = [cx](Handle<BigInt*> left, int32_t right) -> BigInt* { - Rooted<BigInt*> rightBigInt(cx, BigInt::createFromInt64(cx, right)); - if (!rightBigInt) { - return nullptr; - } - return BigInt::add(cx, left, rightBigInt); - }; - - // Step 1. - Rooted<BigInt*> hour(cx, addWithInt32(hours, time.hour)); - if (!hour) { - return false; - } - - // Step 2. - Rooted<BigInt*> minute(cx, addWithInt32(minutes, time.minute)); - if (!minute) { - return false; - } - - // Step 3. - Rooted<BigInt*> second(cx, addWithInt32(seconds, time.second)); - if (!second) { - return false; - } - - // Step 4. - Rooted<BigInt*> millisecond(cx, addWithInt32(milliseconds, time.millisecond)); - if (!millisecond) { - return false; - } - - // Step 5. - Rooted<BigInt*> microsecond(cx, addWithInt32(microseconds, time.microsecond)); - if (!microsecond) { - return false; - } - - // Step 6. - Rooted<BigInt*> nanosecond(cx, addWithInt32(nanoseconds, time.nanosecond)); - if (!nanosecond) { - return false; - } - - // Step 7. (Inlined BalanceTime) - - auto addFloorDiv = [cx](Handle<BigInt*> left, Handle<BigInt*> right, - int32_t divisor) -> BigInt* { - Rooted<BigInt*> quotient(cx, FloorDiv(cx, right, divisor)); - if (!quotient) { - return nullptr; - } - return BigInt::add(cx, left, quotient); - }; - - // BalanceTime, steps 1-2. - microsecond = addFloorDiv(microsecond, nanosecond, 1000); - if (!microsecond) { - return false; - } - - // BalanceTime, steps 3-4. - millisecond = addFloorDiv(millisecond, microsecond, 1000); - if (!millisecond) { - return false; - } - - // BalanceTime, steps 5-6. - second = addFloorDiv(second, millisecond, 1000); - if (!second) { - return false; - } - - // BalanceTime, steps 7-8. - minute = addFloorDiv(minute, second, 60); - if (!minute) { - return false; - } - - // BalanceTime, steps 9-10. - hour = addFloorDiv(hour, minute, 60); - if (!hour) { - return false; - } - - // BalanceTime, steps 11-13. - days = addFloorDiv(days, hour, 24); - if (!days) { - return false; - } - - // The days number is used as the input for a duration. Throw if the BigInt - // when converted to a Number can't be represented in a duration. - double daysNumber = BigInt::numberValue(days); - if (!ThrowIfInvalidDuration(cx, {0, 0, 0, daysNumber})) { - return false; - } - MOZ_ASSERT(IsInteger(daysNumber)); - - *result = daysNumber; - return true; -} - -static mozilla::Maybe<int64_t> AddTimeDays(const PlainTime& time, - const Duration& duration) { - MOZ_ASSERT(IsValidTime(time)); - MOZ_ASSERT(IsValidDuration(duration)); - - int64_t days; - if (!mozilla::NumberEqualsInt64(duration.days, &days)) { - return mozilla::Nothing(); - } - - int64_t hours; - if (!mozilla::NumberEqualsInt64(duration.hours, &hours)) { - return mozilla::Nothing(); - } - - int64_t minutes; - if (!mozilla::NumberEqualsInt64(duration.minutes, &minutes)) { - return mozilla::Nothing(); - } - - int64_t seconds; - if (!mozilla::NumberEqualsInt64(duration.seconds, &seconds)) { - return mozilla::Nothing(); - } - - int64_t milliseconds; - if (!mozilla::NumberEqualsInt64(duration.milliseconds, &milliseconds)) { - return mozilla::Nothing(); - } - - int64_t microseconds; - if (!mozilla::NumberEqualsInt64(duration.microseconds, µseconds)) { - return mozilla::Nothing(); - } - - int64_t nanoseconds; - if (!mozilla::NumberEqualsInt64(duration.nanoseconds, &nanoseconds)) { - return mozilla::Nothing(); - } - - // Step 1. - auto hour = mozilla::CheckedInt64(time.hour) + hours; - if (!hour.isValid()) { - return mozilla::Nothing(); - } - - // Step 2. - auto minute = mozilla::CheckedInt64(time.minute) + minutes; - if (!minute.isValid()) { - return mozilla::Nothing(); - } - - // Step 3. - auto second = mozilla::CheckedInt64(time.second) + seconds; - if (!second.isValid()) { - return mozilla::Nothing(); - } - - // Step 4. - auto millisecond = mozilla::CheckedInt64(time.millisecond) + milliseconds; - if (!millisecond.isValid()) { - return mozilla::Nothing(); - } - - // Step 5. - auto microsecond = mozilla::CheckedInt64(time.microsecond) + microseconds; - if (!microsecond.isValid()) { - return mozilla::Nothing(); - } - - // Step 6. - auto nanosecond = mozilla::CheckedInt64(time.nanosecond) + nanoseconds; - if (!nanosecond.isValid()) { - return mozilla::Nothing(); - } - - // Step 7. (Inlined BalanceTime) - - // BalanceTime, steps 1-2. - microsecond += FloorDiv(nanosecond.value(), 1000); - if (!microsecond.isValid()) { - return mozilla::Nothing(); - } - - // BalanceTime, steps 3-4. - millisecond += FloorDiv(microsecond.value(), 1000); - if (!millisecond.isValid()) { - return mozilla::Nothing(); - } - - // BalanceTime, steps 5-6. - second += FloorDiv(millisecond.value(), 1000); - if (!second.isValid()) { - return mozilla::Nothing(); - } - - // BalanceTime, steps 7-8. - minute += FloorDiv(second.value(), 60); - if (!minute.isValid()) { - return mozilla::Nothing(); - } - - // BalanceTime, steps 9-10. - hour += FloorDiv(minute.value(), 60); - if (!hour.isValid()) { - return mozilla::Nothing(); - } - - // BalanceTime, steps 11-13. - auto result = mozilla::CheckedInt64(days) + FloorDiv(hour.value(), 24); - if (!result.isValid()) { - return mozilla::Nothing(); - } - return mozilla::Some(result.value()); -} - -static bool AddTimeDays(JSContext* cx, const PlainTime& time, - const Duration& duration, double* result) { - // Fast-path when we can perform the whole computation with int64 values. - if (auto days = AddTimeDays(time, duration)) { - *result = *days; - return true; - } - return AddTimeDaysSlow(cx, time, duration, result); -} - -/** - * AddTime ( hour, minute, second, millisecond, microsecond, nanosecond, hours, - * minutes, seconds, milliseconds, microseconds, nanoseconds ) - */ -bool js::temporal::AddTime(JSContext* cx, const PlainTime& time, - const Duration& duration, PlainTime* result, - double* daysResult) { - MOZ_ASSERT(IsValidTime(time)); - MOZ_ASSERT(IsValidDuration(duration)); - - // Steps 1-7. - auto balanced = ::AddTime(time, duration); - - // Compute |days| separately to ensure no loss of precision occurs. - // - // The single caller of this |AddTime| function also needs to compute the - // addition of |duration.days| and the balanced days. Perform this addition - // here, so we don't need to pass around BigInt values for exact mathematical - // results. - double days; - if (!AddTimeDays(cx, time, duration, &days)) { - return false; - } - MOZ_ASSERT(IsInteger(days)); - - *result = balanced; - *daysResult = days; - return true; + ::BalanceTime<int64_t>(time.hour, time.minute, second, time.millisecond, + time.microsecond, nanosecond); + return {balanced.days, balanced.time}; } /** @@ -1699,30 +939,28 @@ static bool DifferenceTemporalPlainTime(JSContext* cx, // Step 5. auto diff = DifferenceTime(temporalTime, other); - MOZ_ASSERT(diff.days == 0); // Step 6. - auto roundedDuration = diff.toDuration(); if (settings.smallestUnit != TemporalUnit::Nanosecond || settings.roundingIncrement != Increment{1}) { // Steps 6.a-b. - if (!RoundDuration(cx, roundedDuration.time(), settings.roundingIncrement, - settings.smallestUnit, settings.roundingMode, - &roundedDuration)) { - return false; - } + diff = RoundDuration(diff, settings.roundingIncrement, + settings.smallestUnit, settings.roundingMode); } // Step 7. - auto balancedDuration = - BalanceTimeDuration(roundedDuration, settings.largestUnit); + TimeDuration balancedDuration; + if (!BalanceTimeDuration(cx, diff, settings.largestUnit, &balancedDuration)) { + return false; + } // Step 8. + auto duration = balancedDuration.toDuration(); if (operation == TemporalDifference::Since) { - balancedDuration = balancedDuration.negate(); + duration = duration.negate(); } - auto* result = CreateTemporalDuration(cx, balancedDuration); + auto* result = CreateTemporalDuration(cx, duration); if (!result) { return false; } @@ -1754,13 +992,14 @@ static bool AddDurationToOrSubtractDurationFromPlainTime( if (operation == PlainTimeDuration::Subtract) { duration = duration.negate(); } - auto result = AddTime(time, duration); + auto timeDuration = NormalizeTimeDuration(duration); // Step 4. - MOZ_ASSERT(IsValidTime(result)); + auto result = AddTime(time, timeDuration); + MOZ_ASSERT(IsValidTime(result.time)); // Step 5. - auto* obj = CreateTemporalTime(cx, result); + auto* obj = CreateTemporalTime(cx, result.time); if (!obj) { return false; } @@ -1864,7 +1103,7 @@ static bool PlainTime_from(JSContext* cx, unsigned argc, Value* vp) { } // Steps 4-5. - auto result = ToTemporalTime(cx, args.get(0), overflow); + auto* result = ToTemporalTime(cx, args.get(0), overflow); if (!result) { return false; } @@ -2059,29 +1298,27 @@ static bool PlainTime_with(JSContext* cx, const CallArgs& args) { if (!temporalTimeLike) { return false; } - - // Step 4. - if (!RejectTemporalLikeObject(cx, temporalTimeLike)) { + if (!ThrowIfTemporalLikeObject(cx, temporalTimeLike)) { return false; } auto overflow = TemporalOverflow::Constrain; if (args.hasDefined(1)) { - // Step 5. + // Step 4. Rooted<JSObject*> options(cx, RequireObjectArg(cx, "options", "with", args[1])); if (!options) { return false; } - // Step 6. + // Step 5. if (!ToTemporalOverflow(cx, options, &overflow)) { return false; } } - // Steps 7-19. - TimeRecord partialTime = { + // Steps 6-18. + TemporalTimeLike partialTime = { double(time.hour), double(time.minute), double(time.second), double(time.millisecond), double(time.microsecond), double(time.nanosecond), @@ -2090,13 +1327,13 @@ static bool PlainTime_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 20. + // Step 19. PlainTime result; if (!RegulateTime(cx, partialTime, overflow, &result)) { return false; } - // Step 21. + // Step 20. auto* obj = CreateTemporalTime(cx, result); if (!obj) { return false; diff --git a/js/src/builtin/temporal/PlainTime.h b/js/src/builtin/temporal/PlainTime.h index b6da469913..0614430e46 100644 --- a/js/src/builtin/temporal/PlainTime.h +++ b/js/src/builtin/temporal/PlainTime.h @@ -112,19 +112,24 @@ PlainTimeObject* CreateTemporalTime(JSContext* cx, const PlainTime& time); bool ToTemporalTime(JSContext* cx, JS::Handle<JS::Value> item, PlainTime* result); +struct AddedTime { + int32_t days = 0; + PlainTime time; +}; + /** - * AddTime ( hour, minute, second, millisecond, microsecond, nanosecond, hours, - * minutes, seconds, milliseconds, microseconds, nanoseconds ) + * AddTime ( hour, minute, second, millisecond, microsecond, nanosecond, norm ) */ -bool AddTime(JSContext* cx, const PlainTime& time, const Duration& duration, - PlainTime* result, double* daysResult); +AddedTime AddTime(const PlainTime& time, + const NormalizedTimeDuration& duration); /** * DifferenceTime ( h1, min1, s1, ms1, mus1, ns1, h2, min2, s2, ms2, mus2, ns2 ) */ -TimeDuration DifferenceTime(const PlainTime& time1, const PlainTime& time2); +NormalizedTimeDuration DifferenceTime(const PlainTime& time1, + const PlainTime& time2); -struct TimeRecord final { +struct TemporalTimeLike final { double hour = 0; double minute = 0; double second = 0; @@ -137,13 +142,13 @@ struct TimeRecord final { * ToTemporalTimeRecord ( temporalTimeLike [ , completeness ] ) */ bool ToTemporalTimeRecord(JSContext* cx, JS::Handle<JSObject*> temporalTimeLike, - TimeRecord* result); + TemporalTimeLike* result); /** * RegulateTime ( hour, minute, second, millisecond, microsecond, nanosecond, * overflow ) */ -bool RegulateTime(JSContext* cx, const TimeRecord& time, +bool RegulateTime(JSContext* cx, const TemporalTimeLike& time, TemporalOverflow overflow, PlainTime* result); /** @@ -169,19 +174,11 @@ struct RoundedTime final { /** * RoundTime ( hour, minute, second, millisecond, microsecond, nanosecond, - * increment, unit, roundingMode [ , dayLengthNs ] ) + * increment, unit, roundingMode ) */ RoundedTime RoundTime(const PlainTime& time, Increment increment, TemporalUnit unit, TemporalRoundingMode roundingMode); -/** - * RoundTime ( hour, minute, second, millisecond, microsecond, nanosecond, - * increment, unit, roundingMode [ , dayLengthNs ] ) - */ -RoundedTime RoundTime(const PlainTime& time, Increment increment, - TemporalUnit unit, TemporalRoundingMode roundingMode, - const InstantSpan& dayLengthNs); - } /* namespace js::temporal */ #endif /* builtin_temporal_PlainTime_h */ diff --git a/js/src/builtin/temporal/PlainYearMonth.cpp b/js/src/builtin/temporal/PlainYearMonth.cpp index b95efd3179..c28277e2be 100644 --- a/js/src/builtin/temporal/PlainYearMonth.cpp +++ b/js/src/builtin/temporal/PlainYearMonth.cpp @@ -111,7 +111,7 @@ static PlainYearMonthObject* CreateTemporalYearMonth( // testing |referenceISODay|? // Step 2. - if (!ISOYearMonthWithinLimits(isoYear, isoMonth)) { + if (!ISOYearMonthWithinLimits(isoYear, int32_t(isoMonth))) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TEMPORAL_PLAIN_YEAR_MONTH_INVALID); return nullptr; @@ -130,16 +130,19 @@ static PlainYearMonthObject* CreateTemporalYearMonth( } // Step 5. - obj->setFixedSlot(PlainYearMonthObject::ISO_YEAR_SLOT, Int32Value(isoYear)); + obj->setFixedSlot(PlainYearMonthObject::ISO_YEAR_SLOT, + Int32Value(int32_t(isoYear))); // Step 6. - obj->setFixedSlot(PlainYearMonthObject::ISO_MONTH_SLOT, Int32Value(isoMonth)); + obj->setFixedSlot(PlainYearMonthObject::ISO_MONTH_SLOT, + Int32Value(int32_t(isoMonth))); // Step 7. obj->setFixedSlot(PlainYearMonthObject::CALENDAR_SLOT, calendar.toValue()); // Step 8. - obj->setFixedSlot(PlainYearMonthObject::ISO_DAY_SLOT, Int32Value(isoDay)); + obj->setFixedSlot(PlainYearMonthObject::ISO_DAY_SLOT, + Int32Value(int32_t(isoDay))); // Step 9. return obj; @@ -151,7 +154,7 @@ static PlainYearMonthObject* CreateTemporalYearMonth( */ PlainYearMonthObject* js::temporal::CreateTemporalYearMonth( JSContext* cx, const PlainDate& date, Handle<CalendarValue> calendar) { - auto& [isoYear, isoMonth, isoDay] = date; + const auto& [isoYear, isoMonth, isoDay] = date; // Step 1. if (!ThrowIfInvalidISODate(cx, date)) { @@ -251,8 +254,8 @@ static Wrapped<PlainYearMonthObject*> ToTemporalYearMonth( // Step 3.f. if (maybeResolvedOptions) { - return CalendarYearMonthFromFields(cx, calendar, fields, - maybeResolvedOptions); + return temporal::CalendarYearMonthFromFields(cx, calendar, fields, + maybeResolvedOptions); } return CalendarYearMonthFromFields(cx, calendar, fields); } @@ -420,9 +423,6 @@ static bool DifferenceTemporalPlainYearMonth(JSContext* cx, } // Step 8. - // FIXME: spec issue - duplicate CreateDataPropertyOrThrow for "largestUnit". - - // Step 9. Rooted<CalendarRecord> calendarRec(cx); if (!CreateCalendarMethodsRecord(cx, calendar, { @@ -435,7 +435,7 @@ static bool DifferenceTemporalPlainYearMonth(JSContext* cx, return false; } - // Step 10. + // Step 9. JS::RootedVector<PropertyKey> fieldNames(cx); if (!CalendarFields(cx, calendarRec, {CalendarField::MonthCode, CalendarField::Year}, @@ -443,101 +443,92 @@ static bool DifferenceTemporalPlainYearMonth(JSContext* cx, return false; } - // Step 11. + // Step 10. Rooted<PlainObject*> thisFields( cx, PrepareTemporalFields(cx, yearMonth, fieldNames)); if (!thisFields) { return false; } - // Step 12. + // Step 11. Value one = Int32Value(1); auto handleOne = Handle<Value>::fromMarkedLocation(&one); if (!DefineDataProperty(cx, thisFields, cx->names().day, handleOne)) { return false; } - // Step 13. + // Step 12. Rooted<Wrapped<PlainDateObject*>> thisDate( cx, CalendarDateFromFields(cx, calendarRec, thisFields)); if (!thisDate) { return false; } - // Step 14. + // Step 13. Rooted<PlainObject*> otherFields( cx, PrepareTemporalFields(cx, other, fieldNames)); if (!otherFields) { return false; } - // Step 15. + // Step 14. if (!DefineDataProperty(cx, otherFields, cx->names().day, handleOne)) { return false; } - // Step 16. + // Step 15. Rooted<Wrapped<PlainDateObject*>> otherDate( cx, CalendarDateFromFields(cx, calendarRec, otherFields)); if (!otherDate) { return false; } - // Steps 17-18. - Duration result; + // Steps 16-17. + DateDuration until; if (resolvedOptions) { - // Step 17. - Rooted<Value> largestUnitValue( - cx, StringValue(TemporalUnitToString(cx, settings.largestUnit))); - if (!DefineDataProperty(cx, resolvedOptions, cx->names().largestUnit, - largestUnitValue)) { - return false; - } - - // Step 18. if (!CalendarDateUntil(cx, calendarRec, thisDate, otherDate, - resolvedOptions, &result)) { + settings.largestUnit, resolvedOptions, &until)) { return false; } } else { - // Steps 17-18. if (!CalendarDateUntil(cx, calendarRec, thisDate, otherDate, - settings.largestUnit, &result)) { + settings.largestUnit, &until)) { return false; } } // We only care about years and months here, all other fields are set to zero. - Duration duration = {result.years, result.months}; + auto dateDuration = DateDuration{until.years, until.months}; - // Step 19. + // Step 18. if (settings.smallestUnit != TemporalUnit::Month || settings.roundingIncrement != Increment{1}) { - // Steps 19.a-b. - Duration roundResult; - if (!RoundDuration(cx, duration, settings.roundingIncrement, + // Steps 18.a-b. + NormalizedDuration roundResult; + if (!RoundDuration(cx, {dateDuration, {}}, settings.roundingIncrement, settings.smallestUnit, settings.roundingMode, thisDate, calendarRec, &roundResult)) { return false; } - // Step 19.c. - auto toBalance = Duration{roundResult.years, roundResult.months}; - DateDuration balanceResult; + // Step 18.c. + auto toBalance = + DateDuration{roundResult.date.years, roundResult.date.months}; if (!temporal::BalanceDateDurationRelative( cx, toBalance, settings.largestUnit, settings.smallestUnit, - thisDate, calendarRec, &balanceResult)) { + thisDate, calendarRec, &dateDuration)) { return false; } - duration = balanceResult.toDuration(); } - // Step 20. + // Step 19. + auto duration = + Duration{double(dateDuration.years), double(dateDuration.months)}; if (operation == TemporalDifference::Since) { duration = duration.negate(); } - auto* obj = CreateTemporalDuration(cx, {duration.years, duration.months}); + auto* obj = CreateTemporalDuration(cx, duration); if (!obj) { return false; } @@ -569,16 +560,37 @@ static bool AddDurationToOrSubtractDurationFromPlainYearMonth( } // Step 3. - TimeDuration balanceResult; - if (!BalanceTimeDuration(cx, duration, TemporalUnit::Day, &balanceResult)) { + Rooted<JSObject*> options(cx); + if (args.hasDefined(1)) { + const char* name = + operation == PlainYearMonthDuration::Add ? "add" : "subtract"; + options = RequireObjectArg(cx, "options", name, args[1]); + } else { + // TODO: Avoid creating an options object if not necessary. + options = NewPlainObjectWithProto(cx, nullptr); + } + if (!options) { return false; } // Step 4. - int32_t sign = DurationSign( - {duration.years, duration.months, duration.weeks, balanceResult.days}); + auto timeDuration = NormalizeTimeDuration(duration); // Step 5. + auto balancedTime = BalanceTimeDuration(timeDuration, TemporalUnit::Day); + + // Steps 6 and 16. (Reordered) + auto durationToAdd = DateDuration{ + int64_t(duration.years), + int64_t(duration.months), + int64_t(duration.weeks), + int64_t(duration.days) + balancedTime.days, + }; + + // Step 7. + int32_t sign = DurationSign(durationToAdd); + + // Step 8. Rooted<CalendarValue> calendarValue(cx, yearMonth->calendar()); Rooted<CalendarRecord> calendar(cx); if (!CreateCalendarMethodsRecord(cx, calendarValue, @@ -593,7 +605,7 @@ static bool AddDurationToOrSubtractDurationFromPlainYearMonth( return false; }; - // Step 6. + // Step 9. JS::RootedVector<PropertyKey> fieldNames(cx); if (!CalendarFields(cx, calendar, {CalendarField::MonthCode, CalendarField::Year}, @@ -601,34 +613,34 @@ static bool AddDurationToOrSubtractDurationFromPlainYearMonth( return false; } - // Step 7. + // Step 10. Rooted<PlainObject*> fields(cx, PrepareTemporalFields(cx, yearMonth, fieldNames)); if (!fields) { return false; } - // Step 8. + // Step 11. Rooted<PlainObject*> fieldsCopy(cx, SnapshotOwnProperties(cx, fields)); if (!fieldsCopy) { return false; } - // Step 9. + // Step 12. Value one = Int32Value(1); auto handleOne = Handle<Value>::fromMarkedLocation(&one); if (!DefineDataProperty(cx, fields, cx->names().day, handleOne)) { return false; } - // Step 10. + // Step 13. Rooted<Wrapped<PlainDateObject*>> intermediateDate( cx, CalendarDateFromFields(cx, calendar, fields)); if (!intermediateDate) { return false; } - // Steps 11-12. + // Steps 14-15. Rooted<Wrapped<PlainDateObject*>> date(cx); if (sign < 0) { // |intermediateDate| is initialized to the first day of |yearMonth|'s @@ -645,10 +657,10 @@ static bool AddDurationToOrSubtractDurationFromPlainYearMonth( // some days are skipped, for example consider the Julian-to-Gregorian // calendar transition. - // Step 11.a. - Duration oneMonthDuration = {0, 1}; + // Step 14.a. + auto oneMonthDuration = DateDuration{0, 1}; - // Step 11.b. + // Step 14.b. Rooted<Wrapped<PlainDateObject*>> nextMonth( cx, CalendarDateAdd(cx, calendar, intermediateDate, oneMonthDuration)); if (!nextMonth) { @@ -661,87 +673,63 @@ static bool AddDurationToOrSubtractDurationFromPlainYearMonth( } auto nextMonthDate = ToPlainDate(unwrappedNextMonth); - // Step 11.c. - PlainDate endOfMonthISO; - if (!AddISODate(cx, nextMonthDate, {0, 0, 0, -1}, - TemporalOverflow::Constrain, &endOfMonthISO)) { - return false; - } + // Step 14.c. + auto endOfMonthISO = BalanceISODate(nextMonthDate.year, nextMonthDate.month, + nextMonthDate.day - 1); - // Step 11.d. + // Step 14.d. Rooted<PlainDateWithCalendar> endOfMonth(cx); if (!CreateTemporalDate(cx, endOfMonthISO, calendar.receiver(), &endOfMonth)) { return false; } - // Step 11.e. + // Step 14.e. Rooted<Value> day(cx); if (!CalendarDay(cx, calendar, endOfMonth.date(), &day)) { return false; } - // Step 11.f. + // Step 14.f. if (!DefineDataProperty(cx, fieldsCopy, cx->names().day, day)) { return false; } - // Step 11.g. + // Step 14.g. date = CalendarDateFromFields(cx, calendar, fieldsCopy); if (!date) { return false; } } else { - // Step 12.a. + // Step 15.a. date = intermediateDate; } - // Step 13. - Duration durationToAdd = {duration.years, duration.months, duration.weeks, - balanceResult.days}; - - // FIXME: spec issue - GetOptionsObject should be called after - // ToTemporalDurationRecord to validate the input type before performing any - // other user-visible operations. - // https://github.com/tc39/proposal-temporal/issues/2721 - - // Step 14. - Rooted<JSObject*> options(cx); - if (args.hasDefined(1)) { - const char* name = - operation == PlainYearMonthDuration::Add ? "add" : "subtract"; - options = RequireObjectArg(cx, "options", name, args[1]); - } else { - // TODO: Avoid creating an options object if not necessary. - options = NewPlainObjectWithProto(cx, nullptr); - } - if (!options) { - return false; - } + // Step 16. (Moved above) - // Step 15. + // Step 17. Rooted<PlainObject*> optionsCopy(cx, SnapshotOwnProperties(cx, options)); if (!optionsCopy) { return false; } - // Step 16. + // Step 18. Rooted<Wrapped<PlainDateObject*>> addedDate( cx, AddDate(cx, calendar, date, durationToAdd, options)); if (!addedDate) { return false; } - // Step 17. + // Step 19. Rooted<PlainObject*> addedDateFields( cx, PrepareTemporalFields(cx, addedDate, fieldNames)); if (!addedDateFields) { return false; } - // Step 18. - auto obj = - CalendarYearMonthFromFields(cx, calendar, addedDateFields, optionsCopy); + // Step 20. + auto obj = temporal::CalendarYearMonthFromFields( + cx, calendar, addedDateFields, optionsCopy); if (!obj) { return false; } @@ -1081,13 +1069,11 @@ static bool PlainYearMonth_with(JSContext* cx, const CallArgs& args) { if (!temporalYearMonthLike) { return false; } - - // Step 4. - if (!RejectTemporalLikeObject(cx, temporalYearMonthLike)) { + if (!ThrowIfTemporalLikeObject(cx, temporalYearMonthLike)) { return false; } - // Step 5. + // Step 4. Rooted<PlainObject*> resolvedOptions(cx); if (args.hasDefined(1)) { Rooted<JSObject*> options(cx, @@ -1103,7 +1089,7 @@ static bool PlainYearMonth_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 6. + // Step 5. Rooted<CalendarRecord> calendar(cx); if (!CreateCalendarMethodsRecord(cx, calendarValue, { @@ -1115,7 +1101,7 @@ static bool PlainYearMonth_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 7. + // Step 6. JS::RootedVector<PropertyKey> fieldNames(cx); if (!CalendarFields( cx, calendar, @@ -1124,35 +1110,36 @@ static bool PlainYearMonth_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 8. + // Step 7. Rooted<PlainObject*> fields(cx, PrepareTemporalFields(cx, yearMonth, fieldNames)); if (!fields) { return false; } - // Step 9. + // Step 8. Rooted<PlainObject*> partialYearMonth( cx, PreparePartialTemporalFields(cx, temporalYearMonthLike, fieldNames)); if (!partialYearMonth) { return false; } - // Step 10. + // Step 9. Rooted<JSObject*> mergedFields( cx, CalendarMergeFields(cx, calendar, fields, partialYearMonth)); if (!mergedFields) { return false; } - // Step 11. + // Step 10. fields = PrepareTemporalFields(cx, mergedFields, fieldNames); if (!fields) { return false; } - // Step 12. - auto obj = CalendarYearMonthFromFields(cx, calendar, fields, resolvedOptions); + // Step 11. + auto obj = temporal::CalendarYearMonthFromFields(cx, calendar, fields, + resolvedOptions); if (!obj) { return false; } @@ -1466,20 +1453,7 @@ static bool PlainYearMonth_toPlainDate(JSContext* cx, const CallArgs& args) { } // Step 12. - Rooted<PlainObject*> options(cx, NewPlainObjectWithProto(cx, nullptr)); - if (!options) { - return false; - } - - // Step 13. - Rooted<Value> overflow(cx, StringValue(cx->names().constrain)); - if (!DefineDataProperty(cx, options, cx->names().overflow, overflow)) { - return false; - } - - // Step 14. - auto obj = CalendarDateFromFields(cx, calendar, mergedFromConcatenatedFields, - options); + auto obj = CalendarDateFromFields(cx, calendar, mergedFromConcatenatedFields); if (!obj) { return false; } diff --git a/js/src/builtin/temporal/Temporal.cpp b/js/src/builtin/temporal/Temporal.cpp index 3960a2832d..f729a7ce0f 100644 --- a/js/src/builtin/temporal/Temporal.cpp +++ b/js/src/builtin/temporal/Temporal.cpp @@ -6,8 +6,10 @@ #include "builtin/temporal/Temporal.h" +#include "mozilla/Casting.h" #include "mozilla/CheckedInt.h" #include "mozilla/Likely.h" +#include "mozilla/MathAlgorithms.h" #include "mozilla/Maybe.h" #include <algorithm> @@ -15,8 +17,10 @@ #include <cstdlib> #include <initializer_list> #include <iterator> +#include <limits> #include <stdint.h> #include <string_view> +#include <type_traits> #include <utility> #include "jsfriendapi.h" @@ -25,6 +29,7 @@ #include "NamespaceImports.h" #include "builtin/temporal/Instant.h" +#include "builtin/temporal/Int128.h" #include "builtin/temporal/PlainDate.h" #include "builtin/temporal/PlainDateTime.h" #include "builtin/temporal/PlainMonthDay.h" @@ -47,7 +52,6 @@ #include "js/RootingAPI.h" #include "js/String.h" #include "js/Value.h" -#include "vm/BigIntType.h" #include "vm/BytecodeUtil.h" #include "vm/GlobalObject.h" #include "vm/JSAtomState.h" @@ -137,16 +141,16 @@ static bool GetNumberOption(JSContext* cx, Handle<JSObject*> options, bool js::temporal::ToTemporalRoundingIncrement(JSContext* cx, Handle<JSObject*> options, Increment* increment) { - // Step 1. + // Steps 1-3. double number = 1; if (!GetNumberOption(cx, options, cx->names().roundingIncrement, &number)) { return false; } - // Step 3. (Reordered) + // Step 5. (Reordered) number = std::trunc(number); - // Steps 2 and 4. + // Steps 4 and 6. if (!std::isfinite(number) || number < 1 || number > 1'000'000'000) { ToCStringBuf cbuf; const char* numStr = NumberToCString(&cbuf, number); @@ -157,6 +161,7 @@ bool js::temporal::ToTemporalRoundingIncrement(JSContext* cx, return false; } + // Step 7. *increment = Increment{uint32_t(number)}; return true; } @@ -177,7 +182,7 @@ bool js::temporal::ValidateTemporalRoundingIncrement(JSContext* cx, // Steps 3-4. if (increment.value() > maximum || dividend % increment.value() != 0) { Int32ToCStringBuf cbuf; - const char* numStr = Int32ToCString(&cbuf, increment.value()); + const char* numStr = Int32ToCString(&cbuf, int32_t(increment.value())); // TODO: Better error message could be helpful. JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, @@ -394,7 +399,7 @@ bool js::temporal::GetTemporalUnit(JSContext* cx, Handle<JSString*> value, bool js::temporal::ToTemporalRoundingMode(JSContext* cx, Handle<JSObject*> options, TemporalRoundingMode* mode) { - // Step 1. + // Steps 1-2. Rooted<JSString*> string(cx); if (!GetStringOption(cx, options, cx->names().roundingMode, &string)) { return false; @@ -439,556 +444,339 @@ bool js::temporal::ToTemporalRoundingMode(JSContext* cx, return true; } -static BigInt* Divide(JSContext* cx, Handle<BigInt*> dividend, int64_t divisor, - TemporalRoundingMode roundingMode) { - MOZ_ASSERT(divisor > 0); - - Rooted<BigInt*> div(cx, BigInt::createFromInt64(cx, divisor)); - if (!div) { - return nullptr; - } - - Rooted<BigInt*> quotient(cx); - Rooted<BigInt*> remainder(cx); - if (!BigInt::divmod(cx, dividend, div, "ient, &remainder)) { - return nullptr; - } - - // No rounding needed when the remainder is zero. - if (remainder->isZero()) { - return quotient; - } - - switch (roundingMode) { - case TemporalRoundingMode::Ceil: { - if (!remainder->isNegative()) { - return BigInt::inc(cx, quotient); - } - return quotient; - } - case TemporalRoundingMode::Floor: { - if (remainder->isNegative()) { - return BigInt::dec(cx, quotient); - } - return quotient; - } - case TemporalRoundingMode::Trunc: - // BigInt division truncates. - return quotient; - case TemporalRoundingMode::Expand: { - if (!remainder->isNegative()) { - return BigInt::inc(cx, quotient); - } - return BigInt::dec(cx, quotient); - } - case TemporalRoundingMode::HalfCeil: { - int64_t rem; - MOZ_ALWAYS_TRUE(BigInt::isInt64(remainder, &rem)); - - if (!remainder->isNegative()) { - if (uint64_t(std::abs(rem)) * 2 >= uint64_t(divisor)) { - return BigInt::inc(cx, quotient); - } - } else { - if (uint64_t(std::abs(rem)) * 2 > uint64_t(divisor)) { - return BigInt::dec(cx, quotient); - } - } - return quotient; - } - case TemporalRoundingMode::HalfFloor: { - int64_t rem; - MOZ_ALWAYS_TRUE(BigInt::isInt64(remainder, &rem)); - - if (remainder->isNegative()) { - if (uint64_t(std::abs(rem)) * 2 >= uint64_t(divisor)) { - return BigInt::dec(cx, quotient); - } - } else { - if (uint64_t(std::abs(rem)) * 2 > uint64_t(divisor)) { - return BigInt::inc(cx, quotient); - } - } - return quotient; - } - case TemporalRoundingMode::HalfExpand: { - int64_t rem; - MOZ_ALWAYS_TRUE(BigInt::isInt64(remainder, &rem)); - - if (uint64_t(std::abs(rem)) * 2 >= uint64_t(divisor)) { - if (!dividend->isNegative()) { - return BigInt::inc(cx, quotient); - } - return BigInt::dec(cx, quotient); - } - return quotient; - } - case TemporalRoundingMode::HalfTrunc: { - int64_t rem; - MOZ_ALWAYS_TRUE(BigInt::isInt64(remainder, &rem)); - - if (uint64_t(std::abs(rem)) * 2 > uint64_t(divisor)) { - if (!dividend->isNegative()) { - return BigInt::inc(cx, quotient); - } - return BigInt::dec(cx, quotient); - } - return quotient; - } - case TemporalRoundingMode::HalfEven: { - int64_t rem; - MOZ_ALWAYS_TRUE(BigInt::isInt64(remainder, &rem)); - - if (uint64_t(std::abs(rem)) * 2 == uint64_t(divisor)) { - bool isOdd = !quotient->isZero() && (quotient->digit(0) & 1) == 1; - if (isOdd) { - if (!dividend->isNegative()) { - return BigInt::inc(cx, quotient); - } - return BigInt::dec(cx, quotient); - } - } - if (uint64_t(std::abs(rem)) * 2 > uint64_t(divisor)) { - if (!dividend->isNegative()) { - return BigInt::inc(cx, quotient); - } - return BigInt::dec(cx, quotient); - } - return quotient; - } - } - - MOZ_CRASH("invalid rounding mode"); +#ifdef DEBUG +template <typename T> +static bool IsValidMul(const T& x, const T& y) { + return (mozilla::CheckedInt<T>(x) * y).isValid(); } -static BigInt* Divide(JSContext* cx, Handle<BigInt*> dividend, - Handle<BigInt*> divisor, - TemporalRoundingMode roundingMode) { - MOZ_ASSERT(!divisor->isNegative()); - MOZ_ASSERT(!divisor->isZero()); +// Copied from mozilla::CheckedInt. +template <> +bool IsValidMul<Int128>(const Int128& x, const Int128& y) { + static constexpr auto min = Int128{1} << 127; + static constexpr auto max = ~min; - Rooted<BigInt*> quotient(cx); - Rooted<BigInt*> remainder(cx); - if (!BigInt::divmod(cx, dividend, divisor, "ient, &remainder)) { - return nullptr; - } - - // No rounding needed when the remainder is zero. - if (remainder->isZero()) { - return quotient; - } - - switch (roundingMode) { - case TemporalRoundingMode::Ceil: { - if (!remainder->isNegative()) { - return BigInt::inc(cx, quotient); - } - return quotient; - } - case TemporalRoundingMode::Floor: { - if (remainder->isNegative()) { - return BigInt::dec(cx, quotient); - } - return quotient; - } - case TemporalRoundingMode::Trunc: - // BigInt division truncates. - return quotient; - case TemporalRoundingMode::Expand: { - if (!remainder->isNegative()) { - return BigInt::inc(cx, quotient); - } - return BigInt::dec(cx, quotient); - } - case TemporalRoundingMode::HalfCeil: { - BigInt* rem = BigInt::add(cx, remainder, remainder); - if (!rem) { - return nullptr; - } - - if (!remainder->isNegative()) { - if (BigInt::absoluteCompare(rem, divisor) >= 0) { - return BigInt::inc(cx, quotient); - } - } else { - if (BigInt::absoluteCompare(rem, divisor) > 0) { - return BigInt::dec(cx, quotient); - } - } - return quotient; - } - case TemporalRoundingMode::HalfFloor: { - BigInt* rem = BigInt::add(cx, remainder, remainder); - if (!rem) { - return nullptr; - } - - if (remainder->isNegative()) { - if (BigInt::absoluteCompare(rem, divisor) >= 0) { - return BigInt::dec(cx, quotient); - } - } else { - if (BigInt::absoluteCompare(rem, divisor) > 0) { - return BigInt::inc(cx, quotient); - } - } - return quotient; - } - case TemporalRoundingMode::HalfExpand: { - BigInt* rem = BigInt::add(cx, remainder, remainder); - if (!rem) { - return nullptr; - } - - if (BigInt::absoluteCompare(rem, divisor) >= 0) { - if (!dividend->isNegative()) { - return BigInt::inc(cx, quotient); - } - return BigInt::dec(cx, quotient); - } - return quotient; - } - case TemporalRoundingMode::HalfTrunc: { - BigInt* rem = BigInt::add(cx, remainder, remainder); - if (!rem) { - return nullptr; - } - - if (BigInt::absoluteCompare(rem, divisor) > 0) { - if (!dividend->isNegative()) { - return BigInt::inc(cx, quotient); - } - return BigInt::dec(cx, quotient); - } - return quotient; - } - case TemporalRoundingMode::HalfEven: { - BigInt* rem = BigInt::add(cx, remainder, remainder); - if (!rem) { - return nullptr; - } - - if (BigInt::absoluteCompare(rem, divisor) == 0) { - bool isOdd = !quotient->isZero() && (quotient->digit(0) & 1) == 1; - if (isOdd) { - if (!dividend->isNegative()) { - return BigInt::inc(cx, quotient); - } - return BigInt::dec(cx, quotient); - } - } - if (BigInt::absoluteCompare(rem, divisor) > 0) { - if (!dividend->isNegative()) { - return BigInt::inc(cx, quotient); - } - return BigInt::dec(cx, quotient); - } - return quotient; - } - } - - MOZ_CRASH("invalid rounding mode"); -} - -static BigInt* RoundNumberToIncrementSlow(JSContext* cx, Handle<BigInt*> x, - int64_t divisor, int64_t increment, - TemporalRoundingMode roundingMode) { - // Steps 1-8. - Rooted<BigInt*> rounded(cx, Divide(cx, x, divisor, roundingMode)); - if (!rounded) { - return nullptr; - } - - // We can skip the next step when |increment=1|. - if (increment == 1) { - return rounded; + if (x == Int128{0} || y == Int128{0}) { + return true; } - - // Step 9. - Rooted<BigInt*> inc(cx, BigInt::createFromInt64(cx, increment)); - if (!inc) { - return nullptr; + if (x > Int128{0}) { + return y > Int128{0} ? x <= max / y : y >= min / x; } - return BigInt::mul(cx, rounded, inc); -} - -static BigInt* RoundNumberToIncrementSlow(JSContext* cx, Handle<BigInt*> x, - int64_t increment, - TemporalRoundingMode roundingMode) { - return RoundNumberToIncrementSlow(cx, x, increment, increment, roundingMode); + return y > Int128{0} ? x >= min / y : y >= max / x; } +#endif /** * RoundNumberToIncrement ( x, increment, roundingMode ) */ -bool js::temporal::RoundNumberToIncrement(JSContext* cx, const Instant& x, - int64_t increment, - TemporalRoundingMode roundingMode, - Instant* result) { - MOZ_ASSERT(temporal::IsValidEpochInstant(x)); - MOZ_ASSERT(increment > 0); - MOZ_ASSERT(increment <= ToNanoseconds(TemporalUnit::Day)); - - // Fast path for the default case. - if (increment == 1) { - *result = x; - return true; - } +Int128 js::temporal::RoundNumberToIncrement(int64_t numerator, + int64_t denominator, + Increment increment, + TemporalRoundingMode roundingMode) { + MOZ_ASSERT(denominator > 0); + MOZ_ASSERT(Increment::min() <= increment && increment <= Increment::max()); // Dividing zero is always zero. - if (x == Instant{}) { - *result = x; - return true; + if (numerator == 0) { + return Int128{0}; + } + + // We don't have to adjust the divisor when |increment=1|. + if (increment == Increment{1}) { + // Steps 1-8 and implicit step 9. + return Int128{Divide(numerator, denominator, roundingMode)}; } // Fast-path when we can perform the whole computation with int64 values. - if (auto num = x.toNanoseconds(); MOZ_LIKELY(num.isValid())) { + auto divisor = mozilla::CheckedInt64(denominator) * increment.value(); + if (MOZ_LIKELY(divisor.isValid())) { + MOZ_ASSERT(divisor.value() > 0); + // Steps 1-8. - int64_t rounded = Divide(num.value(), increment, roundingMode); + int64_t rounded = Divide(numerator, divisor.value(), roundingMode); // Step 9. - mozilla::CheckedInt64 checked = rounded; - checked *= increment; - if (MOZ_LIKELY(checked.isValid())) { - *result = Instant::fromNanoseconds(checked.value()); - return true; + auto result = mozilla::CheckedInt64(rounded) * increment.value(); + if (MOZ_LIKELY(result.isValid())) { + return Int128{result.value()}; } } - Rooted<BigInt*> bi(cx, ToEpochNanoseconds(cx, x)); - if (!bi) { - return false; - } - - auto* rounded = RoundNumberToIncrementSlow(cx, bi, increment, roundingMode); - if (!rounded) { - return false; - } - - *result = ToInstant(rounded); - return true; + // Int128 path on overflow. + return RoundNumberToIncrement(Int128{numerator}, Int128{denominator}, + increment, roundingMode); } /** * RoundNumberToIncrement ( x, increment, roundingMode ) */ -bool js::temporal::RoundNumberToIncrement(JSContext* cx, int64_t numerator, - TemporalUnit unit, - Increment increment, - TemporalRoundingMode roundingMode, - double* result) { - MOZ_ASSERT(unit >= TemporalUnit::Day); +Int128 js::temporal::RoundNumberToIncrement(const Int128& numerator, + const Int128& denominator, + Increment increment, + TemporalRoundingMode roundingMode) { + MOZ_ASSERT(denominator > Int128{0}); MOZ_ASSERT(Increment::min() <= increment && increment <= Increment::max()); - // Take the slow path when the increment is too large. - if (MOZ_UNLIKELY(increment > Increment{100'000})) { - Rooted<BigInt*> bi(cx, BigInt::createFromInt64(cx, numerator)); - if (!bi) { - return false; - } + auto inc = Int128{increment.value()}; + MOZ_ASSERT(IsValidMul(denominator, inc), "unsupported overflow"); - Rooted<BigInt*> denominator( - cx, BigInt::createFromInt64(cx, ToNanoseconds(unit))); - if (!denominator) { - return false; - } - - return RoundNumberToIncrement(cx, bi, denominator, increment, roundingMode, - result); - } - - int64_t divisor = ToNanoseconds(unit) * increment.value(); - MOZ_ASSERT(divisor > 0); - MOZ_ASSERT(divisor <= 8'640'000'000'000'000'000); - - // Division by one has no remainder. - if (divisor == 1) { - MOZ_ASSERT(increment == Increment{1}); - *result = double(numerator); - return true; - } + auto divisor = denominator * inc; + MOZ_ASSERT(divisor > Int128{0}); // Steps 1-8. - int64_t rounded = Divide(numerator, divisor, roundingMode); + auto rounded = Divide(numerator, divisor, roundingMode); // Step 9. - mozilla::CheckedInt64 checked = rounded; - checked *= increment.value(); - if (checked.isValid()) { - *result = double(checked.value()); - return true; - } - - Rooted<BigInt*> bi(cx, BigInt::createFromInt64(cx, numerator)); - if (!bi) { - return false; - } - return RoundNumberToIncrement(cx, bi, unit, increment, roundingMode, result); + MOZ_ASSERT(IsValidMul(rounded, inc), "unsupported overflow"); + return rounded * inc; } /** * RoundNumberToIncrement ( x, increment, roundingMode ) */ -bool js::temporal::RoundNumberToIncrement( - JSContext* cx, Handle<BigInt*> numerator, TemporalUnit unit, - Increment increment, TemporalRoundingMode roundingMode, double* result) { - MOZ_ASSERT(unit >= TemporalUnit::Day); - MOZ_ASSERT(Increment::min() <= increment && increment <= Increment::max()); +Int128 js::temporal::RoundNumberToIncrement(const Int128& x, + const Int128& increment, + TemporalRoundingMode roundingMode) { + MOZ_ASSERT(increment > Int128{0}); - // Take the slow path when the increment is too large. - if (MOZ_UNLIKELY(increment > Increment{100'000})) { - Rooted<BigInt*> denominator( - cx, BigInt::createFromInt64(cx, ToNanoseconds(unit))); - if (!denominator) { - return false; - } - - return RoundNumberToIncrement(cx, numerator, denominator, increment, - roundingMode, result); - } - - int64_t divisor = ToNanoseconds(unit) * increment.value(); - MOZ_ASSERT(divisor > 0); - MOZ_ASSERT(divisor <= 8'640'000'000'000'000'000); - - // Division by one has no remainder. - if (divisor == 1) { - MOZ_ASSERT(increment == Increment{1}); - *result = BigInt::numberValue(numerator); - return true; - } - - // Dividing zero is always zero. - if (numerator->isZero()) { - *result = 0; - return true; - } - - // All callers are already in the slow path, so we don't need to fast-path the - // case when |x| can be represented by an int64 value. + // Steps 1-8. + auto rounded = Divide(x, increment, roundingMode); - // Steps 1-9. - auto* rounded = RoundNumberToIncrementSlow(cx, numerator, divisor, - increment.value(), roundingMode); - if (!rounded) { - return false; - } + // Step 9. + MOZ_ASSERT(IsValidMul(rounded, increment), "unsupported overflow"); + return rounded * increment; +} - *result = BigInt::numberValue(rounded); - return true; +template <typename IntT> +static inline constexpr bool IsSafeInteger(const IntT& x) { + constexpr IntT MaxSafeInteger = IntT{int64_t(1) << 53}; + constexpr IntT MinSafeInteger = -MaxSafeInteger; + return MinSafeInteger < x && x < MaxSafeInteger; } /** - * RoundNumberToIncrement ( x, increment, roundingMode ) + * Return the real number value of the fraction |numerator / denominator|. + * + * As an optimization we multiply the remainder by 16 when computing the number + * of digits after the decimal point, i.e. we compute four instead of one bit of + * the fractional digits. The denominator is therefore required to not exceed + * 2**(N - log2(16)), where N is the number of non-sign bits in the mantissa. */ -bool js::temporal::RoundNumberToIncrement(JSContext* cx, int64_t numerator, - int64_t denominator, - Increment increment, - TemporalRoundingMode roundingMode, - double* result) { - MOZ_ASSERT(denominator > 0); - MOZ_ASSERT(Increment::min() <= increment && increment <= Increment::max()); - - // Dividing zero is always zero. - if (numerator == 0) { - *result = 0; - return true; - } - - // We don't have to adjust the divisor when |increment=1|. - if (increment == Increment{1}) { - int64_t divisor = denominator; - int64_t rounded = Divide(numerator, divisor, roundingMode); - - *result = double(rounded); - return true; - } - - auto divisor = mozilla::CheckedInt64(denominator) * increment.value(); - if (MOZ_LIKELY(divisor.isValid())) { - MOZ_ASSERT(divisor.value() > 0); - - // Steps 1-8. - int64_t rounded = Divide(numerator, divisor.value(), roundingMode); - - // Step 9. - auto adjusted = mozilla::CheckedInt64(rounded) * increment.value(); - if (MOZ_LIKELY(adjusted.isValid())) { - *result = double(adjusted.value()); - return true; +template <typename T> +static double FractionToDoubleSlow(const T& numerator, const T& denominator) { + MOZ_ASSERT(denominator > T{0}, "expected positive denominator"); + MOZ_ASSERT(denominator <= (T{1} << (std::numeric_limits<T>::digits - 4)), + "denominator too large"); + + auto absValue = [](const T& value) { + if constexpr (std::is_same_v<T, Int128>) { + return value.abs(); + } else { + // NB: Not std::abs, because std::abs(INT64_MIN) is undefined behavior. + return mozilla::Abs(value); } - } + }; - // Slow path on overflow. + using UnsignedT = decltype(absValue(T{0})); + static_assert(!std::numeric_limits<UnsignedT>::is_signed); - Rooted<BigInt*> bi(cx, BigInt::createFromInt64(cx, numerator)); - if (!bi) { - return false; - } + auto divrem = [](const UnsignedT& x, const UnsignedT& y) { + if constexpr (std::is_same_v<T, Int128>) { + return x.divrem(y); + } else { + return std::pair{x / y, x % y}; + } + }; - Rooted<BigInt*> denom(cx, BigInt::createFromInt64(cx, denominator)); - if (!denom) { - return false; + auto [quot, rem] = + divrem(absValue(numerator), static_cast<UnsignedT>(denominator)); + + // Simple case when no remainder is present. + if (rem == UnsignedT{0}) { + double sign = numerator < T{0} ? -1 : 1; + return sign * double(quot); + } + + using Double = mozilla::FloatingPoint<double>; + + // Significand including the implicit one of IEEE-754 floating point numbers. + static constexpr uint32_t SignificandWidthWithImplicitOne = + Double::kSignificandWidth + 1; + + // Number of leading zeros for a correctly adjusted significand. + static constexpr uint32_t SignificandLeadingZeros = + 64 - SignificandWidthWithImplicitOne; + + // Exponent bias for an integral significand. (`Double::kExponentBias` is the + // bias for the binary fraction `1.xyz * 2**exp`. For an integral significand + // the significand width has to be added to the bias.) + static constexpr int32_t ExponentBias = + Double::kExponentBias + Double::kSignificandWidth; + + // Significand, possibly unnormalized. + uint64_t significand = 0; + + // Significand ignored msd bits. + uint32_t ignoredBits = 0; + + // Read quotient, from most to least significant digit. Stop when the + // significand got too large for double precision. + int32_t shift = std::numeric_limits<UnsignedT>::digits; + for (; shift != 0 && ignoredBits == 0; shift -= 4) { + uint64_t digit = uint64_t(quot >> (shift - 4)) & 0xf; + + significand = significand * 16 + digit; + ignoredBits = significand >> SignificandWidthWithImplicitOne; + } + + // Read remainder, from most to least significant digit. Stop when the + // remainder is zero or the significand got too large. + int32_t fractionDigit = 0; + for (; rem != UnsignedT{0} && ignoredBits == 0; fractionDigit++) { + auto [digit, next] = + divrem(rem * UnsignedT{16}, static_cast<UnsignedT>(denominator)); + rem = next; + + significand = significand * 16 + uint64_t(digit); + ignoredBits = significand >> SignificandWidthWithImplicitOne; + } + + // Unbiased exponent. (`shift` remaining bits in the quotient, minus the + // fractional digits.) + int32_t exponent = shift - (fractionDigit * 4); + + // Significand got too large and some bits are now ignored. Adjust the + // significand and exponent. + if (ignoredBits != 0) { + // significand + // ___________|__________ + // / \ + // [xxx················yyy| + // \_/ \_/ + // | | + // ignoredBits extraBits + // + // `ignoredBits` have to be shifted back into the 53 bits of the significand + // and `extraBits` has to be checked if the result has to be rounded up. + + // Number of ignored/extra bits in the significand. + uint32_t extraBitsCount = 32 - mozilla::CountLeadingZeroes32(ignoredBits); + MOZ_ASSERT(extraBitsCount > 0); + + // Extra bits in the significand. + uint32_t extraBits = uint32_t(significand) & ((1 << extraBitsCount) - 1); + + // Move the ignored bits into the proper significand position and adjust the + // exponent to reflect the now moved out extra bits. + significand >>= extraBitsCount; + exponent += extraBitsCount; + + MOZ_ASSERT((significand >> SignificandWidthWithImplicitOne) == 0, + "no excess bits in the significand"); + + // When the most significant digit in the extra bits is set, we may need to + // round the result. + uint32_t msdExtraBit = extraBits >> (extraBitsCount - 1); + if (msdExtraBit != 0) { + // Extra bits, excluding the most significant digit. + uint32_t extraBitExcludingMsdMask = (1 << (extraBitsCount - 1)) - 1; + + // Unprocessed bits in the quotient. + auto bitsBelowExtraBits = quot & ((UnsignedT{1} << shift) - UnsignedT{1}); + + // Round up if the extra bit's msd is set and either the significand is + // odd or any other bits below the extra bit's msd are non-zero. + // + // Bits below the extra bit's msd are: + // 1. The remaining bits of the extra bits. + // 2. Any bits below the extra bits. + // 3. Any rest of the remainder. + bool shouldRoundUp = (significand & 1) != 0 || + (extraBits & extraBitExcludingMsdMask) != 0 || + bitsBelowExtraBits != UnsignedT{0} || + rem != UnsignedT{0}; + if (shouldRoundUp) { + // Add one to the significand bits. + significand += 1; + + // If they overflow, the exponent must also be increased. + if ((significand >> SignificandWidthWithImplicitOne) != 0) { + exponent++; + significand >>= 1; + } + } + } } - return RoundNumberToIncrement(cx, bi, denom, increment, roundingMode, result); + MOZ_ASSERT(significand > 0, "significand is non-zero"); + MOZ_ASSERT((significand >> SignificandWidthWithImplicitOne) == 0, + "no excess bits in the significand"); + + // Move the significand into the correct position and adjust the exponent + // accordingly. + uint32_t significandZeros = mozilla::CountLeadingZeroes64(significand); + if (significandZeros < SignificandLeadingZeros) { + uint32_t shift = SignificandLeadingZeros - significandZeros; + significand >>= shift; + exponent += shift; + } else if (significandZeros > SignificandLeadingZeros) { + uint32_t shift = significandZeros - SignificandLeadingZeros; + significand <<= shift; + exponent -= shift; + } + + // Combine the individual bits of the double value and return it. + uint64_t signBit = uint64_t(numerator < T{0} ? 1 : 0) + << (Double::kExponentWidth + Double::kSignificandWidth); + uint64_t exponentBits = static_cast<uint64_t>(exponent + ExponentBias) + << Double::kExponentShift; + uint64_t significandBits = significand & Double::kSignificandBits; + return mozilla::BitwiseCast<double>(signBit | exponentBits | significandBits); } -/** - * RoundNumberToIncrement ( x, increment, roundingMode ) - */ -bool js::temporal::RoundNumberToIncrement( - JSContext* cx, Handle<BigInt*> numerator, Handle<BigInt*> denominator, - Increment increment, TemporalRoundingMode roundingMode, double* result) { - MOZ_ASSERT(!denominator->isNegative()); - MOZ_ASSERT(!denominator->isZero()); - MOZ_ASSERT(Increment::min() <= increment && increment <= Increment::max()); +double js::temporal::FractionToDouble(int64_t numerator, int64_t denominator) { + MOZ_ASSERT(denominator > 0); - // Dividing zero is always zero. - if (numerator->isZero()) { - *result = 0; - return true; + // Zero divided by any divisor is still zero. + if (numerator == 0) { + return 0; } - // We don't have to adjust the divisor when |increment=1|. - if (increment == Increment{1}) { - auto divisor = denominator; - - auto* rounded = Divide(cx, numerator, divisor, roundingMode); - if (!rounded) { - return false; - } - - *result = BigInt::numberValue(rounded); - return true; + // When both values can be represented as doubles, use double division to + // compute the exact result. The result is exact, because double division is + // guaranteed to return the exact result. + if (MOZ_LIKELY(::IsSafeInteger(numerator) && ::IsSafeInteger(denominator))) { + return double(numerator) / double(denominator); } - Rooted<BigInt*> inc(cx, BigInt::createFromUint64(cx, increment.value())); - if (!inc) { - return false; + // Otherwise call into |FractionToDoubleSlow| to compute the exact result. + if (denominator <= + (int64_t(1) << (std::numeric_limits<int64_t>::digits - 4))) { + // Slightly faster, but still slow approach when |denominator| is small + // enough to allow computing on int64 values. + return FractionToDoubleSlow(numerator, denominator); } + return FractionToDoubleSlow(Int128{numerator}, Int128{denominator}); +} - Rooted<BigInt*> divisor(cx, BigInt::mul(cx, denominator, inc)); - if (!divisor) { - return false; - } - MOZ_ASSERT(!divisor->isNegative()); - MOZ_ASSERT(!divisor->isZero()); +double js::temporal::FractionToDouble(const Int128& numerator, + const Int128& denominator) { + MOZ_ASSERT(denominator > Int128{0}); - // Steps 1-8. - Rooted<BigInt*> rounded(cx, Divide(cx, numerator, divisor, roundingMode)); - if (!rounded) { - return false; + // Zero divided by any divisor is still zero. + if (numerator == Int128{0}) { + return 0; } - // Step 9. - auto* adjusted = BigInt::mul(cx, rounded, inc); - if (!adjusted) { - return false; + // When both values can be represented as doubles, use double division to + // compute the exact result. The result is exact, because double division is + // guaranteed to return the exact result. + if (MOZ_LIKELY(::IsSafeInteger(numerator) && ::IsSafeInteger(denominator))) { + return double(numerator) / double(denominator); } - *result = BigInt::numberValue(adjusted); - return true; + // Otherwise call into |FractionToDoubleSlow| to compute the exact result. + return FractionToDoubleSlow(numerator, denominator); } /** @@ -1404,17 +1192,14 @@ static JSObject* MaybeUnwrapIf(JSObject* object) { return nullptr; } -// FIXME: spec issue - "Reject" is exclusively used for Promise rejection. The -// existing `RejectPromise` abstract operation unconditionally rejects, whereas -// this operation conditionally rejects. -// https://github.com/tc39/proposal-temporal/issues/2534 - /** - * RejectTemporalLikeObject ( object ) + * IsPartialTemporalObject ( object ) */ -bool js::temporal::RejectTemporalLikeObject(JSContext* cx, - Handle<JSObject*> object) { - // Step 1. +bool js::temporal::ThrowIfTemporalLikeObject(JSContext* cx, + Handle<JSObject*> object) { + // Step 1. (Handled in caller) + + // Step 2. if (auto* unwrapped = MaybeUnwrapIf<PlainDateObject, PlainDateTimeObject, PlainMonthDayObject, PlainTimeObject, @@ -1427,31 +1212,31 @@ bool js::temporal::RejectTemporalLikeObject(JSContext* cx, Rooted<Value> property(cx); - // Step 2. + // Step 3. if (!GetProperty(cx, object, object, cx->names().calendar, &property)) { return false; } - // Step 3. + // Step 4. if (!property.isUndefined()) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TEMPORAL_UNEXPECTED_PROPERTY, "calendar"); return false; } - // Step 4. + // Step 5. if (!GetProperty(cx, object, object, cx->names().timeZone, &property)) { return false; } - // Step 5. + // Step 6. if (!property.isUndefined()) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TEMPORAL_UNEXPECTED_PROPERTY, "timeZone"); return false; } - // Step 6. + // Step 7. return true; } @@ -1813,10 +1598,18 @@ static bool TemporalClassFinish(JSContext* cx, Handle<JSObject*> temporal, }; // Add the constructor properties. - for (const auto& protoKey : - {JSProto_Calendar, JSProto_Duration, JSProto_Instant, JSProto_PlainDate, - JSProto_PlainDateTime, JSProto_PlainMonthDay, JSProto_PlainTime, - JSProto_PlainYearMonth, JSProto_TimeZone, JSProto_ZonedDateTime}) { + for (const auto& protoKey : { + JSProto_Calendar, + JSProto_Duration, + JSProto_Instant, + JSProto_PlainDate, + JSProto_PlainDateTime, + JSProto_PlainMonthDay, + JSProto_PlainTime, + JSProto_PlainYearMonth, + JSProto_TimeZone, + JSProto_ZonedDateTime, + }) { if (!defineProperty(protoKey, ClassName(protoKey, cx))) { return false; } diff --git a/js/src/builtin/temporal/Temporal.h b/js/src/builtin/temporal/Temporal.h index 3d014bfaa7..8955c1d88a 100644 --- a/js/src/builtin/temporal/Temporal.h +++ b/js/src/builtin/temporal/Temporal.h @@ -13,6 +13,7 @@ #include "jstypes.h" +#include "builtin/temporal/Int128.h" #include "builtin/temporal/TemporalRoundingMode.h" #include "builtin/temporal/TemporalUnit.h" #include "js/RootingAPI.h" @@ -35,9 +36,6 @@ class TemporalObject : public NativeObject { static const ClassSpec classSpec_; }; -struct Instant; -struct PlainTime; - /** * Rounding increment, which is an integer in the range [1, 1'000'000'000]. * @@ -171,37 +169,32 @@ bool ToTemporalRoundingMode(JSContext* cx, JS::Handle<JSObject*> options, /** * RoundNumberToIncrement ( x, increment, roundingMode ) */ -bool RoundNumberToIncrement(JSContext* cx, const Instant& x, int64_t increment, - TemporalRoundingMode roundingMode, Instant* result); +Int128 RoundNumberToIncrement(int64_t numerator, int64_t denominator, + Increment increment, + TemporalRoundingMode roundingMode); /** * RoundNumberToIncrement ( x, increment, roundingMode ) */ -bool RoundNumberToIncrement(JSContext* cx, int64_t numerator, TemporalUnit unit, - Increment increment, - TemporalRoundingMode roundingMode, double* result); +Int128 RoundNumberToIncrement(const Int128& numerator, + const Int128& denominator, Increment increment, + TemporalRoundingMode roundingMode); /** * RoundNumberToIncrement ( x, increment, roundingMode ) */ -bool RoundNumberToIncrement(JSContext* cx, JS::Handle<JS::BigInt*> numerator, - TemporalUnit unit, Increment increment, - TemporalRoundingMode roundingMode, double* result); +Int128 RoundNumberToIncrement(const Int128& x, const Int128& increment, + TemporalRoundingMode roundingMode); /** - * RoundNumberToIncrement ( x, increment, roundingMode ) + * Return the double value of the fractional number `numerator / denominator`. */ -bool RoundNumberToIncrement(JSContext* cx, int64_t numerator, - int64_t denominator, Increment increment, - TemporalRoundingMode roundingMode, double* result); +double FractionToDouble(int64_t numerator, int64_t denominator); /** - * RoundNumberToIncrement ( x, increment, roundingMode ) + * Return the double value of the fractional number `numerator / denominator`. */ -bool RoundNumberToIncrement(JSContext* cx, JS::Handle<JS::BigInt*> numerator, - JS::Handle<JS::BigInt*> denominator, - Increment increment, - TemporalRoundingMode roundingMode, double* result); +double FractionToDouble(const Int128& numerator, const Int128& denominator); enum class CalendarOption { Auto, Always, Never, Critical }; @@ -221,7 +214,7 @@ class Precision final { constexpr Precision(int8_t value, Tag) : value_(value) {} public: - constexpr explicit Precision(uint8_t value) : value_(value) { + constexpr explicit Precision(uint8_t value) : value_(int8_t(value)) { MOZ_ASSERT(value < 10); } @@ -306,9 +299,12 @@ bool ToShowOffsetOption(JSContext* cx, JS::Handle<JSObject*> options, ShowOffsetOption* result); /** - * RejectTemporalLikeObject ( object ) + * IsPartialTemporalObject ( object ) + * + * Our implementation performs error reporting in this function instead of in + * the caller to provide better error messages. */ -bool RejectTemporalLikeObject(JSContext* cx, JS::Handle<JSObject*> object); +bool ThrowIfTemporalLikeObject(JSContext* cx, JS::Handle<JSObject*> object); /** * ToPositiveIntegerWithTruncation ( argument ) diff --git a/js/src/builtin/temporal/TemporalFields.cpp b/js/src/builtin/temporal/TemporalFields.cpp index 9ac2e44639..72027123e7 100644 --- a/js/src/builtin/temporal/TemporalFields.cpp +++ b/js/src/builtin/temporal/TemporalFields.cpp @@ -214,7 +214,7 @@ static Value TemporalFieldDefaultValue(TemporalField field) { static bool TemporalFieldConvertValue(JSContext* cx, TemporalField field, MutableHandle<Value> value) { - auto* name = ToCString(field); + const auto* name = ToCString(field); switch (field) { case TemporalField::Year: case TemporalField::Hour: @@ -365,7 +365,7 @@ bool js::temporal::PrepareTemporalFields( Rooted<Value> value(cx); for (auto fieldName : fieldNames) { auto* property = ToPropertyName(cx, fieldName); - auto* cstr = ToCString(fieldName); + const auto* cstr = ToCString(fieldName); // Step 6.a. (Not applicable in our implementation.) @@ -837,8 +837,8 @@ bool js::temporal::AppendSorted( return false; } - auto* left = std::prev(fieldNames.end(), additionalNames.size()); - auto* right = additionalNames.end(); + const auto* left = std::prev(fieldNames.end(), additionalNames.size()); + const auto* right = additionalNames.end(); auto* out = fieldNames.end(); // Write backwards into the newly allocated space. diff --git a/js/src/builtin/temporal/TemporalFields.h b/js/src/builtin/temporal/TemporalFields.h index 1af3631169..4cdbade772 100644 --- a/js/src/builtin/temporal/TemporalFields.h +++ b/js/src/builtin/temporal/TemporalFields.h @@ -7,6 +7,7 @@ #ifndef builtin_temporal_TemporalFields_h #define builtin_temporal_TemporalFields_h +#include "mozilla/Attributes.h" #include "mozilla/FloatingPoint.h" #include <initializer_list> @@ -46,7 +47,7 @@ enum class TemporalField { // NaN whereas pointer fields use nullptr. // // [1] <https://tc39.es/proposal-temporal/#table-temporal-field-requirements> -struct TemporalFields final { +struct MOZ_STACK_CLASS TemporalFields final { double year = mozilla::UnspecifiedNaN<double>(); double month = mozilla::UnspecifiedNaN<double>(); JSString* monthCode = nullptr; diff --git a/js/src/builtin/temporal/TemporalNow.cpp b/js/src/builtin/temporal/TemporalNow.cpp index adc84361af..3b06736673 100644 --- a/js/src/builtin/temporal/TemporalNow.cpp +++ b/js/src/builtin/temporal/TemporalNow.cpp @@ -116,9 +116,9 @@ static JSString* SystemTimeZoneIdentifier(JSContext* cx) { size_t n = etcGMT.copy(offsetString, etcGMT.length()); offsetString[n++] = offset < 0 ? '+' : '-'; if (offsetHours >= 10) { - offsetString[n++] = '0' + (offsetHours / 10); + offsetString[n++] = char('0' + (offsetHours / 10)); } - offsetString[n++] = '0' + (offsetHours % 10); + offsetString[n++] = char('0' + (offsetHours % 10)); MOZ_ASSERT(n == etcGMT.length() + 2 || n == etcGMT.length() + 3); diff --git a/js/src/builtin/temporal/TemporalParser.cpp b/js/src/builtin/temporal/TemporalParser.cpp index c117e63b31..b3a7a58c62 100644 --- a/js/src/builtin/temporal/TemporalParser.cpp +++ b/js/src/builtin/temporal/TemporalParser.cpp @@ -80,11 +80,11 @@ bool EqualCharIgnoreCaseAscii(CharT c1, char c2) { // Convert both characters to lower case before the comparison. char c = c1; if (mozilla::IsAsciiUppercaseAlpha(c1)) { - c = c + toLower; + c = char(c + toLower); } char d = c2; if (mozilla::IsAsciiUppercaseAlpha(c2)) { - d = d + toLower; + d = char(d + toLower); } return c == d; } @@ -544,10 +544,10 @@ class TemporalParser final { return mozilla::Some(num); } - // TimeFractionalPart : + // TimeFractionalPart ::: // Digit{1, 9} // - // Fraction : + // Fraction ::: // DecimalSeparator TimeFractionalPart mozilla::Maybe<int32_t> fraction() { if (!reader_.hasMore(2)) { @@ -679,11 +679,11 @@ class TemporalParser final { return true; } - // Sign : + // Sign ::: // ASCIISign // U+2212 // - // ASCIISign : one of + // ASCIISign ::: one of // + - bool hasSign() const { return hasOneOf({'+', '-', 0x2212}); } @@ -698,61 +698,61 @@ class TemporalParser final { return plus ? 1 : -1; } - // DecimalSeparator : one of + // DecimalSeparator ::: one of // . , bool hasDecimalSeparator() const { return hasOneOf({'.', ','}); } bool decimalSeparator() { return oneOf({'.', ','}); } - // DaysDesignator : one of + // DaysDesignator ::: one of // D d bool daysDesignator() { return oneOf({'D', 'd'}); } - // HoursDesignator : one of + // HoursDesignator ::: one of // H h bool hoursDesignator() { return oneOf({'H', 'h'}); } - // MinutesDesignator : one of + // MinutesDesignator ::: one of // M m bool minutesDesignator() { return oneOf({'M', 'm'}); } - // MonthsDesignator : one of + // MonthsDesignator ::: one of // M m bool monthsDesignator() { return oneOf({'M', 'm'}); } - // DurationDesignator : one of + // DurationDesignator ::: one of // P p bool durationDesignator() { return oneOf({'P', 'p'}); } - // SecondsDesignator : one of + // SecondsDesignator ::: one of // S s bool secondsDesignator() { return oneOf({'S', 's'}); } - // DateTimeSeparator : + // DateTimeSeparator ::: // <SP> // T // t bool dateTimeSeparator() { return oneOf({' ', 'T', 't'}); } - // TimeDesignator : one of + // TimeDesignator ::: one of // T t bool hasTimeDesignator() const { return hasOneOf({'T', 't'}); } bool timeDesignator() { return oneOf({'T', 't'}); } - // WeeksDesignator : one of + // WeeksDesignator ::: one of // W w bool weeksDesignator() { return oneOf({'W', 'w'}); } - // YearsDesignator : one of + // YearsDesignator ::: one of // Y y bool yearsDesignator() { return oneOf({'Y', 'y'}); } - // UTCDesignator : one of + // UTCDesignator ::: one of // Z z bool utcDesignator() { return oneOf({'Z', 'z'}); } - // TZLeadingChar : + // TZLeadingChar ::: // Alpha // . // _ @@ -762,7 +762,7 @@ class TemporalParser final { }); } - // TZChar : + // TZChar ::: // TZLeadingChar // DecimalDigit // - @@ -774,11 +774,11 @@ class TemporalParser final { }); } - // AnnotationCriticalFlag : + // AnnotationCriticalFlag ::: // ! bool annotationCriticalFlag() { return character('!'); } - // AKeyLeadingChar : + // AKeyLeadingChar ::: // LowercaseAlpha // _ bool aKeyLeadingChar() { @@ -787,7 +787,7 @@ class TemporalParser final { }); } - // AKeyChar : + // AKeyChar ::: // AKeyLeadingChar // DecimalDigit // - @@ -798,7 +798,7 @@ class TemporalParser final { }); } - // AnnotationValueComponent : + // AnnotationValueComponent ::: // Alpha AnnotationValueComponent? // DecimalDigit AnnotationValueComponent? bool annotationValueComponent() { @@ -929,7 +929,7 @@ class TemporalParser final { template <typename CharT> mozilla::Result<ZonedDateTimeString, ParserError> TemporalParser<CharT>::dateTime() { - // DateTime : + // DateTime ::: // Date // Date DateTimeSeparator TimeSpec DateTimeUTCOffset? ZonedDateTimeString result = {}; @@ -961,12 +961,12 @@ TemporalParser<CharT>::dateTime() { template <typename CharT> mozilla::Result<PlainDate, ParserError> TemporalParser<CharT>::date() { - // Date : + // Date ::: // DateYear - DateMonth - DateDay // DateYear DateMonth DateDay PlainDate result = {}; - // DateYear : + // DateYear ::: // DecimalDigit{4} // Sign DecimalDigit{6} if (auto year = digits(4)) { @@ -988,7 +988,7 @@ mozilla::Result<PlainDate, ParserError> TemporalParser<CharT>::date() { // Optional: - character('-'); - // DateMonth : + // DateMonth ::: // 0 NonzeroDigit // 10 // 11 @@ -1005,7 +1005,7 @@ mozilla::Result<PlainDate, ParserError> TemporalParser<CharT>::date() { // Optional: - character('-'); - // DateDay : + // DateDay ::: // 0 NonzeroDigit // 1 DecimalDigit // 2 DecimalDigit @@ -1025,7 +1025,7 @@ mozilla::Result<PlainDate, ParserError> TemporalParser<CharT>::date() { template <typename CharT> mozilla::Result<PlainTime, ParserError> TemporalParser<CharT>::timeSpec() { - // TimeSpec : + // TimeSpec ::: // TimeHour // TimeHour : TimeMinute // TimeHour TimeMinute @@ -1033,12 +1033,11 @@ mozilla::Result<PlainTime, ParserError> TemporalParser<CharT>::timeSpec() { // TimeHour TimeMinute TimeSecond TimeFraction? PlainTime result = {}; - // TimeHour : - // Hour[+Padded] + // TimeHour ::: + // Hour // - // Hour[Padded] : - // [~Padded] DecimalDigit - // [~Padded] 0 DecimalDigit + // Hour ::: + // 0 DecimalDigit // 1 DecimalDigit // 20 // 21 @@ -1056,10 +1055,10 @@ mozilla::Result<PlainTime, ParserError> TemporalParser<CharT>::timeSpec() { // Optional: : bool needsMinutes = character(':'); - // TimeMinute : + // TimeMinute ::: // MinuteSecond // - // MinuteSecond : + // MinuteSecond ::: // 0 DecimalDigit // 1 DecimalDigit // 2 DecimalDigit @@ -1075,7 +1074,7 @@ mozilla::Result<PlainTime, ParserError> TemporalParser<CharT>::timeSpec() { // Optional: : bool needsSeconds = needsMinutes && character(':'); - // TimeSecond : + // TimeSecond ::: // MinuteSecond // 60 if (auto second = digits(2)) { @@ -1084,7 +1083,7 @@ mozilla::Result<PlainTime, ParserError> TemporalParser<CharT>::timeSpec() { return mozilla::Err(JSMSG_TEMPORAL_PARSER_INVALID_LEAPSECOND); } - // TimeFraction : + // TimeFraction ::: // Fraction if (auto f = fraction()) { int32_t fractionalPart = f.value(); @@ -1105,7 +1104,7 @@ mozilla::Result<PlainTime, ParserError> TemporalParser<CharT>::timeSpec() { template <typename CharT> mozilla::Result<TimeZoneString, ParserError> TemporalParser<CharT>::dateTimeUTCOffset() { - // DateTimeUTCOffset : + // DateTimeUTCOffset ::: // UTCDesignator // UTCOffsetSubMinutePrecision @@ -1127,13 +1126,13 @@ TemporalParser<CharT>::dateTimeUTCOffset() { template <typename CharT> mozilla::Result<TimeZoneUTCOffset, ParserError> TemporalParser<CharT>::timeZoneUTCOffsetName() { - // TimeZoneUTCOffsetName : + // TimeZoneUTCOffsetName ::: // UTCOffsetMinutePrecision // - // UTCOffsetMinutePrecision : - // Sign Hour[+Padded] - // Sign Hour[+Padded] TimeSeparator[+Extended] MinuteSecond - // Sign Hour[+Padded] TimeSeparator[~Extended] MinuteSecond + // UTCOffsetMinutePrecision ::: + // Sign Hour + // Sign Hour TimeSeparator[+Extended] MinuteSecond + // Sign Hour TimeSeparator[~Extended] MinuteSecond TimeZoneUTCOffset result = {}; @@ -1142,9 +1141,8 @@ TemporalParser<CharT>::timeZoneUTCOffsetName() { } result.sign = sign(); - // Hour[Padded] : - // [~Padded] DecimalDigit - // [+Padded] 0 DecimalDigit + // Hour ::: + // 0 DecimalDigit // 1 DecimalDigit // 20 // 21 @@ -1159,12 +1157,12 @@ TemporalParser<CharT>::timeZoneUTCOffsetName() { return mozilla::Err(JSMSG_TEMPORAL_PARSER_MISSING_HOUR); } - // TimeSeparator[Extended] : + // TimeSeparator[Extended] ::: // [+Extended] : // [~Extended] [empty] bool needsMinutes = character(':'); - // MinuteSecond : + // MinuteSecond ::: // 0 DecimalDigit // 1 DecimalDigit // 2 DecimalDigit @@ -1192,18 +1190,18 @@ mozilla::Result<DateTimeUTCOffset, ParserError> TemporalParser<CharT>::utcOffsetSubMinutePrecision() { // clang-format off // - // UTCOffsetSubMinutePrecision : + // UTCOffsetSubMinutePrecision ::: // UTCOffsetMinutePrecision // UTCOffsetWithSubMinuteComponents[+Extended] // UTCOffsetWithSubMinuteComponents[~Extended] // - // UTCOffsetMinutePrecision : - // Sign Hour[+Padded] - // Sign Hour[+Padded] TimeSeparator[+Extended] MinuteSecond - // Sign Hour[+Padded] TimeSeparator[~Extended] MinuteSecond + // UTCOffsetMinutePrecision ::: + // Sign Hour + // Sign Hour TimeSeparator[+Extended] MinuteSecond + // Sign Hour TimeSeparator[~Extended] MinuteSecond // - // UTCOffsetWithSubMinuteComponents[Extended] : - // Sign Hour[+Padded] TimeSeparator[?Extended] MinuteSecond TimeSeparator[?Extended] MinuteSecond Fraction? + // UTCOffsetWithSubMinuteComponents[Extended] ::: + // Sign Hour TimeSeparator[?Extended] MinuteSecond TimeSeparator[?Extended] MinuteSecond Fraction? // // clang-format on @@ -1214,9 +1212,8 @@ TemporalParser<CharT>::utcOffsetSubMinutePrecision() { } result.sign = sign(); - // Hour[Padded] : - // [~Padded] DecimalDigit - // [+Padded] 0 DecimalDigit + // Hour ::: + // 0 DecimalDigit // 1 DecimalDigit // 20 // 21 @@ -1231,12 +1228,12 @@ TemporalParser<CharT>::utcOffsetSubMinutePrecision() { return mozilla::Err(JSMSG_TEMPORAL_PARSER_MISSING_HOUR); } - // TimeSeparator[Extended] : + // TimeSeparator[Extended] ::: // [+Extended] : // [~Extended] [empty] bool needsMinutes = character(':'); - // MinuteSecond : + // MinuteSecond ::: // 0 DecimalDigit // 1 DecimalDigit // 2 DecimalDigit @@ -1249,12 +1246,12 @@ TemporalParser<CharT>::utcOffsetSubMinutePrecision() { return mozilla::Err(JSMSG_TEMPORAL_PARSER_INVALID_MINUTE); } - // TimeSeparator[Extended] : + // TimeSeparator[Extended] ::: // [+Extended] : // [~Extended] [empty] bool needsSeconds = needsMinutes && character(':'); - // MinuteSecond : + // MinuteSecond ::: // 0 DecimalDigit // 1 DecimalDigit // 2 DecimalDigit @@ -1285,7 +1282,7 @@ TemporalParser<CharT>::utcOffsetSubMinutePrecision() { template <typename CharT> mozilla::Result<TimeZoneAnnotation, ParserError> TemporalParser<CharT>::timeZoneIdentifier() { - // TimeZoneIdentifier : + // TimeZoneIdentifier ::: // TimeZoneUTCOffsetName // TimeZoneIANAName @@ -1310,7 +1307,7 @@ TemporalParser<CharT>::timeZoneIdentifier() { template <typename CharT> mozilla::Result<TimeZoneAnnotation, ParserError> TemporalParser<CharT>::timeZoneAnnotation() { - // TimeZoneAnnotation : + // TimeZoneAnnotation ::: // [ AnnotationCriticalFlag? TimeZoneIdentifier ] if (!character('[')) { @@ -1335,11 +1332,11 @@ TemporalParser<CharT>::timeZoneAnnotation() { template <typename CharT> mozilla::Result<TimeZoneName, ParserError> TemporalParser<CharT>::timeZoneIANAName() { - // TimeZoneIANAName : + // TimeZoneIANAName ::: // TimeZoneIANANameComponent // TimeZoneIANAName / TimeZoneIANANameComponent // - // TimeZoneIANANameComponent : + // TimeZoneIANANameComponent ::: // TZLeadingChar // TimeZoneIANANameComponent TZChar @@ -1385,7 +1382,7 @@ TemporalParser<CharT>::parseTemporalInstantString() { // clang-format off // - // TemporalInstantString : + // TemporalInstantString ::: // Date DateTimeSeparator TimeSpec DateTimeUTCOffset TimeZoneAnnotation? Annotations? // // clang-format on @@ -1492,7 +1489,7 @@ bool js::temporal::ParseTemporalInstantString(JSContext* cx, template <typename CharT> mozilla::Result<ZonedDateTimeString, ParserError> TemporalParser<CharT>::parseTemporalTimeZoneString() { - // TimeZoneIdentifier : + // TimeZoneIdentifier ::: // TimeZoneUTCOffsetName // TimeZoneIANAName @@ -1819,10 +1816,10 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) { // Initialize all fields to zero. TemporalDurationString result = {}; - // TemporalDurationString : + // TemporalDurationString ::: // Duration // - // Duration : + // Duration ::: // Sign? DurationDesignator DurationDate // Sign? DurationDesignator DurationTime @@ -1834,7 +1831,7 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) { return mozilla::Err(JSMSG_TEMPORAL_PARSER_MISSING_DURATION_DESIGNATOR); } - // DurationDate : + // DurationDate ::: // DurationYearsPart DurationTime? // DurationMonthsPart DurationTime? // DurationWeeksPart DurationTime? @@ -1851,12 +1848,12 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) { num = *d; } - // DurationYearsPart : + // DurationYearsPart ::: // DurationYears YearsDesignator DurationMonthsPart // DurationYears YearsDesignator DurationWeeksPart // DurationYears YearsDesignator DurationDaysPart? // - // DurationYears : + // DurationYears ::: // DecimalDigits[~Sep] if (yearsDesignator()) { result.years = num; @@ -1873,11 +1870,11 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) { } } - // DurationMonthsPart : + // DurationMonthsPart ::: // DurationMonths MonthsDesignator DurationWeeksPart // DurationMonths MonthsDesignator DurationDaysPart? // - // DurationMonths : + // DurationMonths ::: // DecimalDigits[~Sep] if (monthsDesignator()) { result.months = num; @@ -1894,10 +1891,10 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) { } } - // DurationWeeksPart : + // DurationWeeksPart ::: // DurationWeeks WeeksDesignator DurationDaysPart? // - // DurationWeeks : + // DurationWeeks ::: // DecimalDigits[~Sep] if (weeksDesignator()) { result.weeks = num; @@ -1914,10 +1911,10 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) { } } - // DurationDaysPart : + // DurationDaysPart ::: // DurationDays DaysDesignator // - // DurationDays : + // DurationDays ::: // DecimalDigits[~Sep] if (daysDesignator()) { result.days = num; @@ -1932,7 +1929,7 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) { return mozilla::Err(JSMSG_TEMPORAL_PARSER_GARBAGE_AFTER_INPUT); } while (false); - // DurationTime : + // DurationTime ::: // DurationTimeDesignator DurationHoursPart // DurationTimeDesignator DurationMinutesPart // DurationTimeDesignator DurationSecondsPart @@ -1958,18 +1955,18 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) { // clang-format off // - // DurationHoursPart : + // DurationHoursPart ::: // DurationWholeHours DurationHoursFraction HoursDesignator // DurationWholeHours HoursDesignator DurationMinutesPart // DurationWholeHours HoursDesignator DurationSecondsPart? // - // DurationWholeHours : + // DurationWholeHours ::: // DecimalDigits[~Sep] // - // DurationHoursFraction : + // DurationHoursFraction ::: // TimeFraction // - // TimeFraction : + // TimeFraction ::: // Fraction // // clang-format on @@ -1988,17 +1985,17 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) { // clang-format off // - // DurationMinutesPart : + // DurationMinutesPart ::: // DurationWholeMinutes DurationMinutesFraction MinutesDesignator // DurationWholeMinutes MinutesDesignator DurationSecondsPart? // - // DurationWholeMinutes : + // DurationWholeMinutes ::: // DecimalDigits[~Sep] // - // DurationMinutesFraction : + // DurationMinutesFraction ::: // TimeFraction // - // TimeFraction : + // TimeFraction ::: // Fraction // // clang-format on @@ -2018,16 +2015,16 @@ TemporalParser<CharT>::parseTemporalDurationString(JSContext* cx) { } } - // DurationSecondsPart : + // DurationSecondsPart ::: // DurationWholeSeconds DurationSecondsFraction? SecondsDesignator // - // DurationWholeSeconds : + // DurationWholeSeconds ::: // DecimalDigits[~Sep] // - // DurationSecondsFraction : + // DurationSecondsFraction ::: // TimeFraction // - // TimeFraction : + // TimeFraction ::: // Fraction if (secondsDesignator()) { if (hasHoursFraction || hasMinutesFraction) { @@ -2106,14 +2103,14 @@ bool js::temporal::ParseTemporalDurationString(JSContext* cx, // Steps 9.b-d. int64_t h = int64_t(parsed.hoursFraction) * 60; - minutes = h / 1'000'000'000; + minutes = double(h / 1'000'000'000); // Steps 13 and 15-17. int64_t min = (h % 1'000'000'000) * 60; - seconds = min / 1'000'000'000; - milliseconds = (min % 1'000'000'000) / 1'000'000; - microseconds = (min % 1'000'000) / 1'000; - nanoseconds = (min % 1'000); + seconds = double(min / 1'000'000'000); + milliseconds = double((min % 1'000'000'000) / 1'000'000); + microseconds = double((min % 1'000'000) / 1'000); + nanoseconds = double(min % 1'000); } // Step 11. @@ -2130,10 +2127,10 @@ bool js::temporal::ParseTemporalDurationString(JSContext* cx, // Steps 11.b-d and 15-17. int64_t min = int64_t(parsed.minutesFraction) * 60; - seconds = min / 1'000'000'000; - milliseconds = (min % 1'000'000'000) / 1'000'000; - microseconds = (min % 1'000'000) / 1'000; - nanoseconds = (min % 1'000); + seconds = double(min / 1'000'000'000); + milliseconds = double((min % 1'000'000'000) / 1'000'000); + microseconds = double((min % 1'000'000) / 1'000); + nanoseconds = double(min % 1'000); } // Step 14. @@ -2148,9 +2145,9 @@ bool js::temporal::ParseTemporalDurationString(JSContext* cx, seconds = parsed.seconds; // Steps 14, 16-17 - milliseconds = (parsed.secondsFraction / 1'000'000); - microseconds = ((parsed.secondsFraction % 1'000'000) / 1'000); - nanoseconds = (parsed.secondsFraction % 1'000); + milliseconds = double(parsed.secondsFraction / 1'000'000); + microseconds = double((parsed.secondsFraction % 1'000'000) / 1'000); + nanoseconds = double(parsed.secondsFraction % 1'000); } else { // Step 10. minutes = parsed.minutes; @@ -2168,7 +2165,7 @@ bool js::temporal::ParseTemporalDurationString(JSContext* cx, int32_t factor = parsed.sign ? parsed.sign : 1; MOZ_ASSERT(factor == -1 || factor == 1); - // Step 20. + // Steps 20-29. *result = { (years * factor) + (+0.0), (months * factor) + (+0.0), (weeks * factor) + (+0.0), (days * factor) + (+0.0), @@ -2176,16 +2173,15 @@ bool js::temporal::ParseTemporalDurationString(JSContext* cx, (seconds * factor) + (+0.0), (milliseconds * factor) + (+0.0), (microseconds * factor) + (+0.0), (nanoseconds * factor) + (+0.0), }; - if (!ThrowIfInvalidDuration(cx, *result)) { - return false; - } - return true; + + // Steps 30-31. + return ThrowIfInvalidDuration(cx, *result); } template <typename CharT> mozilla::Result<AnnotationKey, ParserError> TemporalParser<CharT>::annotationKey() { - // AnnotationKey : + // AnnotationKey ::: // AKeyLeadingChar // AnnotationKey AKeyChar @@ -2205,7 +2201,7 @@ TemporalParser<CharT>::annotationKey() { template <typename CharT> mozilla::Result<AnnotationValue, ParserError> TemporalParser<CharT>::annotationValue() { - // AnnotationValue : + // AnnotationValue ::: // AnnotationValueComponent // AnnotationValueComponent - AnnotationValue @@ -2222,7 +2218,7 @@ TemporalParser<CharT>::annotationValue() { template <typename CharT> mozilla::Result<Annotation, ParserError> TemporalParser<CharT>::annotation() { - // Annotation : + // Annotation ::: // [ AnnotationCriticalFlag? AnnotationKey = AnnotationValue ] if (!character('[')) { @@ -2255,7 +2251,7 @@ mozilla::Result<Annotation, ParserError> TemporalParser<CharT>::annotation() { template <typename CharT> mozilla::Result<CalendarName, ParserError> TemporalParser<CharT>::annotations() { - // Annotations: + // Annotations ::: // Annotation Annotations? MOZ_ASSERT(hasAnnotationStart()); @@ -2269,9 +2265,6 @@ TemporalParser<CharT>::annotations() { } auto [key, value, critical] = anno.unwrap(); - // FIXME: spec issue - ignore case for "[u-ca=" to match BCP47? - // https://github.com/tc39/proposal-temporal/issues/2524 - static constexpr std::string_view ca = "u-ca"; auto keySpan = reader_.substring(key); @@ -2295,7 +2288,7 @@ mozilla::Result<ZonedDateTimeString, ParserError> TemporalParser<CharT>::annotatedTime() { // clang-format off // - // AnnotatedTime : + // AnnotatedTime ::: // TimeDesignator TimeSpec DateTimeUTCOffset? TimeZoneAnnotation? Annotations? // TimeSpecWithOptionalOffsetNotAmbiguous TimeZoneAnnotation? Annotations? // @@ -2339,7 +2332,7 @@ TemporalParser<CharT>::annotatedTime() { // clang-format off // - // TimeSpecWithOptionalOffsetNotAmbiguous : + // TimeSpecWithOptionalOffsetNotAmbiguous ::: // TimeSpec DateTimeUTCOffset? but not one of ValidMonthDay or DateSpecYearMonth // // clang-format on @@ -2407,7 +2400,7 @@ TemporalParser<CharT>::annotatedTime() { template <typename CharT> mozilla::Result<ZonedDateTimeString, ParserError> TemporalParser<CharT>::annotatedDateTime() { - // AnnotatedDateTime[Zoned] : + // AnnotatedDateTime[Zoned] ::: // [~Zoned] DateTime TimeZoneAnnotation? Annotations? // [+Zoned] DateTime TimeZoneAnnotation Annotations? @@ -2441,7 +2434,7 @@ mozilla::Result<ZonedDateTimeString, ParserError> TemporalParser<CharT>::annotatedDateTimeTimeRequired() { // clang-format off // - // AnnotatedDateTimeTimeRequired : + // AnnotatedDateTimeTimeRequired ::: // Date DateTimeSeparator TimeSpec DateTimeUTCOffset? TimeZoneAnnotation? Annotations? // // clang-format on @@ -2494,7 +2487,7 @@ TemporalParser<CharT>::annotatedDateTimeTimeRequired() { template <typename CharT> mozilla::Result<ZonedDateTimeString, ParserError> TemporalParser<CharT>::annotatedYearMonth() { - // AnnotatedYearMonth : + // AnnotatedYearMonth ::: // DateSpecYearMonth TimeZoneAnnotation? Annotations? ZonedDateTimeString result = {}; @@ -2527,7 +2520,7 @@ TemporalParser<CharT>::annotatedYearMonth() { template <typename CharT> mozilla::Result<ZonedDateTimeString, ParserError> TemporalParser<CharT>::annotatedMonthDay() { - // AnnotatedMonthDay : + // AnnotatedMonthDay ::: // DateSpecMonthDay TimeZoneAnnotation? Annotations? ZonedDateTimeString result = {}; @@ -2560,11 +2553,11 @@ TemporalParser<CharT>::annotatedMonthDay() { template <typename CharT> mozilla::Result<PlainDate, ParserError> TemporalParser<CharT>::dateSpecYearMonth() { - // DateSpecYearMonth : + // DateSpecYearMonth ::: // DateYear -? DateMonth PlainDate result = {}; - // DateYear : + // DateYear ::: // DecimalDigit{4} // Sign DecimalDigit{6} if (auto year = digits(4)) { @@ -2585,7 +2578,7 @@ TemporalParser<CharT>::dateSpecYearMonth() { character('-'); - // DateMonth : + // DateMonth ::: // 0 NonzeroDigit // 10 // 11 @@ -2608,16 +2601,17 @@ TemporalParser<CharT>::dateSpecYearMonth() { template <typename CharT> mozilla::Result<PlainDate, ParserError> TemporalParser<CharT>::dateSpecMonthDay() { - // DateSpecMonthDay : + // DateSpecMonthDay ::: // -- DateMonth -? DateDay // DateMonth -? DateDay PlainDate result = {}; + // Optional: -- string("--"); result.year = AbsentYear; - // DateMonth : + // DateMonth ::: // 0 NonzeroDigit // 10 // 11 @@ -2631,9 +2625,10 @@ TemporalParser<CharT>::dateSpecMonthDay() { return mozilla::Err(JSMSG_TEMPORAL_PARSER_MISSING_MONTH); } + // Optional: - character('-'); - // DateDay : + // DateDay ::: // 0 NonzeroDigit // 1 DecimalDigit // 2 DecimalDigit @@ -2653,19 +2648,19 @@ TemporalParser<CharT>::dateSpecMonthDay() { template <typename CharT> mozilla::Result<PlainDate, ParserError> TemporalParser<CharT>::validMonthDay() { - // ValidMonthDay : + // ValidMonthDay ::: // DateMonth -? 0 NonZeroDigit // DateMonth -? 1 DecimalDigit // DateMonth -? 2 DecimalDigit // DateMonth -? 30 but not one of 0230 or 02-30 // DateMonthWithThirtyOneDays -? 31 // - // DateMonthWithThirtyOneDays : one of + // DateMonthWithThirtyOneDays ::: one of // 01 03 05 07 08 10 12 PlainDate result = {}; - // DateMonth : + // DateMonth ::: // 0 NonzeroDigit // 10 // 11 @@ -2679,6 +2674,7 @@ mozilla::Result<PlainDate, ParserError> TemporalParser<CharT>::validMonthDay() { return mozilla::Err(JSMSG_TEMPORAL_PARSER_MISSING_MONTH); } + // Optional: - character('-'); if (auto day = digits(2)) { @@ -2834,7 +2830,7 @@ JSLinearString* js::temporal::ParseTemporalCalendarString( template <typename CharT> mozilla::Result<ZonedDateTimeString, ParserError> TemporalParser<CharT>::parseTemporalTimeString() { - // TemporalTimeString : + // TemporalTimeString ::: // AnnotatedTime // AnnotatedDateTimeTimeRequired @@ -2915,7 +2911,7 @@ bool js::temporal::ParseTemporalTimeString(JSContext* cx, Handle<JSString*> str, template <typename CharT> mozilla::Result<ZonedDateTimeString, ParserError> TemporalParser<CharT>::parseTemporalMonthDayString() { - // TemporalMonthDayString : + // TemporalMonthDayString ::: // AnnotatedMonthDay // AnnotatedDateTime[~Zoned] @@ -3014,7 +3010,7 @@ bool js::temporal::ParseTemporalMonthDayString( template <typename CharT> mozilla::Result<ZonedDateTimeString, ParserError> TemporalParser<CharT>::parseTemporalYearMonthString() { - // TemporalYearMonthString : + // TemporalYearMonthString ::: // AnnotatedYearMonth // AnnotatedDateTime[~Zoned] @@ -3112,7 +3108,7 @@ bool js::temporal::ParseTemporalYearMonthString( template <typename CharT> mozilla::Result<ZonedDateTimeString, ParserError> TemporalParser<CharT>::parseTemporalDateTimeString() { - // TemporalDateTimeString[Zoned] : + // TemporalDateTimeString[Zoned] ::: // AnnotatedDateTime[?Zoned] auto dateTime = annotatedDateTime(); @@ -3209,10 +3205,10 @@ mozilla::Result<ZonedDateTimeString, ParserError> TemporalParser<CharT>::parseTemporalZonedDateTimeString() { // Parse goal: TemporalDateTimeString[+Zoned] // - // TemporalDateTimeString[Zoned] : + // TemporalDateTimeString[Zoned] ::: // AnnotatedDateTime[?Zoned] // - // AnnotatedDateTime[Zoned] : + // AnnotatedDateTime[Zoned] ::: // [~Zoned] DateTime TimeZoneAnnotation? Annotations? // [+Zoned] DateTime TimeZoneAnnotation Annotations? @@ -3269,7 +3265,7 @@ static auto ParseTemporalZonedDateTimeString(Handle<JSLinearString*> str) { bool js::temporal::ParseTemporalZonedDateTimeString( JSContext* cx, Handle<JSString*> str, PlainDateTime* dateTime, bool* isUTC, bool* hasOffset, int64_t* timeZoneOffset, - MutableHandle<ParsedTimeZone> timeZoneName, + MutableHandle<ParsedTimeZone> timeZoneAnnotation, MutableHandle<JSString*> calendar) { Rooted<JSLinearString*> linear(cx, str->ensureLinear(cx)); if (!linear) { @@ -3313,7 +3309,7 @@ bool js::temporal::ParseTemporalZonedDateTimeString( // { [[Z]]: false, [[OffsetString]]: undefined, [[Name]]: "Europe/Berlin" } const auto& annotation = parsed.timeZone.annotation; - if (!ParseTimeZoneAnnotation(cx, annotation, linear, timeZoneName)) { + if (!ParseTimeZoneAnnotation(cx, annotation, linear, timeZoneAnnotation)) { return false; } @@ -3370,7 +3366,7 @@ static auto ParseTemporalRelativeToString(Handle<JSLinearString*> str) { bool js::temporal::ParseTemporalRelativeToString( JSContext* cx, Handle<JSString*> str, PlainDateTime* dateTime, bool* isUTC, bool* hasOffset, int64_t* timeZoneOffset, - MutableHandle<ParsedTimeZone> timeZoneName, + MutableHandle<ParsedTimeZone> timeZoneAnnotation, MutableHandle<JSString*> calendar) { Rooted<JSLinearString*> linear(cx, str->ensureLinear(cx)); if (!linear) { @@ -3420,7 +3416,7 @@ bool js::temporal::ParseTemporalRelativeToString( // { [[Z]]: false, [[OffsetString]]: undefined, [[Name]]: "Europe/Berlin" } const auto& annotation = parsed.timeZone.annotation; - if (!ParseTimeZoneAnnotation(cx, annotation, linear, timeZoneName)) { + if (!ParseTimeZoneAnnotation(cx, annotation, linear, timeZoneAnnotation)) { return false; } @@ -3444,7 +3440,7 @@ bool js::temporal::ParseTemporalRelativeToString( *isUTC = false; *hasOffset = false; *timeZoneOffset = 0; - timeZoneName.set(ParsedTimeZone{}); + timeZoneAnnotation.set(ParsedTimeZone{}); } // Step 4. (ParseISODateTime, steps 23-24.) diff --git a/js/src/builtin/temporal/TemporalParser.h b/js/src/builtin/temporal/TemporalParser.h index 677a90b58d..86ac7bbd82 100644 --- a/js/src/builtin/temporal/TemporalParser.h +++ b/js/src/builtin/temporal/TemporalParser.h @@ -8,6 +8,7 @@ #define builtin_temporal_TemporalParser_h #include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" #include <cstdlib> #include <stdint.h> @@ -26,7 +27,7 @@ struct PlainDate; struct PlainDateTime; struct PlainTime; -struct ParsedTimeZone { +struct MOZ_STACK_CLASS ParsedTimeZone final { JSLinearString* name = nullptr; int32_t offset = INT32_MIN; @@ -129,7 +130,7 @@ bool ParseTemporalDateTimeString(JSContext* cx, JS::Handle<JSString*> str, bool ParseTemporalZonedDateTimeString( JSContext* cx, JS::Handle<JSString*> str, PlainDateTime* dateTime, bool* isUTC, bool* hasOffset, int64_t* timeZoneOffset, - JS::MutableHandle<ParsedTimeZone> timeZoneName, + JS::MutableHandle<ParsedTimeZone> timeZoneAnnotation, JS::MutableHandle<JSString*> calendar); /** @@ -138,7 +139,7 @@ bool ParseTemporalZonedDateTimeString( bool ParseTemporalRelativeToString( JSContext* cx, JS::Handle<JSString*> str, PlainDateTime* dateTime, bool* isUTC, bool* hasOffset, int64_t* timeZoneOffset, - JS::MutableHandle<ParsedTimeZone> timeZoneName, + JS::MutableHandle<ParsedTimeZone> timeZoneAnnotation, JS::MutableHandle<JSString*> calendar); } /* namespace js::temporal */ diff --git a/js/src/builtin/temporal/TemporalRoundingMode.h b/js/src/builtin/temporal/TemporalRoundingMode.h index 91ef758fc6..23d3996d09 100644 --- a/js/src/builtin/temporal/TemporalRoundingMode.h +++ b/js/src/builtin/temporal/TemporalRoundingMode.h @@ -12,6 +12,8 @@ #include <cmath> #include <stdint.h> +#include "builtin/temporal/Int128.h" + namespace js::temporal { // Overview of integer rounding modes is available at @@ -428,6 +430,286 @@ inline int64_t Divide(int64_t dividend, int64_t divisor, MOZ_CRASH("invalid rounding mode"); } +/** + * Compute ceiling division ⌈dividend / divisor⌉. The divisor must be a positive + * number. + */ +constexpr Int128 CeilDiv(const Int128& dividend, const Int128& divisor) { + MOZ_ASSERT(divisor > Int128{0}, "negative divisor not supported"); + + auto [quotient, remainder] = dividend.divrem(divisor); + + // Ceiling division rounds the quotient toward positive infinity. When the + // quotient is negative, this is equivalent to rounding toward zero. See [1]. + // + // Int128 division truncates, so rounding toward zero for negative quotients + // is already covered. When there is a non-zero positive remainder, the + // quotient is positive and we have to increment it by one to implement + // rounding toward positive infinity. + // + // [1] + // https://tc39.es/proposal-temporal/#table-temporal-unsigned-rounding-modes + if (remainder > Int128{0}) { + quotient += Int128{1}; + } + return quotient; +} + +/** + * Compute floor division ⌊dividend / divisor⌋. The divisor must be a positive + * number. + */ +constexpr Int128 FloorDiv(const Int128& dividend, const Int128& divisor) { + MOZ_ASSERT(divisor > Int128{0}, "negative divisor not supported"); + + auto [quotient, remainder] = dividend.divrem(divisor); + + // Floor division rounds the quotient toward negative infinity. When the + // quotient is positive, this is equivalent to rounding toward zero. See [1]. + // + // Int128 division truncates, so rounding toward zero for positive quotients + // is already covered. When there is a non-zero negative remainder, the + // quotient is negative and we have to decrement it by one to implement + // rounding toward negative infinity. + // + // [1] + // https://tc39.es/proposal-temporal/#table-temporal-unsigned-rounding-modes + if (remainder < Int128{0}) { + quotient -= Int128{1}; + } + return quotient; +} + +/** + * Compute "round toward infinity" division `dividend / divisor`. The divisor + * must be a positive number. + */ +constexpr Int128 ExpandDiv(const Int128& dividend, const Int128& divisor) { + MOZ_ASSERT(divisor > Int128{0}, "negative divisor not supported"); + + auto [quotient, remainder] = dividend.divrem(divisor); + + // "Round toward infinity" division rounds positive quotients toward positive + // infinity and negative quotients toward negative infinity. See [1]. + // + // When there is a non-zero positive remainder, the quotient is positive and + // we have to increment it by one to implement rounding toward positive + // infinity. When there is a non-zero negative remainder, the quotient is + // negative and we have to decrement it by one to implement rounding toward + // negative infinity. + // + // [1] + // https://tc39.es/proposal-temporal/#table-temporal-unsigned-rounding-modes + if (remainder > Int128{0}) { + quotient += Int128{1}; + } + if (remainder < Int128{0}) { + quotient -= Int128{1}; + } + return quotient; +} + +/** + * Compute truncating division `dividend / divisor`. The divisor must be a + * positive number. + */ +constexpr Int128 TruncDiv(const Int128& dividend, const Int128& divisor) { + MOZ_ASSERT(divisor > Int128{0}, "negative divisor not supported"); + + // Truncating division rounds both positive and negative quotients toward + // zero, cf. [1]. + // + // Int128 division truncates, so rounding toward zero implicitly happens. + // + // [1] + // https://tc39.es/proposal-temporal/#table-temporal-unsigned-rounding-modes + return dividend / divisor; +} + +/** + * Compute "round half toward positive infinity" division `dividend / divisor`. + * The divisor must be a positive number. + */ +inline Int128 HalfCeilDiv(const Int128& dividend, const Int128& divisor) { + MOZ_ASSERT(divisor > Int128{0}, "negative divisor not supported"); + + auto [quotient, remainder] = dividend.divrem(divisor); + + // "Round half toward positive infinity" division rounds the quotient toward + // positive infinity when the fractional part of the remainder is ≥0.5. When + // the quotient is negative, this is equivalent to rounding toward zero + // instead of toward positive infinity. See [1]. + // + // When the remainder is a non-zero positive value, the quotient is positive, + // too. When additionally the fractional part of the remainder is ≥0.5, we + // have to increment the quotient by one to implement rounding toward positive + // infinity. + // + // Int128 division truncates, so we implicitly round toward zero for negative + // quotients. When the absolute value of the fractional part of the remainder + // is >0.5, we should instead have rounded toward negative infinity, so we + // need to decrement the quotient by one. + // + // [1] + // https://tc39.es/proposal-temporal/#table-temporal-unsigned-rounding-modes + if (remainder > Int128{0} && + Uint128(remainder.abs()) * Uint128{2} >= static_cast<Uint128>(divisor)) { + quotient += Int128{1}; + } + if (remainder < Int128{0} && + Uint128(remainder.abs()) * Uint128{2} > static_cast<Uint128>(divisor)) { + quotient -= Int128{1}; + } + return quotient; +} + +/** + * Compute "round half toward negative infinity" division `dividend / divisor`. + * The divisor must be a positive number. + */ +inline Int128 HalfFloorDiv(const Int128& dividend, const Int128& divisor) { + MOZ_ASSERT(divisor > Int128{0}, "negative divisor not supported"); + + auto [quotient, remainder] = dividend.divrem(divisor); + + // "Round half toward negative infinity" division rounds the quotient toward + // negative infinity when the fractional part of the remainder is ≥0.5. When + // the quotient is positive, this is equivalent to rounding toward zero + // instead of toward negative infinity. See [1]. + // + // When the remainder is a non-zero negative value, the quotient is negative, + // too. When additionally the fractional part of the remainder is ≥0.5, we + // have to decrement the quotient by one to implement rounding toward negative + // infinity. + // + // Int128 division truncates, so we implicitly round toward zero for positive + // quotients. When the absolute value of the fractional part of the remainder + // is >0.5, we should instead have rounded toward positive infinity, so we + // need to increment the quotient by one. + // + // [1] + // https://tc39.es/proposal-temporal/#table-temporal-unsigned-rounding-modes + if (remainder < Int128{0} && + Uint128(remainder.abs()) * Uint128{2} >= static_cast<Uint128>(divisor)) { + quotient -= Int128{1}; + } + if (remainder > Int128{0} && + Uint128(remainder.abs()) * Uint128{2} > static_cast<Uint128>(divisor)) { + quotient += Int128{1}; + } + return quotient; +} + +/** + * Compute "round half toward infinity" division `dividend / divisor`. The + * divisor must be a positive number. + */ +inline Int128 HalfExpandDiv(const Int128& dividend, const Int128& divisor) { + MOZ_ASSERT(divisor > Int128{0}, "negative divisor not supported"); + + auto [quotient, remainder] = dividend.divrem(divisor); + + // "Round half toward infinity" division rounds positive quotients whose + // remainder has a fractional part ≥0.5 toward positive infinity. And negative + // quotients whose remainder has a fractional part ≥0.5 toward negative + // infinity. See [1]. + // + // Int128 division truncates, which means it rounds toward zero, so we have + // to increment resp. decrement the quotient when the fractional part of the + // remainder is ≥0.5 to round toward ±infinity. + // + // [1] + // https://tc39.es/proposal-temporal/#table-temporal-unsigned-rounding-modes + if (Uint128(remainder.abs()) * Uint128{2} >= static_cast<Uint128>(divisor)) { + quotient += (dividend > Int128{0}) ? Int128{1} : Int128{-1}; + } + return quotient; +} + +/** + * Compute "round half toward zero" division `dividend / divisor`. The divisor + * must be a positive number. + */ +inline Int128 HalfTruncDiv(const Int128& dividend, const Int128& divisor) { + MOZ_ASSERT(divisor > Int128{0}, "negative divisor not supported"); + + auto [quotient, remainder] = dividend.divrem(divisor); + + // "Round half toward zero" division rounds both positive and negative + // quotients whose remainder has a fractional part ≤0.5 toward zero. See [1]. + // + // Int128 division truncates, so we implicitly round toward zero. When the + // fractional part of the remainder is >0.5, we should instead have rounded + // toward ±infinity, so we need to increment resp. decrement the quotient by + // one. + // + // [1] + // https://tc39.es/proposal-temporal/#table-temporal-unsigned-rounding-modes + if (Uint128(remainder.abs()) * Uint128{2} > static_cast<Uint128>(divisor)) { + quotient += (dividend > Int128{0}) ? Int128{1} : Int128{-1}; + } + return quotient; +} + +/** + * Compute "round half to even" division `dividend / divisor`. The divisor must + * be a positive number. + */ +inline Int128 HalfEvenDiv(const Int128& dividend, const Int128& divisor) { + MOZ_ASSERT(divisor > Int128{0}, "negative divisor not supported"); + + auto [quotient, remainder] = dividend.divrem(divisor); + + // "Round half to even" division rounds both positive and negative quotients + // to the nearest even integer. See [1]. + // + // Int128 division truncates, so we implicitly round toward zero. When the + // fractional part of the remainder is 0.5 and the quotient is odd or when the + // fractional part of the remainder is >0.5, we should instead have rounded + // toward ±infinity, so we need to increment resp. decrement the quotient by + // one. + // + // [1] + // https://tc39.es/proposal-temporal/#table-temporal-unsigned-rounding-modes + if ((quotient & Int128{1}) == Int128{1} && + Uint128(remainder.abs()) * Uint128{2} == static_cast<Uint128>(divisor)) { + quotient += (dividend > Int128{0}) ? Int128{1} : Int128{-1}; + } + if (Uint128(remainder.abs()) * Uint128{2} > static_cast<Uint128>(divisor)) { + quotient += (dividend > Int128{0}) ? Int128{1} : Int128{-1}; + } + return quotient; +} + +/** + * Perform `dividend / divisor` and round the result according to the given + * rounding mode. + */ +inline Int128 Divide(const Int128& dividend, const Int128& divisor, + TemporalRoundingMode roundingMode) { + switch (roundingMode) { + case TemporalRoundingMode::Ceil: + return CeilDiv(dividend, divisor); + case TemporalRoundingMode::Floor: + return FloorDiv(dividend, divisor); + case TemporalRoundingMode::Expand: + return ExpandDiv(dividend, divisor); + case TemporalRoundingMode::Trunc: + return TruncDiv(dividend, divisor); + case TemporalRoundingMode::HalfCeil: + return HalfCeilDiv(dividend, divisor); + case TemporalRoundingMode::HalfFloor: + return HalfFloorDiv(dividend, divisor); + case TemporalRoundingMode::HalfExpand: + return HalfExpandDiv(dividend, divisor); + case TemporalRoundingMode::HalfTrunc: + return HalfTruncDiv(dividend, divisor); + case TemporalRoundingMode::HalfEven: + return HalfEvenDiv(dividend, divisor); + } + MOZ_CRASH("invalid rounding mode"); +} + } /* namespace js::temporal */ #endif /* builtin_temporal_TemporalRoundingMode_h */ diff --git a/js/src/builtin/temporal/TemporalTypes.h b/js/src/builtin/temporal/TemporalTypes.h index 654fd65a3b..b645a9a175 100644 --- a/js/src/builtin/temporal/TemporalTypes.h +++ b/js/src/builtin/temporal/TemporalTypes.h @@ -11,7 +11,9 @@ #include "mozilla/CheckedInt.h" #include <stdint.h> +#include <type_traits> +#include "builtin/temporal/Int128.h" #include "builtin/temporal/TemporalUnit.h" namespace js::temporal { @@ -181,15 +183,19 @@ struct SecondsAndNanoseconds { /** * Return the nanoseconds value. - * - * The returned nanoseconds amount can be invalid on overflow. The caller is - * responsible for handling the overflow case. */ - constexpr mozilla::CheckedInt64 toNanoseconds() const { - mozilla::CheckedInt64 nanos = seconds; - nanos *= ToNanoseconds(TemporalUnit::Second); - nanos += nanoseconds; - return nanos; + constexpr Int128 toNanoseconds() const { + return Int128{seconds} * Int128{ToNanoseconds(TemporalUnit::Second)} + + Int128{nanoseconds}; + } + + /** + * Cast to a different representation. + */ + template <class Other> + constexpr Other to() const { + static_assert(std::is_base_of_v<SecondsAndNanoseconds<Other>, Other>); + return Other{seconds, nanoseconds}; } /** @@ -209,7 +215,7 @@ struct SecondsAndNanoseconds { */ static constexpr Derived fromMilliseconds(int64_t milliseconds) { int64_t seconds = milliseconds / 1'000; - int32_t millis = milliseconds % 1'000; + int32_t millis = int32_t(milliseconds % 1'000); if (millis < 0) { seconds -= 1; millis += 1'000; @@ -222,7 +228,7 @@ struct SecondsAndNanoseconds { */ static constexpr Derived fromMicroseconds(int64_t microseconds) { int64_t seconds = microseconds / 1'000'000; - int32_t micros = microseconds % 1'000'000; + int32_t micros = int32_t(microseconds % 1'000'000); if (micros < 0) { seconds -= 1; micros += 1'000'000; @@ -235,7 +241,21 @@ struct SecondsAndNanoseconds { */ static constexpr Derived fromNanoseconds(int64_t nanoseconds) { int64_t seconds = nanoseconds / 1'000'000'000; - int32_t nanos = nanoseconds % 1'000'000'000; + int32_t nanos = int32_t(nanoseconds % 1'000'000'000); + if (nanos < 0) { + seconds -= 1; + nanos += 1'000'000'000; + } + return {seconds, nanos}; + } + + /** + * Create from a nanoseconds value. + */ + static constexpr Derived fromNanoseconds(const Int128& nanoseconds) { + auto div = nanoseconds.divrem(Int128{1'000'000'000}); + int64_t seconds = int64_t(div.first); + int32_t nanos = int32_t(div.second); if (nanos < 0) { seconds -= 1; nanos += 1'000'000'000; @@ -365,6 +385,32 @@ struct Instant final : SecondsAndNanoseconds<Instant> { static constexpr Instant min() { return -max(); } }; +// Minimum and maximum valid epoch day relative to midnight at the beginning of +// 1 January 1970 UTC. +// +// NOTE in ISODateTimeWithinLimits: +// +// Temporal.PlainDateTime objects can represent points in time within 24 hours +// (8.64 × 10**13 nanoseconds) of the Temporal.Instant boundaries. This ensures +// that a Temporal.Instant object can be converted into a Temporal.PlainDateTime +// object using any time zone. +// +// This limits the maximum valid date-time to +275760-09-13T23:59:59.999Z and +// the minimum valid date-time -271821-04-19T00:00:00.001Z. The corresponding +// maximum and minimum valid date values are therefore +275760-09-13 and +// -271821-04-19. There are exactly 100'000'000 days from 1 January 1970 UTC to +// the maximum valid date and -100'000'001 days to the minimum valid date. +constexpr inline int32_t MinEpochDay = -100'000'001; +constexpr inline int32_t MaxEpochDay = 100'000'000; + +static_assert(MinEpochDay == + Instant::min().seconds / ToSeconds(TemporalUnit::Day) - 1); +static_assert(MaxEpochDay == + Instant::max().seconds / ToSeconds(TemporalUnit::Day)); + +// Maximum number of days between two valid epoch days. +constexpr inline int32_t MaxEpochDaysDuration = MaxEpochDay - MinEpochDay; + /** * Plain date represents a date in the ISO 8601 calendar. */ @@ -437,6 +483,9 @@ struct PlainDateTime final { } }; +struct DateDuration; +struct TimeDuration; + /** * Duration represents the difference between dates or times. Each duration * component is an integer and all components must have the same sign. @@ -453,7 +502,7 @@ struct Duration final { double microseconds = 0; double nanoseconds = 0; - bool operator==(const Duration& other) const { + constexpr bool operator==(const Duration& other) const { return years == other.years && months == other.months && weeks == other.weeks && days == other.days && hours == other.hours && minutes == other.minutes && seconds == other.seconds && @@ -462,35 +511,14 @@ struct Duration final { nanoseconds == other.nanoseconds; } - bool operator!=(const Duration& other) const { return !(*this == other); } - - /** - * Return the date components of this duration. - */ - Duration date() const { return {years, months, weeks, days}; } - - /** - * Return the time components of this duration. - */ - Duration time() const { - return { - 0, - 0, - 0, - 0, - hours, - minutes, - seconds, - milliseconds, - microseconds, - nanoseconds, - }; + constexpr bool operator!=(const Duration& other) const { + return !(*this == other); } /** * Return a new duration with every component negated. */ - Duration negate() const { + constexpr Duration negate() const { // Add zero to convert -0 to +0. return { -years + (+0.0), -months + (+0.0), -weeks + (+0.0), @@ -499,6 +527,11 @@ struct Duration final { -nanoseconds + (+0.0), }; } + + /** + * Return the date components of this duration. + */ + inline DateDuration toDateDuration() const; }; /** @@ -506,41 +539,144 @@ struct Duration final { * component is an integer and all components must have the same sign. */ struct DateDuration final { - double years = 0; - double months = 0; - double weeks = 0; - double days = 0; + // abs(years) < 2**32 + int64_t years = 0; + + // abs(months) < 2**32 + int64_t months = 0; + + // abs(weeks) < 2**32 + int64_t weeks = 0; + + // abs(days) < ⌈(2**53) / (24 * 60 * 60)⌉ + int64_t days = 0; - Duration toDuration() { return {years, months, weeks, days}; } + constexpr bool operator==(const DateDuration& other) const { + return years == other.years && months == other.months && + weeks == other.weeks && days == other.days; + } + + constexpr bool operator!=(const DateDuration& other) const { + return !(*this == other); + } + + constexpr Duration toDuration() const { + return { + double(years), + double(months), + double(weeks), + double(days), + }; + } }; +inline DateDuration Duration::toDateDuration() const { + return {int64_t(years), int64_t(months), int64_t(weeks), int64_t(days)}; +} + /** * Time duration represents the difference between times. Each duration * component is an integer and all components must have the same sign. */ struct TimeDuration final { - double days = 0; - double hours = 0; - double minutes = 0; - double seconds = 0; - double milliseconds = 0; + // abs(days) < ⌈(2**53) / (24 * 60 * 60)⌉ + int64_t days = 0; + + // abs(hours) < ⌈(2**53) / (60 * 60)⌉ + int64_t hours = 0; + + // abs(minutes) < ⌈(2**53) / 60⌉ + int64_t minutes = 0; + + // abs(seconds) < (2**53) + int64_t seconds = 0; + + // abs(milliseconds) < (2**53) * (1000**1) + int64_t milliseconds = 0; + + // abs(microseconds) < (2**53) * (1000**2) double microseconds = 0; + + // abs(nanoseconds) < (2**53) * (1000**3) double nanoseconds = 0; - Duration toDuration() { + constexpr Duration toDuration() const { return {0, 0, 0, - days, - hours, - minutes, - seconds, - milliseconds, + double(days), + double(hours), + double(minutes), + double(seconds), + double(milliseconds), microseconds, nanoseconds}; } }; +/** + * Normalized time duration with a seconds value in the range + * [-9'007'199'254'740'991, +9'007'199'254'740'991] and a nanoseconds value in + * the range [0, 999'999'999]. + */ +struct NormalizedTimeDuration final + : SecondsAndNanoseconds<NormalizedTimeDuration> { + constexpr NormalizedTimeDuration& operator+=( + const NormalizedTimeDuration& other) { + *this = add(*this, other); + return *this; + } + + constexpr NormalizedTimeDuration& operator-=( + const NormalizedTimeDuration& other) { + *this = subtract(*this, other); + return *this; + } + + constexpr NormalizedTimeDuration operator+( + const NormalizedTimeDuration& other) const { + return add(*this, other); + } + + constexpr NormalizedTimeDuration operator-( + const NormalizedTimeDuration& other) const { + return subtract(*this, other); + } + + constexpr NormalizedTimeDuration operator-() const { return negate(*this); } + + /** + * Returns the maximum normalized time duration value. + */ + static constexpr NormalizedTimeDuration max() { + constexpr int64_t seconds = 0x1f'ffff'ffff'ffff; + constexpr int64_t nanos = 999'999'999; + return {seconds, nanos}; + } + + /** + * Returns the minimum normalized time duration value. + */ + static constexpr NormalizedTimeDuration min() { return -max(); } +}; + +/** + * Duration represents the difference between dates or times. Each duration + * component is an integer and all components must have the same sign. + */ +struct NormalizedDuration final { + DateDuration date; + NormalizedTimeDuration time; + + constexpr bool operator==(const NormalizedDuration& other) const { + return date == other.date && time == other.time; + } + + constexpr bool operator!=(const NormalizedDuration& other) const { + return !(*this == other); + } +}; + } /* namespace js::temporal */ #endif /* builtin_temporal_TemporalTypes_h */ diff --git a/js/src/builtin/temporal/TemporalUnit.h b/js/src/builtin/temporal/TemporalUnit.h index 3c8801cb85..0294c1062d 100644 --- a/js/src/builtin/temporal/TemporalUnit.h +++ b/js/src/builtin/temporal/TemporalUnit.h @@ -52,6 +52,31 @@ constexpr int64_t ToNanoseconds(TemporalUnit unit) { MOZ_CRASH("Unexpected temporal unit"); } +constexpr int64_t ToMicroseconds(TemporalUnit unit) { + switch (unit) { + case TemporalUnit::Day: + return 86'400'000'000; + case TemporalUnit::Hour: + return 3'600'000'000; + case TemporalUnit::Minute: + return 60'000'000; + case TemporalUnit::Second: + return 1'000'000; + case TemporalUnit::Millisecond: + return 1'000; + case TemporalUnit::Microsecond: + return 1; + + case TemporalUnit::Auto: + case TemporalUnit::Year: + case TemporalUnit::Month: + case TemporalUnit::Week: + case TemporalUnit::Nanosecond: + break; + } + MOZ_CRASH("Unexpected temporal unit"); +} + constexpr int64_t ToMilliseconds(TemporalUnit unit) { switch (unit) { case TemporalUnit::Day: @@ -76,6 +101,29 @@ constexpr int64_t ToMilliseconds(TemporalUnit unit) { MOZ_CRASH("Unexpected temporal unit"); } +constexpr int64_t ToSeconds(TemporalUnit unit) { + switch (unit) { + case TemporalUnit::Day: + return 86'400; + case TemporalUnit::Hour: + return 3'600; + case TemporalUnit::Minute: + return 60; + case TemporalUnit::Second: + return 1; + + case TemporalUnit::Auto: + case TemporalUnit::Year: + case TemporalUnit::Month: + case TemporalUnit::Week: + case TemporalUnit::Millisecond: + case TemporalUnit::Microsecond: + case TemporalUnit::Nanosecond: + break; + } + MOZ_CRASH("Unexpected temporal unit"); +} + constexpr int64_t UnitsPerDay(TemporalUnit unit) { switch (unit) { case TemporalUnit::Day: diff --git a/js/src/builtin/temporal/TimeZone.cpp b/js/src/builtin/temporal/TimeZone.cpp index ca7e1b9f11..8282b6739e 100644 --- a/js/src/builtin/temporal/TimeZone.cpp +++ b/js/src/builtin/temporal/TimeZone.cpp @@ -1131,23 +1131,23 @@ JSString* js::temporal::FormatUTCOffsetNanoseconds(JSContext* cx, // Steps 7-8. (Inlined FormatTimeString). result[n++] = sign; - result[n++] = '0' + (hour / 10); - result[n++] = '0' + (hour % 10); + result[n++] = char('0' + (hour / 10)); + result[n++] = char('0' + (hour % 10)); result[n++] = ':'; - result[n++] = '0' + (minute / 10); - result[n++] = '0' + (minute % 10); + result[n++] = char('0' + (minute / 10)); + result[n++] = char('0' + (minute % 10)); if (second != 0 || subSecondNanoseconds != 0) { result[n++] = ':'; - result[n++] = '0' + (second / 10); - result[n++] = '0' + (second % 10); + result[n++] = char('0' + (second / 10)); + result[n++] = char('0' + (second % 10)); if (uint32_t fractional = subSecondNanoseconds) { result[n++] = '.'; uint32_t k = 100'000'000; do { - result[n++] = '0' + (fractional / k); + result[n++] = char('0' + (fractional / k)); fractional %= k; k /= 10; } while (fractional); @@ -1338,28 +1338,28 @@ static PlainDateTime GetISOPartsFromEpoch(const Instant& instant) { int32_t remainderNs = instant.nanoseconds % 1'000'000; // Step 3. - int64_t epochMilliseconds = instant.floorToMilliseconds(); + double epochMilliseconds = double(instant.floorToMilliseconds()); // Step 4. - int32_t year = JS::YearFromTime(epochMilliseconds); + int32_t year = int32_t(JS::YearFromTime(epochMilliseconds)); // Step 5. - int32_t month = JS::MonthFromTime(epochMilliseconds) + 1; + int32_t month = int32_t(JS::MonthFromTime(epochMilliseconds)) + 1; // Step 6. - int32_t day = JS::DayFromTime(epochMilliseconds); + int32_t day = int32_t(JS::DayFromTime(epochMilliseconds)); // Step 7. - int32_t hour = HourFromTime(epochMilliseconds); + int32_t hour = int32_t(HourFromTime(epochMilliseconds)); // Step 8. - int32_t minute = MinFromTime(epochMilliseconds); + int32_t minute = int32_t(MinFromTime(epochMilliseconds)); // Step 9. - int32_t second = SecFromTime(epochMilliseconds); + int32_t second = int32_t(SecFromTime(epochMilliseconds)); // Step 10. - int32_t millisecond = msFromTime(epochMilliseconds); + int32_t millisecond = int32_t(msFromTime(epochMilliseconds)); // Step 11. int32_t microsecond = remainderNs / 1000; @@ -1389,11 +1389,11 @@ static PlainDateTime BalanceISODateTime(const PlainDateTime& dateTime, MOZ_ASSERT(ISODateTimeWithinLimits(dateTime)); MOZ_ASSERT(std::abs(nanoseconds) < ToNanoseconds(TemporalUnit::Day)); - auto& [date, time] = dateTime; + const auto& [date, time] = dateTime; // Step 1. auto balancedTime = BalanceTime(time, nanoseconds); - MOZ_ASSERT(-1 <= balancedTime.days && balancedTime.days <= 1); + MOZ_ASSERT(std::abs(balancedTime.days) <= 1); // Step 2. auto balancedDate = @@ -1429,9 +1429,6 @@ static PlainDateTimeObject* GetPlainDateTimeFor( // Steps 5-7. auto dateTime = GetPlainDateTimeFor(ToInstant(unwrappedInstant), offsetNanoseconds); - - // FIXME: spec issue - CreateTemporalDateTime is infallible - // https://github.com/tc39/proposal-temporal/issues/2523 MOZ_ASSERT(ISODateTimeWithinLimits(dateTime)); return CreateTemporalDateTime(cx, dateTime, calendar); @@ -1455,9 +1452,6 @@ PlainDateTime js::temporal::GetPlainDateTimeFor(const Instant& instant, // Step 6. auto balanced = BalanceISODateTime(dateTime, offsetNanoseconds); - - // FIXME: spec issue - CreateTemporalDateTime is infallible - // https://github.com/tc39/proposal-temporal/issues/2523 MOZ_ASSERT(ISODateTimeWithinLimits(balanced)); // Step 7. @@ -1524,9 +1518,6 @@ PlainDateTimeObject* js::temporal::GetPlainDateTimeFor( if (!GetPlainDateTimeFor(cx, timeZone, instant, &dateTime)) { return nullptr; } - - // FIXME: spec issue - CreateTemporalDateTime is infallible - // https://github.com/tc39/proposal-temporal/issues/2523 MOZ_ASSERT(ISODateTimeWithinLimits(dateTime)); // Step 7. @@ -1544,9 +1535,6 @@ PlainDateTimeObject* js::temporal::GetPlainDateTimeFor( // Steps 1-6. auto dateTime = GetPlainDateTimeFor(instant, offsetNanoseconds); - - // FIXME: spec issue - CreateTemporalDateTime is infallible - // https://github.com/tc39/proposal-temporal/issues/2523 MOZ_ASSERT(ISODateTimeWithinLimits(dateTime)); // Step 7. @@ -1628,6 +1616,8 @@ static bool GetPossibleInstantsForSlow( JSContext* cx, Handle<TimeZoneRecord> timeZone, Handle<Wrapped<PlainDateTimeObject*>> dateTime, MutableHandle<InstantVector> list) { + MOZ_ASSERT(list.empty()); + // Step 1. (Inlined call to TimeZoneMethodsRecordCall) Rooted<Value> fval(cx, ObjectValue(*timeZone.getPossibleInstantsFor())); auto thisv = timeZone.receiver().toObject(); @@ -1647,23 +1637,46 @@ static bool GetPossibleInstantsForSlow( // Step 4. (Not applicable in our implementation.) - // Steps 5-6. + // Step 5. + auto min = Instant::max(); + auto max = Instant::min(); Rooted<Value> nextValue(cx); while (true) { - // Steps 6.a and 6.b.i. + // Step 5.a. bool done; if (!iterator.next(&nextValue, &done)) { return false; } + + // Step 5.b. if (done) { - break; + // Steps 5.b.i-ii. + if (list.length() > 1) { + // Steps 5.b.ii.1-4. (Not applicable in our implementation.) + + // Step 5.b.ii.5. + constexpr auto nsPerDay = + InstantSpan::fromNanoseconds(ToNanoseconds(TemporalUnit::Day)); + if ((max - min).abs() > nsPerDay) { + JS_ReportErrorNumberASCII( + cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_TIMEZONE_OFFSET_SHIFT_ONE_DAY); + return false; + } + } + + // Step 5.b.iii. + return true; } - // Steps 6.b.ii. + // Step 5.d. (Reordered) if (nextValue.isObject()) { JSObject* obj = &nextValue.toObject(); - if (obj->canUnwrapAs<InstantObject>()) { - // Step 6.b.iii. + if (auto* unwrapped = obj->maybeUnwrapIf<InstantObject>()) { + auto instant = ToInstant(unwrapped); + min = std::min(min, instant); + max = std::max(max, instant); + if (!list.append(obj)) { return false; } @@ -1671,17 +1684,14 @@ static bool GetPossibleInstantsForSlow( } } - // Step 6.b.ii.1. + // Step 5.c.1. ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_IGNORE_STACK, nextValue, nullptr, "not an instant"); - // Step 6.b.ii.2. + // Step 5.c.2. iterator.closeThrow(); return false; } - - // Step 7. - return true; } /** @@ -1714,7 +1724,7 @@ static bool GetPossibleInstantsFor( } } - // Steps 1 and 3-7. + // Steps 1 and 3-5. return GetPossibleInstantsForSlow(cx, timeZone, dateTimeObj, list); } @@ -1753,7 +1763,7 @@ bool js::temporal::GetPossibleInstantsFor( return false; } - // Steps 1 and 3-7. + // Steps 1 and 3-5. return GetPossibleInstantsForSlow(cx, timeZone, dateTimeObj, list); } @@ -1763,9 +1773,9 @@ bool js::temporal::GetPossibleInstantsFor( */ static auto AddTime(const PlainTime& time, int64_t nanoseconds) { MOZ_ASSERT(IsValidTime(time)); - MOZ_ASSERT(std::abs(nanoseconds) <= 2 * ToNanoseconds(TemporalUnit::Day)); + MOZ_ASSERT(std::abs(nanoseconds) <= ToNanoseconds(TemporalUnit::Day)); - // Steps 1-7. + // Steps 1-3. return BalanceTime(time, nanoseconds); } @@ -1871,79 +1881,80 @@ bool js::temporal::DisambiguatePossibleInstants( int64_t nanoseconds = offsetAfter - offsetBefore; // Step 18. + if (std::abs(nanoseconds) > ToNanoseconds(TemporalUnit::Day)) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_TIMEZONE_OFFSET_SHIFT_ONE_DAY); + return false; + } + + // Step 19. if (disambiguation == TemporalDisambiguation::Earlier) { - // Step 18.a. + // Steps 19.a-b. auto earlierTime = ::AddTime(dateTime.time, -nanoseconds); - MOZ_ASSERT(std::abs(earlierTime.days) <= 2, - "subtracting nanoseconds is at most two days"); + MOZ_ASSERT(std::abs(earlierTime.days) <= 1, + "subtracting nanoseconds is at most one day"); - // Step 18.b. - PlainDate earlierDate; - if (!AddISODate(cx, dateTime.date, {0, 0, 0, double(earlierTime.days)}, - TemporalOverflow::Constrain, &earlierDate)) { - return false; - } + // Step 19.c. + auto earlierDate = BalanceISODate(dateTime.date.year, dateTime.date.month, + dateTime.date.day + earlierTime.days); - // Step 18.c. + // Step 19.d. Rooted<CalendarValue> calendar(cx, CalendarValue(cx->names().iso8601)); Rooted<PlainDateTimeWithCalendar> earlierDateTime( cx, PlainDateTimeWithCalendar{{earlierDate, earlierTime.time}, calendar}); - // Step 18.d. + // Step 19.e. Rooted<InstantVector> earlierInstants(cx, InstantVector(cx)); if (!GetPossibleInstantsFor(cx, timeZone, earlierDateTime, &earlierInstants)) { return false; } - // Step 18.e. + // Step 19.f. if (earlierInstants.empty()) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TEMPORAL_TIMEZONE_INSTANT_AMBIGUOUS); return false; } - // Step 18.f. + // Step 19.g. result.set(earlierInstants[0]); return true; } - // Step 19. + // Step 20. MOZ_ASSERT(disambiguation == TemporalDisambiguation::Compatible || disambiguation == TemporalDisambiguation::Later); - // Step 20. + // Steps 21-22. auto laterTime = ::AddTime(dateTime.time, nanoseconds); - MOZ_ASSERT(std::abs(laterTime.days) <= 2, - "adding nanoseconds is at most two days"); + MOZ_ASSERT(std::abs(laterTime.days) <= 1, + "adding nanoseconds is at most one day"); - // Step 21. - PlainDate laterDate; - if (!AddISODate(cx, dateTime.date, {0, 0, 0, double(laterTime.days)}, - TemporalOverflow::Constrain, &laterDate)) { - return false; - } + // Step 23. + auto laterDate = BalanceISODate(dateTime.date.year, dateTime.date.month, + dateTime.date.day + laterTime.days); - // Step 22. + // Step 24. Rooted<CalendarValue> calendar(cx, CalendarValue(cx->names().iso8601)); Rooted<PlainDateTimeWithCalendar> laterDateTime( cx, PlainDateTimeWithCalendar{{laterDate, laterTime.time}, calendar}); - // Step 23. + // Step 25. Rooted<InstantVector> laterInstants(cx, InstantVector(cx)); if (!GetPossibleInstantsFor(cx, timeZone, laterDateTime, &laterInstants)) { return false; } - // Steps 24-25. + // Steps 26-27. if (laterInstants.empty()) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TEMPORAL_TIMEZONE_INSTANT_AMBIGUOUS); return false; } - // Step 26. + // Step 28. size_t last = laterInstants.length() - 1; result.set(laterInstants[last]); return true; @@ -2282,11 +2293,14 @@ static bool TimeZone_getOffsetNanosecondsFor(JSContext* cx, unsigned argc, static bool TimeZone_getOffsetStringFor(JSContext* cx, const CallArgs& args) { Rooted<TimeZoneValue> timeZone(cx, &args.thisv().toObject()); - // FIXME: spec issue - CreateTimeZoneMethodsRecord called before - // ToTemporalInstant whereas TimeZone.p.{getPlainDateTimeFor,getInstantFor} - // first convert the input arguments. - // Step 3. + Rooted<Wrapped<InstantObject*>> instant(cx, + ToTemporalInstant(cx, args.get(0))); + if (!instant) { + return false; + } + + // Step 4. Rooted<TimeZoneRecord> timeZoneRec(cx); if (!CreateTimeZoneMethodsRecord(cx, timeZone, { @@ -2296,13 +2310,6 @@ static bool TimeZone_getOffsetStringFor(JSContext* cx, const CallArgs& args) { return false; } - // Step 4. - Rooted<Wrapped<InstantObject*>> instant(cx, - ToTemporalInstant(cx, args.get(0))); - if (!instant) { - return false; - } - // Step 5. JSString* str = GetOffsetStringFor(cx, timeZoneRec, instant); if (!str) { diff --git a/js/src/builtin/temporal/TimeZone.h b/js/src/builtin/temporal/TimeZone.h index f1d0bf3f1f..f13421111a 100644 --- a/js/src/builtin/temporal/TimeZone.h +++ b/js/src/builtin/temporal/TimeZone.h @@ -8,6 +8,7 @@ #define builtin_temporal_TimeZone_h #include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" #include "mozilla/EnumSet.h" #include <stddef.h> @@ -142,7 +143,7 @@ namespace js::temporal { * * Option 2 is a bit easier to implement, so we use this approach for now. */ -class TimeZoneValue final { +class MOZ_STACK_CLASS TimeZoneValue final { JSObject* object_ = nullptr; public: @@ -252,7 +253,7 @@ enum class TimeZoneMethod { GetPossibleInstantsFor, }; -class TimeZoneRecord { +class MOZ_STACK_CLASS TimeZoneRecord final { TimeZoneValue receiver_; // Null unless non-builtin time zone methods are used. diff --git a/js/src/builtin/temporal/ToString.cpp b/js/src/builtin/temporal/ToString.cpp index c789c5e95c..e13ad8eb03 100644 --- a/js/src/builtin/temporal/ToString.cpp +++ b/js/src/builtin/temporal/ToString.cpp @@ -169,7 +169,7 @@ static void FormatFractionalSeconds(TemporalStringBuilder& result, result.append('.'); // Steps 1.b-c. - uint32_t k = 100'000'000; + int32_t k = 100'000'000; do { result.append(char('0' + (subSecondNanoseconds / k))); subSecondNanoseconds %= k; @@ -186,7 +186,7 @@ static void FormatFractionalSeconds(TemporalStringBuilder& result, result.append('.'); // Steps 2.b-c. - uint32_t k = 100'000'000; + int32_t k = 100'000'000; for (uint8_t i = 0; i < p; i++) { result.append(char('0' + (subSecondNanoseconds / k))); subSecondNanoseconds %= k; @@ -274,7 +274,7 @@ static int32_t RoundNanosecondsToMinutes(int64_t offsetNanoseconds) { if (std::abs(remainder * 2) >= increment) { quotient += (offsetNanoseconds > 0 ? 1 : -1); } - return quotient; + return int32_t(quotient); } /** @@ -636,11 +636,8 @@ JSString* js::temporal::TemporalZonedDateTimeToString( // Steps 1-3. (Not applicable in our implementation.) // Step 4. - Instant ns; - if (!RoundTemporalInstant(cx, zonedDateTime.instant(), increment, unit, - roundingMode, &ns)) { - return nullptr; - } + auto ns = RoundTemporalInstant(zonedDateTime.instant(), increment, unit, + roundingMode); // Step 5. auto timeZone = zonedDateTime.timeZone(); diff --git a/js/src/builtin/temporal/ZonedDateTime.cpp b/js/src/builtin/temporal/ZonedDateTime.cpp index 92842a9626..e75b368ba9 100644 --- a/js/src/builtin/temporal/ZonedDateTime.cpp +++ b/js/src/builtin/temporal/ZonedDateTime.cpp @@ -10,6 +10,7 @@ #include "mozilla/Maybe.h" #include <cstdlib> +#include <limits> #include <utility> #include "jspubtd.h" @@ -18,6 +19,7 @@ #include "builtin/temporal/Calendar.h" #include "builtin/temporal/Duration.h" #include "builtin/temporal/Instant.h" +#include "builtin/temporal/Int96.h" #include "builtin/temporal/PlainDate.h" #include "builtin/temporal/PlainDateTime.h" #include "builtin/temporal/PlainMonthDay.h" @@ -119,7 +121,8 @@ bool js::temporal::InterpretISODateTimeOffset( // Step 5. if (offsetBehaviour == OffsetBehaviour::Wall || - offsetOption == TemporalOffset::Ignore) { + (offsetBehaviour == OffsetBehaviour::Option && + offsetOption == TemporalOffset::Ignore)) { // Steps 5.a-b. return GetInstantFor(cx, timeZone, temporalDateTime, disambiguation, result); @@ -127,7 +130,8 @@ bool js::temporal::InterpretISODateTimeOffset( // Step 6. if (offsetBehaviour == OffsetBehaviour::Exact || - offsetOption == TemporalOffset::Use) { + (offsetBehaviour == OffsetBehaviour::Option && + offsetOption == TemporalOffset::Use)) { // Step 6.a. auto epochNanoseconds = GetUTCEpochNanoseconds( dateTime, InstantSpan::fromNanoseconds(offsetNanoseconds)); @@ -151,27 +155,21 @@ bool js::temporal::InterpretISODateTimeOffset( MOZ_ASSERT(offsetOption == TemporalOffset::Prefer || offsetOption == TemporalOffset::Reject); - // FIXME: spec issue - duplicate assertion - // Step 9. - MOZ_ASSERT(TimeZoneMethodsRecordHasLookedUp( - timeZone, TimeZoneMethod::GetPossibleInstantsFor)); - - // Step 10. Rooted<InstantVector> possibleInstants(cx, InstantVector(cx)); if (!GetPossibleInstantsFor(cx, timeZone, temporalDateTime, &possibleInstants)) { return false; } - // Step 11. + // Step 10. if (!possibleInstants.empty()) { - // Step 11.a. + // Step 10.a. Rooted<Wrapped<InstantObject*>> candidate(cx); for (size_t i = 0; i < possibleInstants.length(); i++) { candidate = possibleInstants[i]; - // Step 11.a.i. + // Step 10.a.i. int64_t candidateNanoseconds; if (!GetOffsetNanosecondsFor(cx, timeZone, candidate, &candidateNanoseconds)) { @@ -180,7 +178,7 @@ bool js::temporal::InterpretISODateTimeOffset( MOZ_ASSERT(std::abs(candidateNanoseconds) < ToNanoseconds(TemporalUnit::Day)); - // Step 11.a.ii. + // Step 10.a.ii. if (candidateNanoseconds == offsetNanoseconds) { auto* unwrapped = candidate.unwrap(cx); if (!unwrapped) { @@ -191,20 +189,20 @@ bool js::temporal::InterpretISODateTimeOffset( return true; } - // Step 11.a.iii. + // Step 10.a.iii. if (matchBehaviour == MatchBehaviour::MatchMinutes) { - // Step 11.a.iii.1. + // Step 10.a.iii.1. int64_t roundedCandidateNanoseconds = RoundNanosecondsToMinutesIncrement(candidateNanoseconds); - // Step 11.a.iii.2. + // Step 10.a.iii.2. if (roundedCandidateNanoseconds == offsetNanoseconds) { auto* unwrapped = candidate.unwrap(cx); if (!unwrapped) { return false; } - // Step 11.a.iii.2.a. + // Step 10.a.iii.2.a. *result = ToInstant(unwrapped); return true; } @@ -212,14 +210,14 @@ bool js::temporal::InterpretISODateTimeOffset( } } - // Step 12. + // Step 11. if (offsetOption == TemporalOffset::Reject) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TEMPORAL_ZONED_DATE_TIME_NO_TIME_FOUND); return false; } - // Step 13. + // Step 12. Rooted<Wrapped<InstantObject*>> instant(cx); if (!DisambiguatePossibleInstants(cx, possibleInstants, timeZone, ToPlainDateTime(temporalDateTime), @@ -232,7 +230,7 @@ bool js::temporal::InterpretISODateTimeOffset( return false; } - // Step 14. + // Step 13. *result = ToInstant(unwrappedInstant); return true; } @@ -430,19 +428,19 @@ static bool ToTemporalZonedDateTime(JSContext* cx, Handle<Value> item, bool isUTC; bool hasOffset; int64_t timeZoneOffset; - Rooted<ParsedTimeZone> timeZoneString(cx); + Rooted<ParsedTimeZone> timeZoneAnnotation(cx); Rooted<JSString*> calendarString(cx); - if (!ParseTemporalZonedDateTimeString(cx, string, &dateTime, &isUTC, - &hasOffset, &timeZoneOffset, - &timeZoneString, &calendarString)) { + if (!ParseTemporalZonedDateTimeString( + cx, string, &dateTime, &isUTC, &hasOffset, &timeZoneOffset, + &timeZoneAnnotation, &calendarString)) { return false; } // Step 6.d. - MOZ_ASSERT(timeZoneString); + MOZ_ASSERT(timeZoneAnnotation); // Step 6.e. - if (!ToTemporalTimeZone(cx, timeZoneString, &timeZone)) { + if (!ToTemporalTimeZone(cx, timeZoneAnnotation, &timeZone)) { return false; } @@ -624,7 +622,7 @@ struct PlainDateTimeAndInstant { static bool AddDaysToZonedDateTime(JSContext* cx, const Instant& instant, const PlainDateTime& dateTime, Handle<TimeZoneRecord> timeZone, - Handle<CalendarValue> calendar, double days, + Handle<CalendarValue> calendar, int64_t days, TemporalOverflow overflow, PlainDateTimeAndInstant* result) { // Step 1. (Not applicable in our implementation.) @@ -669,7 +667,7 @@ static bool AddDaysToZonedDateTime(JSContext* cx, const Instant& instant, bool js::temporal::AddDaysToZonedDateTime( JSContext* cx, const Instant& instant, const PlainDateTime& dateTime, Handle<TimeZoneRecord> timeZone, Handle<CalendarValue> calendar, - double days, TemporalOverflow overflow, Instant* result) { + int64_t days, TemporalOverflow overflow, Instant* result) { // Steps 1-7. PlainDateTimeAndInstant dateTimeAndInstant; if (!::AddDaysToZonedDateTime(cx, instant, dateTime, timeZone, calendar, days, @@ -689,7 +687,7 @@ bool js::temporal::AddDaysToZonedDateTime(JSContext* cx, const Instant& instant, const PlainDateTime& dateTime, Handle<TimeZoneRecord> timeZone, Handle<CalendarValue> calendar, - double days, Instant* result) { + int64_t days, Instant* result) { // Step 2. auto overflow = TemporalOverflow::Constrain; @@ -700,18 +698,16 @@ bool js::temporal::AddDaysToZonedDateTime(JSContext* cx, const Instant& instant, /** * AddZonedDateTime ( epochNanoseconds, timeZoneRec, calendarRec, years, months, - * weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds - * [ , precalculatedPlainDateTime [ , options ] ] ) + * weeks, days, norm [ , precalculatedPlainDateTime [ , options ] ] ) */ static bool AddZonedDateTime(JSContext* cx, const Instant& epochNanoseconds, Handle<TimeZoneRecord> timeZone, Handle<CalendarRecord> calendar, - const Duration& duration, + const NormalizedDuration& duration, mozilla::Maybe<const PlainDateTime&> dateTime, Handle<JSObject*> maybeOptions, Instant* result) { MOZ_ASSERT(IsValidEpochInstant(epochNanoseconds)); - MOZ_ASSERT(IsValidDuration(duration.date())); - MOZ_ASSERT(IsValidDuration(duration.time())); + MOZ_ASSERT(IsValidDuration(duration)); // Step 1. MOZ_ASSERT(TimeZoneMethodsRecordHasLookedUp( @@ -725,10 +721,9 @@ static bool AddZonedDateTime(JSContext* cx, const Instant& epochNanoseconds, // Steps 4-5. (Not applicable in our implementation) // Step 6. - if (duration.years == 0 && duration.months == 0 && duration.weeks == 0 && - duration.days == 0) { + if (duration.date == DateDuration{}) { // Step 6.a. - return AddInstant(cx, epochNanoseconds, duration, result); + return AddInstant(cx, epochNanoseconds, duration.time, result); } // Step 7. (Not applicable in our implementation) @@ -748,7 +743,8 @@ static bool AddZonedDateTime(JSContext* cx, const Instant& epochNanoseconds, auto& [date, time] = temporalDateTime; // Step 10. - if (duration.years == 0 && duration.months == 0 && duration.weeks == 0) { + if (duration.date.years == 0 && duration.date.months == 0 && + duration.date.weeks == 0) { // Step 10.a. auto overflow = TemporalOverflow::Constrain; if (maybeOptions) { @@ -760,13 +756,13 @@ static bool AddZonedDateTime(JSContext* cx, const Instant& epochNanoseconds, // Step 10.b. Instant intermediate; if (!AddDaysToZonedDateTime(cx, epochNanoseconds, temporalDateTime, - timeZone, calendar.receiver(), duration.days, - overflow, &intermediate)) { + timeZone, calendar.receiver(), + duration.date.days, overflow, &intermediate)) { return false; } // Step 10.c. - return AddInstant(cx, intermediate, duration.time(), result); + return AddInstant(cx, intermediate, duration.time, result); } // Step 11. @@ -777,13 +773,13 @@ static bool AddZonedDateTime(JSContext* cx, const Instant& epochNanoseconds, const auto& datePart = date; // Step 13. - auto dateDuration = duration.date(); + const auto& dateDuration = duration.date; // Step 14. PlainDate addedDate; if (maybeOptions) { - if (!CalendarDateAdd(cx, calendar, datePart, dateDuration, maybeOptions, - &addedDate)) { + if (!temporal::CalendarDateAdd(cx, calendar, datePart, dateDuration, + maybeOptions, &addedDate)) { return false; } } else { @@ -808,18 +804,17 @@ static bool AddZonedDateTime(JSContext* cx, const Instant& epochNanoseconds, } // Step 17. - return AddInstant(cx, intermediateInstant, duration.time(), result); + return AddInstant(cx, intermediateInstant, duration.time, result); } /** * AddZonedDateTime ( epochNanoseconds, timeZoneRec, calendarRec, years, months, - * weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds - * [ , precalculatedPlainDateTime [ , options ] ] ) + * weeks, days, norm [ , precalculatedPlainDateTime [ , options ] ] ) */ static bool AddZonedDateTime(JSContext* cx, const Instant& epochNanoseconds, Handle<TimeZoneRecord> timeZone, Handle<CalendarRecord> calendar, - const Duration& duration, + const NormalizedDuration& duration, Handle<JSObject*> maybeOptions, Instant* result) { return ::AddZonedDateTime(cx, epochNanoseconds, timeZone, calendar, duration, mozilla::Nothing(), maybeOptions, result); @@ -827,84 +822,94 @@ static bool AddZonedDateTime(JSContext* cx, const Instant& epochNanoseconds, /** * AddZonedDateTime ( epochNanoseconds, timeZoneRec, calendarRec, years, months, - * weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds - * [ , precalculatedPlainDateTime [ , options ] ] ) + * weeks, days, norm [ , precalculatedPlainDateTime [ , options ] ] ) */ bool js::temporal::AddZonedDateTime(JSContext* cx, const Instant& epochNanoseconds, Handle<TimeZoneRecord> timeZone, Handle<CalendarRecord> calendar, - const Duration& duration, Instant* result) { + const NormalizedDuration& duration, + Instant* result) { return ::AddZonedDateTime(cx, epochNanoseconds, timeZone, calendar, duration, mozilla::Nothing(), nullptr, result); } /** * AddZonedDateTime ( epochNanoseconds, timeZoneRec, calendarRec, years, months, - * weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds - * [ , precalculatedPlainDateTime [ , options ] ] ) + * weeks, days, norm [ , precalculatedPlainDateTime [ , options ] ] ) */ -bool js::temporal::AddZonedDateTime( - JSContext* cx, const Instant& epochNanoseconds, - Handle<TimeZoneRecord> timeZone, Handle<CalendarRecord> calendar, - const Duration& duration, const PlainDateTime& dateTime, Instant* result) { +bool js::temporal::AddZonedDateTime(JSContext* cx, + const Instant& epochNanoseconds, + Handle<TimeZoneRecord> timeZone, + Handle<CalendarRecord> calendar, + const NormalizedDuration& duration, + const PlainDateTime& dateTime, + Instant* result) { return ::AddZonedDateTime(cx, epochNanoseconds, timeZone, calendar, duration, mozilla::SomeRef(dateTime), nullptr, result); } -double js::temporal::NanosecondsAndDays::daysNumber() const { - if (days) { - return BigInt::numberValue(days); - } - return double(daysInt); +/** + * AddZonedDateTime ( epochNanoseconds, timeZoneRec, calendarRec, years, months, + * weeks, days, norm [ , precalculatedPlainDateTime [ , options ] ] ) + */ +bool js::temporal::AddZonedDateTime(JSContext* cx, + const Instant& epochNanoseconds, + Handle<TimeZoneRecord> timeZone, + Handle<CalendarRecord> calendar, + const DateDuration& duration, + Instant* result) { + return ::AddZonedDateTime(cx, epochNanoseconds, timeZone, calendar, + {duration, {}}, mozilla::Nothing(), nullptr, + result); } -void js::temporal::NanosecondsAndDays::trace(JSTracer* trc) { - if (days) { - TraceRoot(trc, &days, "NanosecondsAndDays::days"); - } +/** + * AddZonedDateTime ( epochNanoseconds, timeZoneRec, calendarRec, years, months, + * weeks, days, norm [ , precalculatedPlainDateTime [ , options ] ] ) + */ +bool js::temporal::AddZonedDateTime(JSContext* cx, + const Instant& epochNanoseconds, + Handle<TimeZoneRecord> timeZone, + Handle<CalendarRecord> calendar, + const DateDuration& duration, + const PlainDateTime& dateTime, + Instant* result) { + return ::AddZonedDateTime(cx, epochNanoseconds, timeZone, calendar, + {duration, {}}, mozilla::SomeRef(dateTime), nullptr, + result); } /** - * NanosecondsToDays ( nanoseconds, zonedRelativeTo, timeZoneRec [ , + * NormalizedTimeDurationToDays ( norm, zonedRelativeTo, timeZoneRec [ , * precalculatedPlainDateTime ] ) */ -static bool NanosecondsToDays( - JSContext* cx, const InstantSpan& nanoseconds, +static bool NormalizedTimeDurationToDays( + JSContext* cx, const NormalizedTimeDuration& duration, Handle<ZonedDateTime> zonedRelativeTo, Handle<TimeZoneRecord> timeZone, mozilla::Maybe<const PlainDateTime&> precalculatedPlainDateTime, - MutableHandle<NanosecondsAndDays> result) { - MOZ_ASSERT(IsValidInstantSpan(nanoseconds)); + NormalizedTimeAndDays* result) { + MOZ_ASSERT(IsValidNormalizedTimeDuration(duration)); // Step 1. - if (nanoseconds == InstantSpan{}) { - result.set(NanosecondsAndDays::from( - int64_t(0), InstantSpan{}, - InstantSpan::fromNanoseconds(ToNanoseconds(TemporalUnit::Day)))); - return true; - } + int32_t sign = NormalizedTimeDurationSign(duration); // Step 2. - int32_t sign = nanoseconds < InstantSpan{} ? -1 : 1; + if (sign == 0) { + *result = {int64_t(0), int64_t(0), ToNanoseconds(TemporalUnit::Day)}; + return true; + } // Step 3. - auto startNs = zonedRelativeTo.instant(); - auto calendar = zonedRelativeTo.calendar(); + const auto& startNs = zonedRelativeTo.instant(); // Step 5. - // - // NB: This addition can't overflow, because we've checked that |nanoseconds| - // can be represented as an InstantSpan value. - auto endNs = startNs + nanoseconds; - - // Step 6. - if (!IsValidEpochInstant(endNs)) { - JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, - JSMSG_TEMPORAL_INSTANT_INVALID); + Instant endNs; + if (!AddInstant(cx, startNs, duration, &endNs)) { return false; } - // Steps 4 and 8. + // Steps 4 and 7. PlainDateTime startDateTime; if (!precalculatedPlainDateTime) { if (!GetPlainDateTimeFor(cx, timeZone, startNs, &startDateTime)) { @@ -914,145 +919,157 @@ static bool NanosecondsToDays( startDateTime = *precalculatedPlainDateTime; } - // Steps 7 and 9. + // Steps 6 and 8. PlainDateTime endDateTime; if (!GetPlainDateTimeFor(cx, timeZone, endNs, &endDateTime)) { return false; } - // Steps 10-11. (Not applicable in our implementation.) + // Steps 9-10. (Not applicable in our implementation.) - // Step 12. - // - // Overflows in step 21 can be safely ignored, because they take too long to - // happen for int64. - int64_t days = DaysUntil(startDateTime.date, endDateTime.date); + // Step 11. + int32_t days = DaysUntil(startDateTime.date, endDateTime.date); + MOZ_ASSERT(std::abs(days) <= MaxEpochDaysDuration); - // Step 13. + // Step 12. int32_t timeSign = CompareTemporalTime(startDateTime.time, endDateTime.time); - // Steps 14-15. + // Steps 13-14. if (days > 0 && timeSign > 0) { days -= 1; } else if (days < 0 && timeSign < 0) { days += 1; } - // Step 16. + // Step 15. PlainDateTimeAndInstant relativeResult; - if (!::AddDaysToZonedDateTime(cx, startNs, startDateTime, timeZone, calendar, - days, TemporalOverflow::Constrain, - &relativeResult)) { + if (!::AddDaysToZonedDateTime(cx, startNs, startDateTime, timeZone, + zonedRelativeTo.calendar(), days, + TemporalOverflow::Constrain, &relativeResult)) { return false; } MOZ_ASSERT(IsValidISODateTime(relativeResult.dateTime)); MOZ_ASSERT(IsValidEpochInstant(relativeResult.instant)); - // Step 17. - if (sign > 0) { - // Step 17.a. - while (days > 0 && relativeResult.instant > endNs) { - // This loop can iterate indefinitely when given a specially crafted - // time zone object, so we need to check for interrupts. - if (!CheckForInterrupt(cx)) { - return false; - } - - // Step 17.a.i. - days -= 1; + // Step 16. + if (sign > 0 && days > 0 && relativeResult.instant > endNs) { + // Step 16.a. + days -= 1; - // Step 17.a.ii. - if (!::AddDaysToZonedDateTime(cx, startNs, startDateTime, timeZone, - calendar, days, TemporalOverflow::Constrain, - &relativeResult)) { - return false; - } - MOZ_ASSERT(IsValidISODateTime(relativeResult.dateTime)); - MOZ_ASSERT(IsValidEpochInstant(relativeResult.instant)); + // Step 16.b. + if (!::AddDaysToZonedDateTime( + cx, startNs, startDateTime, timeZone, zonedRelativeTo.calendar(), + days, TemporalOverflow::Constrain, &relativeResult)) { + return false; + } + MOZ_ASSERT(IsValidISODateTime(relativeResult.dateTime)); + MOZ_ASSERT(IsValidEpochInstant(relativeResult.instant)); + + // Step 16.c. + if (days > 0 && relativeResult.instant > endNs) { + JS_ReportErrorNumberASCII( + cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_ZONED_DATE_TIME_INCONSISTENT_INSTANT); + return false; } - MOZ_ASSERT_IF(days > 0, relativeResult.instant <= endNs); } MOZ_ASSERT_IF(days == 0, relativeResult.instant == startNs); - // Step 18. + // Step 17. (Inlined NormalizedTimeDurationFromEpochNanosecondsDifference) auto ns = endNs - relativeResult.instant; MOZ_ASSERT(IsValidInstantSpan(ns)); - // Steps 19-21. - InstantSpan dayLengthNs{}; - while (true) { - // This loop can iterate indefinitely when given a specially crafted time - // zone object, so we need to check for interrupts. - if (!CheckForInterrupt(cx)) { - return false; - } + // Step 18. + PlainDateTimeAndInstant oneDayFarther; + if (!::AddDaysToZonedDateTime(cx, relativeResult.instant, + relativeResult.dateTime, timeZone, + zonedRelativeTo.calendar(), sign, + TemporalOverflow::Constrain, &oneDayFarther)) { + return false; + } + MOZ_ASSERT(IsValidISODateTime(oneDayFarther.dateTime)); + MOZ_ASSERT(IsValidEpochInstant(oneDayFarther.instant)); + + // Step 19. (Inlined NormalizedTimeDurationFromEpochNanosecondsDifference) + auto dayLengthNs = oneDayFarther.instant - relativeResult.instant; + MOZ_ASSERT(IsValidInstantSpan(dayLengthNs)); + + // clang-format off + // + // ns = endNs - relativeResult.instant + // dayLengthNs = oneDayFarther.instant - relativeResult.instant + // oneDayLess = ns - dayLengthNs + // = (endNs - relativeResult.instant) - (oneDayFarther.instant - relativeResult.instant) + // = endNs - relativeResult.instant - oneDayFarther.instant + relativeResult.instant + // = endNs - oneDayFarther.instant + // + // |endNs| and |oneDayFarther.instant| are both valid epoch instant values, + // so the difference |oneDayLess| is a valid epoch instant difference value. + // + // clang-format on + // Step 20. (Inlined SubtractNormalizedTimeDuration) + auto oneDayLess = ns - dayLengthNs; + MOZ_ASSERT(IsValidInstantSpan(oneDayLess)); + MOZ_ASSERT(oneDayLess == (endNs - oneDayFarther.instant)); + + // Step 21. + if (oneDayLess == InstantSpan{} || + ((oneDayLess < InstantSpan{}) == (sign < 0))) { // Step 21.a. + ns = oneDayLess; + + // Step 21.b. + relativeResult = oneDayFarther; + + // Step 21.c. + days += sign; + + // Step 21.d. PlainDateTimeAndInstant oneDayFarther; if (!::AddDaysToZonedDateTime( cx, relativeResult.instant, relativeResult.dateTime, timeZone, - calendar, sign, TemporalOverflow::Constrain, &oneDayFarther)) { + zonedRelativeTo.calendar(), sign, TemporalOverflow::Constrain, + &oneDayFarther)) { return false; } MOZ_ASSERT(IsValidISODateTime(oneDayFarther.dateTime)); MOZ_ASSERT(IsValidEpochInstant(oneDayFarther.instant)); - // Step 21.b. + // Step 21.e. (Inlined NormalizedTimeDurationFromEpochNanosecondsDifference) dayLengthNs = oneDayFarther.instant - relativeResult.instant; MOZ_ASSERT(IsValidInstantSpan(dayLengthNs)); // clang-format off // - // First iteration: - // - // ns = endNs - relativeResult.instant - // dayLengthNs = oneDayFarther.instant - relativeResult.instant - // diff = ns - dayLengthNs - // = (endNs - relativeResult.instant) - (oneDayFarther.instant - relativeResult.instant) - // = endNs - relativeResult.instant - oneDayFarther.instant + relativeResult.instant - // = endNs - oneDayFarther.instant - // - // Second iteration: - // - // ns = diff' + // ns = oneDayLess' // = endNs - oneDayFarther.instant' // relativeResult.instant = oneDayFarther.instant' // dayLengthNs = oneDayFarther.instant - relativeResult.instant // = oneDayFarther.instant - oneDayFarther.instant' - // diff = ns - dayLengthNs - // = (endNs - oneDayFarther.instant') - (oneDayFarther.instant - oneDayFarther.instant') - // = endNs - oneDayFarther.instant' - oneDayFarther.instant + oneDayFarther.instant' - // = endNs - oneDayFarther.instant - // - // Where |diff'| and |oneDayFarther.instant'| denote the variables from the - // previous iteration. + // oneDayLess = ns - dayLengthNs + // = (endNs - oneDayFarther.instant') - (oneDayFarther.instant - oneDayFarther.instant') + // = endNs - oneDayFarther.instant' - oneDayFarther.instant + oneDayFarther.instant' + // = endNs - oneDayFarther.instant // - // This repeats for all following iterations. + // Where |oneDayLess'| and |oneDayFarther.instant'| denote the variables + // from before this if-statement block. // // |endNs| and |oneDayFarther.instant| are both valid epoch instant values, - // so the difference is a valid epoch instant difference value, too. + // so the difference |oneDayLess| is a valid epoch instant difference value. // // clang-format on - // Step 21.c. - auto diff = ns - dayLengthNs; - MOZ_ASSERT(IsValidInstantSpan(diff)); - MOZ_ASSERT(diff == (endNs - oneDayFarther.instant)); - - if (diff == InstantSpan{} || ((diff < InstantSpan{}) == (sign < 0))) { - // Step 21.c.i. - ns = diff; - - // Step 21.c.ii. - relativeResult = oneDayFarther; - - // Step 21.c.iii. - days += sign; - } else { - // Step 21.d. - break; + // Step 21.f. + auto oneDayLess = ns - dayLengthNs; + if (oneDayLess == InstantSpan{} || + ((oneDayLess < InstantSpan{}) == (sign < 0))) { + JS_ReportErrorNumberASCII( + cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_ZONED_DATE_TIME_INCONSISTENT_INSTANT); + return false; } } @@ -1075,15 +1092,6 @@ static bool NanosecondsToDays( MOZ_ASSERT(IsValidInstantSpan(dayLengthNs)); MOZ_ASSERT(IsValidInstantSpan(ns)); - // FIXME: spec issue - rewrite steps 24-25 as: - // - // If sign = -1, then - // If nanoseconds > 0, throw a RangeError. - // Else, - // Assert: nanoseconds ≥ 0. - // - // https://github.com/tc39/proposal-temporal/issues/2530 - // Steps 24-25. if (sign < 0) { if (ns > InstantSpan{}) { @@ -1096,39 +1104,57 @@ static bool NanosecondsToDays( MOZ_ASSERT(ns >= InstantSpan{}); } - // Step 26. - MOZ_ASSERT(ns.abs() < dayLengthNs.abs()); + // Steps 26-27. + dayLengthNs = dayLengthNs.abs(); + MOZ_ASSERT(ns.abs() < dayLengthNs); - // Step 27. - result.set(NanosecondsAndDays::from(days, ns, dayLengthNs.abs())); + // Step 28. + constexpr auto maxDayLength = Int128{1} << 53; + auto dayLengthNanos = dayLengthNs.toNanoseconds(); + if (dayLengthNanos >= maxDayLength) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_ZONED_DATE_TIME_INCORRECT_SIGN, + "days"); + return false; + } + + auto timeNanos = ns.toNanoseconds(); + MOZ_ASSERT(timeNanos == Int128{int64_t(timeNanos)}, + "abs(ns) < dayLengthNs < 2**53 implies that |ns| fits in int64"); + + // Step 29. + static_assert(std::numeric_limits<decltype(days)>::max() <= + ((int64_t(1) << 53) / (24 * 60 * 60))); + + // Step 30. + *result = {int64_t(days), int64_t(timeNanos), int64_t(dayLengthNanos)}; return true; } /** - * NanosecondsToDays ( nanoseconds, zonedRelativeTo, timeZoneRec [ , + * NormalizedTimeDurationToDays ( norm, zonedRelativeTo, timeZoneRec [ , * precalculatedPlainDateTime ] ) */ -bool js::temporal::NanosecondsToDays(JSContext* cx, - const InstantSpan& nanoseconds, - Handle<ZonedDateTime> zonedRelativeTo, - Handle<TimeZoneRecord> timeZone, - MutableHandle<NanosecondsAndDays> result) { - return ::NanosecondsToDays(cx, nanoseconds, zonedRelativeTo, timeZone, - mozilla::Nothing(), result); +bool js::temporal::NormalizedTimeDurationToDays( + JSContext* cx, const NormalizedTimeDuration& duration, + Handle<ZonedDateTime> zonedRelativeTo, Handle<TimeZoneRecord> timeZone, + NormalizedTimeAndDays* result) { + return ::NormalizedTimeDurationToDays(cx, duration, zonedRelativeTo, timeZone, + mozilla::Nothing(), result); } /** - * NanosecondsToDays ( nanoseconds, zonedRelativeTo, timeZoneRec [ , + * NormalizedTimeDurationToDays ( norm, zonedRelativeTo, timeZoneRec [ , * precalculatedPlainDateTime ] ) */ -bool js::temporal::NanosecondsToDays( - JSContext* cx, const InstantSpan& nanoseconds, +bool js::temporal::NormalizedTimeDurationToDays( + JSContext* cx, const NormalizedTimeDuration& duration, Handle<ZonedDateTime> zonedRelativeTo, Handle<TimeZoneRecord> timeZone, const PlainDateTime& precalculatedPlainDateTime, - MutableHandle<NanosecondsAndDays> result) { - return ::NanosecondsToDays(cx, nanoseconds, zonedRelativeTo, timeZone, - mozilla::SomeRef(precalculatedPlainDateTime), - result); + NormalizedTimeAndDays* result) { + return ::NormalizedTimeDurationToDays( + cx, duration, zonedRelativeTo, timeZone, + mozilla::SomeRef(precalculatedPlainDateTime), result); } /** @@ -1139,27 +1165,22 @@ static bool DifferenceZonedDateTime( JSContext* cx, const Instant& ns1, const Instant& ns2, Handle<TimeZoneRecord> timeZone, Handle<CalendarRecord> calendar, TemporalUnit largestUnit, Handle<PlainObject*> maybeOptions, - mozilla::Maybe<const PlainDateTime&> precalculatedPlainDateTime, - Duration* result) { + const PlainDateTime& precalculatedPlainDateTime, + NormalizedDuration* result) { MOZ_ASSERT(IsValidEpochInstant(ns1)); MOZ_ASSERT(IsValidEpochInstant(ns2)); // Steps 1. if (ns1 == ns2) { - *result = {}; + *result = CreateNormalizedDurationRecord({}, {}); return true; } + // FIXME: spec issue - precalculatedPlainDateTime is never undefined + // https://github.com/tc39/proposal-temporal/issues/2822 + // Steps 2-3. - PlainDateTime startDateTime; - if (!precalculatedPlainDateTime) { - // Steps 2.a-b. - if (!GetPlainDateTimeFor(cx, timeZone, ns1, &startDateTime)) { - return false; - } - } else { - startDateTime = *precalculatedPlainDateTime; - } + const auto& startDateTime = precalculatedPlainDateTime; // Steps 4-5. PlainDateTime endDateTime; @@ -1168,65 +1189,100 @@ static bool DifferenceZonedDateTime( } // Step 6. - Duration dateDifference; - if (maybeOptions) { - if (!DifferenceISODateTime(cx, startDateTime, endDateTime, calendar, - largestUnit, maybeOptions, &dateDifference)) { - return false; - } - } else { - if (!DifferenceISODateTime(cx, startDateTime, endDateTime, calendar, - largestUnit, &dateDifference)) { - return false; - } - } + int32_t sign = (ns2 - ns1 < InstantSpan{}) ? -1 : 1; // Step 7. - Instant intermediateNs; - if (!AddZonedDateTime(cx, ns1, timeZone, calendar, - { - dateDifference.years, - dateDifference.months, - dateDifference.weeks, - }, - startDateTime, &intermediateNs)) { - return false; - } - MOZ_ASSERT(IsValidEpochInstant(intermediateNs)); + int32_t maxDayCorrection = 1 + (sign > 0); // Step 8. - auto timeRemainder = ns2 - intermediateNs; - MOZ_ASSERT(IsValidInstantSpan(timeRemainder)); + int32_t dayCorrection = 0; // Step 9. - Rooted<ZonedDateTime> intermediate( - cx, - ZonedDateTime{intermediateNs, timeZone.receiver(), calendar.receiver()}); + auto timeDuration = DifferenceTime(startDateTime.time, endDateTime.time); // Step 10. - Rooted<NanosecondsAndDays> nanosAndDays(cx); - if (!NanosecondsToDays(cx, timeRemainder, intermediate, timeZone, - &nanosAndDays)) { - return false; + if (NormalizedTimeDurationSign(timeDuration) == -sign) { + dayCorrection += 1; } - // Step 11. - TimeDuration timeDifference; - if (!BalanceTimeDuration(cx, nanosAndDays.nanoseconds(), TemporalUnit::Hour, - &timeDifference)) { - return false; + // Steps 11-12. + Rooted<PlainDateTimeWithCalendar> intermediateDateTime(cx); + while (dayCorrection <= maxDayCorrection) { + // Step 12.a. + auto intermediateDate = + BalanceISODate(endDateTime.date.year, endDateTime.date.month, + endDateTime.date.day - dayCorrection * sign); + + // FIXME: spec issue - CreateTemporalDateTime is fallible + // https://github.com/tc39/proposal-temporal/issues/2824 + + // Step 12.b. + if (!CreateTemporalDateTime(cx, {intermediateDate, startDateTime.time}, + calendar.receiver(), &intermediateDateTime)) { + return false; + } + + // Steps 12.c-d. + Instant intermediateInstant; + if (!GetInstantFor(cx, timeZone, intermediateDateTime, + TemporalDisambiguation::Compatible, + &intermediateInstant)) { + return false; + } + + // Step 12.e. + auto norm = NormalizedTimeDurationFromEpochNanosecondsDifference( + ns2, intermediateInstant); + + // Step 12.f. + int32_t timeSign = NormalizedTimeDurationSign(norm); + + // Step 12.g. + if (sign != -timeSign) { + // Step 13.a. + const auto& date1 = startDateTime.date; + MOZ_ASSERT(ISODateTimeWithinLimits(date1)); + + // Step 13.b. + const auto& date2 = intermediateDate; + MOZ_ASSERT(ISODateTimeWithinLimits(date2)); + + // Step 13.c. + auto dateLargestUnit = std::min(largestUnit, TemporalUnit::Day); + + // Steps 13.d-e. + // + // The spec performs an unnecessary copy operation. As an optimization, we + // omit this copy. + auto untilOptions = maybeOptions; + + // Step 13.f. + DateDuration dateDifference; + if (untilOptions) { + if (!DifferenceDate(cx, calendar, date1, date2, dateLargestUnit, + untilOptions, &dateDifference)) { + return false; + } + } else { + if (!DifferenceDate(cx, calendar, date1, date2, dateLargestUnit, + &dateDifference)) { + return false; + } + } + + // Step 13.g. + return CreateNormalizedDurationRecord(cx, dateDifference, norm, result); + } + + // Step 12.h. + dayCorrection += 1; } - // Step 12. - *result = { - dateDifference.years, dateDifference.months, - dateDifference.weeks, nanosAndDays.daysNumber(), - timeDifference.hours, timeDifference.minutes, - timeDifference.seconds, timeDifference.milliseconds, - timeDifference.microseconds, timeDifference.nanoseconds, - }; - MOZ_ASSERT(IsValidDuration(*result)); - return true; + // Steps 14-15. + JS_ReportErrorNumberASCII( + cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_ZONED_DATE_TIME_INCONSISTENT_INSTANT); + return false; } /** @@ -1237,10 +1293,10 @@ bool js::temporal::DifferenceZonedDateTime( JSContext* cx, const Instant& ns1, const Instant& ns2, Handle<TimeZoneRecord> timeZone, Handle<CalendarRecord> calendar, TemporalUnit largestUnit, const PlainDateTime& precalculatedPlainDateTime, - Duration* result) { - return ::DifferenceZonedDateTime( - cx, ns1, ns2, timeZone, calendar, largestUnit, nullptr, - mozilla::SomeRef(precalculatedPlainDateTime), result); + NormalizedDuration* result) { + return ::DifferenceZonedDateTime(cx, ns1, ns2, timeZone, calendar, + largestUnit, nullptr, + precalculatedPlainDateTime, result); } /** @@ -1287,46 +1343,6 @@ static bool TimeZoneEqualsOrThrow(JSContext* cx, Handle<TimeZoneValue> one, } /** - * RoundISODateTime ( year, month, day, hour, minute, second, millisecond, - * microsecond, nanosecond, increment, unit, roundingMode [ , dayLength ] ) - */ -static bool RoundISODateTime(JSContext* cx, const PlainDateTime& dateTime, - Increment increment, TemporalUnit unit, - TemporalRoundingMode roundingMode, - const InstantSpan& dayLength, - PlainDateTime* result) { - MOZ_ASSERT(IsValidInstantSpan(dayLength)); - MOZ_ASSERT(dayLength > (InstantSpan{})); - - const auto& [date, time] = dateTime; - - // Step 1. - MOZ_ASSERT(IsValidISODateTime(dateTime)); - MOZ_ASSERT(ISODateTimeWithinLimits(dateTime)); - - // Step 2. (Not applicable in our implementation.) - - // Step 3. - auto roundedTime = RoundTime(time, increment, unit, roundingMode, dayLength); - - // |dayLength| can be as small as 1, so the number of rounded days can be as - // large as the number of nanoseconds in |time|. - MOZ_ASSERT(0 <= roundedTime.days && - roundedTime.days < ToNanoseconds(TemporalUnit::Day)); - - // Step 4. - PlainDate balanceResult; - if (!BalanceISODate(cx, date.year, date.month, - int64_t(date.day) + roundedTime.days, &balanceResult)) { - return false; - } - - // Step 5. - *result = {balanceResult, roundedTime.time}; - return true; -} - -/** * DifferenceTemporalZonedDateTime ( operation, zonedDateTime, other, options ) */ static bool DifferenceTemporalZonedDateTime(JSContext* cx, @@ -1385,20 +1401,24 @@ static bool DifferenceTemporalZonedDateTime(JSContext* cx, MOZ_ASSERT(settings.smallestUnit >= settings.largestUnit); // Step 6.a. - Duration difference; - if (!DifferenceInstant(cx, zonedDateTime.instant(), other.instant(), - settings.roundingIncrement, settings.smallestUnit, - settings.largestUnit, settings.roundingMode, - &difference)) { + auto difference = DifferenceInstant( + zonedDateTime.instant(), other.instant(), settings.roundingIncrement, + settings.smallestUnit, settings.roundingMode); + + // Step 6.b. + TimeDuration balancedTime; + if (!BalanceTimeDuration(cx, difference, settings.largestUnit, + &balancedTime)) { return false; } - // Step 6.b. + // Step 6.c. + auto duration = balancedTime.toDuration(); if (operation == TemporalDifference::Since) { - difference = difference.negate(); + duration = duration.negate(); } - auto* result = CreateTemporalDuration(cx, difference); + auto* result = CreateTemporalDuration(cx, duration); if (!result) { return false; } @@ -1407,15 +1427,12 @@ static bool DifferenceTemporalZonedDateTime(JSContext* cx, return true; } - // FIXME: spec issue - move this step next to the calendar validation? - // https://github.com/tc39/proposal-temporal/issues/2533 - - // Step 7. + // Steps 7-8. if (!TimeZoneEqualsOrThrow(cx, zonedDateTime.timeZone(), other.timeZone())) { return false; } - // Step 8. + // Step 9. if (zonedDateTime.instant() == other.instant()) { auto* obj = CreateTemporalDuration(cx, {}); if (!obj) { @@ -1426,7 +1443,7 @@ static bool DifferenceTemporalZonedDateTime(JSContext* cx, return true; } - // Step 9. + // Step 10. Rooted<TimeZoneRecord> timeZone(cx); if (!CreateTimeZoneMethodsRecord(cx, zonedDateTime.timeZone(), { @@ -1437,7 +1454,7 @@ static bool DifferenceTemporalZonedDateTime(JSContext* cx, return false; } - // Step 10. + // Step 11. Rooted<CalendarRecord> calendar(cx); if (!CreateCalendarMethodsRecord(cx, zonedDateTime.calendar(), { @@ -1448,14 +1465,14 @@ static bool DifferenceTemporalZonedDateTime(JSContext* cx, return false; } - // Steps 11-12. + // Steps 12-13. PlainDateTime precalculatedPlainDateTime; if (!GetPlainDateTimeFor(cx, timeZone, zonedDateTime.instant(), &precalculatedPlainDateTime)) { return false; } - // Step 13. + // Step 14. Rooted<PlainDateObject*> plainRelativeTo( cx, CreateTemporalDate(cx, precalculatedPlainDateTime.date, calendar.receiver())); @@ -1463,23 +1480,12 @@ static bool DifferenceTemporalZonedDateTime(JSContext* cx, return false; } - // Step 14. - if (resolvedOptions) { - Rooted<Value> largestUnitValue( - cx, StringValue(TemporalUnitToString(cx, settings.largestUnit))); - if (!DefineDataProperty(cx, resolvedOptions, cx->names().largestUnit, - largestUnitValue)) { - return false; - } - } - // Step 15. - Duration difference; - if (!::DifferenceZonedDateTime( - cx, zonedDateTime.instant(), other.instant(), timeZone, calendar, - settings.largestUnit, resolvedOptions, - mozilla::SomeRef<const PlainDateTime>(precalculatedPlainDateTime), - &difference)) { + NormalizedDuration difference; + if (!::DifferenceZonedDateTime(cx, zonedDateTime.instant(), other.instant(), + timeZone, calendar, settings.largestUnit, + resolvedOptions, precalculatedPlainDateTime, + &difference)) { return false; } @@ -1489,59 +1495,76 @@ static bool DifferenceTemporalZonedDateTime(JSContext* cx, settings.roundingIncrement == Increment{1}; // Step 17. - if (roundingGranularityIsNoop) { - if (operation == TemporalDifference::Since) { - difference = difference.negate(); + if (!roundingGranularityIsNoop) { + // Steps 17.a-b. + NormalizedDuration roundResult; + if (!RoundDuration(cx, difference, settings.roundingIncrement, + settings.smallestUnit, settings.roundingMode, + plainRelativeTo, calendar, zonedDateTime, timeZone, + precalculatedPlainDateTime, &roundResult)) { + return false; } - auto* obj = CreateTemporalDuration(cx, difference); - if (!obj) { + // Step 17.c. + NormalizedTimeAndDays timeAndDays; + if (!NormalizedTimeDurationToDays(cx, roundResult.time, zonedDateTime, + timeZone, &timeAndDays)) { return false; } - args.rval().setObject(*obj); - return true; - } + // Step 17.d. + int64_t days = roundResult.date.days + timeAndDays.days; + + // Step 17.e. + auto toAdjust = NormalizedDuration{ + { + roundResult.date.years, + roundResult.date.months, + roundResult.date.weeks, + days, + }, + NormalizedTimeDuration::fromNanoseconds(timeAndDays.time), + }; + NormalizedDuration adjustResult; + if (!AdjustRoundedDurationDays(cx, toAdjust, settings.roundingIncrement, + settings.smallestUnit, settings.roundingMode, + zonedDateTime, calendar, timeZone, + precalculatedPlainDateTime, &adjustResult)) { + return false; + } - // Steps 18-19. - Duration roundResult; - if (!RoundDuration(cx, difference, settings.roundingIncrement, - settings.smallestUnit, settings.roundingMode, - plainRelativeTo, calendar, zonedDateTime, timeZone, - precalculatedPlainDateTime, &roundResult)) { - return false; - } + // Step 17.f. + DateDuration balanceResult; + if (!temporal::BalanceDateDurationRelative( + cx, adjustResult.date, settings.largestUnit, settings.smallestUnit, + plainRelativeTo, calendar, &balanceResult)) { + return false; + } - // Step 20. - Duration adjustResult; - if (!AdjustRoundedDurationDays(cx, roundResult, settings.roundingIncrement, - settings.smallestUnit, settings.roundingMode, - zonedDateTime, calendar, timeZone, - precalculatedPlainDateTime, &adjustResult)) { - return false; + // Step 17.g. + if (!CombineDateAndNormalizedTimeDuration(cx, balanceResult, + adjustResult.time, &difference)) { + return false; + } } - // Step 21. - DateDuration balanceResult; - if (!temporal::BalanceDateDurationRelative( - cx, adjustResult.date(), settings.largestUnit, settings.smallestUnit, - plainRelativeTo, calendar, &balanceResult)) { - return false; - } + // Step 18. + auto timeDuration = BalanceTimeDuration(difference.time, TemporalUnit::Hour); - // Step 22. - auto result = Duration{ - balanceResult.years, balanceResult.months, - balanceResult.weeks, balanceResult.days, - adjustResult.hours, adjustResult.minutes, - adjustResult.seconds, adjustResult.milliseconds, - adjustResult.microseconds, adjustResult.nanoseconds, + // Step 19. + auto duration = Duration{ + double(difference.date.years), double(difference.date.months), + double(difference.date.weeks), double(difference.date.days), + double(timeDuration.hours), double(timeDuration.minutes), + double(timeDuration.seconds), double(timeDuration.milliseconds), + timeDuration.microseconds, timeDuration.nanoseconds, }; if (operation == TemporalDifference::Since) { - result = result.negate(); + duration = duration.negate(); } + MOZ_ASSERT(IsValidDuration(duration)); - auto* obj = CreateTemporalDuration(cx, result); + auto* obj = CreateTemporalDuration(cx, duration); if (!obj) { return false; } @@ -1607,15 +1630,17 @@ static bool AddDurationToOrSubtractDurationFromZonedDateTime( if (operation == ZonedDateTimeDuration::Subtract) { duration = duration.negate(); } + auto normalized = CreateNormalizedDurationRecord(duration); + // Step 7. Instant resultInstant; if (!::AddZonedDateTime(cx, zonedDateTime.instant(), timeZone, calendar, - duration, options, &resultInstant)) { + normalized, options, &resultInstant)) { return false; } MOZ_ASSERT(IsValidEpochInstant(resultInstant)); - // Step 7. + // Step 8. auto* result = CreateTemporalZonedDateTime( cx, resultInstant, timeZone.receiver(), calendar.receiver()); if (!result) { @@ -1764,8 +1789,8 @@ static bool ZonedDateTime_compare(JSContext* cx, unsigned argc, Value* vp) { } // Step 3. - auto oneNs = one.instant(); - auto twoNs = two.instant(); + const auto& oneNs = one.instant(); + const auto& twoNs = two.instant(); args.rval().setInt32(oneNs > twoNs ? 1 : oneNs < twoNs ? -1 : 0); return true; } @@ -2359,7 +2384,7 @@ static bool ZonedDateTime_hoursInDay(JSContext* cx, const CallArgs& args) { } // Step 4. - auto instant = zonedDateTime.instant(); + const auto& instant = zonedDateTime.instant(); // Step 5. PlainDateTime temporalDateTime; @@ -2402,20 +2427,12 @@ static bool ZonedDateTime_hoursInDay(JSContext* cx, const CallArgs& args) { } // Step 14. - auto diffNs = tomorrowInstant - todayInstant; - MOZ_ASSERT(IsValidInstantSpan(diffNs)); + auto diff = tomorrowInstant - todayInstant; + MOZ_ASSERT(IsValidInstantSpan(diff)); // Step 15. - constexpr int32_t secPerHour = 60 * 60; - constexpr int64_t nsPerSec = ToNanoseconds(TemporalUnit::Second); - constexpr double nsPerHour = ToNanoseconds(TemporalUnit::Hour); - - int64_t hours = diffNs.seconds / secPerHour; - int64_t seconds = diffNs.seconds % secPerHour; - int64_t nanoseconds = seconds * nsPerSec + diffNs.nanoseconds; - - double result = double(hours) + double(nanoseconds) / nsPerHour; - args.rval().setNumber(result); + constexpr auto nsPerHour = Int128{ToNanoseconds(TemporalUnit::Hour)}; + args.rval().setNumber(FractionToDouble(diff.toNanoseconds(), nsPerHour)); return true; } @@ -2587,7 +2604,7 @@ static bool ZonedDateTime_offsetNanoseconds(JSContext* cx, auto timeZone = zonedDateTime.timeZone(); // Step 4. - auto instant = zonedDateTime.instant(); + const auto& instant = zonedDateTime.instant(); // Step 5. int64_t offsetNanoseconds; @@ -2622,7 +2639,7 @@ static bool ZonedDateTime_offset(JSContext* cx, const CallArgs& args) { auto timeZone = zonedDateTime.timeZone(); // Step 4. - auto instant = zonedDateTime.instant(); + const auto& instant = zonedDateTime.instant(); // Step 5. JSString* str = GetOffsetStringFor(cx, timeZone, instant); @@ -2658,13 +2675,11 @@ static bool ZonedDateTime_with(JSContext* cx, const CallArgs& args) { if (!temporalZonedDateTimeLike) { return false; } - - // Step 4. - if (!RejectTemporalLikeObject(cx, temporalZonedDateTimeLike)) { + if (!ThrowIfTemporalLikeObject(cx, temporalZonedDateTimeLike)) { return false; } - // Step 5. + // Step 4. Rooted<PlainObject*> resolvedOptions(cx); if (args.hasDefined(1)) { Rooted<JSObject*> options(cx, @@ -2680,7 +2695,7 @@ static bool ZonedDateTime_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 6. + // Step 5. Rooted<CalendarRecord> calendar(cx); if (!CreateCalendarMethodsRecord(cx, zonedDateTime.calendar(), { @@ -2692,7 +2707,7 @@ static bool ZonedDateTime_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 7. + // Step 6. Rooted<TimeZoneRecord> timeZone(cx); if (!CreateTimeZoneMethodsRecord(cx, zonedDateTime.timeZone(), { @@ -2703,16 +2718,16 @@ static bool ZonedDateTime_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 8. - auto instant = zonedDateTime.instant(); + // Step 7. + const auto& instant = zonedDateTime.instant(); - // Step 9. + // Step 8. int64_t offsetNanoseconds; if (!GetOffsetNanosecondsFor(cx, timeZone, instant, &offsetNanoseconds)) { return false; } - // Step 10. + // Step 9. Rooted<PlainDateTimeObject*> dateTime( cx, GetPlainDateTimeFor(cx, instant, calendar.receiver(), offsetNanoseconds)); @@ -2720,7 +2735,7 @@ static bool ZonedDateTime_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 11. + // Step 10. JS::RootedVector<PropertyKey> fieldNames(cx); if (!CalendarFields(cx, calendar, {CalendarField::Day, CalendarField::Month, @@ -2729,14 +2744,14 @@ static bool ZonedDateTime_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 12. + // Step 11. Rooted<PlainObject*> fields(cx, PrepareTemporalFields(cx, dateTime, fieldNames)); if (!fields) { return false; } - // Steps 13-18. + // Steps 12-17. struct TimeField { using FieldName = ImmutableTenuredPtr<PropertyName*> JSAtomState::*; @@ -2761,7 +2776,7 @@ static bool ZonedDateTime_with(JSContext* cx, const CallArgs& args) { } } - // Step 19. + // Step 18. JSString* fieldsOffset = FormatUTCOffsetNanoseconds(cx, offsetNanoseconds); if (!fieldsOffset) { return false; @@ -2772,7 +2787,7 @@ static bool ZonedDateTime_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 20. + // Step 19. if (!AppendSorted(cx, fieldNames.get(), { TemporalField::Hour, @@ -2786,7 +2801,7 @@ static bool ZonedDateTime_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 21. + // Step 20. Rooted<PlainObject*> partialZonedDateTime( cx, PreparePartialTemporalFields(cx, temporalZonedDateTimeLike, fieldNames)); @@ -2794,56 +2809,56 @@ static bool ZonedDateTime_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 22. + // Step 21. Rooted<JSObject*> mergedFields( cx, CalendarMergeFields(cx, calendar, fields, partialZonedDateTime)); if (!mergedFields) { return false; } - // Step 23. + // Step 22. fields = PrepareTemporalFields(cx, mergedFields, fieldNames, {TemporalField::Offset}); if (!fields) { return false; } - // Step 24-25. + // Step 23-24. auto disambiguation = TemporalDisambiguation::Compatible; if (!ToTemporalDisambiguation(cx, resolvedOptions, &disambiguation)) { return false; } - // Step 26. + // Step 25. auto offset = TemporalOffset::Prefer; if (!ToTemporalOffset(cx, resolvedOptions, &offset)) { return false; } - // Step 27. + // Step 26. PlainDateTime dateTimeResult; if (!InterpretTemporalDateTimeFields(cx, calendar, fields, resolvedOptions, &dateTimeResult)) { return false; } - // Step 28. + // Step 27. Rooted<Value> offsetString(cx); if (!GetProperty(cx, fields, fields, cx->names().offset, &offsetString)) { return false; } - // Step 29. + // Step 28. MOZ_ASSERT(offsetString.isString()); - // Step 30. + // Step 29. Rooted<JSString*> offsetStr(cx, offsetString.toString()); int64_t newOffsetNanoseconds; if (!ParseDateTimeUTCOffset(cx, offsetStr, &newOffsetNanoseconds)) { return false; } - // Step 31. + // Step 30. Instant epochNanoseconds; if (!InterpretISODateTimeOffset( cx, dateTimeResult, OffsetBehaviour::Option, newOffsetNanoseconds, @@ -2852,7 +2867,7 @@ static bool ZonedDateTime_with(JSContext* cx, const CallArgs& args) { return false; } - // Step 32. + // Step 31. auto* result = CreateTemporalZonedDateTime( cx, epochNanoseconds, timeZone.receiver(), calendar.receiver()); if (!result) { @@ -2880,7 +2895,7 @@ static bool ZonedDateTime_withPlainTime(JSContext* cx, const CallArgs& args) { Rooted<ZonedDateTime> zonedDateTime( cx, ZonedDateTime{&args.thisv().toObject().as<ZonedDateTimeObject>()}); - // Steps 3-4. + // Step 3. (Inlined ToTemporalTimeOrMidnight) PlainTime time = {}; if (args.hasDefined(0)) { if (!ToTemporalTime(cx, args[0], &time)) { @@ -2888,7 +2903,7 @@ static bool ZonedDateTime_withPlainTime(JSContext* cx, const CallArgs& args) { } } - // Step 5. + // Step 4. Rooted<TimeZoneRecord> timeZone(cx); if (!CreateTimeZoneMethodsRecord(cx, zonedDateTime.timeZone(), { @@ -2899,31 +2914,31 @@ static bool ZonedDateTime_withPlainTime(JSContext* cx, const CallArgs& args) { return false; } - // Steps 6 and 8. + // Steps 5 and 7. PlainDateTime plainDateTime; if (!GetPlainDateTimeFor(cx, timeZone, zonedDateTime.instant(), &plainDateTime)) { return false; } - // Step 7. + // Step 6. auto calendar = zonedDateTime.calendar(); - // Step 9. + // Step 8. Rooted<PlainDateTimeWithCalendar> resultPlainDateTime(cx); if (!CreateTemporalDateTime(cx, {plainDateTime.date, time}, calendar, &resultPlainDateTime)) { return false; } - // Step 10. + // Step 9. Instant instant; if (!GetInstantFor(cx, timeZone, resultPlainDateTime, TemporalDisambiguation::Compatible, &instant)) { return false; } - // Step 11. + // Step 10. auto* result = CreateTemporalZonedDateTime(cx, instant, timeZone.receiver(), calendar); if (!result) { @@ -3273,57 +3288,101 @@ static bool ZonedDateTime_round(JSContext* cx, const CallArgs& args) { GetPlainDateTimeFor(zonedDateTime.instant(), offsetNanoseconds); // Step 19. - Rooted<CalendarValue> isoCalendar(cx, CalendarValue(cx->names().iso8601)); - Rooted<PlainDateTimeWithCalendar> dtStart(cx); - if (!CreateTemporalDateTime(cx, {temporalDateTime.date, {}}, isoCalendar, - &dtStart)) { - return false; - } + Instant epochNanoseconds; + if (smallestUnit == TemporalUnit::Day) { + // Step 19.a. + Rooted<CalendarValue> isoCalendar(cx, CalendarValue(cx->names().iso8601)); + Rooted<PlainDateTimeWithCalendar> dtStart(cx); + if (!CreateTemporalDateTime(cx, {temporalDateTime.date, {}}, isoCalendar, + &dtStart)) { + return false; + } - // Steps 20-21. - Instant startNs; - if (!GetInstantFor(cx, timeZone, dtStart, TemporalDisambiguation::Compatible, - &startNs)) { - return false; - } + // Step 19.b. + auto dateEnd = + BalanceISODate(temporalDateTime.date.year, temporalDateTime.date.month, + temporalDateTime.date.day + 1); - // Step 22. - Instant endNs; - if (!AddDaysToZonedDateTime(cx, startNs, ToPlainDateTime(dtStart), timeZone, - calendar, 1, &endNs)) { - return false; - } - MOZ_ASSERT(IsValidEpochInstant(endNs)); + // Step 19.c. + Rooted<PlainDateTimeWithCalendar> dtEnd(cx); + if (!CreateTemporalDateTime(cx, {dateEnd, {}}, isoCalendar, &dtEnd)) { + return false; + } - // Step 23. - auto dayLengthNs = endNs - startNs; - MOZ_ASSERT(IsValidInstantSpan(dayLengthNs)); + // Step 19.d. + const auto& thisNs = zonedDateTime.instant(); - // Step 24. - if (dayLengthNs <= InstantSpan{}) { - JS_ReportErrorNumberASCII( - cx, GetErrorMessage, nullptr, - JSMSG_TEMPORAL_ZONED_DATE_TIME_NON_POSITIVE_DAY_LENGTH); - return false; - } + // Steps 19.e-f. + Instant startNs; + if (!GetInstantFor(cx, timeZone, dtStart, + TemporalDisambiguation::Compatible, &startNs)) { + return false; + } - // Step 25. - PlainDateTime roundResult; - if (!RoundISODateTime(cx, temporalDateTime, roundingIncrement, smallestUnit, - roundingMode, dayLengthNs, &roundResult)) { - return false; - } + // Step 19.g. + if (thisNs < startNs) { + JS_ReportErrorNumberASCII( + cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_ZONED_DATE_TIME_INCONSISTENT_INSTANT); + return false; + } - // Step 26. - Instant epochNanoseconds; - if (!InterpretISODateTimeOffset( - cx, roundResult, OffsetBehaviour::Option, offsetNanoseconds, timeZone, - TemporalDisambiguation::Compatible, TemporalOffset::Prefer, - MatchBehaviour::MatchExactly, &epochNanoseconds)) { - return false; + // Steps 19.h-i. + Instant endNs; + if (!GetInstantFor(cx, timeZone, dtEnd, TemporalDisambiguation::Compatible, + &endNs)) { + return false; + } + + // Step 19.j. + if (thisNs >= endNs) { + JS_ReportErrorNumberASCII( + cx, GetErrorMessage, nullptr, + JSMSG_TEMPORAL_ZONED_DATE_TIME_INCONSISTENT_INSTANT); + return false; + } + + // Step 19.k. + auto dayLengthNs = endNs - startNs; + MOZ_ASSERT(IsValidInstantSpan(dayLengthNs)); + MOZ_ASSERT(dayLengthNs > InstantSpan{}, "dayLengthNs is positive"); + + // Step 19.l. (Inlined NormalizedTimeDurationFromEpochNanosecondsDifference) + auto dayProgressNs = thisNs - startNs; + MOZ_ASSERT(IsValidInstantSpan(dayProgressNs)); + MOZ_ASSERT(dayProgressNs >= InstantSpan{}, "dayProgressNs is non-negative"); + + MOZ_ASSERT(startNs <= thisNs && thisNs < endNs); + MOZ_ASSERT(dayProgressNs < dayLengthNs); + + // Step 19.m. (Inlined RoundNormalizedTimeDurationToIncrement) + auto rounded = + RoundNumberToIncrement(dayProgressNs.toNanoseconds(), + dayLengthNs.toNanoseconds(), roundingMode); + auto roundedDaysNs = InstantSpan::fromNanoseconds(rounded); + MOZ_ASSERT(roundedDaysNs == InstantSpan{} || roundedDaysNs == dayLengthNs); + MOZ_ASSERT(IsValidInstantSpan(roundedDaysNs)); + + // Step 19.n. + epochNanoseconds = startNs + roundedDaysNs; + MOZ_ASSERT(epochNanoseconds == startNs || epochNanoseconds == endNs); + } else { + // Step 20.a. + auto roundResult = RoundISODateTime(temporalDateTime, roundingIncrement, + smallestUnit, roundingMode); + + // Step 20.b. + if (!InterpretISODateTimeOffset( + cx, roundResult, OffsetBehaviour::Option, offsetNanoseconds, + timeZone, TemporalDisambiguation::Compatible, + TemporalOffset::Prefer, MatchBehaviour::MatchExactly, + &epochNanoseconds)) { + return false; + } } + MOZ_ASSERT(IsValidEpochInstant(epochNanoseconds)); - // Step 27. + // Step 22. auto* result = CreateTemporalZonedDateTime(cx, epochNanoseconds, timeZone.receiver(), calendar); if (!result) { @@ -3557,7 +3616,7 @@ static bool ZonedDateTime_startOfDay(JSContext* cx, const CallArgs& args) { auto calendar = zonedDateTime.calendar(); // Step 5. - auto instant = zonedDateTime.instant(); + const auto& instant = zonedDateTime.instant(); // Steps 5-6. PlainDateTime temporalDateTime; @@ -3864,7 +3923,7 @@ static bool ZonedDateTime_getISOFields(JSContext* cx, const CallArgs& args) { Rooted<IdValueVector> fields(cx, IdValueVector(cx)); // Step 4. - auto instant = zonedDateTime.instant(); + const auto& instant = zonedDateTime.instant(); // Step 5. auto calendar = zonedDateTime.calendar(); diff --git a/js/src/builtin/temporal/ZonedDateTime.h b/js/src/builtin/temporal/ZonedDateTime.h index 73e3a3384f..7d75a33201 100644 --- a/js/src/builtin/temporal/ZonedDateTime.h +++ b/js/src/builtin/temporal/ZonedDateTime.h @@ -8,6 +8,7 @@ #define builtin_temporal_ZonedDateTime_h #include "mozilla/Assertions.h" +#include "mozilla/Attributes.h" #include <stdint.h> @@ -69,7 +70,7 @@ inline Instant ToInstant(const ZonedDateTimeObject* zonedDateTime) { return {zonedDateTime->seconds(), zonedDateTime->nanoseconds()}; } -class ZonedDateTime { +class MOZ_STACK_CLASS ZonedDateTime final { Instant instant_; TimeZoneValue timeZone_; CalendarValue calendar_; @@ -125,7 +126,7 @@ ZonedDateTimeObject* CreateTemporalZonedDateTime( bool AddDaysToZonedDateTime(JSContext* cx, const Instant& instant, const PlainDateTime& dateTime, JS::Handle<TimeZoneRecord> timeZone, - JS::Handle<CalendarValue> calendar, double days, + JS::Handle<CalendarValue> calendar, int64_t days, TemporalOverflow overflow, Instant* result); /** @@ -135,29 +136,46 @@ bool AddDaysToZonedDateTime(JSContext* cx, const Instant& instant, bool AddDaysToZonedDateTime(JSContext* cx, const Instant& instant, const PlainDateTime& dateTime, JS::Handle<TimeZoneRecord> timeZone, - JS::Handle<CalendarValue> calendar, double days, + JS::Handle<CalendarValue> calendar, int64_t days, Instant* result); /** * AddZonedDateTime ( epochNanoseconds, timeZoneRec, calendarRec, years, months, - * weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds - * [ , precalculatedPlainDateTime [ , options ] ] ) + * weeks, days, norm [ , precalculatedPlainDateTime [ , options ] ] ) */ bool AddZonedDateTime(JSContext* cx, const Instant& epochNanoseconds, JS::Handle<TimeZoneRecord> timeZone, JS::Handle<CalendarRecord> calendar, - const Duration& duration, Instant* result); + const NormalizedDuration& duration, Instant* result); /** * AddZonedDateTime ( epochNanoseconds, timeZoneRec, calendarRec, years, months, - * weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds - * [ , precalculatedPlainDateTime [ , options ] ] ) + * weeks, days, norm [ , precalculatedPlainDateTime [ , options ] ] ) */ bool AddZonedDateTime(JSContext* cx, const Instant& epochNanoseconds, JS::Handle<TimeZoneRecord> timeZone, JS::Handle<CalendarRecord> calendar, - const Duration& duration, const PlainDateTime& dateTime, - Instant* result); + const NormalizedDuration& duration, + const PlainDateTime& dateTime, Instant* result); + +/** + * AddZonedDateTime ( epochNanoseconds, timeZoneRec, calendarRec, years, months, + * weeks, days, norm [ , precalculatedPlainDateTime [ , options ] ] ) + */ +bool AddZonedDateTime(JSContext* cx, const Instant& epochNanoseconds, + JS::Handle<TimeZoneRecord> timeZone, + JS::Handle<CalendarRecord> calendar, + const DateDuration& duration, Instant* result); + +/** + * AddZonedDateTime ( epochNanoseconds, timeZoneRec, calendarRec, years, months, + * weeks, days, norm [ , precalculatedPlainDateTime [ , options ] ] ) + */ +bool AddZonedDateTime(JSContext* cx, const Instant& epochNanoseconds, + JS::Handle<TimeZoneRecord> timeZone, + JS::Handle<CalendarRecord> calendar, + const DateDuration& duration, + const PlainDateTime& dateTime, Instant* result); /** * DifferenceZonedDateTime ( ns1, ns2, timeZoneRec, calendarRec, largestUnit, @@ -169,48 +187,34 @@ bool DifferenceZonedDateTime(JSContext* cx, const Instant& ns1, JS::Handle<CalendarRecord> calendar, TemporalUnit largestUnit, const PlainDateTime& precalculatedPlainDateTime, - Duration* result); - -struct NanosecondsAndDays final { - JS::BigInt* days = nullptr; - int64_t daysInt = 0; - InstantSpan nanoseconds; - InstantSpan dayLength; - - double daysNumber() const; + NormalizedDuration* result); - void trace(JSTracer* trc); - - static NanosecondsAndDays from(int64_t days, const InstantSpan& nanoseconds, - const InstantSpan& dayLength) { - return {nullptr, days, nanoseconds, dayLength}; - } - - static NanosecondsAndDays from(JS::BigInt* days, - const InstantSpan& nanoseconds, - const InstantSpan& dayLength) { - return {days, 0, nanoseconds, dayLength}; - } +struct NormalizedTimeAndDays final { + int64_t days = 0; + int64_t time = 0; + int64_t dayLength = 0; }; /** - * NanosecondsToDays ( nanoseconds, zonedRelativeTo, timeZoneRec [ , + * NormalizedTimeDurationToDays ( norm, zonedRelativeTo, timeZoneRec [ , * precalculatedPlainDateTime ] ) */ -bool NanosecondsToDays(JSContext* cx, const InstantSpan& nanoseconds, - JS::Handle<ZonedDateTime> zonedRelativeTo, - JS::Handle<TimeZoneRecord> timeZone, - JS::MutableHandle<NanosecondsAndDays> result); +bool NormalizedTimeDurationToDays(JSContext* cx, + const NormalizedTimeDuration& duration, + JS::Handle<ZonedDateTime> zonedRelativeTo, + JS::Handle<TimeZoneRecord> timeZone, + NormalizedTimeAndDays* result); /** - * NanosecondsToDays ( nanoseconds, zonedRelativeTo, timeZoneRec [ , + * NormalizedTimeDurationToDays ( norm, zonedRelativeTo, timeZoneRec [ , * precalculatedPlainDateTime ] ) */ -bool NanosecondsToDays(JSContext* cx, const InstantSpan& nanoseconds, - JS::Handle<ZonedDateTime> zonedRelativeTo, - JS::Handle<TimeZoneRecord> timeZone, - const PlainDateTime& precalculatedPlainDateTime, - JS::MutableHandle<NanosecondsAndDays> result); +bool NormalizedTimeDurationToDays( + JSContext* cx, const NormalizedTimeDuration& duration, + JS::Handle<ZonedDateTime> zonedRelativeTo, + JS::Handle<TimeZoneRecord> timeZone, + const PlainDateTime& precalculatedPlainDateTime, + NormalizedTimeAndDays* result); enum class OffsetBehaviour { Option, Exact, Wall }; @@ -255,26 +259,6 @@ class WrappedPtrOperations<temporal::ZonedDateTime, Wrapper> { } }; -template <typename Wrapper> -class WrappedPtrOperations<temporal::NanosecondsAndDays, Wrapper> { - const auto& object() const { - return static_cast<const Wrapper*>(this)->get(); - } - - public: - double daysNumber() const { return object().daysNumber(); } - - JS::Handle<JS::BigInt*> days() const { - return JS::Handle<JS::BigInt*>::fromMarkedLocation(&object().days); - } - - int64_t daysInt() const { return object().daysInt; } - - temporal::InstantSpan nanoseconds() const { return object().nanoseconds; } - - temporal::InstantSpan dayLength() const { return object().dayLength; } -}; - } /* namespace js */ #endif /* builtin_temporal_ZonedDateTime_h */ diff --git a/js/src/builtin/temporal/moz.build b/js/src/builtin/temporal/moz.build index ae3bb618ad..3c09960783 100644 --- a/js/src/builtin/temporal/moz.build +++ b/js/src/builtin/temporal/moz.build @@ -17,6 +17,7 @@ if CONFIG["JS_HAS_TEMPORAL_API"]: "Calendar.cpp", "Duration.cpp", "Instant.cpp", + "Int128.cpp", "Int96.cpp", "PlainDate.cpp", "PlainDateTime.cpp", diff --git a/js/src/debugger/DebugAPI-inl.h b/js/src/debugger/DebugAPI-inl.h index 77f81b800f..63d80e3d90 100644 --- a/js/src/debugger/DebugAPI-inl.h +++ b/js/src/debugger/DebugAPI-inl.h @@ -142,6 +142,15 @@ NativeResumeMode DebugAPI::onNativeCall(JSContext* cx, const CallArgs& args, } /* static */ +bool DebugAPI::shouldAvoidSideEffects(JSContext* cx) { + if (MOZ_UNLIKELY(cx->realm()->isDebuggee())) { + return slowPathShouldAvoidSideEffects(cx); + } + + return false; +} + +/* static */ bool DebugAPI::onDebuggerStatement(JSContext* cx, AbstractFramePtr frame) { if (MOZ_UNLIKELY(cx->realm()->isDebuggee())) { return slowPathOnDebuggerStatement(cx, frame); diff --git a/js/src/debugger/DebugAPI.h b/js/src/debugger/DebugAPI.h index df082ab5ba..67f3b62883 100644 --- a/js/src/debugger/DebugAPI.h +++ b/js/src/debugger/DebugAPI.h @@ -7,6 +7,7 @@ #ifndef debugger_DebugAPI_h #define debugger_DebugAPI_h +#include "js/Debug.h" #include "vm/GlobalObject.h" #include "vm/Interpreter.h" #include "vm/JSContext.h" @@ -228,6 +229,8 @@ class DebugAPI { const CallArgs& args, CallReason reason); + static inline bool shouldAvoidSideEffects(JSContext* cx); + /* * Announce to the debugger a |debugger;| statement on has been * encountered on the youngest JS frame on |cx|. Call whatever hooks have @@ -385,6 +388,7 @@ class DebugAPI { static NativeResumeMode slowPathOnNativeCall(JSContext* cx, const CallArgs& args, CallReason reason); + static bool slowPathShouldAvoidSideEffects(JSContext* cx); [[nodiscard]] static bool slowPathOnDebuggerStatement(JSContext* cx, AbstractFramePtr frame); [[nodiscard]] static bool slowPathOnExceptionUnwind(JSContext* cx, diff --git a/js/src/debugger/Debugger.cpp b/js/src/debugger/Debugger.cpp index 37c1e79a9d..44bd1a8eaa 100644 --- a/js/src/debugger/Debugger.cpp +++ b/js/src/debugger/Debugger.cpp @@ -536,6 +536,7 @@ Debugger::Debugger(JSContext* cx, NativeObject* dbg) exclusiveDebuggerOnEval(false), inspectNativeCallArguments(false), collectCoverageInfo(false), + shouldAvoidSideEffects(false), observedGCs(cx->zone()), allocationsLog(cx), trackingAllocationSites(false), @@ -1049,6 +1050,12 @@ NativeResumeMode DebugAPI::slowPathOnNativeCall(JSContext* cx, return NativeResumeMode::Continue; } +/* static */ +bool DebugAPI::slowPathShouldAvoidSideEffects(JSContext* cx) { + return DebuggerExists( + cx->global(), [=](Debugger* dbg) { return dbg->shouldAvoidSideEffects; }); +} + /* * RAII class to mark a generator as "running" temporarily while running * debugger code. @@ -4187,6 +4194,8 @@ struct MOZ_STACK_CLASS Debugger::CallData { bool setOnEnterFrame(); bool getOnNativeCall(); bool setOnNativeCall(); + bool getShouldAvoidSideEffects(); + bool setShouldAvoidSideEffects(); bool getOnNewGlobalObject(); bool setOnNewGlobalObject(); bool getOnNewPromise(); @@ -4405,6 +4414,22 @@ bool Debugger::CallData::setOnNativeCall() { return true; } +bool Debugger::CallData::getShouldAvoidSideEffects() { + args.rval().setBoolean(dbg->shouldAvoidSideEffects); + return true; +} + +bool Debugger::CallData::setShouldAvoidSideEffects() { + if (!args.requireAtLeast(cx, "Debugger.set shouldAvoidSideEffects", 1)) { + return false; + } + + dbg->shouldAvoidSideEffects = ToBoolean(args[0]); + + args.rval().setUndefined(); + return true; +} + bool Debugger::CallData::getOnNewGlobalObject() { return getHookImpl(cx, args, *dbg, OnNewGlobalObject); } @@ -4608,6 +4633,11 @@ GlobalObject* Debugger::unwrapDebuggeeArgument(JSContext* cx, const Value& v) { return nullptr; } + if (JS_IsDeadWrapper(obj)) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEAD_OBJECT); + return nullptr; + } + // If that didn't produce a global object, it's an error. if (!obj->is<GlobalObject>()) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, @@ -6518,6 +6548,8 @@ const JSPropertySpec Debugger::properties[] = { JS_DEBUG_PSGS("onPromiseSettled", getOnPromiseSettled, setOnPromiseSettled), JS_DEBUG_PSGS("onEnterFrame", getOnEnterFrame, setOnEnterFrame), JS_DEBUG_PSGS("onNativeCall", getOnNativeCall, setOnNativeCall), + JS_DEBUG_PSGS("shouldAvoidSideEffects", getShouldAvoidSideEffects, + setShouldAvoidSideEffects), JS_DEBUG_PSGS("onNewGlobalObject", getOnNewGlobalObject, setOnNewGlobalObject), JS_DEBUG_PSGS("uncaughtExceptionHook", getUncaughtExceptionHook, @@ -7259,5 +7291,9 @@ JS_PUBLIC_API bool FireOnGarbageCollectionHook( return true; } +bool ShouldAvoidSideEffects(JSContext* cx) { + return DebugAPI::shouldAvoidSideEffects(cx); +} + } // namespace dbg } // namespace JS diff --git a/js/src/debugger/Debugger.h b/js/src/debugger/Debugger.h index 5155927419..537e47b913 100644 --- a/js/src/debugger/Debugger.h +++ b/js/src/debugger/Debugger.h @@ -652,6 +652,10 @@ class Debugger : private mozilla::LinkedListElement<Debugger> { // Whether to enable code coverage on the Debuggee. bool collectCoverageInfo; + // Whether to ask avoid side-effects in the native code. + // See JS::dbg::ShouldAvoidSideEffects. + bool shouldAvoidSideEffects; + template <typename T> struct DebuggerLinkAccess { static mozilla::DoublyLinkedListElement<T>& Get(T* aThis) { diff --git a/js/src/debugger/Script.cpp b/js/src/debugger/Script.cpp index 29ea9f1ea1..933dd6d362 100644 --- a/js/src/debugger/Script.cpp +++ b/js/src/debugger/Script.cpp @@ -1620,6 +1620,7 @@ static bool BytecodeIsEffectful(JSScript* script, size_t offset) { case JSOp::Object: case JSOp::Typeof: case JSOp::TypeofExpr: + case JSOp::TypeofEq: case JSOp::ToAsyncIter: case JSOp::ToPropertyKey: case JSOp::Lambda: diff --git a/js/src/devtools/automation/autospider.py b/js/src/devtools/automation/autospider.py index 5e427fd3a5..edd7c5597f 100755 --- a/js/src/devtools/automation/autospider.py +++ b/js/src/devtools/automation/autospider.py @@ -570,6 +570,10 @@ if use_minidump: for v in ("JSTESTS_EXTRA_ARGS", "JITTEST_EXTRA_ARGS"): env[v] = "--args='--dll %s' %s" % (injector_lib, env.get(v, "")) +# Report longest running jit-tests in automation. +env["JITTEST_EXTRA_ARGS"] = "--show-slow " + env.get("JITTEST_EXTRA_ARGS", "") +env["JSTESTS_EXTRA_ARGS"] = "--show-slow " + env.get("JSTESTS_EXTRA_ARGS", "") + # Always run all enabled tests, even if earlier ones failed. But return the # first failed status. results = [("(make-nonempty)", 0)] diff --git a/js/src/devtools/automation/variants/rootanalysis b/js/src/devtools/automation/variants/rootanalysis index 89da2eaf1a..4424e55a80 100644 --- a/js/src/devtools/automation/variants/rootanalysis +++ b/js/src/devtools/automation/variants/rootanalysis @@ -4,6 +4,7 @@ "debug": true, "env": { "JS_GC_ZEAL": "GenerationalGC", + "JITTEST_EXTRA_ARGS": "--args='--gc-param=semispaceNurseryEnabled=1'", "JSTESTS_EXTRA_ARGS": "--jitflags=debug --args='--gc-param=semispaceNurseryEnabled=1'" } } diff --git a/js/src/doc/Debugger/Debugger.md b/js/src/doc/Debugger/Debugger.md index ad7d57e22d..d3b01832a9 100644 --- a/js/src/doc/Debugger/Debugger.md +++ b/js/src/doc/Debugger/Debugger.md @@ -87,6 +87,13 @@ access to browser-level features like the `alert` function, which this API's implementation does not, making it possible to present debugger errors to the developer in a way suited to the context.) +### `shouldAvoidSideEffects` +A boolean value used to ask a side-effectful native code to abort. + +If set to true, `JS::dbg::ShouldAvoidSideEffects(cx)` returns true. +Native code can opt into this to support debugger who wants to perform +side-effect-free evaluation. + ## Debugger Handler Functions diff --git a/js/src/doc/feature_checklist.md b/js/src/doc/feature_checklist.md index 7cf847f725..e08821deda 100644 --- a/js/src/doc/feature_checklist.md +++ b/js/src/doc/feature_checklist.md @@ -9,12 +9,12 @@ work directly top-down) [Exposure Guidelines](https://wiki.mozilla.org/ExposureGuidelines) process. We historically haven't been amazing at sending intent-to-prototype emails, but we can always get better. -- ☐ Create a shell option for the feature. - ☐ Stage 2 or earlier proposals should be developed under compile time guards, disabled by default. -- ☐ Create a browser preference for the feature. +- ☐ Create a preference for the feature in `modules/libpref/init/StaticPrefList.yaml` + and a command line option in `js/src/shell/js.cpp`. - ☐ Implement the Feature. -- ☐ Land feature disabled by pref and shell-option. +- ☐ Land feature disabled by pref. - ☐ Import the test262 test cases for the feature, or enable them if they're already imported. (See `js/src/test/Readme.txt` for guidance) - ☐ Contact `fuzzing@mozilla.org` to arrange fuzzing for the feature. @@ -22,10 +22,15 @@ work directly top-down) fuzzers as well that the feature is ready for fuzzing. - ☐ Send an Intent to Ship Email to `dev-platform`. This is also part of the [Exposure Guidelines](https://wiki.mozilla.org/ExposureGuidelines) process. -- ☐ Ship the feature; default the preference to true and the command-line - option to true. -- ☐ Open a followup bug to later remove the preference and the command line - option. +- ☐ Ship the feature: + - ☐ default the preference to true. + - ☐ Double check for any code that is currently `NIGHTLY_BUILD` that should now be built unconditionally, e.g. in `js/src/vm/JSObject.cpp`. + You may want to run a [central as beta simulation](https://wiki.mozilla.org/Sheriffing/How_To/Beta_simulations#TRUNK_AS_EARLY_BETA) + to make sure you've caught any lingering `NIGHTLY_BUILD` parts. + - ☐ Update ` js/xpconnect/tests/chrome/test_xrayToJS.xhtml` for any changes to existing global objects. + - ☐ For new globals, the following tests also need updates: + `dom/serviceworkers/test/test_serviceworker_interfaces.js`, `tests/mochitest/general/test_interfaces.js`, and `dom/workers/test/test_worker_interfaces.js` +- ☐ Open a followup bug to later remove the preference. ## Supplemental Checklists diff --git a/js/src/ds/OrderedHashTable.h b/js/src/ds/OrderedHashTable.h index 75c22bd123..9dd3e216d3 100644 --- a/js/src/ds/OrderedHashTable.h +++ b/js/src/ds/OrderedHashTable.h @@ -263,6 +263,12 @@ class OrderedHashTable { } *foundp = true; + return remove(e); + } + + bool remove(Data* e) { + MOZ_ASSERT(uint32_t(e - data) < dataCapacity); + liveCount--; Ops::makeEmpty(&e->element); @@ -277,6 +283,7 @@ class OrderedHashTable { return false; } } + return true; } @@ -967,6 +974,12 @@ class OrderedHashMap { bool remove(const Lookup& key, bool* foundp) { return impl.remove(key, foundp); } + // Remove an entry returned by get(). + bool remove(Entry* entry) { + static_assert(offsetof(typename Impl::Data, element) == 0); + auto* data = reinterpret_cast<typename Impl::Data*>(entry); + return impl.remove(data); + } [[nodiscard]] bool clear() { return impl.clear(); } template <typename K, typename V> diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp index 2759fa5924..f288d333e1 100644 --- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -72,6 +72,7 @@ #include "vm/Scope.h" // GetScopeDataTrailingNames #include "vm/SharedStencil.h" // ScopeNote #include "vm/ThrowMsgKind.h" // ThrowMsgKind +#include "vm/TypeofEqOperand.h" // TypeofEqOperand using namespace js; using namespace js::frontend; @@ -11499,6 +11500,101 @@ bool BytecodeEmitter::emitTypeof(UnaryNode* typeofNode, JSOp op) { return emit1(op); } +bool BytecodeEmitter::tryEmitTypeofEq(ListNode* node, bool* emitted) { + // Emit specialized opcode for `typeof val == "type` or `typeof val != "type` + // if possible. + // + // NOTE: Given the comparison is done for string, `==` and `===` have + // no difference. Same for `!=` and `!==`. + MOZ_ASSERT(node->isKind(ParseNodeKind::StrictEqExpr) || + node->isKind(ParseNodeKind::EqExpr) || + node->isKind(ParseNodeKind::StrictNeExpr) || + node->isKind(ParseNodeKind::NeExpr)); + + if (node->count() != 2) { + *emitted = false; + return true; + } + + ParseNode* left = node->head(); + ParseNode* right = left->pn_next; + MOZ_ASSERT(right); + + UnaryNode* typeofNode; + NameNode* typenameNode; + JSOp op; + + if (node->isKind(ParseNodeKind::StrictEqExpr) || + node->isKind(ParseNodeKind::EqExpr)) { + op = JSOp::Eq; + } else { + op = JSOp::Ne; + } + + // NOTE: ParseNodeKind::TypeOfExpr cannot use JSOp::TypeofEq. + // See JSOp::GetName document. + if (left->isKind(ParseNodeKind::TypeOfNameExpr) && + right->isKind(ParseNodeKind::StringExpr)) { + typeofNode = &left->as<UnaryNode>(); + typenameNode = &right->as<NameNode>(); + } else if (right->isKind(ParseNodeKind::TypeOfNameExpr) && + left->isKind(ParseNodeKind::StringExpr)) { + typeofNode = &right->as<UnaryNode>(); + typenameNode = &left->as<NameNode>(); + } else { + *emitted = false; + return true; + } + + JSType type; + TaggedParserAtomIndex typeName = typenameNode->atom(); + if (typeName == TaggedParserAtomIndex::WellKnown::undefined()) { + type = JSTYPE_UNDEFINED; + } else if (typeName == TaggedParserAtomIndex::WellKnown::object()) { + type = JSTYPE_OBJECT; + } else if (typeName == TaggedParserAtomIndex::WellKnown::function()) { + type = JSTYPE_FUNCTION; + } else if (typeName == TaggedParserAtomIndex::WellKnown::string()) { + type = JSTYPE_STRING; + } else if (typeName == TaggedParserAtomIndex::WellKnown::number()) { + type = JSTYPE_NUMBER; + } else if (typeName == TaggedParserAtomIndex::WellKnown::boolean()) { + type = JSTYPE_BOOLEAN; + } else if (typeName == TaggedParserAtomIndex::WellKnown::symbol()) { + type = JSTYPE_SYMBOL; + } else if (typeName == TaggedParserAtomIndex::WellKnown::bigint()) { + type = JSTYPE_BIGINT; + } +#ifdef ENABLE_RECORD_TUPLE + else if (typeName == TaggedParserAtomIndex::WellKnown::record()) { + type = JSTYPE_RECORD; + } else if (typeName == TaggedParserAtomIndex::WellKnown::tuple()) { + type = JSTYPE_TUPLE; + } +#endif + else { + *emitted = false; + return true; + } + + if (!updateSourceCoordNotes(typeofNode->pn_pos.begin)) { + return false; + } + + if (!emitTree(typeofNode->kid())) { + // [stack] VAL + return false; + } + + if (!emit2(JSOp::TypeofEq, TypeofEqOperand(type, op).rawValue())) { + // [stack] CMP + return false; + } + + *emitted = true; + return true; +} + bool BytecodeEmitter::emitFunctionFormalParameters(ParamsBodyNode* paramsBody) { FunctionBox* funbox = sc->asFunctionBox(); @@ -12394,15 +12490,25 @@ bool BytecodeEmitter::emitTree( } break; + case ParseNodeKind::StrictEqExpr: + case ParseNodeKind::EqExpr: + case ParseNodeKind::StrictNeExpr: + case ParseNodeKind::NeExpr: { + bool emitted; + if (!tryEmitTypeofEq(&pn->as<ListNode>(), &emitted)) { + return false; + } + if (emitted) { + return true; + } + } + [[fallthrough]]; + case ParseNodeKind::AddExpr: case ParseNodeKind::SubExpr: case ParseNodeKind::BitOrExpr: case ParseNodeKind::BitXorExpr: case ParseNodeKind::BitAndExpr: - case ParseNodeKind::StrictEqExpr: - case ParseNodeKind::EqExpr: - case ParseNodeKind::StrictNeExpr: - case ParseNodeKind::NeExpr: case ParseNodeKind::LtExpr: case ParseNodeKind::LeExpr: case ParseNodeKind::GtExpr: diff --git a/js/src/frontend/BytecodeEmitter.h b/js/src/frontend/BytecodeEmitter.h index 251797d1f7..a0e58d629f 100644 --- a/js/src/frontend/BytecodeEmitter.h +++ b/js/src/frontend/BytecodeEmitter.h @@ -925,6 +925,8 @@ struct MOZ_STACK_CLASS BytecodeEmitter { // |op| must be JSOp::Typeof or JSOp::TypeofExpr. [[nodiscard]] bool emitTypeof(UnaryNode* typeofNode, JSOp op); + [[nodiscard]] bool tryEmitTypeofEq(ListNode* node, bool* emitted); + [[nodiscard]] bool emitUnary(UnaryNode* unaryNode); [[nodiscard]] bool emitRightAssociative(ListNode* node); [[nodiscard]] bool emitLeftAssociative(ListNode* node); diff --git a/js/src/frontend/Stencil.cpp b/js/src/frontend/Stencil.cpp index 67ed2a90ca..447a83f595 100644 --- a/js/src/frontend/Stencil.cpp +++ b/js/src/frontend/Stencil.cpp @@ -2783,6 +2783,8 @@ JSScript* CompilationStencil::instantiateSelfHostedTopLevelForRealm( JSFunction* CompilationStencil::instantiateSelfHostedLazyFunction( JSContext* cx, CompilationAtomCache& atomCache, ScriptIndex index, Handle<JSAtom*> name) { + MOZ_ASSERT(cx->zone()->suppressAllocationMetadataBuilder); + GeneratorKind generatorKind = scriptExtra[index].immutableFlags.hasFlag( ImmutableScriptFlagsEnum::IsGenerator) ? GeneratorKind::Generator diff --git a/js/src/frontend/Stencil.h b/js/src/frontend/Stencil.h index 91308ffcc9..b5baa8e6c4 100644 --- a/js/src/frontend/Stencil.h +++ b/js/src/frontend/Stencil.h @@ -502,13 +502,14 @@ class ScopeStencil { } }; -class StencilModuleAssertion { +class StencilModuleImportAttribute { public: TaggedParserAtomIndex key; TaggedParserAtomIndex value; - StencilModuleAssertion() = default; - StencilModuleAssertion(TaggedParserAtomIndex key, TaggedParserAtomIndex value) + StencilModuleImportAttribute() = default; + StencilModuleImportAttribute(TaggedParserAtomIndex key, + TaggedParserAtomIndex value) : key(key), value(value) {} }; @@ -516,9 +517,9 @@ class StencilModuleRequest { public: TaggedParserAtomIndex specifier; - using AssertionVector = - Vector<StencilModuleAssertion, 0, js::SystemAllocPolicy>; - AssertionVector assertions; + using ImportAttributeVector = + Vector<StencilModuleImportAttribute, 0, js::SystemAllocPolicy>; + ImportAttributeVector attributes; // For XDR only. StencilModuleRequest() = default; @@ -531,23 +532,23 @@ class StencilModuleRequest { StencilModuleRequest(const StencilModuleRequest& other) : specifier(other.specifier) { AutoEnterOOMUnsafeRegion oomUnsafe; - if (!assertions.appendAll(other.assertions)) { + if (!attributes.appendAll(other.attributes)) { oomUnsafe.crash("StencilModuleRequest::StencilModuleRequest"); } } StencilModuleRequest(StencilModuleRequest&& other) noexcept - : specifier(other.specifier), assertions(std::move(other.assertions)) {} + : specifier(other.specifier), attributes(std::move(other.attributes)) {} StencilModuleRequest& operator=(StencilModuleRequest& other) { specifier = other.specifier; - assertions = std::move(other.assertions); + attributes = std::move(other.attributes); return *this; } StencilModuleRequest& operator=(StencilModuleRequest&& other) noexcept { specifier = other.specifier; - assertions = std::move(other.assertions); + attributes = std::move(other.attributes); return *this; } }; diff --git a/js/src/frontend/StencilXdr.cpp b/js/src/frontend/StencilXdr.cpp index 1146d023d4..ca65b905e2 100644 --- a/js/src/frontend/StencilXdr.cpp +++ b/js/src/frontend/StencilXdr.cpp @@ -577,7 +577,7 @@ template <XDRMode mode> /* static */ XDRResult StencilXDR::codeModuleRequest( XDRState<mode>* xdr, StencilModuleRequest& stencil) { MOZ_TRY(xdr->codeUint32(stencil.specifier.rawDataRef())); - MOZ_TRY(XDRVectorContent(xdr, stencil.assertions)); + MOZ_TRY(XDRVectorContent(xdr, stencil.attributes)); return Ok(); } diff --git a/js/src/fuzz-tests/gluesmith/Cargo.toml b/js/src/fuzz-tests/gluesmith/Cargo.toml index c5f7118ba4..d22ac49f2e 100644 --- a/js/src/fuzz-tests/gluesmith/Cargo.toml +++ b/js/src/fuzz-tests/gluesmith/Cargo.toml @@ -5,6 +5,6 @@ authors = ["Christian Holler"] license = "MPL-2.0" [dependencies] -wasm-smith = "0.201.0" +wasm-smith = "0.205.0" arbitrary = { version = "1.0.0", features = ["derive"] } libc = "0.2" diff --git a/js/src/fuzz-tests/moz.build b/js/src/fuzz-tests/moz.build index ccec998f0b..89f16e681f 100644 --- a/js/src/fuzz-tests/moz.build +++ b/js/src/fuzz-tests/moz.build @@ -33,9 +33,10 @@ if CONFIG["FUZZING"]: include("/tools/fuzzing/libfuzzer-config.mozbuild") if CONFIG["FUZZING_INTERFACES"]: - USE_LIBS += [ - "static:fuzzer", - ] + if CONFIG["LIBFUZZER"]: + USE_LIBS += ["static:fuzzer"] + else: + USE_LIBS += ["static:fuzzer-interface"] USE_LIBS += [ "static:js", diff --git a/js/src/fuzz-tests/tests.cpp b/js/src/fuzz-tests/tests.cpp index 408920eecc..7b288bec9a 100644 --- a/js/src/fuzz-tests/tests.cpp +++ b/js/src/fuzz-tests/tests.cpp @@ -12,6 +12,7 @@ #include "js/GlobalObject.h" #include "js/Initialization.h" #include "js/Prefs.h" +#include "js/RealmOptions.h" #include "js/RootingAPI.h" #include "js/Stack.h" #include "vm/JSContext.h" diff --git a/js/src/gc/GC.cpp b/js/src/gc/GC.cpp index 68dd66898c..bdd252907b 100644 --- a/js/src/gc/GC.cpp +++ b/js/src/gc/GC.cpp @@ -411,6 +411,8 @@ GCRuntime::GCRuntime(JSRuntime* rt) helperThreadRatio(TuningDefaults::HelperThreadRatio), maxHelperThreads(TuningDefaults::MaxHelperThreads), helperThreadCount(1), + maxMarkingThreads(TuningDefaults::MaxMarkingThreads), + markingThreadCount(1), createBudgetCallback(nullptr), minEmptyChunkCount_(TuningDefaults::MinEmptyChunkCount), maxEmptyChunkCount_(TuningDefaults::MaxEmptyChunkCount), @@ -1049,7 +1051,7 @@ bool GCRuntime::setParameter(JSContext* cx, JSGCParamKey key, uint32_t value) { static bool IsGCThreadParameter(JSGCParamKey key) { return key == JSGC_HELPER_THREAD_RATIO || key == JSGC_MAX_HELPER_THREADS || - key == JSGC_MARKING_THREAD_COUNT; + key == JSGC_MAX_MARKING_THREADS; } bool GCRuntime::setParameter(JSGCParamKey key, uint32_t value, @@ -1120,8 +1122,8 @@ bool GCRuntime::setThreadParameter(JSGCParamKey key, uint32_t value, } maxHelperThreads = value; break; - case JSGC_MARKING_THREAD_COUNT: - markingThreadCount = std::min(size_t(value), MaxParallelWorkers); + case JSGC_MAX_MARKING_THREADS: + maxMarkingThreads = std::min(size_t(value), MaxParallelWorkers); break; default: MOZ_CRASH("Unexpected parameter key"); @@ -1201,8 +1203,8 @@ void GCRuntime::resetThreadParameter(JSGCParamKey key, AutoLockGC& lock) { case JSGC_MAX_HELPER_THREADS: maxHelperThreads = TuningDefaults::MaxHelperThreads; break; - case JSGC_MARKING_THREAD_COUNT: - markingThreadCount = 0; + case JSGC_MAX_MARKING_THREADS: + maxMarkingThreads = TuningDefaults::MaxMarkingThreads; break; default: MOZ_CRASH("Unexpected parameter key"); @@ -1265,6 +1267,8 @@ uint32_t GCRuntime::getParameter(JSGCParamKey key, const AutoLockGC& lock) { return maxHelperThreads; case JSGC_HELPER_THREAD_COUNT: return helperThreadCount; + case JSGC_MAX_MARKING_THREADS: + return maxMarkingThreads; case JSGC_MARKING_THREAD_COUNT: return markingThreadCount; case JSGC_SYSTEM_PAGE_SIZE_KB: @@ -1316,8 +1320,12 @@ void GCRuntime::updateHelperThreadCount() { std::clamp(size_t(double(cpuCount) * helperThreadRatio.ref()), size_t(1), maxHelperThreads.ref()); + // Calculate the target thread count for parallel marking, which uses separate + // parameters to let us adjust this independently. + markingThreadCount = std::min(cpuCount / 2, maxMarkingThreads.ref()); + // Calculate the overall target thread count taking into account the separate - // parameter for parallel marking threads. Add spare threads to avoid blocking + // target for parallel marking threads. Add spare threads to avoid blocking // parallel marking when there is other GC work happening. size_t targetCount = std::max(helperThreadCount.ref(), @@ -1334,9 +1342,13 @@ void GCRuntime::updateHelperThreadCount() { MOZ_ASSERT(availableThreadCount != 0); targetCount = std::min(targetCount, availableThreadCount); helperThreadCount = std::min(helperThreadCount.ref(), availableThreadCount); - markingThreadCount = - std::min(markingThreadCount.ref(), - availableThreadCount - SpareThreadsDuringParallelMarking); + if (availableThreadCount < SpareThreadsDuringParallelMarking) { + markingThreadCount = 1; + } else { + markingThreadCount = + std::min(markingThreadCount.ref(), + availableThreadCount - SpareThreadsDuringParallelMarking); + } // Update the maximum number of threads that will be used for GC work. maxParallelThreads = targetCount; @@ -2948,6 +2960,10 @@ void GCRuntime::beginMarkPhase(AutoGCSession& session) { checkNoRuntimeRoots(session); } else { AutoUpdateLiveCompartments updateLive(this); +#ifdef DEBUG + AutoSetThreadIsMarking threadIsMarking; +#endif // DEBUG + marker().setRootMarkingMode(true); traceRuntimeForMajorGC(marker().tracer(), session); marker().setRootMarkingMode(false); @@ -3093,6 +3109,10 @@ IncrementalProgress GCRuntime::markUntilBudgetExhausted( } } +#ifdef DEBUG + AutoSetThreadIsMarking threadIsMarking; +#endif // DEBUG + if (processTestMarkQueue() == QueueYielded) { return NotFinished; } @@ -3112,10 +3132,6 @@ IncrementalProgress GCRuntime::markUntilBudgetExhausted( return Finished; } -#ifdef DEBUG - AutoSetThreadIsMarking threadIsMarking; -#endif // DEBUG - return marker().markUntilBudgetExhausted(sliceBudget, reportTime) ? Finished : NotFinished; @@ -5054,7 +5070,7 @@ void GCRuntime::checkHashTablesAfterMovingGC() { } for (ZonesIter zone(this, SkipAtoms); !zone.done(); zone.next()) { zone->checkUniqueIdTableAfterMovingGC(); - zone->shapeZone().checkTablesAfterMovingGC(); + zone->shapeZone().checkTablesAfterMovingGC(zone); zone->checkAllCrossCompartmentWrappersAfterMovingGC(); zone->checkScriptMapsAfterMovingGC(); @@ -5063,15 +5079,17 @@ void GCRuntime::checkHashTablesAfterMovingGC() { for (auto map = zone->cellIterUnsafe<NormalPropMap>(); !map.done(); map.next()) { if (PropMapTable* table = map->asLinked()->maybeTable(nogc)) { - table->checkAfterMovingGC(); + table->checkAfterMovingGC(zone); } } for (auto map = zone->cellIterUnsafe<DictionaryPropMap>(); !map.done(); map.next()) { if (PropMapTable* table = map->asLinked()->maybeTable(nogc)) { - table->checkAfterMovingGC(); + table->checkAfterMovingGC(zone); } } + + WeakMapBase::checkWeakMapsAfterMovingGC(zone); } for (CompartmentsIter c(this); !c.done(); c.next()) { diff --git a/js/src/gc/GC.h b/js/src/gc/GC.h index 7f603b066f..b907b0cddb 100644 --- a/js/src/gc/GC.h +++ b/js/src/gc/GC.h @@ -82,7 +82,8 @@ class TenuredChunk; _("helperThreadRatio", JSGC_HELPER_THREAD_RATIO, true) \ _("maxHelperThreads", JSGC_MAX_HELPER_THREADS, true) \ _("helperThreadCount", JSGC_HELPER_THREAD_COUNT, false) \ - _("markingThreadCount", JSGC_MARKING_THREAD_COUNT, true) \ + _("maxMarkingThreads", JSGC_MAX_MARKING_THREADS, true) \ + _("markingThreadCount", JSGC_MARKING_THREAD_COUNT, false) \ _("systemPageSizeKB", JSGC_SYSTEM_PAGE_SIZE_KB, false) \ _("semispaceNurseryEnabled", JSGC_SEMISPACE_NURSERY_ENABLED, true) diff --git a/js/src/gc/GCEnum.h b/js/src/gc/GCEnum.h index d60cfaea76..572d5f34a6 100644 --- a/js/src/gc/GCEnum.h +++ b/js/src/gc/GCEnum.h @@ -122,6 +122,7 @@ enum class GCAbortReason { _(ModuleCyclicFields) \ _(ModuleSyntheticFields) \ _(ModuleExports) \ + _(ModuleImportAttributes) \ _(BaselineScript) \ _(IonScript) \ _(ArgumentsData) \ diff --git a/js/src/gc/GCLock.h b/js/src/gc/GCLock.h index 64c28ac544..86429106d2 100644 --- a/js/src/gc/GCLock.h +++ b/js/src/gc/GCLock.h @@ -15,8 +15,6 @@ namespace js { -class AutoUnlockGC; - /* * RAII class that takes the GC lock while it is live. * @@ -32,7 +30,7 @@ class MOZ_RAII AutoLockGC { ~AutoLockGC() { lockGuard_.reset(); } - js::LockGuard<js::Mutex>& guard() { return lockGuard_.ref(); } + LockGuard<Mutex>& guard() { return lockGuard_.ref(); } protected: void lock() { @@ -48,12 +46,12 @@ class MOZ_RAII AutoLockGC { gc::GCRuntime* const gc; private: - mozilla::Maybe<js::LockGuard<js::Mutex>> lockGuard_; + mozilla::Maybe<LockGuard<Mutex>> lockGuard_; AutoLockGC(const AutoLockGC&) = delete; AutoLockGC& operator=(const AutoLockGC&) = delete; - friend class AutoUnlockGC; // For lock/unlock. + friend class UnlockGuard<AutoLockGC>; // For lock/unlock. }; /* @@ -92,18 +90,7 @@ class MOZ_RAII AutoLockGCBgAlloc : public AutoLockGC { bool startBgAlloc = false; }; -class MOZ_RAII AutoUnlockGC { - public: - explicit AutoUnlockGC(AutoLockGC& lock) : lock(lock) { lock.unlock(); } - - ~AutoUnlockGC() { lock.lock(); } - - private: - AutoLockGC& lock; - - AutoUnlockGC(const AutoUnlockGC&) = delete; - AutoUnlockGC& operator=(const AutoUnlockGC&) = delete; -}; +using AutoUnlockGC = UnlockGuard<AutoLockGC>; } // namespace js diff --git a/js/src/gc/GCMarker.h b/js/src/gc/GCMarker.h index 9d34d0a0dc..898f458c02 100644 --- a/js/src/gc/GCMarker.h +++ b/js/src/gc/GCMarker.h @@ -124,6 +124,7 @@ class MarkStack { public: TaggedPtr() = default; TaggedPtr(Tag tag, Cell* ptr); + uintptr_t asBits() const; Tag tag() const; uintptr_t tagUnchecked() const; template <typename T> @@ -144,6 +145,7 @@ class MarkStack { TaggedPtr ptr() const; void setStart(size_t newStart); + void setEmpty(); private: static constexpr size_t StartShift = 2; @@ -385,12 +387,6 @@ class GCMarker { // structures. void abortLinearWeakMarking(); - // 'delegate' is no longer the delegate of 'key'. - void severWeakDelegate(JSObject* key, JSObject* delegate); - - // 'delegate' is now the delegate of 'key'. Update weakmap marking state. - void restoreWeakDelegate(JSObject* key, JSObject* delegate); - #ifdef DEBUG // We can't check atom marking if the helper thread lock is already held by // the current thread. This allows us to disable the check. @@ -429,7 +425,7 @@ class GCMarker { void markAndTraverse(T* thing); template <typename T> - void markImplicitEdges(T* oldThing); + void markImplicitEdges(T* markedThing); private: /* @@ -524,9 +520,6 @@ class GCMarker { inline void pushValueRange(JSObject* obj, SlotsOrElementsKind kind, size_t start, size_t end); - template <typename T> - void markImplicitEdgesHelper(T markedThing); - // Mark through edges whose target color depends on the colors of two source // entities (eg a WeakMap and one of its keys), and push the target onto the // mark stack. diff --git a/js/src/gc/GCParallelTask.cpp b/js/src/gc/GCParallelTask.cpp index 27cb39df36..f33174ea2e 100644 --- a/js/src/gc/GCParallelTask.cpp +++ b/js/src/gc/GCParallelTask.cpp @@ -100,6 +100,12 @@ void js::GCParallelTask::joinWithLockHeld(AutoLockHelperThreadState& lock, return; } + if (lock.hasQueuedTasks()) { + // Unlock to allow task dispatch without lock held, otherwise we could wait + // forever. + AutoUnlockHelperThreadState unlock(lock); + } + if (isNotYetRunning(lock) && deadline.isNothing()) { // If the task was dispatched but has not yet started then cancel the task // and run it from the main thread. This stops us from blocking here when diff --git a/js/src/gc/GCParallelTask.h b/js/src/gc/GCParallelTask.h index 9ac51d02be..88e0ad6255 100644 --- a/js/src/gc/GCParallelTask.h +++ b/js/src/gc/GCParallelTask.h @@ -161,8 +161,6 @@ class GCParallelTask : private mozilla::LinkedListElement<GCParallelTask>, void joinWithLockHeld( AutoLockHelperThreadState& lock, mozilla::Maybe<mozilla::TimeStamp> deadline = mozilla::Nothing()); - void joinNonIdleTask(mozilla::Maybe<mozilla::TimeStamp> deadline, - AutoLockHelperThreadState& lock); // Instead of dispatching to a helper, run the task on the current thread. void runFromMainThread(); @@ -247,6 +245,9 @@ class GCParallelTask : private mozilla::LinkedListElement<GCParallelTask>, } friend class gc::GCRuntime; + void joinNonIdleTask(mozilla::Maybe<mozilla::TimeStamp> deadline, + AutoLockHelperThreadState& lock); + void runTask(JS::GCContext* gcx, AutoLockHelperThreadState& lock); // Implement the HelperThreadTask interface. diff --git a/js/src/gc/GCRuntime.h b/js/src/gc/GCRuntime.h index 851e477359..6b85223e9e 100644 --- a/js/src/gc/GCRuntime.h +++ b/js/src/gc/GCRuntime.h @@ -1027,6 +1027,7 @@ class GCRuntime { MainThreadData<double> helperThreadRatio; MainThreadData<size_t> maxHelperThreads; MainThreadOrGCTaskData<size_t> helperThreadCount; + MainThreadData<size_t> maxMarkingThreads; MainThreadData<size_t> markingThreadCount; // Per-runtime helper thread task queue. Can be accessed from helper threads diff --git a/js/src/gc/Marking-inl.h b/js/src/gc/Marking-inl.h index 4afc9f7c8c..90f6337657 100644 --- a/js/src/gc/Marking-inl.h +++ b/js/src/gc/Marking-inl.h @@ -188,9 +188,40 @@ inline void PreWriteBarrierDuringFlattening(JSString* str) { #ifdef JSGC_HASH_TABLE_CHECKS +// Moving GC things whose pointers are used in hash table keys has the potential +// to break hash tables in subtle and terrifying ways. For example, a key might +// be reported as not present but iterating the table could still return it. +// +// Check that a table is correct following a moving GC, ensuring that nothing is +// present in the table that points into the nursery or that has not been moved, +// and that the hash table entries are discoverable. +// +// |checkEntryAndGetLookup| should check any GC thing pointers in the entry are +// valid and return the lookup required to get this entry from the table. + +template <typename Table, typename Range, typename Lookup> +void CheckTableEntryAfterMovingGC(const Table& table, const Range& r, + const Lookup& lookup) { + auto ptr = table.lookup(lookup); + MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front()); +} + +template <typename Table, typename F> +void CheckTableAfterMovingGC(const Table& table, F&& checkEntryAndGetLookup) { + for (auto r = table.all(); !r.empty(); r.popFront()) { + auto lookup = checkEntryAndGetLookup(r.front()); + CheckTableEntryAfterMovingGC(table, r, lookup); + } +} + template <typename T> inline bool IsGCThingValidAfterMovingGC(T* t) { - return !IsInsideNursery(t) && !t->isForwarded(); + if (!t->isTenured()) { + return false; + } + + TenuredCell* cell = &t->asTenured(); + return cell->arena()->allocated() && !cell->isForwarded(); } template <typename T> @@ -201,8 +232,24 @@ inline void CheckGCThingAfterMovingGC(T* t) { } template <typename T> -inline void CheckGCThingAfterMovingGC(const WeakHeapPtr<T*>& t) { - CheckGCThingAfterMovingGC(t.unbarrieredGet()); +inline void CheckGCThingAfterMovingGC(T* t, JS::Zone* expectedZone) { + if (t) { + MOZ_RELEASE_ASSERT(IsGCThingValidAfterMovingGC(t)); + JS::Zone* zone = t->zoneFromAnyThread(); + MOZ_RELEASE_ASSERT(zone == expectedZone || zone->isAtomsZone()); + } +} + +template <typename T> +inline void CheckGCThingAfterMovingGC(const WeakHeapPtr<T*>& t, + JS::Zone* expectedZone) { + CheckGCThingAfterMovingGC(t.unbarrieredGet(), expectedZone); +} + +inline void CheckProtoAfterMovingGC(const TaggedProto& proto, JS::Zone* zone) { + if (proto.isObject()) { + CheckGCThingAfterMovingGC(proto.toObject(), zone); + } } #endif // JSGC_HASH_TABLE_CHECKS diff --git a/js/src/gc/Marking.cpp b/js/src/gc/Marking.cpp index 6b8742c980..6bec46940f 100644 --- a/js/src/gc/Marking.cpp +++ b/js/src/gc/Marking.cpp @@ -331,12 +331,20 @@ static bool ShouldTraceCrossCompartment(JSTracer* trc, JSObject* src, #ifdef DEBUG -inline void js::gc::AssertShouldMarkInZone(GCMarker* marker, Cell* thing) { - if (!thing->isMarkedBlack()) { - Zone* zone = thing->zone(); - MOZ_ASSERT(zone->isAtomsZone() || - zone->shouldMarkInZone(marker->markColor())); +template <typename T> +void js::gc::AssertShouldMarkInZone(GCMarker* marker, T* thing) { + if (thing->isMarkedBlack()) { + return; } + + // Allow marking marking atoms if we're not collected the atoms zone, except + // for symbols which may entrain other GC things if they're used as weakmap + // keys. + bool allowAtoms = !std::is_same_v<T, JS::Symbol>; + + Zone* zone = thing->zone(); + MOZ_ASSERT(zone->shouldMarkInZone(marker->markColor()) || + (allowAtoms && zone->isAtomsZone())); } void js::gc::AssertRootMarkingPhase(JSTracer* trc) { @@ -718,26 +726,6 @@ void js::gc::TraceRangeInternal(JSTracer* trc, size_t len, T* vec, namespace js { -using HasNoImplicitEdgesType = bool; - -template <typename T> -struct ImplicitEdgeHolderType { - using Type = HasNoImplicitEdgesType; -}; - -// For now, we only handle JSObject* and BaseScript* keys, but the linear time -// algorithm can be easily extended by adding in more types here, then making -// GCMarker::traverse<T> call markImplicitEdges. -template <> -struct ImplicitEdgeHolderType<JSObject*> { - using Type = JSObject*; -}; - -template <> -struct ImplicitEdgeHolderType<BaseScript*> { - using Type = BaseScript*; -}; - void GCMarker::markEphemeronEdges(EphemeronEdgeVector& edges, gc::MarkColor srcColor) { // This is called as part of GC weak marking or by barriers outside of GC. @@ -771,86 +759,21 @@ void GCMarker::markEphemeronEdges(EphemeronEdgeVector& edges, } } -// 'delegate' is no longer the delegate of 'key'. -void GCMarker::severWeakDelegate(JSObject* key, JSObject* delegate) { - MOZ_ASSERT(CurrentThreadIsMainThread()); - - JS::Zone* zone = delegate->zone(); - MOZ_ASSERT(zone->needsIncrementalBarrier()); - - auto* p = zone->gcEphemeronEdges(delegate).get(delegate); - if (!p) { - return; - } - - // We are losing 3 edges here: key -> delegate, delegate -> key, and - // <delegate, map> -> value. Maintain snapshot-at-beginning (hereafter, - // S-A-B) by conservatively assuming the delegate will end up black and - // marking through the latter 2 edges. - // - // Note that this does not fully give S-A-B: - // - // 1. If the map is gray, then the value will only be marked gray here even - // though the map could later be discovered to be black. - // - // 2. If the map has not yet been marked, we won't have any entries to mark - // here in the first place. - // - // 3. We're not marking the delegate, since that would cause eg nukeAllCCWs - // to keep everything alive for another collection. - // - // We can't even assume that the delegate passed in here is live, because we - // could have gotten here from nukeAllCCWs, which iterates over all CCWs - // including dead ones. - // - // This is ok because S-A-B is only needed to prevent the case where an - // unmarked object is removed from the graph and then re-inserted where it is - // reachable only by things that have already been marked. None of the 3 - // target objects will be re-inserted anywhere as a result of this action. - - EphemeronEdgeVector& edges = p->value; - MOZ_ASSERT(markColor() == MarkColor::Black); - markEphemeronEdges(edges, MarkColor::Black); -} - -// 'delegate' is now the delegate of 'key'. Update weakmap marking state. -void GCMarker::restoreWeakDelegate(JSObject* key, JSObject* delegate) { - MOZ_ASSERT(CurrentThreadIsMainThread()); - - MOZ_ASSERT(key->zone()->needsIncrementalBarrier()); - - if (!delegate->zone()->needsIncrementalBarrier()) { - // Normally we should not have added the key -> value edge if the delegate - // zone is not marking (because the delegate would have been seen as black, - // so we would mark the key immediately instead). But if there wasn't a - // delegate (the key was nuked), then we won't have consulted it. So we - // can't do the same assertion as above. - // - // Specifically, the sequence would be: - // 1. Nuke the key. - // 2. Start the incremental GC. - // 3. Mark the WeakMap. Insert a key->value edge with a DeadObjectProxy key. - // 4. Un-nuke the key with a delegate in a nonmarking Zone. - // - // The result is an ephemeron edge (from <map,key> to value, but stored - // as key to value) involving a key with a delegate in a nonmarking Zone, - // something that ordinarily would not happen. - return; - } +template <typename T> +struct TypeCanHaveImplicitEdges : std::false_type {}; +template <> +struct TypeCanHaveImplicitEdges<JSObject> : std::true_type {}; +template <> +struct TypeCanHaveImplicitEdges<BaseScript> : std::true_type {}; +template <> +struct TypeCanHaveImplicitEdges<JS::Symbol> : std::true_type {}; - auto* p = key->zone()->gcEphemeronEdges(key).get(key); - if (!p) { +template <typename T> +void GCMarker::markImplicitEdges(T* markedThing) { + if constexpr (!TypeCanHaveImplicitEdges<T>::value) { return; } - // Similar to severWeakDelegate above, mark through the key -> value edge. - EphemeronEdgeVector& edges = p->value; - MOZ_ASSERT(markColor() == MarkColor::Black); - markEphemeronEdges(edges, MarkColor::Black); -} - -template <typename T> -void GCMarker::markImplicitEdgesHelper(T markedThing) { if (!isWeakMarking()) { return; } @@ -859,30 +782,34 @@ void GCMarker::markImplicitEdgesHelper(T markedThing) { MOZ_ASSERT(zone->isGCMarking()); MOZ_ASSERT(!zone->isGCSweeping()); - auto p = zone->gcEphemeronEdges().get(markedThing); + auto& ephemeronTable = zone->gcEphemeronEdges(); + auto* p = ephemeronTable.get(markedThing); if (!p) { return; } + EphemeronEdgeVector& edges = p->value; // markedThing might be a key in a debugger weakmap, which can end up marking // values that are in a different compartment. AutoClearTracingSource acts(tracer()); - CellColor thingColor = gc::detail::GetEffectiveColor(this, markedThing); - markEphemeronEdges(edges, AsMarkColor(thingColor)); -} + MarkColor thingColor = markColor(); + MOZ_ASSERT(CellColor(thingColor) == + gc::detail::GetEffectiveColor(this, markedThing)); -template <> -void GCMarker::markImplicitEdgesHelper(HasNoImplicitEdgesType) {} + markEphemeronEdges(edges, thingColor); -template <typename T> -void GCMarker::markImplicitEdges(T* thing) { - markImplicitEdgesHelper<typename ImplicitEdgeHolderType<T*>::Type>(thing); + if (edges.empty()) { + ephemeronTable.remove(p); + } } template void GCMarker::markImplicitEdges(JSObject*); template void GCMarker::markImplicitEdges(BaseScript*); +#ifdef NIGHTLY_BUILD +template void GCMarker::markImplicitEdges(JS::Symbol*); +#endif } // namespace js @@ -959,6 +886,9 @@ static void TraceEdgeForBarrier(GCMarker* gcmarker, TenuredCell* thing, MOZ_ASSERT(ShouldMark(gcmarker, thing)); CheckTracedThing(gcmarker->tracer(), thing); AutoClearTracingSource acts(gcmarker->tracer()); +#ifdef DEBUG + AutoSetThreadIsMarking threadIsMarking; +#endif // DEBUG gcmarker->markAndTraverse<NormalMarkingOptions>(thing); }); } @@ -1100,6 +1030,11 @@ void GCMarker::traverse(GetterSetter* thing) { } template <uint32_t opts> void GCMarker::traverse(JS::Symbol* thing) { +#ifdef NIGHTLY_BUILD + if constexpr (bool(opts & MarkingOptions::MarkImplicitEdges)) { + markImplicitEdges(thing); + } +#endif traceChildren<opts>(thing); } template <uint32_t opts> @@ -1253,6 +1188,13 @@ bool js::GCMarker::mark(T* thing) { return false; } + // Don't mark symbols if we're not collecting the atoms zone. + if constexpr (std::is_same_v<T, JS::Symbol>) { + if (!thing->zone()->isGCMarkingOrVerifyingPreBarriers()) { + return false; + } + } + AssertShouldMarkInZone(this, thing); MarkColor color = @@ -1465,7 +1407,10 @@ void GCMarker::updateRangesAtStartOfSlice() { for (MarkStackIter iter(stack); !iter.done(); iter.next()) { if (iter.isSlotsOrElementsRange()) { MarkStack::SlotsOrElementsRange& range = iter.slotsOrElementsRange(); - if (range.kind() == SlotsOrElementsKind::Elements) { + JSObject* obj = range.ptr().asRangeObject(); + if (!obj->is<NativeObject>()) { + range.setEmpty(); + } else if (range.kind() == SlotsOrElementsKind::Elements) { NativeObject* obj = &range.ptr().asRangeObject()->as<NativeObject>(); size_t index = range.start(); size_t numShifted = obj->getElementsHeader()->numShiftedElements(); @@ -1736,6 +1681,8 @@ inline MarkStack::TaggedPtr::TaggedPtr(Tag tag, Cell* ptr) assertValid(); } +inline uintptr_t MarkStack::TaggedPtr::asBits() const { return bits; } + inline uintptr_t MarkStack::TaggedPtr::tagUnchecked() const { return bits & TagMask; } @@ -1801,6 +1748,12 @@ inline void MarkStack::SlotsOrElementsRange::setStart(size_t newStart) { MOZ_ASSERT(start() == newStart); } +inline void MarkStack::SlotsOrElementsRange::setEmpty() { + TaggedPtr entry = TaggedPtr(ObjectTag, ptr().asRangeObject()); + ptr_ = entry; + startAndKind_ = entry.asBits(); +} + inline MarkStack::TaggedPtr MarkStack::SlotsOrElementsRange::ptr() const { return ptr_; } diff --git a/js/src/gc/Memory.cpp b/js/src/gc/Memory.cpp index 7d7e22640d..8f35f833ce 100644 --- a/js/src/gc/Memory.cpp +++ b/js/src/gc/Memory.cpp @@ -437,6 +437,7 @@ void* MapAlignedPages(size_t length, size_t alignment) { void* region = nullptr; if (int err = posix_memalign(®ion, alignment, length)) { MOZ_ASSERT(err == ENOMEM); + (void)err; return nullptr; } MOZ_ASSERT(region != nullptr); diff --git a/js/src/gc/Nursery.cpp b/js/src/gc/Nursery.cpp index 4753848c56..e3afd5d055 100644 --- a/js/src/gc/Nursery.cpp +++ b/js/src/gc/Nursery.cpp @@ -613,6 +613,9 @@ void js::Nursery::leaveZealMode() { MOZ_ASSERT(isEmpty()); + // Reset the nursery size. + setCapacity(minSpaceSize()); + toSpace.moveToStartOfChunk(this, 0); toSpace.setStartToCurrentPosition(); @@ -1810,7 +1813,7 @@ void Nursery::requestMinorGC(JS::GCReason reason) { } else if (heapState == JS::HeapState::MajorCollecting) { // The GC runs sweeping tasks that may access the storebuffer in parallel // and these require taking the store buffer lock. - MOZ_ASSERT(CurrentThreadIsGCSweeping()); + MOZ_ASSERT(!CurrentThreadIsGCMarking()); runtime()->gc.assertCurrentThreadHasLockedStoreBuffer(); } else { MOZ_CRASH("Unexpected heap state"); diff --git a/js/src/gc/Scheduling.h b/js/src/gc/Scheduling.h index c5ed56dd5f..a48f5397fd 100644 --- a/js/src/gc/Scheduling.h +++ b/js/src/gc/Scheduling.h @@ -545,6 +545,9 @@ static const double HelperThreadRatio = 0.5; /* JSGC_MAX_HELPER_THREADS */ static const size_t MaxHelperThreads = 8; +/* JSGC_MAX_MARKING_THREADS */ +static const size_t MaxMarkingThreads = 2; + } // namespace TuningDefaults /* diff --git a/js/src/gc/Tenuring.cpp b/js/src/gc/Tenuring.cpp index d38a374599..bcd2bd3304 100644 --- a/js/src/gc/Tenuring.cpp +++ b/js/src/gc/Tenuring.cpp @@ -521,7 +521,7 @@ void JSDependentString::sweepTypedAfterMinorGC() { const CharT* newBaseChars = tenuredBase->JSString::nonInlineCharsRaw<CharT>(); relocateNonInlineChars(newBaseChars, offset); - + MOZ_ASSERT(tenuredBase->assertIsValidBase()); d.s.u3.base = tenuredBase; } @@ -1051,6 +1051,8 @@ void js::gc::TenuringTracer::relocateDependentStringChars( tenuredDependentStr->relocateNonInlineChars<const CharT*>( tenuredRootBase->nonInlineChars<CharT>(nogc), *offset); tenuredDependentStr->setBase(tenuredRootBase); + MOZ_ASSERT(tenuredRootBase->assertIsValidBase()); + if (tenuredDependentStr->isTenured() && !tenuredRootBase->isTenured()) { runtime()->gc.storeBuffer().putWholeCell(tenuredDependentStr); } @@ -1077,6 +1079,7 @@ void js::gc::TenuringTracer::relocateDependentStringChars( } tenuredDependentStr->setBase(*rootBase); + MOZ_ASSERT((*rootBase)->assertIsValidBase()); return; } @@ -1138,7 +1141,7 @@ void js::gc::TenuringTracer::collectToStringFixedPoint() { bool rootBaseNotYetForwarded = false; JSLinearString* rootBase = nullptr; - if (str->isDependent()) { + if (str->isDependent() && !str->isAtomRef()) { if (str->hasTwoByteChars()) { relocateDependentStringChars<char16_t>( &str->asDependent(), p->savedNurseryBaseOrRelocOverlay(), &offset, @@ -1173,6 +1176,7 @@ void js::gc::TenuringTracer::collectToStringFixedPoint() { } str->setBase(tenuredRootBase); + MOZ_ASSERT(tenuredRootBase->assertIsValidBase()); if (str->isTenured() && !tenuredRootBase->isTenured()) { runtime()->gc.storeBuffer().putWholeCell(str); } diff --git a/js/src/gc/Tracer.h b/js/src/gc/Tracer.h index 52c60cd27f..186a87d9c5 100644 --- a/js/src/gc/Tracer.h +++ b/js/src/gc/Tracer.h @@ -122,10 +122,12 @@ bool TraceWeakMapKeyInternal(JSTracer* trc, Zone* zone, T* thingp, #ifdef DEBUG void AssertRootMarkingPhase(JSTracer* trc); -void AssertShouldMarkInZone(GCMarker* marker, gc::Cell* thing); +template <typename T> +void AssertShouldMarkInZone(GCMarker* marker, T* thing); #else inline void AssertRootMarkingPhase(JSTracer* trc) {} -inline void AssertShouldMarkInZone(GCMarker* marker, gc::Cell* thing) {} +template <typename T> +void AssertShouldMarkInZone(GCMarker* marker, T* thing) {} #endif } // namespace gc diff --git a/js/src/gc/WeakMap-inl.h b/js/src/gc/WeakMap-inl.h index d7b5feb5a6..b1e52aacc8 100644 --- a/js/src/gc/WeakMap-inl.h +++ b/js/src/gc/WeakMap-inl.h @@ -22,6 +22,7 @@ #include "js/TraceKind.h" #include "vm/JSContext.h" +#include "gc/Marking-inl.h" #include "gc/StableCellHasher-inl.h" namespace js { @@ -184,23 +185,24 @@ bool WeakMap<K, V>::markEntry(GCMarker* marker, gc::CellColor mapColor, K& key, } if (populateWeakKeysTable) { + MOZ_ASSERT(trc->weakMapAction() == JS::WeakMapTraceAction::Expand); + // Note that delegateColor >= keyColor because marking a key marks its // delegate, so we only need to check whether keyColor < mapColor to tell // this. - if (keyColor < mapColor) { - MOZ_ASSERT(trc->weakMapAction() == JS::WeakMapTraceAction::Expand); - // The final color of the key is not yet known. Record this weakmap and - // the lookup key in the list of weak keys. If the key has a delegate, - // then the lookup key is the delegate (because marking the key will end - // up marking the delegate and thereby mark the entry.) + // The final color of the key is not yet known. Add an edge to the + // relevant ephemerons table to ensure that the value will be marked if + // the key is marked. If the key has a delegate, also add an edge to + // ensure the key is marked if the delegate is marked. + gc::TenuredCell* tenuredValue = nullptr; if (cellValue && cellValue->isTenured()) { tenuredValue = &cellValue->asTenured(); } - if (!this->addImplicitEdges(AsMarkColor(mapColor), keyCell, delegate, - tenuredValue)) { + if (!this->addEphemeronEdgesForEntry(AsMarkColor(mapColor), keyCell, + delegate, tenuredValue)) { marker->abortLinearWeakMarking(); } } @@ -392,6 +394,24 @@ bool WeakMap<K, V>::checkMarking() const { } #endif +#ifdef JSGC_HASH_TABLE_CHECKS +template <class K, class V> +void WeakMap<K, V>::checkAfterMovingGC() const { + for (Range r = all(); !r.empty(); r.popFront()) { + gc::Cell* key = gc::ToMarkable(r.front().key()); + gc::Cell* value = gc::ToMarkable(r.front().value()); + CheckGCThingAfterMovingGC(key); + if (!allowKeysInOtherZones()) { + Zone* keyZone = key->zoneFromAnyThread(); + MOZ_RELEASE_ASSERT(keyZone == zone() || keyZone->isAtomsZone()); + } + CheckGCThingAfterMovingGC(value, zone()); + auto ptr = lookupUnbarriered(r.front().key()); + MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front()); + } +} +#endif // JSGC_HASH_TABLE_CHECKS + inline HashNumber GetHash(JS::Symbol* sym) { return sym->hash(); } inline bool HashMatch(JS::Symbol* key, JS::Symbol* lookup) { diff --git a/js/src/gc/WeakMap.cpp b/js/src/gc/WeakMap.cpp index 749ea52937..61d6b14e6d 100644 --- a/js/src/gc/WeakMap.cpp +++ b/js/src/gc/WeakMap.cpp @@ -72,42 +72,27 @@ bool WeakMapBase::markMap(MarkColor markColor) { } } -bool WeakMapBase::addImplicitEdges(MarkColor mapColor, Cell* key, - Cell* delegate, TenuredCell* value) { - if (delegate) { - return addEphemeronTableEntries(mapColor, delegate, key, value); +bool WeakMapBase::addEphemeronEdgesForEntry(MarkColor mapColor, Cell* key, + Cell* delegate, + TenuredCell* value) { + if (delegate && !addEphemeronEdge(mapColor, delegate, key)) { + return false; } - if (value) { - return addEphemeronTableEntries(mapColor, key, value, nullptr); + if (value && !addEphemeronEdge(mapColor, key, value)) { + return false; } return true; } -bool WeakMapBase::addEphemeronTableEntries(MarkColor mapColor, gc::Cell* key, - gc::Cell* value1, - gc::Cell* maybeValue2) { - // Add implicit edges from |key| to |value1| and |maybeValue2| if supplied. - // - // Note the key and values do not necessarily correspond to the weak map - // entry's key and value at this point. - - auto& edgeTable = key->zone()->gcEphemeronEdges(key); - auto* ptr = edgeTable.getOrAdd(key); - if (!ptr) { - return false; - } - - if (!ptr->value.emplaceBack(mapColor, value1)) { - return false; - } - - if (maybeValue2 && !ptr->value.emplaceBack(mapColor, maybeValue2)) { - return false; - } +bool WeakMapBase::addEphemeronEdge(MarkColor color, gc::Cell* src, + gc::Cell* dst) { + // Add an implicit edge from |src| to |dst|. - return true; + auto& edgeTable = src->zone()->gcEphemeronEdges(src); + auto* ptr = edgeTable.getOrAdd(src); + return ptr && ptr->value.emplaceBack(color, dst); } #if defined(JS_GC_ZEAL) || defined(DEBUG) @@ -126,6 +111,15 @@ bool WeakMapBase::checkMarkingForZone(JS::Zone* zone) { } #endif +#ifdef JSGC_HASH_TABLE_CHECKS +/* static */ +void WeakMapBase::checkWeakMapsAfterMovingGC(JS::Zone* zone) { + for (WeakMapBase* map : zone->gcWeakMapList()) { + map->checkAfterMovingGC(); + } +} +#endif + bool WeakMapBase::markZoneIteratively(JS::Zone* zone, GCMarker* marker) { bool markedAny = false; for (WeakMapBase* m : zone->gcWeakMapList()) { @@ -228,12 +222,3 @@ void ObjectWeakMap::trace(JSTracer* trc) { map.trace(trc); } size_t ObjectWeakMap::sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) { return map.shallowSizeOfExcludingThis(mallocSizeOf); } - -#ifdef JSGC_HASH_TABLE_CHECKS -void ObjectWeakMap::checkAfterMovingGC() { - for (ObjectValueWeakMap::Range r = map.all(); !r.empty(); r.popFront()) { - CheckGCThingAfterMovingGC(r.front().key().get()); - CheckGCThingAfterMovingGC(&r.front().value().toObject()); - } -} -#endif // JSGC_HASH_TABLE_CHECKS diff --git a/js/src/gc/WeakMap.h b/js/src/gc/WeakMap.h index 959a6fa57e..76c40749d7 100644 --- a/js/src/gc/WeakMap.h +++ b/js/src/gc/WeakMap.h @@ -140,6 +140,10 @@ class WeakMapBase : public mozilla::LinkedListElement<WeakMapBase> { static bool checkMarkingForZone(JS::Zone* zone); #endif +#ifdef JSGC_HASH_TABLE_CHECKS + static void checkWeakMapsAfterMovingGC(JS::Zone* zone); +#endif + protected: // Instance member functions called by the above. Instantiations of WeakMap // override these with definitions appropriate for their Key and Value types. @@ -150,14 +154,14 @@ class WeakMapBase : public mozilla::LinkedListElement<WeakMapBase> { virtual void clearAndCompact() = 0; // We have a key that, if it or its delegate is marked, may lead to a WeakMap - // value getting marked. Insert it or its delegate (if any) into the - // appropriate zone's gcEphemeronEdges or gcNurseryEphemeronEdges. - [[nodiscard]] bool addImplicitEdges(gc::MarkColor mapColor, gc::Cell* key, - gc::Cell* delegate, - gc::TenuredCell* value); - [[nodiscard]] bool addEphemeronTableEntries(gc::MarkColor mapColor, - gc::Cell* key, gc::Cell* value, - gc::Cell* maybeValue); + // value getting marked. Insert the necessary edges into the appropriate + // zone's gcEphemeronEdges or gcNurseryEphemeronEdges tables. + [[nodiscard]] bool addEphemeronEdgesForEntry(gc::MarkColor mapColor, + gc::Cell* key, + gc::Cell* delegate, + gc::TenuredCell* value); + [[nodiscard]] bool addEphemeronEdge(gc::MarkColor color, gc::Cell* src, + gc::Cell* dst); virtual bool markEntries(GCMarker* marker) = 0; @@ -172,6 +176,10 @@ class WeakMapBase : public mozilla::LinkedListElement<WeakMapBase> { gc::Cell*); #endif +#ifdef JSGC_HASH_TABLE_CHECKS + virtual void checkAfterMovingGC() const = 0; +#endif + // Object that this weak map is part of, if any. HeapPtr<JSObject*> memberOf; @@ -329,6 +337,10 @@ class WeakMap #ifdef JS_GC_ZEAL bool checkMarking() const override; #endif + +#ifdef JSGC_HASH_TABLE_CHECKS + void checkAfterMovingGC() const override; +#endif }; using ObjectValueWeakMap = WeakMap<HeapPtr<JSObject*>, HeapPtr<Value>>; @@ -355,10 +367,6 @@ class ObjectWeakMap { } ObjectValueWeakMap& valueMap() { return map; } - -#ifdef JSGC_HASH_TABLE_CHECKS - void checkAfterMovingGC(); -#endif }; // Get the hash from the Symbol. diff --git a/js/src/gc/Zone.cpp b/js/src/gc/Zone.cpp index 6437f6f4c3..13324d7e43 100644 --- a/js/src/gc/Zone.cpp +++ b/js/src/gc/Zone.cpp @@ -27,6 +27,7 @@ #include "gc/GC-inl.h" #include "gc/Marking-inl.h" #include "gc/Nursery-inl.h" +#include "gc/StableCellHasher-inl.h" #include "gc/WeakMap-inl.h" #include "vm/JSScript-inl.h" #include "vm/Realm-inl.h" @@ -367,17 +368,12 @@ void Zone::checkAllCrossCompartmentWrappersAfterMovingGC() { } void Zone::checkStringWrappersAfterMovingGC() { - for (StringWrapperMap::Enum e(crossZoneStringWrappers()); !e.empty(); - e.popFront()) { - // Assert that the postbarriers have worked and that nothing is left in the - // wrapper map that points into the nursery, and that the hash table entries - // are discoverable. - auto key = e.front().key(); - CheckGCThingAfterMovingGC(key.get()); - - auto ptr = crossZoneStringWrappers().lookup(key); - MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &e.front()); - } + CheckTableAfterMovingGC(crossZoneStringWrappers(), [this](const auto& entry) { + JSString* key = entry.key().get(); + CheckGCThingAfterMovingGC(key); // Keys may be in a different zone. + CheckGCThingAfterMovingGC(entry.value().unbarrieredGet(), this); + return key; + }); } #endif @@ -546,25 +542,24 @@ void JS::Zone::traceWeakJitScripts(JSTracer* trc) { void JS::Zone::beforeClearDelegateInternal(JSObject* wrapper, JSObject* delegate) { + // 'delegate' is no longer the delegate of 'wrapper'. MOZ_ASSERT(js::gc::detail::GetDelegate(wrapper) == delegate); MOZ_ASSERT(needsIncrementalBarrier()); MOZ_ASSERT(!RuntimeFromMainThreadIsHeapMajorCollecting(this)); - runtimeFromMainThread()->gc.marker().severWeakDelegate(wrapper, delegate); -} -void JS::Zone::afterAddDelegateInternal(JSObject* wrapper) { - MOZ_ASSERT(!RuntimeFromMainThreadIsHeapMajorCollecting(this)); - JSObject* delegate = js::gc::detail::GetDelegate(wrapper); - if (delegate) { - runtimeFromMainThread()->gc.marker().restoreWeakDelegate(wrapper, delegate); + // If |wrapper| might be a key in a weak map, trigger a barrier to account for + // the removal of the automatically added edge from delegate to wrapper. + if (HasUniqueId(wrapper)) { + PreWriteBarrier(wrapper); } } #ifdef JSGC_HASH_TABLE_CHECKS void JS::Zone::checkUniqueIdTableAfterMovingGC() { - for (auto r = uniqueIds().all(); !r.empty(); r.popFront()) { - js::gc::CheckGCThingAfterMovingGC(r.front().key()); - } + CheckTableAfterMovingGC(uniqueIds(), [this](const auto& entry) { + js::gc::CheckGCThingAfterMovingGC(entry.key(), this); + return entry.key(); + }); } #endif @@ -862,47 +857,42 @@ void Zone::fixupScriptMapsAfterMovingGC(JSTracer* trc) { #ifdef JSGC_HASH_TABLE_CHECKS void Zone::checkScriptMapsAfterMovingGC() { + // |debugScriptMap| is checked automatically because it is s a WeakMap. + if (scriptCountsMap) { - for (auto r = scriptCountsMap->all(); !r.empty(); r.popFront()) { - BaseScript* script = r.front().key(); - MOZ_ASSERT(script->zone() == this); - CheckGCThingAfterMovingGC(script); - auto ptr = scriptCountsMap->lookup(script); - MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front()); - } + CheckTableAfterMovingGC(*scriptCountsMap, [this](const auto& entry) { + BaseScript* script = entry.key(); + CheckGCThingAfterMovingGC(script, this); + return script; + }); } if (scriptLCovMap) { - for (auto r = scriptLCovMap->all(); !r.empty(); r.popFront()) { - BaseScript* script = r.front().key(); - MOZ_ASSERT(script->zone() == this); - CheckGCThingAfterMovingGC(script); - auto ptr = scriptLCovMap->lookup(script); - MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front()); - } + CheckTableAfterMovingGC(*scriptLCovMap, [this](const auto& entry) { + BaseScript* script = entry.key(); + CheckGCThingAfterMovingGC(script, this); + return script; + }); } # ifdef MOZ_VTUNE if (scriptVTuneIdMap) { - for (auto r = scriptVTuneIdMap->all(); !r.empty(); r.popFront()) { - BaseScript* script = r.front().key(); - MOZ_ASSERT(script->zone() == this); - CheckGCThingAfterMovingGC(script); - auto ptr = scriptVTuneIdMap->lookup(script); - MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front()); - } + CheckTableAfterMovingGC(*scriptVTuneIdMap, [this](const auto& entry) { + BaseScript* script = entry.key(); + CheckGCThingAfterMovingGC(script, this); + return script; + }); } # endif // MOZ_VTUNE # ifdef JS_CACHEIR_SPEW if (scriptFinalWarmUpCountMap) { - for (auto r = scriptFinalWarmUpCountMap->all(); !r.empty(); r.popFront()) { - BaseScript* script = r.front().key(); - MOZ_ASSERT(script->zone() == this); - CheckGCThingAfterMovingGC(script); - auto ptr = scriptFinalWarmUpCountMap->lookup(script); - MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front()); - } + CheckTableAfterMovingGC(*scriptFinalWarmUpCountMap, + [this](const auto& entry) { + BaseScript* script = entry.key(); + CheckGCThingAfterMovingGC(script, this); + return script; + }); } # endif // JS_CACHEIR_SPEW } diff --git a/js/src/gc/Zone.h b/js/src/gc/Zone.h index a5ce161cc4..b47d5b186f 100644 --- a/js/src/gc/Zone.h +++ b/js/src/gc/Zone.h @@ -715,14 +715,7 @@ class Zone : public js::ZoneAllocator, public js::gc::GraphNodeBase<JS::Zone> { } } - void afterAddDelegate(JSObject* wrapper) { - if (needsIncrementalBarrier()) { - afterAddDelegateInternal(wrapper); - } - } - void beforeClearDelegateInternal(JSObject* wrapper, JSObject* delegate); - void afterAddDelegateInternal(JSObject* wrapper); js::gc::EphemeronEdgeTable& gcEphemeronEdges() { return gcEphemeronEdges_.ref(); } diff --git a/js/src/jit-test/jit_test.py b/js/src/jit-test/jit_test.py index d9f08a7e15..4a5a0b96da 100755 --- a/js/src/jit-test/jit_test.py +++ b/js/src/jit-test/jit_test.py @@ -368,6 +368,18 @@ def main(argv): op.add_argument( "-z", "--gc-zeal", help="GC zeal mode to use when running the shell" ) + op.add_argument( + "--show-slow", + action="store_true", + help="Show tests taking longer than a minimum time (in seconds).", + ) + op.add_argument( + "--slow-test-threshold", + type=float, + default=5.0, + help="Time in seconds a test can take until it is considered slow " + "(default %(default)s).", + ) options, test_args = op.parse_known_args(argv) js_shell = which(options.js_shell) diff --git a/js/src/jit-test/tests/asm.js/bug1174372.js b/js/src/jit-test/tests/asm.js/bug1174372.js index e7031ea104..d48d2a0533 100644 --- a/js/src/jit-test/tests/asm.js/bug1174372.js +++ b/js/src/jit-test/tests/asm.js/bug1174372.js @@ -1,4 +1,4 @@ -// |jit-test| --no-baseline; --non-writable-jitcode +// |jit-test| --no-baseline (function(stdlib, foreign, heap) { "use asm"; function f() {} diff --git a/js/src/jit-test/tests/basic/bug1892300.js b/js/src/jit-test/tests/basic/bug1892300.js new file mode 100644 index 0000000000..e4c2b1f5b7 --- /dev/null +++ b/js/src/jit-test/tests/basic/bug1892300.js @@ -0,0 +1,4 @@ +newGlobal().eval(`(function () { + enableShellAllocationMetadataBuilder(); + return arguments[Symbol.iterator]; +})();`); diff --git a/js/src/jit-test/tests/basic/bug1894883.js b/js/src/jit-test/tests/basic/bug1894883.js new file mode 100644 index 0000000000..74312c9721 --- /dev/null +++ b/js/src/jit-test/tests/basic/bug1894883.js @@ -0,0 +1,8 @@ +function makeObj() { return { x: 1, y: 2 }; } + +var o1 = makeObj(); +var o2 = makeObj(); + +var snapshot = createShapeSnapshot(o1); +delete o1.x; +checkShapeSnapshot(snapshot, o2); diff --git a/js/src/jit-test/tests/basic/shell-flags-fuzzing.js b/js/src/jit-test/tests/basic/shell-flags-fuzzing.js new file mode 100644 index 0000000000..e6be22cf5a --- /dev/null +++ b/js/src/jit-test/tests/basic/shell-flags-fuzzing.js @@ -0,0 +1,3 @@ +// |jit-test| --fuzzing-safe; --enable-foobarbaz; error:987 +// If --fuzzing-safe is used, unknown shell flags that follow it are ignored. +throw 987; diff --git a/js/src/jit-test/tests/basic/shell-prefs-fuzzing.js b/js/src/jit-test/tests/basic/shell-prefs-fuzzing.js new file mode 100644 index 0000000000..29d3acb347 --- /dev/null +++ b/js/src/jit-test/tests/basic/shell-prefs-fuzzing.js @@ -0,0 +1,4 @@ +// |jit-test| --fuzzing-safe; --setpref=foobar=123; error:987 +// If --fuzzing-safe is used, unknown pref names are ignored, similar to unknown +// shell flags. +throw 987; diff --git a/js/src/jit-test/tests/basic/shell-prefs-no-fuzzing.js b/js/src/jit-test/tests/basic/shell-prefs-no-fuzzing.js new file mode 100644 index 0000000000..a9aa4d5d77 --- /dev/null +++ b/js/src/jit-test/tests/basic/shell-prefs-no-fuzzing.js @@ -0,0 +1,2 @@ +// |jit-test| --setpref=foobar=123; exitstatus: 1 +// If --fuzzing-safe is not used, unknown pref names are reported as an error. diff --git a/js/src/jit-test/tests/basic/testTypeofEq.js b/js/src/jit-test/tests/basic/testTypeofEq.js new file mode 100644 index 0000000000..cf42a7c6c9 --- /dev/null +++ b/js/src/jit-test/tests/basic/testTypeofEq.js @@ -0,0 +1,492 @@ +var testcases = [ + [1, "NUMBER"], + [1.1, "NUMBER"], + [true, "BOOLEAN"], + [false, "BOOLEAN"], + [null, "OBJECT"], + [undefined, "UNDEFINED"], + ["foo", "STRING"], + [Symbol.iterator, "SYMBOL"], + [function f() {}, "FUNCTION"], + [{}, "OBJECT"], +]; + +function runTest(f) { + for (let i = 0; i < 2000; i++) { + let testcase = testcases[i % testcases.length]; + assertEq(f(testcase[0]), testcase[1]); + } +} + +function loose_left(x) { + if (typeof x == "boolean") { + return "BOOLEAN"; + } + if (typeof x == "function") { + return "FUNCTION"; + } + if (typeof x == "number") { + return "NUMBER"; + } + if (typeof x == "object") { + return "OBJECT"; + } + if (typeof x == "string") { + return "STRING"; + } + if (typeof x == "symbol") { + return "SYMBOL"; + } + if (typeof x == "undefined") { + return "UNDEFINED"; + } + return "???"; +} + +function loose_right(x) { + if ("boolean" == typeof x) { + return "BOOLEAN"; + } + if ("function" == typeof x) { + return "FUNCTION"; + } + if ("number" == typeof x) { + return "NUMBER"; + } + if ("object" == typeof x) { + return "OBJECT"; + } + if ("string" == typeof x) { + return "STRING"; + } + if ("symbol" == typeof x) { + return "SYMBOL"; + } + if ("undefined" == typeof x) { + return "UNDEFINED"; + } + return "???"; +} + +function strict_left(x) { + if (typeof x === "boolean") { + return "BOOLEAN"; + } + if (typeof x === "function") { + return "FUNCTION"; + } + if (typeof x === "number") { + return "NUMBER"; + } + if (typeof x === "object") { + return "OBJECT"; + } + if (typeof x === "string") { + return "STRING"; + } + if (typeof x === "symbol") { + return "SYMBOL"; + } + if (typeof x === "undefined") { + return "UNDEFINED"; + } + return "???"; +} + +function strict_right(x) { + if ("boolean" === typeof x) { + return "BOOLEAN"; + } + if ("function" === typeof x) { + return "FUNCTION"; + } + if ("number" === typeof x) { + return "NUMBER"; + } + if ("object" === typeof x) { + return "OBJECT"; + } + if ("string" === typeof x) { + return "STRING"; + } + if ("symbol" === typeof x) { + return "SYMBOL"; + } + if ("undefined" === typeof x) { + return "UNDEFINED"; + } + return "???"; +} + +function loose_left_ne(x) { + if (typeof x != "boolean") { + } else { + return "BOOLEAN"; + } + if (typeof x != "function") { + } else { + return "FUNCTION"; + } + if (typeof x != "number") { + } else { + return "NUMBER"; + } + if (typeof x != "object") { + } else { + return "OBJECT"; + } + if (typeof x != "string") { + } else { + return "STRING"; + } + if (typeof x != "symbol") { + } else { + return "SYMBOL"; + } + if (typeof x != "undefined") { + } else { + return "UNDEFINED"; + } + return "???"; +} + +function loose_right_ne(x) { + if ("boolean" != typeof x) { + } else { + return "BOOLEAN"; + } + if ("function" != typeof x) { + } else { + return "FUNCTION"; + } + if ("number" != typeof x) { + } else { + return "NUMBER"; + } + if ("object" != typeof x) { + } else { + return "OBJECT"; + } + if ("string" != typeof x) { + } else { + return "STRING"; + } + if ("symbol" != typeof x) { + } else { + return "SYMBOL"; + } + if ("undefined" != typeof x) { + } else { + return "UNDEFINED"; + } + return "???"; +} + +function strict_left_ne(x) { + if (typeof x !== "boolean") { + } else { + return "BOOLEAN"; + } + if (typeof x !== "function") { + } else { + return "FUNCTION"; + } + if (typeof x !== "number") { + } else { + return "NUMBER"; + } + if (typeof x !== "object") { + } else { + return "OBJECT"; + } + if (typeof x !== "string") { + } else { + return "STRING"; + } + if (typeof x !== "symbol") { + } else { + return "SYMBOL"; + } + if (typeof x !== "undefined") { + } else { + return "UNDEFINED"; + } + return "???"; +} + +function strict_right_ne(x) { + if ("boolean" !== typeof x) { + } else { + return "BOOLEAN"; + } + if ("function" !== typeof x) { + } else { + return "FUNCTION"; + } + if ("number" !== typeof x) { + } else { + return "NUMBER"; + } + if ("object" !== typeof x) { + } else { + return "OBJECT"; + } + if ("string" !== typeof x) { + } else { + return "STRING"; + } + if ("symbol" !== typeof x) { + } else { + return "SYMBOL"; + } + if ("undefined" !== typeof x) { + } else { + return "UNDEFINED"; + } + return "???"; +} + +function loose_left_expr(x) { + if (typeof (0, x) == "boolean") { + return "BOOLEAN"; + } + if (typeof (0, x) == "function") { + return "FUNCTION"; + } + if (typeof (0, x) == "number") { + return "NUMBER"; + } + if (typeof (0, x) == "object") { + return "OBJECT"; + } + if (typeof (0, x) == "string") { + return "STRING"; + } + if (typeof (0, x) == "symbol") { + return "SYMBOL"; + } + if (typeof (0, x) == "undefined") { + return "UNDEFINED"; + } + return "???"; +} + +function loose_right_expr(x) { + if ("boolean" == typeof (0, x)) { + return "BOOLEAN"; + } + if ("function" == typeof (0, x)) { + return "FUNCTION"; + } + if ("number" == typeof (0, x)) { + return "NUMBER"; + } + if ("object" == typeof (0, x)) { + return "OBJECT"; + } + if ("string" == typeof (0, x)) { + return "STRING"; + } + if ("symbol" == typeof (0, x)) { + return "SYMBOL"; + } + if ("undefined" == typeof (0, x)) { + return "UNDEFINED"; + } + return "???"; +} + +function strict_left_expr(x) { + if (typeof (0, x) === "boolean") { + return "BOOLEAN"; + } + if (typeof (0, x) === "function") { + return "FUNCTION"; + } + if (typeof (0, x) === "number") { + return "NUMBER"; + } + if (typeof (0, x) === "object") { + return "OBJECT"; + } + if (typeof (0, x) === "string") { + return "STRING"; + } + if (typeof (0, x) === "symbol") { + return "SYMBOL"; + } + if (typeof (0, x) === "undefined") { + return "UNDEFINED"; + } + return "???"; +} + +function strict_right_expr(x) { + if ("boolean" === typeof (0, x)) { + return "BOOLEAN"; + } + if ("function" === typeof (0, x)) { + return "FUNCTION"; + } + if ("number" === typeof (0, x)) { + return "NUMBER"; + } + if ("object" === typeof (0, x)) { + return "OBJECT"; + } + if ("string" === typeof (0, x)) { + return "STRING"; + } + if ("symbol" === typeof (0, x)) { + return "SYMBOL"; + } + if ("undefined" === typeof (0, x)) { + return "UNDEFINED"; + } + return "???"; +} + +function loose_left_ne_expr(x) { + if (typeof (0, x) != "boolean") { + } else { + return "BOOLEAN"; + } + if (typeof (0, x) != "function") { + } else { + return "FUNCTION"; + } + if (typeof (0, x) != "number") { + } else { + return "NUMBER"; + } + if (typeof (0, x) != "object") { + } else { + return "OBJECT"; + } + if (typeof (0, x) != "string") { + } else { + return "STRING"; + } + if (typeof (0, x) != "symbol") { + } else { + return "SYMBOL"; + } + if (typeof (0, x) != "undefined") { + } else { + return "UNDEFINED"; + } + return "???"; +} + +function loose_right_ne_expr(x) { + if ("boolean" != typeof (0, x)) { + } else { + return "BOOLEAN"; + } + if ("function" != typeof (0, x)) { + } else { + return "FUNCTION"; + } + if ("number" != typeof (0, x)) { + } else { + return "NUMBER"; + } + if ("object" != typeof (0, x)) { + } else { + return "OBJECT"; + } + if ("string" != typeof (0, x)) { + } else { + return "STRING"; + } + if ("symbol" != typeof (0, x)) { + } else { + return "SYMBOL"; + } + if ("undefined" != typeof (0, x)) { + } else { + return "UNDEFINED"; + } + return "???"; +} + +function strict_left_ne_expr(x) { + if (typeof (0, x) !== "boolean") { + } else { + return "BOOLEAN"; + } + if (typeof (0, x) !== "function") { + } else { + return "FUNCTION"; + } + if (typeof (0, x) !== "number") { + } else { + return "NUMBER"; + } + if (typeof (0, x) !== "object") { + } else { + return "OBJECT"; + } + if (typeof (0, x) !== "string") { + } else { + return "STRING"; + } + if (typeof (0, x) !== "symbol") { + } else { + return "SYMBOL"; + } + if (typeof (0, x) !== "undefined") { + } else { + return "UNDEFINED"; + } + return "???"; +} + +function strict_right_ne_expr(x) { + if ("boolean" !== typeof (0, x)) { + } else { + return "BOOLEAN"; + } + if ("function" !== typeof (0, x)) { + } else { + return "FUNCTION"; + } + if ("number" !== typeof (0, x)) { + } else { + return "NUMBER"; + } + if ("object" !== typeof (0, x)) { + } else { + return "OBJECT"; + } + if ("string" !== typeof (0, x)) { + } else { + return "STRING"; + } + if ("symbol" !== typeof (0, x)) { + } else { + return "SYMBOL"; + } + if ("undefined" !== typeof (0, x)) { + } else { + return "UNDEFINED"; + } + return "???"; +} + +runTest(loose_left); +runTest(loose_right); +runTest(strict_left); +runTest(strict_right); +runTest(loose_left_ne); +runTest(loose_right_ne); +runTest(strict_left_ne); +runTest(strict_right_ne); +runTest(loose_left_expr); +runTest(loose_right_expr); +runTest(strict_left_expr); +runTest(strict_right_expr); +runTest(loose_left_ne_expr); +runTest(loose_right_ne_expr); +runTest(strict_left_ne_expr); +runTest(strict_right_ne_expr); diff --git a/js/src/jit-test/tests/bug1894604.js b/js/src/jit-test/tests/bug1894604.js new file mode 100644 index 0000000000..5c14789eef --- /dev/null +++ b/js/src/jit-test/tests/bug1894604.js @@ -0,0 +1,12 @@ +class C { + set f(val) { + this.f = val; + super.g++; + } +} + +let c = new C(); +gczeal(14,50); +try { + c.f = 1; +} catch {} diff --git a/js/src/jit-test/tests/debug/Debugger-dead-global.js b/js/src/jit-test/tests/debug/Debugger-dead-global.js new file mode 100644 index 0000000000..abcb370be0 --- /dev/null +++ b/js/src/jit-test/tests/debug/Debugger-dead-global.js @@ -0,0 +1,26 @@ +var g1 = newGlobal({newCompartment: true}); + +const dbg = new Debugger(); + +function assertThrowsDeadWrapper(f) { + let caught = false; + try { + f(); + } catch (e) { + assertEq(e.message, "can't access dead object"); + caught = true; + } + assertEq(caught, true); +} + +nukeAllCCWs(); + +// Debugger methods should throw explicit error for dead global object. +assertThrowsDeadWrapper(() => dbg.addDebuggee(g1)); +assertThrowsDeadWrapper(() => dbg.removeDebuggee(g1)); +assertThrowsDeadWrapper(() => dbg.findScripts({global: g1})); +assertThrowsDeadWrapper(() => dbg.makeGlobalObjectReference(g1)); +assertThrowsDeadWrapper(() => dbg.enableAsyncStack(g1)); +assertThrowsDeadWrapper(() => dbg.disableAsyncStack(g1)); +assertThrowsDeadWrapper(() => dbg.enableUnlimitedStacksCapturing(g1)); +assertThrowsDeadWrapper(() => dbg.disableUnlimitedStacksCapturing(g1)); diff --git a/js/src/jit-test/tests/debug/Debugger-shouldAvoidSideEffects.js b/js/src/jit-test/tests/debug/Debugger-shouldAvoidSideEffects.js new file mode 100644 index 0000000000..62d6693d4e --- /dev/null +++ b/js/src/jit-test/tests/debug/Debugger-shouldAvoidSideEffects.js @@ -0,0 +1,57 @@ +// Test shouldAvoidSideEffects flag. + +const g = newGlobal({newCompartment: true}); +const dbg = Debugger(g); +const gdbg = dbg.addDebuggee(g); + +gdbg.executeInGlobal(` +var obj, result, reachedNextLine; +`); + +dbg.shouldAvoidSideEffects = false; +assertEq(dbg.shouldAvoidSideEffects, false); + +let result = gdbg.executeInGlobal(` +result = undefined; +reachedNextLine = false; + +obj = createSideEffectfulResolveObject(); +result = obj.test; +reachedNextLine = true; +"finished"; +`); +assertEq(g.result, 42); +assertEq(g.reachedNextLine, true); +assertEq(result.return, "finished"); + +dbg.shouldAvoidSideEffects = true; +assertEq(dbg.shouldAvoidSideEffects, true); + +result = gdbg.executeInGlobal(` +result = undefined; +reachedNextLine = false; + +obj = createSideEffectfulResolveObject(); +result = obj.test; +reachedNextLine = true; +"finished"; +`); +assertEq(g.result, undefined); +assertEq(g.reachedNextLine, false); +assertEq(result, null); + +// Resolve after abort. +dbg.shouldAvoidSideEffects = false; +assertEq(dbg.shouldAvoidSideEffects, false); + +result = gdbg.executeInGlobal(` +result = undefined; +reachedNextLine = false; + +result = obj.test; +reachedNextLine = true; +"finished"; +`); +assertEq(g.result, 42); +assertEq(g.reachedNextLine, true); +assertEq(result.return, "finished"); diff --git a/js/src/jit-test/tests/debug/bug1891662.js b/js/src/jit-test/tests/debug/bug1891662.js new file mode 100644 index 0000000000..0a68f33d0c --- /dev/null +++ b/js/src/jit-test/tests/debug/bug1891662.js @@ -0,0 +1,24 @@ +// |jit-test| --baseline-eager + +var src = ""; +for (var i = 0; i < 100; i++) { + src += "function foo" + i + "() { foo" + (i+1) + "(); }" +} +eval(src); + +function foo100() { + let g = newGlobal({newCompartment: true}); + let d = new g.Debugger(this); + + // When we set this debugger hook, we will trigger 100 + // baseline recompilations. We want an OOM to occur + // during one of those recompilations. We allocate + // about 400 times before starting recompilation, and + // about 30000 times total. This number is picked to + // leave a healthy margin on either side. + oomAtAllocation(5000); + d.onEnterFrame = () => {} +} +try { + foo0(); +} catch {} diff --git a/js/src/jit-test/tests/debug/bug1893554.js b/js/src/jit-test/tests/debug/bug1893554.js new file mode 100644 index 0000000000..dfe76c8b41 --- /dev/null +++ b/js/src/jit-test/tests/debug/bug1893554.js @@ -0,0 +1,31 @@ +let g = newGlobal({ newCompartment: true }); +g.parent = this; +g.eval( + "(" + + function () { + Debugger(parent).onExceptionUnwind = function (frame) { + frame.older; + }; + } + + ")()" +); +function f(x, y) { + try { + Object.setPrototypeOf( + y, + new Proxy(Object.getPrototypeOf(y), { + get(a, b, c) { + return undefined; + }, + }) + ); + } catch (e) {} +} +function h(x, y) { + f(x, y); +} +oomTest(function () { + h("", undefined); + h("", ""); + "".replaceAll(); +}); diff --git a/js/src/jit-test/tests/environments/1890252.js b/js/src/jit-test/tests/environments/1890252.js new file mode 100644 index 0000000000..b44ca2253f --- /dev/null +++ b/js/src/jit-test/tests/environments/1890252.js @@ -0,0 +1,15 @@ +// |jit-test| --more-compartments + +var threw = false; +try { + const v2 = evalcx("lazy"); + const o4 = { + "global": v2, + }; + o4.envChainObject = v2; + evaluate("{ let eval = parseInt; eval()}", o4); +} catch (e) { + threw = true; + assertEq(e.toString().includes("envChainObject"), true); +} +assertEq(threw, true); diff --git a/js/src/jit-test/tests/gc/bug-1651001-1.js b/js/src/jit-test/tests/gc/bug-1651001-1.js new file mode 100644 index 0000000000..889ab4a5b9 --- /dev/null +++ b/js/src/jit-test/tests/gc/bug-1651001-1.js @@ -0,0 +1,9 @@ +gczeal(0); +try { + v2 = (x = []); + g1 = newGlobal({ sameZoneAs: x }); + enableShellAllocationMetadataBuilder(); + g1.Uint8ClampedArray.prototype = b1; +} catch(e) {} +startgc(9); +recomputeWrappers(); diff --git a/js/src/jit-test/tests/gc/bug-1651001-2.js b/js/src/jit-test/tests/gc/bug-1651001-2.js new file mode 100644 index 0000000000..ad093ddb22 --- /dev/null +++ b/js/src/jit-test/tests/gc/bug-1651001-2.js @@ -0,0 +1,6 @@ +gczeal(0); +g1 = newGlobal({ sameZoneAs: this }); +enableShellAllocationMetadataBuilder(); +g1.Object; +startgc(1); +recomputeWrappers(); diff --git a/js/src/jit-test/tests/gc/bug-1890670.js b/js/src/jit-test/tests/gc/bug-1890670.js new file mode 100644 index 0000000000..e73c5a99e6 --- /dev/null +++ b/js/src/jit-test/tests/gc/bug-1890670.js @@ -0,0 +1,12 @@ +// |jit-test| --enable-symbols-as-weakmap-keys; skip-if: getBuildConfiguration("release_or_beta") + +gczeal(0); +let wm = new WeakMap(); +let s = Symbol(); +wm.set(s, new WeakMap()); +let ss = Symbol(); +wm.get(s).set(this, ss); +let wm2 = new WeakMap(); +wm2.set(ss, "test"); +ss = null; +gc(); diff --git a/js/src/jit-test/tests/gc/bug-1892564.js b/js/src/jit-test/tests/gc/bug-1892564.js new file mode 100644 index 0000000000..c834615b91 --- /dev/null +++ b/js/src/jit-test/tests/gc/bug-1892564.js @@ -0,0 +1,50 @@ +try { evalInWorker(` +gczeal(0); +try { + Object.defineProperty(this, "x", { + value:{ + parseInt: parseInt, + } + }); +} catch(exc) {} +function dummyAssertCallFunction(f) {} +try { evaluate(\` +(function(global) { + var ObjectCreate = global.Object.create; + var ObjectDefineProperty = global.Object.defineProperty; + function ArrayPush(arr, val) { + var desc = ObjectCreate(null); + desc.value = val; + desc.enumerable = true; + desc.configurable = true; + desc.writable = true; + ObjectDefineProperty(arr, arr.length, desc); + } + var testCasesArray = []; + function TestCase(d, e, a, r) { + this.description = d; + ArrayPush(testCasesArray, this); + } + global.TestCase = TestCase; +})(this); +(function f42(x99) { + new TestCase(new ArrayBuffer()); + f42(x99) + function t9() {} +})(); +\`); } catch(exc) {} +try { evaluate(\` +gczeal(14); +(function(global) { + global.makeIterator = function makeIterator(overrides) { + global.assertThrowsValue = function assertThrowsValue(f, val, msg) {}; + } + global.assertDeepEq = (function(){ + var call = Function.prototype.call, + Symbol_description = call.bind(Object.getOwnPropertyDescriptor(Symbol.prototype, "description").get), + Map_has = call.bind(Map.prototype.has), + Object_getOwnPropertyNames = Object.getOwnPropertyNames; + })(); +})(this); +\`); } catch(exc) {} +`); throw "x"; } catch(exc) {} diff --git a/js/src/jit-test/tests/gc/bug-1893984.js b/js/src/jit-test/tests/gc/bug-1893984.js new file mode 100644 index 0000000000..743be86f4e --- /dev/null +++ b/js/src/jit-test/tests/gc/bug-1893984.js @@ -0,0 +1,3 @@ +gczeal(4, 0) +a = /b/ +Object.defineProperty(a, this + this, {}) diff --git a/js/src/jit-test/tests/gc/bug-1894025.js b/js/src/jit-test/tests/gc/bug-1894025.js new file mode 100644 index 0000000000..06ebd8ceb6 --- /dev/null +++ b/js/src/jit-test/tests/gc/bug-1894025.js @@ -0,0 +1,15 @@ +gczeal(0); + +var ex; +function makeExtensibleStrFrom() { + strstrstr; +} +a = makeExtensibleStrFrom; +b = newDependentString(a, 0, 50, { tenured: false }) +var exc; +try { + c = newDependentString(b, 0, { tenured: true }) +} catch (e) { + exc = e; +} +assertEq(Boolean(exc), true, "b and c required to be in different heaps but are the same"); diff --git a/js/src/jit-test/tests/gc/bug-1894442.js b/js/src/jit-test/tests/gc/bug-1894442.js new file mode 100644 index 0000000000..93bedb74de --- /dev/null +++ b/js/src/jit-test/tests/gc/bug-1894442.js @@ -0,0 +1,6 @@ +// |jit-test| --enable-symbols-as-weakmap-keys; skip-if: helperThreadCount() === 0 || getBuildConfiguration("release_or_beta") +evalInWorker(` + a = new WeakSet + a.add(Symbol.hasInstance) + gczeal(14)(0 .b) +`) diff --git a/js/src/jit-test/tests/gc/bug-1894547.js b/js/src/jit-test/tests/gc/bug-1894547.js new file mode 100644 index 0000000000..78a3cff036 --- /dev/null +++ b/js/src/jit-test/tests/gc/bug-1894547.js @@ -0,0 +1,14 @@ +// |jit-test| --enable-symbols-as-weakmap-keys; skip-if: getBuildConfiguration("release_or_beta") + +gczeal(0); +let wm = new WeakMap(); +let s = {}; +wm.set(s, new WeakMap()); +let ss = {x: Symbol()}; +wm.get(s).set(this, ss); +let wm2 = new WeakMap(); +wm2.set(ss, "test"); +ss = null; + +// Collect only this zone and not the zone containing the symbol. +gc({}); diff --git a/js/src/jit-test/tests/gc/bug-1895842.js b/js/src/jit-test/tests/gc/bug-1895842.js new file mode 100644 index 0000000000..3f41d10020 --- /dev/null +++ b/js/src/jit-test/tests/gc/bug-1895842.js @@ -0,0 +1,5 @@ +// |jit-test| skip-if: helperThreadCount() === 0 +evalInWorker(` + enqueueMark("drain") + startgc() +`) diff --git a/js/src/jit-test/tests/gc/marking-thread-count.js b/js/src/jit-test/tests/gc/marking-thread-count.js index 5b90e14186..3c2f7ed30d 100644 --- a/js/src/jit-test/tests/gc/marking-thread-count.js +++ b/js/src/jit-test/tests/gc/marking-thread-count.js @@ -1,12 +1,18 @@ // |jit-test| skip-if: helperThreadCount() === 0 -let initialGCHelperThreadCount = gcparam('helperThreadCount'); +// Allow maximum number of helper threads +gcparam('maxHelperThreads', 8); +gcparam('helperThreadRatio', 100); + +check(); -let prevHelperThreadCount = helperThreadCount(); for (let i of [0, 1, 4, 8, 4, 0]) { - gcparam('markingThreadCount', i); - assertEq(gcparam('markingThreadCount'), i); - assertEq(gcparam('helperThreadCount'), initialGCHelperThreadCount); - assertEq(true, helperThreadCount() >= Math.max(prevHelperThreadCount, i)); - prevHelperThreadCount = helperThreadCount(); + gcparam('maxMarkingThreads', i); + assertEq(gcparam('maxMarkingThreads'), i); + check(); +} + +function check() { + assertEq(gcparam('markingThreadCount') <= gcparam('maxMarkingThreads'), true); + assertEq(gcparam('markingThreadCount') < gcparam('helperThreadCount'), true); } diff --git a/js/src/jit-test/tests/ion/bug1608256.js b/js/src/jit-test/tests/ion/bug1608256.js index 4445a41157..0929f9d3f6 100644 --- a/js/src/jit-test/tests/ion/bug1608256.js +++ b/js/src/jit-test/tests/ion/bug1608256.js @@ -1,4 +1,4 @@ -// |jit-test| --no-threads; --baseline-warmup-threshold=1; --ion-full-warmup-threshold=1 +// |jit-test| --no-threads; --baseline-warmup-threshold=1 function g(obj, v) { obj.prop = v; } diff --git a/js/src/jit-test/tests/ion/bug1894456-1.js b/js/src/jit-test/tests/ion/bug1894456-1.js new file mode 100644 index 0000000000..2b8f3e0afe --- /dev/null +++ b/js/src/jit-test/tests/ion/bug1894456-1.js @@ -0,0 +1,6 @@ +var f32 = new Float32Array(1); +for (var i = 0; i < 50; i++) { + if (f32[0] != null) { + } + try {} catch {} +} diff --git a/js/src/jit-test/tests/ion/bug1894456-2.js b/js/src/jit-test/tests/ion/bug1894456-2.js new file mode 100644 index 0000000000..20b019738d --- /dev/null +++ b/js/src/jit-test/tests/ion/bug1894456-2.js @@ -0,0 +1,6 @@ +var f32 = new Float32Array(1); +for (var i = 0; i < 50; i++) { + if (f32[0] != undefined) { + } + try {} catch {} +} diff --git a/js/src/jit-test/tests/ion/depended-on-bit-1.js b/js/src/jit-test/tests/ion/depended-on-bit-1.js new file mode 100644 index 0000000000..418e7accaa --- /dev/null +++ b/js/src/jit-test/tests/ion/depended-on-bit-1.js @@ -0,0 +1,52 @@ +var dependedOnStrings = []; + +var length = 50; + +function getSubstr(src, i) { + return src.substring(i, i + 50); +} + +function checkProp(o, prop) { + return o[prop]; +} + +var substrs = []; +var objs = []; + +with({}) +for (var i = 0; i < 1000; i++) { + var pieces = []; + for (var j = 0; j < 99; j++) { + pieces.push("a"); + pieces.push(Math.floor(Math.random() * 10)); + } + dependedOnStrings.push(pieces.join("")); +} + +for (var i = 0; i < 1000; i++) { + // Create a bunch of substrings depending on strings in dependedOnStrings + substrs.push(getSubstr(dependedOnStrings[i], (i * 2) % 50)); + objs.push({}); +} + +for (var i = 0; i < 1000; i++) { + // Use the depended on strings as keys to get them replaced with + // JSAtomRefStrings + checkProp(objs[i], dependedOnStrings[i]); +} + +// Use a bunch of memory to try to ensure that we overwrite the buffers +// that could have erroneously been freed +for (var i = 0; i < 1000; i++) { + var pieces = []; + for (var j = 0; j < 99; j++) { + pieces.push("b"); + pieces.push(Math.floor(Math.random() * 10)); + } + dependedOnStrings.push(pieces.join("")); +} + +// Ensure the buffers were not in fact freed +for (var i = 0; i < 1000; i++) { + assertEq(substrs[i].startsWith("a"), true); +} diff --git a/js/src/jit-test/tests/ion/depended-on-bit-2.js b/js/src/jit-test/tests/ion/depended-on-bit-2.js new file mode 100644 index 0000000000..d4090df949 --- /dev/null +++ b/js/src/jit-test/tests/ion/depended-on-bit-2.js @@ -0,0 +1,56 @@ +var dependedOnStrings = []; + +var length = 50; +var reg = /q[a0-9]{50}/; + +function getSubstr(src, i) { + return reg.exec(src)[0]; +} + +function checkProp(o, prop) { + return o[prop]; +} + +var substrs = []; +var objs = []; + +with({}) +for (var i = 0; i < 1000; i++) { + var pieces = []; + for (var j = 0; j < 99; j++) { + if (j == (i * 2) % 50) { + pieces.push("q"); + } + pieces.push("a"); + pieces.push(Math.floor(Math.random() * 10)); + } + dependedOnStrings.push(pieces.join("")); +} + +for (var i = 0; i < 1000; i++) { + // Create a bunch of substrings depending on strings in dependedOnStrings + substrs.push(getSubstr(dependedOnStrings[i], (i * 2) % 50)); + objs.push({}); +} + +for (var i = 0; i < 1000; i++) { + // Use the depended on strings as keys to get them replaced with + // JSAtomRefStrings + checkProp(objs[i], dependedOnStrings[i]); +} + +// Use a bunch of memory to try to ensure that we overwrite the buffers +// that could have erroneously been freed +for (var i = 0; i < 1000; i++) { + var pieces = []; + for (var j = 0; j < 99; j++) { + pieces.push("b"); + pieces.push(Math.floor(Math.random() * 10)); + } + dependedOnStrings.push(pieces.join("")); +} + +// Ensure the buffers were not in fact freed +for (var i = 0; i < 1000; i++) { + assertEq(substrs[i].startsWith("qa"), true); +} diff --git a/js/src/jit-test/tests/modules/dynamic-import-unsupported-attribute.js b/js/src/jit-test/tests/modules/dynamic-import-unsupported-attribute.js new file mode 100644 index 0000000000..2b6ccb80bf --- /dev/null +++ b/js/src/jit-test/tests/modules/dynamic-import-unsupported-attribute.js @@ -0,0 +1,29 @@ +// |jit-test| --enable-import-attributes + +async function test() { + try { + await import('./not-a-real-file.json', {with:{'unsupportedAttributeKey': 'json'}}); + throw new Error("unreachable"); + } catch (error) { + assertEq(error instanceof TypeError, true); + assertEq(error.message, "Unsupported import attribute: unsupportedAttributeKey"); + } + + try { + await import('./not-a-real-file.json', {with:{'unsupportedAttributeKey': 'json', type: 'json'}}); + throw new Error("unreachable"); + } catch (error) { + assertEq(error instanceof TypeError, true); + assertEq(error.message, "Unsupported import attribute: unsupportedAttributeKey"); + } + + try { + await import('./not-a-real-file.json', {with:{type: 'json', 'unsupportedAttributeKey': 'json'}}); + throw new Error("unreachable"); + } catch (error) { + assertEq(error instanceof TypeError, true); + assertEq(error.message, "Unsupported import attribute: unsupportedAttributeKey"); + } +} + +test();
\ No newline at end of file diff --git a/js/src/jit-test/tests/modules/failure-on-resume.js b/js/src/jit-test/tests/modules/failure-on-resume.js new file mode 100644 index 0000000000..d0e716b0bb --- /dev/null +++ b/js/src/jit-test/tests/modules/failure-on-resume.js @@ -0,0 +1,79 @@ +const dbgGlobal = newGlobal({ newCompartment: true }); +dbgGlobal.parent = this; +dbgGlobal.eval(` +var entered = 0; +var forceReturn = false; +Debugger(parent).onEnterFrame = function () { + entered++; + if (forceReturn) { + return { return: "force return" }; + } + return undefined; +}; +`); + +{ + function* f1() { yield 10; }; + + dbgGlobal.entered = 0; + let g = f1(); + assertEq(dbgGlobal.entered, 1); + dbgGlobal.forceReturn = true; + let ret = g.next(); + dbgGlobal.forceReturn = false; + assertEq(dbgGlobal.entered, 2); + + assertEq(ret.value, "force return"); +} + +{ + async function f2() { await {}; } + + dbgGlobal.entered = 0; + let p = f2(); + assertEq(dbgGlobal.entered, 1); + dbgGlobal.forceReturn = true; + drainJobQueue(); + dbgGlobal.forceReturn = false; + assertEq(dbgGlobal.entered, 2); + + let ret = null; + p.then(x => ret = x); + drainJobQueue(); + assertEq(ret, "force return"); +} + +{ + async function* f3() { await {}; } + + dbgGlobal.entered = 0; + let g = f3(); + assertEq(dbgGlobal.entered, 1); + dbgGlobal.forceReturn = true; + let p = g.next(); + dbgGlobal.forceReturn = false; + assertEq(dbgGlobal.entered, 2); + + let ret = null; + p.then(v => ret = v); + drainJobQueue(); + assertEq(ret.value, "force return"); +} + +{ + let m = registerModule("1", parseModule("await {};")); + moduleLink(m); + + dbgGlobal.entered = 0; + let p = moduleEvaluate(m); + assertEq(dbgGlobal.entered, 1); + dbgGlobal.forceReturn = true; + drainJobQueue(); + dbgGlobal.forceReturn = false; + assertEq(dbgGlobal.entered, 2); + + let ret = null; + p.then(x => ret = x); + drainJobQueue(); + assertEq(ret, undefined); +} diff --git a/js/src/jit-test/tests/modules/import-entries.js b/js/src/jit-test/tests/modules/import-entries.js index e20d4e119b..ed668f0069 100644 --- a/js/src/jit-test/tests/modules/import-entries.js +++ b/js/src/jit-test/tests/modules/import-entries.js @@ -1,21 +1,24 @@ -// |jit-test| --enable-import-assertions +// |jit-test| --enable-import-attributes // Test importEntries property -function assertionEq(actual, expected) { - var actualAssertions = actual['assertions']; - var expectedAssertions = expected['assertions']; +function attributeEq(actual, expected) { + var actualAttributes = actual['attributes']; + var expectedAttributes = expected['attributes']; - if(actualAssertions === null) { - return expectedAssertions === actualAssertions + if(actualAttributes === null) { + return expectedAttributes === actualAttributes } - if(actualAssertions.length !== expectedAssertions.length) { + if(actualAttributes.length !== expectedAttributes.length) { return false; } - for (var i = 0; i < expected.length; i++) { - if(expected[i].type !== actual[i].type) { + for (var i = 0; i < expectedAttributes.length; i++) { + if ( + expectedAttributes[i]['key'] !== actualAttributes[i]['key'] || + expectedAttributes[i]['value'] !== actualAttributes[i]['value'] + ) { return false; } } @@ -28,7 +31,7 @@ function importEntryEq(a, b) { a['importName'] === b['importName'] && a['localName'] === b['localName']; - return r1 && assertionEq(a['moduleRequest'], b['moduleRequest']); + return r1 && attributeEq(a['moduleRequest'], b['moduleRequest']); } function findImportEntry(array, target) @@ -54,34 +57,34 @@ function testImportEntries(source, expected) { testImportEntries('', []); testImportEntries('import v from "mod";', - [{moduleRequest: {specifier: 'mod', assertions: null}, importName: 'default', localName: 'v'}]); + [{moduleRequest: {specifier: 'mod', attributes: null}, importName: 'default', localName: 'v'}]); testImportEntries('import * as ns from "mod";', - [{moduleRequest: {specifier: 'mod', assertions: null}, importName: null, localName: 'ns'}]); + [{moduleRequest: {specifier: 'mod', attributes: null}, importName: null, localName: 'ns'}]); testImportEntries('import {x} from "mod";', - [{moduleRequest: {specifier: 'mod', assertions: null}, importName: 'x', localName: 'x'}]); + [{moduleRequest: {specifier: 'mod', attributes: null}, importName: 'x', localName: 'x'}]); testImportEntries('import {x as v} from "mod";', - [{moduleRequest: {specifier: 'mod', assertions: null}, importName: 'x', localName: 'v'}]); + [{moduleRequest: {specifier: 'mod', attributes: null}, importName: 'x', localName: 'v'}]); testImportEntries('import "mod";', []); testImportEntries('import {x} from "a"; import {y} from "b";', - [{moduleRequest: {specifier: 'a', assertions: null}, importName: 'x', localName: 'x'}, - {moduleRequest: {specifier: 'b', assertions: null}, importName: 'y', localName: 'y'}]); + [{moduleRequest: {specifier: 'a', attributes: null}, importName: 'x', localName: 'x'}, + {moduleRequest: {specifier: 'b', attributes: null}, importName: 'y', localName: 'y'}]); if (getRealmConfiguration("importAttributes")) { - testImportEntries('import v from "mod" assert {};', - [{moduleRequest: {specifier: 'mod', assertions: null}, importName: 'default', localName: 'v'}]); + testImportEntries('import v from "mod" with {};', + [{moduleRequest: {specifier: 'mod', attributes: null}, importName: 'default', localName: 'v'}]); - testImportEntries('import v from "mod" assert { type: "js"};', - [{moduleRequest: {specifier: 'mod', assertions: [{ type: 'js'}]}, importName: 'default', localName: 'v'}]); + testImportEntries('import v from "mod" with { type: "js"};', + [{moduleRequest: {specifier: 'mod', attributes: [{ key: 'type', value: 'js'}]}, importName: 'default', localName: 'v'}]); - testImportEntries('import {x} from "mod" assert { type: "js"};', - [{moduleRequest: {specifier: 'mod', assertions: [{ type: 'js'}]}, importName: 'x', localName: 'x'}]); + testImportEntries('import {x} from "mod" with { type: "js"};', + [{moduleRequest: {specifier: 'mod', attributes: [{ key: 'type', value: 'js'}]}, importName: 'x', localName: 'x'}]); - testImportEntries('import {x as v} from "mod" assert { type: "js"};', - [{moduleRequest: {specifier: 'mod', assertions: [{ type: 'js'}]}, importName: 'x', localName: 'v'}]); + testImportEntries('import {x as v} from "mod" with { type: "js"};', + [{moduleRequest: {specifier: 'mod', attributes: [{ key: 'type', value: 'js'}]}, importName: 'x', localName: 'v'}]); } diff --git a/js/src/jit-test/tests/modules/import-unsupported-attribute.js b/js/src/jit-test/tests/modules/import-unsupported-attribute.js new file mode 100644 index 0000000000..c771c6556b --- /dev/null +++ b/js/src/jit-test/tests/modules/import-unsupported-attribute.js @@ -0,0 +1,2 @@ +// |jit-test| --enable-import-attributes; module; error: TypeError: Unsupported import attribute: unsupported +import a from 'foo' with { unsupported: 'test'} diff --git a/js/src/jit-test/tests/modules/requested-modules.js b/js/src/jit-test/tests/modules/requested-modules.js index ebbf8ce6c1..e0a7fb66b8 100644 --- a/js/src/jit-test/tests/modules/requested-modules.js +++ b/js/src/jit-test/tests/modules/requested-modules.js @@ -1,4 +1,4 @@ -// |jit-test| --enable-import-assertions +// |jit-test| --enable-import-attributes // Test requestedModules property @@ -8,15 +8,16 @@ function testRequestedModules(source, expected) { assertEq(actual.length, expected.length); for (var i = 0; i < actual.length; i++) { assertEq(actual[i].moduleRequest.specifier, expected[i].specifier); - if(expected[i].assertions === null) { - assertEq(actual[i].moduleRequest.assertions, null); + if(expected[i].attributes === null) { + assertEq(actual[i].moduleRequest.attributes, null); } else { - var expectedAssertions = expected[i].assertions; - var actualAssertions = actual[i].moduleRequest.assertions; - assertEq(actualAssertions.length, expectedAssertions.length); - for (var j = 0; j < expectedAssertions.length; j++) { - assertEq(expectedAssertions[j].type, actualAssertions[j].type); + var expectedAttributes = expected[i].attributes; + var actualAttributes = actual[i].moduleRequest.attributes; + assertEq(actualAttributes.length, expectedAttributes.length); + for (var j = 0; j < expectedAttributes.length; j++) { + assertEq(expectedAttributes[j]['key'], actualAttributes[j]['key']); + assertEq(expectedAttributes[j]['value'], actualAttributes[j]['value']); } } } @@ -25,71 +26,71 @@ function testRequestedModules(source, expected) { testRequestedModules("", []); testRequestedModules("import a from 'foo'", [ - { specifier: 'foo', assertions: null } + { specifier: 'foo', attributes: null } ]); testRequestedModules("import a from 'foo'; import b from 'bar'", [ - { specifier: 'foo', assertions: null }, - { specifier: 'bar', assertions: null } + { specifier: 'foo', attributes: null }, + { specifier: 'bar', attributes: null } ]); testRequestedModules("import a from 'foo'; import b from 'bar'; import c from 'foo'", [ - { specifier: 'foo', assertions: null }, - { specifier: 'bar', assertions: null } + { specifier: 'foo', attributes: null }, + { specifier: 'bar', attributes: null } ]); testRequestedModules("export {} from 'foo'", [ - { specifier: 'foo', assertions: null } + { specifier: 'foo', attributes: null } ]); testRequestedModules("export * from 'bar'",[ - { specifier: 'bar', assertions: null } + { specifier: 'bar', attributes: null } ]); testRequestedModules("import a from 'foo'; export {} from 'bar'; export * from 'baz'", [ - { specifier: 'foo', assertions: null }, - { specifier: 'bar', assertions: null }, - { specifier: 'baz', assertions: null } + { specifier: 'foo', attributes: null }, + { specifier: 'bar', attributes: null }, + { specifier: 'baz', attributes: null } ]); if (getRealmConfiguration("importAttributes")) { - testRequestedModules("import a from 'foo' assert {}", [ - { specifier: 'foo', assertions: null }, + testRequestedModules("import a from 'foo' with {}", [ + { specifier: 'foo', attributes: null }, ]); - testRequestedModules("import a from 'foo' assert { type: 'js'}", [ - { specifier: 'foo', assertions: [ { type: 'js' } ] }, + testRequestedModules("import a from 'foo' with { type: 'js'}", [ + { specifier: 'foo', attributes: [ { key: 'type', value: 'js'} ] }, ]); - testRequestedModules("import a from 'foo' assert { unsupported: 'test'}", [ - { specifier: 'foo', assertions: null }, + testRequestedModules("import a from 'foo' with { unsupported: 'test'}", [ + { specifier: 'foo', attributes: [ { key: 'unsupported', value: 'test'} ] }, ]); - testRequestedModules("import a from 'foo' assert { unsupported: 'test', type: 'js', foo: 'bar' }", [ - { specifier: 'foo', assertions: [ { type: 'js' } ] }, + testRequestedModules("import a from 'foo' with { unsupported: 'test', type: 'js', foo: 'bar' }", [ + { specifier: 'foo', attributes: [ { key: 'unsupported', value: 'test'}, { key: 'type', value: 'js'}, { key: 'foo', value: 'bar'} ] }, ]); - testRequestedModules("import a from 'foo' assert { type: 'js1'}; export {} from 'bar' assert { type: 'js2'}; export * from 'baz' assert { type: 'js3'}", [ - { specifier: 'foo', assertions: [ { type: 'js1' } ] }, - { specifier: 'bar', assertions: [ { type: 'js2' } ] }, - { specifier: 'baz', assertions: [ { type: 'js3' } ] } + testRequestedModules("import a from 'foo' with { type: 'js1'}; export {} from 'bar' with { type: 'js2'}; export * from 'baz' with { type: 'js3'}", [ + { specifier: 'foo', attributes: [ { key: 'type', value: 'js1'} ] }, + { specifier: 'bar', attributes: [ { key: 'type', value: 'js2'} ] }, + { specifier: 'baz', attributes: [ { key: 'type', value: 'js3'} ] } ]); - testRequestedModules("export {} from 'foo' assert { type: 'js'}", [ - { specifier: 'foo', assertions: [ { type: 'js' } ] } + testRequestedModules("export {} from 'foo' with { type: 'js'}", [ + { specifier: 'foo', attributes: [ { key: 'type', value: 'js'} ] } ]); - testRequestedModules("export * from 'bar' assert { type: 'json'}",[ - { specifier: 'bar', assertions: [ { type: 'json' } ] } + testRequestedModules("export * from 'bar' with { type: 'json'}",[ + { specifier: 'bar', attributes: [ { key: 'type', value: 'json'} ] } ]); - testRequestedModules("import a from 'foo'; import b from 'bar' assert { type: 'json' };", [ - { specifier: 'foo', assertions: null }, - { specifier: 'bar', assertions: [ { type: 'json' } ] }, + testRequestedModules("import a from 'foo'; import b from 'bar' with { type: 'json' };", [ + { specifier: 'foo', attributes: null }, + { specifier: 'bar', attributes: [ { key: 'type', value: 'json'} ] }, ]); - testRequestedModules("import b from 'bar' assert { type: 'json' }; import a from 'foo';", [ - { specifier: 'bar', assertions: [ { type: 'json' } ] }, - { specifier: 'foo', assertions: null }, + testRequestedModules("import b from 'bar' with { type: 'json' }; import a from 'foo';", [ + { specifier: 'bar', attributes: [ { key: 'type', value: 'json'} ] }, + { specifier: 'foo', attributes: null }, ]); } diff --git a/js/src/jit-test/tests/sharedbuf/size-with-uninitialized.js b/js/src/jit-test/tests/sharedbuf/size-with-uninitialized.js new file mode 100644 index 0000000000..14f6e038ce --- /dev/null +++ b/js/src/jit-test/tests/sharedbuf/size-with-uninitialized.js @@ -0,0 +1,15 @@ +// OOM during SharedArrayBuffer initialization can expose partially initialized +// object to metadata builder. +// It shouldn't crash. + +newGlobal({ newCompartment: true }).Debugger(this).memory.trackingAllocationSites = true; +for (let i = 0; i < 9; i++) { + oomTest(function () { + class C extends WebAssembly.Memory {} + new C({ + initial: 0, + maximum: 1, + shared: 1, + }); + }); +} diff --git a/js/src/jit-test/tests/typedarray/arraybuffer-zero-length-alignment-check.js b/js/src/jit-test/tests/typedarray/arraybuffer-zero-length-alignment-check.js new file mode 100644 index 0000000000..d706977a6e --- /dev/null +++ b/js/src/jit-test/tests/typedarray/arraybuffer-zero-length-alignment-check.js @@ -0,0 +1,29 @@ +// Iterate a few times to increase the likelihood for malloc(0) to return a +// non-aligned memory. +for (let i = 0; i < 100; ++i) { + // Create a zero-length buffer with malloc'ed memory. + let ab = createExternalArrayBuffer(0); + + // Create a typed array which requires 8-byte alignment. + let source = new Float64Array(ab); + + // This call shouldn't assert when copying zero bytes from |source|, even when + // the memory is non-aligned. + let target = new Float64Array(source); + + // Add some uses of the objects. + assertEq(ab.byteLength, 0); + assertEq(source.byteLength, 0); + assertEq(target.byteLength, 0); +} + +// Repeat the above tests with the |createUserArrayBuffer| testing function. +for (let i = 0; i < 100; ++i) { + let ab = createUserArrayBuffer(0); + let source = new Float64Array(ab); + let target = new Float64Array(source); + + assertEq(ab.byteLength, 0); + assertEq(source.byteLength, 0); + assertEq(target.byteLength, 0); +} diff --git a/js/src/jit-test/tests/typedarray/sort-trampoline.js b/js/src/jit-test/tests/typedarray/sort-trampoline.js new file mode 100644 index 0000000000..9af8080b52 --- /dev/null +++ b/js/src/jit-test/tests/typedarray/sort-trampoline.js @@ -0,0 +1,174 @@ +function testGC() { + for (var i = 0; i < 20; i++) { + var arr = new BigInt64Array([1n, 3n, 0n, 12345678901234n, -12345678901234567n]); + arr.sort((x, y) => { + if (i === 17) { + gc(); + } + return Number(x) - Number(y); + }); + assertEq(arr.join(), "-12345678901234567,0,1,3,12345678901234"); + } +} +testGC(); + +function testDetach() { + for (var i = 0; i < 20; i++) { + var arr = new Float32Array([1, 2.5, -0, 3]); + arr.sort((x, y) => { + if (i > 15) { + detachArrayBuffer(arr.buffer); + } + return x - y; + }); + if (i > 15) { + assertEq(arr.length, 0); + assertEq(arr[0], undefined); + } else { + assertEq(arr.join(","), "0,1,2.5,3"); + } + } +} +testDetach(); + +function testException() { + var arr = new BigInt64Array([1n, 3n, 0n, 4n, 1n]); + var ex; + try { + for (var i = 0; i < 20; i++) { + arr.sort((x, y) => { + if (i === 17) { + throw "fit"; + } + return Number(x) - Number(y); + }); + } + } catch (e) { + ex = e; + } + assertEq(ex, "fit"); + assertEq(i, 17); + assertEq(arr.join(), "0,1,1,3,4"); + +} +testException(); + +function testRectifier() { + var arr = new Uint32Array([0xffff, 0xffff_ffff, -1, 0]); + for (var i = 0; i < 20; i++) { + arr.sort(function(x, y, a) { + assertEq(arguments.length, 2); + assertEq(a, undefined); + return y - x; + }); + } + assertEq(arr.join(), "4294967295,4294967295,65535,0"); +} +testRectifier(); + +function testClassConstructor() { + var normal = (x, y) => x - y; + var dummy = {}; + var ctor = (class { constructor(x, y) { + assertEq(x, dummy); + }}); + // Warm up the constructor. + for (var i = 0; i < 20; i++) { + new ctor(dummy, dummy); + } + for (var i = 0; i < 20; i++) { + var arr = new Uint8Array([0, 5, 1, 3]); + var ex; + try { + arr.sort(i < 17 ? normal : ctor); + } catch (e) { + ex = e; + } + assertEq(ex instanceof TypeError, i >= 17); + assertEq(arr.join(""), i >= 17 ? "0513" : "0135"); + } +} +testClassConstructor(); + +function testSwitchRealms() { + var arr = new Uint8ClampedArray([5, 3, 0, 1]); + var g = newGlobal({sameCompartmentAs: this}); + g.foo = 123; + var comp = g.evaluate(`((x, y) => { + assertEq(foo, 123); + return x - y; + })`); + for (var i = 0; i < 20; i++) { + arr.sort(comp); + } + assertEq(arr.join(""), "0135"); +} +testSwitchRealms(); + +function testCrossCompartment() { + var g = newGlobal({newCompartment: true}); + var wrapper = g.evaluate(`((x, y) => { + return Number(x) - Number(y); + })`); + for (var i = 0; i < 20; i++) { + var arr = new BigUint64Array([1n, 0n, 1234567890123n, 98765432109876n, 0n]); + arr.sort(wrapper); + assertEq(arr.join(), "0,0,1,1234567890123,98765432109876"); + } +} +testCrossCompartment(); + +function testBound() { + var fun = (function(a, x, y) { + "use strict"; + assertEq(this, null); + assertEq(a, 1); + return Number(x) - Number(y); + }).bind(null, 1); + for (var i = 0; i < 20; i++) { + var arr = new BigUint64Array([1n, 0n, 1234567890123n, 98765432109876n, 0n]); + arr.sort(fun); + assertEq(arr.join(), "0,0,1,1234567890123,98765432109876"); + } +} +testBound(); + +function testExtraArgs() { + var arr = new Int8Array([1, 3, 5, 0]); + var cmp = (x, y) => x - y - 1; + for (var i = 0; i < 20; i++) { + arr.sort(cmp, cmp, cmp, cmp, cmp, cmp, cmp); + } + assertEq(arr.join(""), "1035"); +} +testExtraArgs(); + +function testBailout() { + for (var i = 0; i < 110; i++) { + var arr = new Float64Array([1, 3.3, 5.5, -0, NaN]); + arr.sort(function(x, y) { + if (i === 108) { + bailout(); + } + return x - y; + }); + assertEq(arr.join(","), "0,1,3.3,5.5,NaN"); + } +} +testBailout(); + +function testExceptionHandlerSwitchRealm() { + var g = newGlobal({sameCompartmentAs: this}); + for (var i = 0; i < 25; i++) { + var ex = null; + try { + Int8Array.prototype.toSorted.call(new Int8Array([1, 2, 3]), () => { + throw "fit"; + }); + } catch (e) { + ex = e; + } + assertEq(ex, "fit"); + } +} +testExceptionHandlerSwitchRealm(); diff --git a/js/src/jit-test/tests/typedarray/sort-wrapper.js b/js/src/jit-test/tests/typedarray/sort-wrapper.js new file mode 100644 index 0000000000..f646ccd0a5 --- /dev/null +++ b/js/src/jit-test/tests/typedarray/sort-wrapper.js @@ -0,0 +1,21 @@ +function test() { + var g = newGlobal({ newCompartment: true }); + var wrapped = g.evaluate("new Int32Array([1, 3, 2, 0])"); + var wrappedOther = g.evaluate("({})"); + var unwrapped = new Int32Array(10); + + var ex; + try { + unwrapped.sort.call(wrappedOther); + } catch (e) { + ex = e; + } + assertEq(ex instanceof TypeError, true); + + assertEq(unwrapped.sort.call(wrapped), wrapped); + assertEq(wrapped.toString(), "0,1,2,3"); + + assertEq(unwrapped.sort.call(wrapped, (a, b) => b - a), wrapped); + assertEq(wrapped.toString(), "3,2,1,0"); +} +test(); diff --git a/js/src/jit-test/tests/warp/bug1683306.js b/js/src/jit-test/tests/warp/bug1683306.js index 3c74c3f612..193da36af4 100644 --- a/js/src/jit-test/tests/warp/bug1683306.js +++ b/js/src/jit-test/tests/warp/bug1683306.js @@ -1,4 +1,4 @@ -// |jit-test| --ion-offthread-compile=off; --ion-full-warmup-threshold=0; --ion-gvn=off; --baseline-eager +// |jit-test| --ion-offthread-compile=off; --ion-gvn=off; --baseline-eager // // Bug 1683306 - Assertion failure: !genObj->hasStackStorage() || genObj->isStackStorageEmpty(), at vm/GeneratorObject.cpp:144 diff --git a/js/src/jit-test/tests/warp/bug1683614.js b/js/src/jit-test/tests/warp/bug1683614.js index 1d0a4724ff..58c67c7a91 100644 --- a/js/src/jit-test/tests/warp/bug1683614.js +++ b/js/src/jit-test/tests/warp/bug1683614.js @@ -1,4 +1,4 @@ -// |jit-test| --ion-offthread-compile=off; --ion-full-warmup-threshold=0; --baseline-eager; skip-if: !this.hasOwnProperty("ReadableStream") +// |jit-test| --ion-offthread-compile=off; --baseline-eager; skip-if: !this.hasOwnProperty("ReadableStream") gczeal(9, 8); function s() { } @@ -10,4 +10,4 @@ new ReadableStream({ async function test() { for (let i17 = 1; i17 <= 30; i17++) await s(0 + function () { return i17 }); -}
\ No newline at end of file +} diff --git a/js/src/jit-test/tests/wasm/branch-hinting/complex_control_flow.js b/js/src/jit-test/tests/wasm/branch-hinting/complex_control_flow.js new file mode 100644 index 0000000000..727a3156fb --- /dev/null +++ b/js/src/jit-test/tests/wasm/branch-hinting/complex_control_flow.js @@ -0,0 +1,38 @@ +// Test branch hinting with nested if. + +var imports = { "":{inc() { counter++ }} }; +counter = 0; + +let module = new WebAssembly.Module(wasmTextToBinary(`(module + (import "" "inc" (func (result i32))) + (func + (result i32) + (@metadata.code.branch_hint "\\00") (if (result i32) + (i32.const 1) + (then + (@metadata.code.branch_hint "\\00") (if (result i32) + (i32.const 2) + (then + (@metadata.code.branch_hint "\\00") (if (result i32) + (i32.const 3) + (then + (@metadata.code.branch_hint "\\00") (if (result i32) + (i32.const 0) + (then (call 0)) + (else (i32.const 42)) + ) + ) + (else (call 0)) + ) + ) + (else (call 0)) + ) + ) + (else (call 0)) + ) + ) + (export "run" (func 1)) +)`, 42, imports)); + +assertEq(counter, 0); +assertEq(wasmParsedBranchHints(module), true); diff --git a/js/src/jit-test/tests/wasm/branch-hinting/directives.txt b/js/src/jit-test/tests/wasm/branch-hinting/directives.txt new file mode 100644 index 0000000000..8fe3d1e8e4 --- /dev/null +++ b/js/src/jit-test/tests/wasm/branch-hinting/directives.txt @@ -0,0 +1 @@ +|jit-test| --setpref=wasm_branch_hinting=true; --wasm-compiler=ion; test-also=--wasm-compiler=baseline;skip-if: !wasmBranchHintingEnabled(); include:wasm.js diff --git a/js/src/jit-test/tests/wasm/branch-hinting/parsing.js b/js/src/jit-test/tests/wasm/branch-hinting/parsing.js new file mode 100644 index 0000000000..0ff9b0f557 --- /dev/null +++ b/js/src/jit-test/tests/wasm/branch-hinting/parsing.js @@ -0,0 +1,154 @@ +// Make sure we are correctly parsing this custom section. +var code =` +(module + (func $$dummy) + (func $main (param i32) (result i32) + i32.const 0 + local.get 0 + i32.eq + ;; Only allowed on br_if and if + (@metadata.code.branch_hint "\\00") if + call $$dummy + i32.const 1 + return + else + call $$dummy + i32.const 0 + return + end + i32.const 3 + return + ) + + (export "_main" (func $main)) +)`; + +let branchHintsModule = new WebAssembly.Module(wasmTextToBinary(code)); +assertEq(WebAssembly.Module.customSections(branchHintsModule, "metadata.code.branch_hint").length, 1); +assertEq(wasmParsedBranchHints(branchHintsModule), true); + +let instance = new WebAssembly.Instance(branchHintsModule); +assertEq(instance.exports._main(0), 1); + +// Testing branch hints parsing on `if` and `br_if` +branchHintsModule = new WebAssembly.Module(wasmTextToBinary(` +(module + (func $main + i32.const 0 + (@metadata.code.branch_hint "\\00") + if + i32.const 0 + (@metadata.code.branch_hint "\\01") + br_if 0 + end + ) + (export "_main" (func $main)) +)`)); +assertEq(wasmParsedBranchHints(branchHintsModule), true); +instance = new WebAssembly.Instance(branchHintsModule); +instance.exports._main(); + +let m = new WebAssembly.Module(wasmTextToBinary(` +(module + (type (;0;) (func)) + (type (;1;) (func (param i32) (result i32))) + (type (;2;) (func (result i32))) + (func $__wasm_nullptr (type 0) + unreachable) + (func $main (type 2) (result i32) + (local i32 i32 i32 i32) + i32.const 0 + local.tee 2 + local.set 3 + loop + local.get 2 + i32.const 50000 + i32.eq + (@metadata.code.branch_hint "\\00") if + i32.const 1 + local.set 3 + end + local.get 2 + i32.const 1 + i32.add + local.tee 2 + i32.const 100000 + i32.ne + (@metadata.code.branch_hint "\\01") br_if 0 (;@1;) + end + local.get 3) + (table (;0;) 1 1 funcref) + (memory (;0;) 17 128) + (global (;0;) (mut i32) (i32.const 42)) + (export "memory" (memory 0)) + (export "_main" (func $main)) + (elem (;0;) (i32.const 0) func $__wasm_nullptr) + (type (;0;) (func (param i32))) +)`)); + +assertEq(wasmParsedBranchHints(m), true); +instance = new WebAssembly.Instance(m); +assertEq(instance.exports._main(0), 1); + +// Testing invalid values for branch hints +assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(` +(module + (func $main (param i32) (result i32) + i32.const 0 + (@metadata.code.branch_hint "\\0000000") if + i32.const 1 + return + end + i32.const 42 + return + ) + ) +`)), SyntaxError, /invalid value for branch hint/); + +assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(` +(module + (func $main (param i32) (result i32) + i32.const 0 + (@metadata.code.branch_hint "\\02") if + i32.const 1 + return + end + i32.const 42 + return + ) + ) +`)), SyntaxError, /invalid value for branch hint/); + +assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(` +(module + (func $main (param i32) (result i32) + i32.const 0 + (@metadata.code.branch_hint "\\aaaa") if + i32.const 1 + return + end + i32.const 42 + return + ) + ) +`)), SyntaxError, /wasm text error/); + +assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(` +(module + (func $main (param i32) (result i32) + i32.const 0 + (@metadata.code.branch_hint) if + i32.const 1 + return + end + i32.const 42 + return + ) + ) +`)), SyntaxError, /wasm text error/); + +assertErrorMessage(() => new WebAssembly.Module(wasmTextToBinary(` +(module + (@metadata.code.branch_hint) +) +`)), SyntaxError, /wasm text error/); diff --git a/js/src/jit-test/tests/wasm/branch-hinting/simple_example.js b/js/src/jit-test/tests/wasm/branch-hinting/simple_example.js new file mode 100644 index 0000000000..141ee02fef --- /dev/null +++ b/js/src/jit-test/tests/wasm/branch-hinting/simple_example.js @@ -0,0 +1,41 @@ +// Branch Hinting proposal + +function runModule(hint) { + let code =` + (module + (func $$dummy) + (func $main (param i32) (result i32) + i32.const 0 + local.get 0 + i32.eq + ;; Only allowed on br_if and if + (@metadata.code.branch_hint "${hint}") if + call $$dummy + i32.const 1 + return + else + call $$dummy + i32.const 0 + return + end + i32.const 3 + return + ) + (export "_main" (func $main)) + )`; + let branchHintsModule = new WebAssembly.Module(wasmTextToBinary(code)); + assertEq(wasmParsedBranchHints(branchHintsModule), true); + + let instance = new WebAssembly.Instance(branchHintsModule); + assertEq(instance.exports._main(0), 1); +} + +// Ensure that we have the same result with different branch hints. +runModule("\\00"); +runModule("\\01"); + +let module = new WebAssembly.Module(wasmTextToBinary(` + (func i32.const 0 (@metadata.code.branch_hint "\\00") if end) +`)) + +assertEq(wasmParsedBranchHints(module), true); diff --git a/js/src/jit-test/tests/wasm/builtin-modules/js-string/basic.js b/js/src/jit-test/tests/wasm/builtin-modules/js-string/basic.js index 2c0ecb89c5..4c789dda19 100644 --- a/js/src/jit-test/tests/wasm/builtin-modules/js-string/basic.js +++ b/js/src/jit-test/tests/wasm/builtin-modules/js-string/basic.js @@ -34,14 +34,14 @@ let testModule = `(module (func (import "wasm:js-string" "fromCharCode") (param i32) - (result externref) + (result (ref extern)) ) (export "fromCharCode" (func 4)) (func (import "wasm:js-string" "fromCodePoint") (param i32) - (result externref) + (result (ref extern)) ) (export "fromCodePoint" (func 5)) @@ -69,14 +69,14 @@ let testModule = `(module (func (import "wasm:js-string" "concat") (param externref externref) - (result externref) + (result (ref extern)) ) (export "concat" (func 9)) (func (import "wasm:js-string" "substring") (param externref i32 i32) - (result externref) + (result (ref extern)) ) (export "substring" (func 10)) diff --git a/js/src/jit-test/tests/wasm/exnref/casting.js b/js/src/jit-test/tests/wasm/exnref/casting.js index fa433fc152..20fbd145fe 100644 --- a/js/src/jit-test/tests/wasm/exnref/casting.js +++ b/js/src/jit-test/tests/wasm/exnref/casting.js @@ -1,110 +1,199 @@ // |jit-test| skip-if: !wasmGcEnabled() -const { - refCast, - refTest, - branch, - branchFail, - refCastNullable, - refTestNullable, - branchNullable, - branchFailNullable, -} = wasmEvalText(`(module - (tag $a) - (func $make (param $null i32) (result exnref) - (if (local.get $null) - (then - (return (ref.null exn)) +// Test exnref +{ + const { + refCast, + refTest, + branch, + branchFail, + refCastNullable, + refTestNullable, + branchNullable, + branchFailNullable, + } = wasmEvalText(`(module + (tag $a) + (func $make (param $null i32) (result exnref) + (if (local.get $null) + (then + (return (ref.null exn)) + ) ) - ) - try_table (catch_all_ref 0) - throw $a - end - unreachable - ) + try_table (catch_all_ref 0) + throw $a + end + unreachable + ) - (func (export "refCast") (param $null i32) - (call $make (local.get $null)) - ref.cast (ref exn) - drop - ) - (func (export "refTest") (param $null i32) (result i32) - (call $make (local.get $null)) - ref.test (ref exn) - ) - (func (export "branch") (param $null i32) (result i32) - (block (result (ref exn)) + (func (export "refCast") (param $null i32) (call $make (local.get $null)) - br_on_cast 0 exnref (ref exn) + ref.cast (ref exn) drop - (return (i32.const 0)) ) - drop - (return (i32.const 1)) - ) - (func (export "branchFail") (param $null i32) (result i32) - (block (result exnref) + (func (export "refTest") (param $null i32) (result i32) (call $make (local.get $null)) - br_on_cast_fail 0 exnref (ref exn) + ref.test (ref exn) + ) + (func (export "branch") (param $null i32) (result i32) + (block (result (ref exn)) + (call $make (local.get $null)) + br_on_cast 0 exnref (ref exn) + drop + (return (i32.const 0)) + ) drop (return (i32.const 1)) ) - drop - (return (i32.const 0)) - ) + (func (export "branchFail") (param $null i32) (result i32) + (block (result exnref) + (call $make (local.get $null)) + br_on_cast_fail 0 exnref (ref exn) + drop + (return (i32.const 1)) + ) + drop + (return (i32.const 0)) + ) - (func (export "refCastNullable") (param $null i32) - (call $make (local.get $null)) - ref.cast exnref - drop - ) - (func (export "refTestNullable") (param $null i32) (result i32) - (call $make (local.get $null)) - ref.test exnref - ) - (func (export "branchNullable") (param $null i32) (result i32) - (block (result exnref) + (func (export "refCastNullable") (param $null i32) (call $make (local.get $null)) - br_on_cast 0 exnref exnref + ref.cast exnref drop - (return (i32.const 0)) ) - drop - (return (i32.const 1)) - ) - (func (export "branchFailNullable") (param $null i32) (result i32) - (block (result exnref) + (func (export "refTestNullable") (param $null i32) (result i32) (call $make (local.get $null)) - br_on_cast_fail 0 exnref exnref + ref.test exnref + ) + (func (export "branchNullable") (param $null i32) (result i32) + (block (result exnref) + (call $make (local.get $null)) + br_on_cast 0 exnref exnref + drop + (return (i32.const 0)) + ) drop (return (i32.const 1)) ) - drop - (return (i32.const 0)) - ) -)`).exports; + (func (export "branchFailNullable") (param $null i32) (result i32) + (block (result exnref) + (call $make (local.get $null)) + br_on_cast_fail 0 exnref exnref + drop + (return (i32.const 1)) + ) + drop + (return (i32.const 0)) + ) + )`).exports; -// cast non-null exnref -> (ref exn) -refCast(0); -assertEq(refTest(0), 1); -assertEq(branch(0), 1); -assertEq(branchFail(0), 1); + // cast non-null exnref -> (ref exn) + refCast(0); + assertEq(refTest(0), 1); + assertEq(branch(0), 1); + assertEq(branchFail(0), 1); -// cast non-null exnref -> exnref -refCastNullable(0); -assertEq(refTestNullable(0), 1); -assertEq(branchNullable(0), 1); -assertEq(branchFailNullable(0), 1); + // cast non-null exnref -> exnref + refCastNullable(0); + assertEq(refTestNullable(0), 1); + assertEq(branchNullable(0), 1); + assertEq(branchFailNullable(0), 1); + + // cast null exnref -> (ref exn) + assertErrorMessage(() => refCast(1), WebAssembly.RuntimeError, /bad cast/); + assertEq(refTest(1), 0); + assertEq(branch(1), 0); + assertEq(branchFail(1), 0); + + // cast null exnref -> exnref + refCastNullable(1); + assertEq(refTestNullable(1), 1); + assertEq(branchNullable(1), 1); + assertEq(branchFailNullable(1), 1); +} + + +// Test nullexnref +{ + const { + refCastNull, + refCastNonNull, + refTestNull, + refTestNonNull, + branchNull, + branchNonNull, + branchFailNull, + branchFailNonNull, + } = wasmEvalText(`(module + (func (export "refCastNull") + ref.null noexn + ref.cast nullexnref + drop + ) + (func (export "refCastNonNull") + ref.null noexn + ref.cast (ref noexn) + drop + ) + (func (export "refTestNull") (result i32) + ref.null noexn + ref.test nullexnref + ) + (func (export "refTestNonNull") (result i32) + ref.null noexn + ref.test (ref noexn) + ) + (func (export "branchNull") (result i32) + (block (result nullexnref) + ref.null noexn + br_on_cast 0 exnref nullexnref + drop + (return (i32.const 0)) + ) + drop + (return (i32.const 1)) + ) + (func (export "branchNonNull") (result i32) + (block (result (ref noexn)) + ref.null noexn + br_on_cast 0 exnref (ref noexn) + drop + (return (i32.const 0)) + ) + drop + (return (i32.const 1)) + ) + (func (export "branchFailNull") (result i32) + (block (result exnref) + ref.null noexn + br_on_cast_fail 0 exnref (ref noexn) + drop + (return (i32.const 1)) + ) + drop + (return (i32.const 0)) + ) + (func (export "branchFailNonNull") (result i32) + (block (result (ref exn)) + ref.null noexn + br_on_cast_fail 0 exnref (ref null noexn) + drop + (return (i32.const 1)) + ) + drop + (return (i32.const 0)) + ) + )`).exports; -// cast null exnref -> (ref exn) -assertErrorMessage(() => refCast(1), WebAssembly.RuntimeError, /bad cast/); -assertEq(refTest(1), 0); -assertEq(branch(1), 0); -assertEq(branchFail(1), 0); + // null exceptions can be casted to nullexnref + refCastNull(); + assertEq(refTestNull(), 1); + assertEq(branchNull(), 1); + assertEq(branchFailNull(), 0); -// cast null exnref -> exnref -refCastNullable(1); -assertEq(refTestNullable(1), 1); -assertEq(branchNullable(1), 1); -assertEq(branchFailNullable(1), 1); + // null exceptions cannot be casted to (ref noexn) + assertErrorMessage(() => refCastNonNull(), WebAssembly.RuntimeError, /bad cast/); + assertEq(refTestNonNull(), 0); + assertEq(branchNonNull(), 0); + assertEq(branchFailNonNull(), 1); +} diff --git a/js/src/jit-test/tests/wasm/exnref/try-table.js b/js/src/jit-test/tests/wasm/exnref/try-table.js index c89330917c..407d6db133 100644 --- a/js/src/jit-test/tests/wasm/exnref/try-table.js +++ b/js/src/jit-test/tests/wasm/exnref/try-table.js @@ -382,3 +382,56 @@ } } } + +// WebAssembly.JSTag property is read-only and enumerable +WebAssembly.JSTag = null; +assertEq(WebAssembly.JSTag !== null, true); +assertEq(WebAssembly.propertyIsEnumerable('JSTag'), true); + +// Test try_table catching JS exceptions and unpacking them using JSTag +{ + let tag = WebAssembly.JSTag; + let values = [...WasmExternrefValues]; + function throwJS(value) { + throw value; + } + let {test} = wasmEvalText(`(module + (import "" "tag" (tag $tag (param externref))) + (import "" "throwJS" (func $throwJS (param externref))) + (func (export "test") (param externref) (result externref) + try_table (catch $tag 0) + local.get 0 + call $throwJS + end + unreachable + ) + )`, {"": {tag, throwJS}}).exports; + + for (let value of values) { + assertEq(value, test(value)); + } +} + +// Test try_table catching JS exceptions using JSTag and unpacking them using JSTag +{ + let tag = WebAssembly.JSTag; + let values = [...WasmExternrefValues]; + function throwJS(value) { + throw new WebAssembly.Exception(tag, [value]); + } + let {test} = wasmEvalText(`(module + (import "" "tag" (tag $tag (param externref))) + (import "" "throwJS" (func $throwJS (param externref))) + (func (export "test") (param externref) (result externref) + try_table (catch $tag 0) + local.get 0 + call $throwJS + end + unreachable + ) + )`, {"": {tag, throwJS}}).exports; + + for (let value of values) { + assertEq(value, test(value)); + } +} diff --git a/js/src/jit-test/tests/wasm/js-promise-integration/basic.js b/js/src/jit-test/tests/wasm/js-promise-integration/basic.js new file mode 100644 index 0000000000..8603886b07 --- /dev/null +++ b/js/src/jit-test/tests/wasm/js-promise-integration/basic.js @@ -0,0 +1,147 @@ +// Example from the proposal. + +var compute_delta = async (i) => Promise.resolve(i / 100 || 1); + +var suspending_compute_delta = new WebAssembly.Function( + { parameters: ['externref', 'i32'], results: ['f64'] }, + compute_delta, + { suspending: "first" } +); + +var ins = wasmEvalText(`(module + (import "js" "init_state" (func $init_state (result f64))) + (import "js" "compute_delta" + (func $compute_delta_import (param externref) (param i32) (result f64))) + + (global $suspender (mut externref) (ref.null extern)) + (global $state (mut f64) (f64.const nan)) + (func $init (global.set $state (call $init_state))) + (start $init) + + (func $compute_delta (param i32) (result f64) + (local $suspender_copy externref) + (;return (f64.const 0.3);) + (;unreachable;) + (global.get $suspender) + (local.tee $suspender_copy) + (local.get 0) + (call $compute_delta_import) + (local.get $suspender_copy) + (global.set $suspender) + (return) + ) + (func $get_state (export "get_state") (result f64) (global.get $state)) + (func $update_state (param i32) (result f64) + (global.set $state (f64.add + (global.get $state) (call $compute_delta (local.get 0)))) + (global.get $state) + ) + + (func (export "update_state_export") + (param $suspender externref) (param i32) (result f64) + (local.get $suspender) + (global.set $suspender) + (local.get 1) + (call $update_state) + (return) + ) +)`, { + js: { + init_state() { return 0; }, + compute_delta: suspending_compute_delta, + }, +}); + +var update_state = new WebAssembly.Function( + { parameters: ['i32'], results: ['externref'] }, + ins.exports.update_state_export, + { promising: "first" } +); + +var res = update_state(4); +var tasks = res.then((r) => { + print(r); + assertEq(ins.exports.get_state(), .04); +}); + +assertEq(ins.exports.get_state(), 0); + +// Also test with exceptions/traps. + +async function test(c) { + var compute_delta = (i) => Promise.resolve(i/100 || 1); + if (c == 1) compute_delta = async (i) => {throw "ff"}; + if (c == 2) compute_delta = () => {throw "ff";} + + var suspending_compute_delta = new WebAssembly.Function( + {parameters:['externref', 'i32'], results:['f64']}, + compute_delta, + {suspending:"first"} + ); + + var ins = wasmEvalText(`(module + (import "js" "init_state" (func $init_state (result f64))) + (import "js" "compute_delta" + (func $compute_delta_import (param externref) (param i32) (result f64))) + + (global $suspender (mut externref) (ref.null extern)) + (global $state (mut f64) (f64.const nan)) + (func $init (global.set $state (call $init_state))) + (start $init) + + (func $compute_delta (param i32) (result f64) + (local $suspender_copy externref) + (;return (f64.const 0.3);) + ${c == 3 ? "(unreachable)" : ""} + (global.get $suspender) + (local.tee $suspender_copy) + (local.get 0) + (call $compute_delta_import) + ${c == 4 ? "(unreachable)" : ""} + (local.get $suspender_copy) + (global.set $suspender) + (return) + ) + (func $get_state (export "get_state") (result f64) (global.get $state)) + (func $update_state (param i32) (result f64) + (global.set $state (f64.add + (global.get $state) (call $compute_delta (local.get 0)))) + (global.get $state) + ) + + (func (export "update_state_export") + (param $suspender externref) (param i32) (result f64) + (local.get $suspender) + (global.set $suspender) + (local.get 1) + (call $update_state) + (return) + ) + )`, { + js: { + init_state() { return 0; }, + compute_delta: suspending_compute_delta, + }, + }); + + var update_state = new WebAssembly.Function( + {parameters:['i32'], results:['externref']}, + ins.exports.update_state_export, + {promising : "first"} + ); + + var res = update_state(4); + var p = res.then((r) => { + assertEq(c, 0); + assertEq(ins.exports.get_state(), .04); + }).catch(_ => { + assertEq(c > 0, true); + }); + + assertEq(ins.exports.get_state(), 0); + await p; +} + +for (let c = 0; c < 5; c++) { + tasks = tasks.then(() => test(c)); +} diff --git a/js/src/jit-test/tests/wasm/js-promise-integration/basic2.js b/js/src/jit-test/tests/wasm/js-promise-integration/basic2.js new file mode 100644 index 0000000000..d381951b2c --- /dev/null +++ b/js/src/jit-test/tests/wasm/js-promise-integration/basic2.js @@ -0,0 +1,97 @@ +// New API experiments. +// Example from the proposal. + +var compute_delta = async (i) => Promise.resolve(i / 100 || 1); + +var suspending_compute_delta = new WebAssembly.Suspending( + compute_delta +); +var ins = wasmEvalText(`(module + (import "js" "init_state" (func $init_state (result f64))) + (import "js" "compute_delta" + (func $compute_delta (param i32) (result f64))) + + (global $suspender (mut externref) (ref.null extern)) + (global $state (mut f64) (f64.const nan)) + (func $init (global.set $state (call $init_state))) + (start $init) + + (func $get_state (export "get_state") (result f64) (global.get $state)) + (func (export "update_state_export") (param i32) (result f64) + (global.set $state (f64.add + (global.get $state) (call $compute_delta (local.get 0)))) + (global.get $state) + ) +)`, { + js: { + init_state() { return 0; }, + compute_delta: suspending_compute_delta, + }, +}); + +var update_state = WebAssembly.promising( + ins.exports.update_state_export +); + +var res = update_state(4); +var tasks = res.then((r) => { + print(r); + assertEq(ins.exports.get_state(), .04); +}); + +assertEq(ins.exports.get_state(), 0); + +// Also test with exceptions/traps. + +async function test(c) { + var compute_delta = (i) => Promise.resolve(i/100 || 1); + if (c == 1) compute_delta = async (i) => {throw "ff"}; + if (c == 2) compute_delta = () => {throw "ff";} + + var suspending_compute_delta = new WebAssembly.Suspending( + compute_delta + ); + var ins = wasmEvalText(`(module + (import "js" "init_state" (func $init_state (result f64))) + (import "js" "compute_delta" + (func $compute_delta (param i32) (result f64))) + + (global $suspender (mut externref) (ref.null extern)) + (global $state (mut f64) (f64.const nan)) + (func $init (global.set $state (call $init_state))) + (start $init) + + (func $get_state (export "get_state") (result f64) (global.get $state)) + (func (export "update_state_export") (param i32) (result f64) + ${c == 3 ? "(unreachable)" : ""} + (global.set $state (f64.add + (global.get $state) (call $compute_delta (local.get 0)))) + ${c == 4 ? "(unreachable)" : ""} + (global.get $state) + ) + )`, { + js: { + init_state() { return 0; }, + compute_delta: suspending_compute_delta, + }, + }); + + var update_state = WebAssembly.promising( + ins.exports.update_state_export +); + + var res = update_state(4); + var p = res.then((r) => { + assertEq(c, 0); + assertEq(ins.exports.get_state(), .04); + }).catch(_ => { + assertEq(c > 0, true); + }); + + assertEq(ins.exports.get_state(), 0); + await p; +} + +for (let c = 0; c < 5; c++) { + tasks = tasks.then(() => test(c)); +} diff --git a/js/src/jit-test/tests/wasm/js-promise-integration/directives.txt b/js/src/jit-test/tests/wasm/js-promise-integration/directives.txt new file mode 100644 index 0000000000..b15152352a --- /dev/null +++ b/js/src/jit-test/tests/wasm/js-promise-integration/directives.txt @@ -0,0 +1 @@ +|jit-test| include:wasm.js; --setpref=wasm_js_promise_integration=true; skip-if: !wasmJSPromiseIntegrationEnabled() diff --git a/js/src/jit-test/tests/wasm/js-promise-integration/gc-2.js b/js/src/jit-test/tests/wasm/js-promise-integration/gc-2.js new file mode 100644 index 0000000000..d17539807e --- /dev/null +++ b/js/src/jit-test/tests/wasm/js-promise-integration/gc-2.js @@ -0,0 +1,69 @@ +// Example from the proposal. + +gczeal(2,5); + +var compute_delta = (i) => Promise.resolve(i / 100 || 1); + +var suspending_compute_delta = new WebAssembly.Function( + { parameters: ['externref', 'i32'], results: ['f64'] }, + compute_delta, + { suspending: "first" } +); + +var ins = wasmEvalText(`(module + (import "js" "init_state" (func $init_state (result f64))) + (import "js" "compute_delta" + (func $compute_delta_import (param externref) (param i32) (result f64))) + + (global $suspender (mut externref) (ref.null extern)) + (global $state (mut f64) (f64.const nan)) + (func $init (global.set $state (call $init_state))) + (start $init) + + (func $compute_delta (param i32) (result f64) + (local $suspender_copy externref) + (;return (f64.const 0.3);) + (;unreachable;) + (global.get $suspender) + (local.tee $suspender_copy) + (local.get 0) + (call $compute_delta_import) + (local.get $suspender_copy) + (global.set $suspender) + (return) + ) + (func $get_state (export "get_state") (result f64) (global.get $state)) + (func $update_state (param i32) (result f64) + (global.set $state (f64.add + (global.get $state) (call $compute_delta (local.get 0)))) + (global.get $state) + ) + + (func (export "update_state_export") + (param $suspender externref) (param i32) (result f64) + (local.get $suspender) + (global.set $suspender) + (local.get 1) + (call $update_state) + (return) + ) +)`, { + js: { + init_state() { return 0; }, + compute_delta: suspending_compute_delta, + }, +}); + +var update_state = new WebAssembly.Function( + { parameters: ['i32'], results: ['externref'] }, + ins.exports.update_state_export, + { promising: "first" } +); + +var res = update_state(4); +var tasks = res.then((r) => { + print(r); + assertEq(ins.exports.get_state(), .04); +}); + +assertEq(ins.exports.get_state(), 0); diff --git a/js/src/jit-test/tests/wasm/js-promise-integration/gc.js b/js/src/jit-test/tests/wasm/js-promise-integration/gc.js new file mode 100644 index 0000000000..c688b99cb5 --- /dev/null +++ b/js/src/jit-test/tests/wasm/js-promise-integration/gc.js @@ -0,0 +1,67 @@ +// Test if we can trace roots on the alternative stack. + +let i = 0; +function js_import() { + return Promise.resolve({i: ++i}); +}; +let wasm_js_import = new WebAssembly.Function( + {parameters: ['externref'], results: ['externref']}, + js_import, + {suspending: 'first'}); + +let wasm_gc_import = new WebAssembly.Function( + {parameters: ['externref'], results: []}, + async () => { gc(); }, + {suspending: 'first'}); + +var ins = wasmEvalText(`(module + (import "m" "import" + (func (param externref) (result externref))) + (import "m" "gc" (func (param externref))) + (import "m" "conv" + (func (param externref) (result i32))) + + (global (export "g") (mut i32) (i32.const 0)) + + (func (export "test") (param externref) + (local i32) + i32.const 5 + local.set 1 + loop + local.get 0 + call 0 + local.get 0 + call 1 + call 2 + global.get 0 + i32.add + global.set 0 + local.get 1 + i32.const 1 + i32.sub + local.tee 1 + br_if 0 + end + ) + +)`, { + m: { + import: wasm_js_import, + gc: wasm_gc_import, + conv: ({i}) => i, + }, +}); + + +let wrapped_export = new WebAssembly.Function( + {parameters:[], results:['externref']}, + ins.exports.test, + {promising : "first"} +); + +let export_promise = wrapped_export(); +assertEq(0, ins.exports.g.value); +assertEq(true, export_promise instanceof Promise); +export_promise.then(() => + assertEq(15, ins.exports.g.value) +); diff --git a/js/src/jit-test/tests/wasm/js-promise-integration/js-promise-integration.new.js b/js/src/jit-test/tests/wasm/js-promise-integration/js-promise-integration.new.js new file mode 100644 index 0000000000..d45d47b072 --- /dev/null +++ b/js/src/jit-test/tests/wasm/js-promise-integration/js-promise-integration.new.js @@ -0,0 +1,270 @@ +// New version of JS promise integration API +// Modified https://github.com/WebAssembly/js-promise-integration/tree/main/test/js-api/js-promise-integration + +var tests = Promise.resolve(); +function test(fn, n) { + + tests = tests.then(() => { + let t = {res: null}; + print("# " + n); + fn(t); + return t.res; + }); +} +function promise_test(fn, n) { + tests = tests.then(() => { + print("# " + n); + return fn(); + }); +} +function assert_true(f) { assertEq(f, true); } +function assert_equals(a, b) { assertEq(a, b); } +function assert_array_equals(a, b) { + assert_equals(a.length, a.length); + for (let i = 0; i < a.length; i++) { + assert_equals(a[i], b[i]); + } +} +function assert_throws(ex, fn) { + try { + fn(); assertEq(false, true); + } catch(e) { + assertEq(e instanceof ex, true); + } +} +function promise_rejects(t, obj, p) { + t.res = p.then(() => { + assertEq(true, false); + }, (e) => { + assertEq(e instanceof obj.constructor, true); + }); +} + +function ToPromising(wasm_export) { + let sig = wasm_export.type(); + assert_true(sig.parameters.length > 0); + assert_equals('externref', sig.parameters[0]); + let wrapper_sig = { + parameters: sig.parameters.slice(1), + results: ['externref'] + }; + return new WebAssembly.Function( + wrapper_sig, wasm_export, {promising: 'first'}); +} + +promise_test(async () => { + let js_import = new WebAssembly.Suspending( + () => Promise.resolve(42) + ); + let instance = wasmEvalText(`(module + (import "m" "import" (func $import (result i32))) + (func (export "test") (result i32) + call $import + ) + )`, {m: {import: js_import}}); + let wrapped_export = WebAssembly.promising(instance.exports.test); + let export_promise = wrapped_export(); + assert_true(export_promise instanceof Promise); + assert_equals(42, await export_promise); +}, "Suspend once"); + +promise_test(async () => { + let i = 0; + function js_import() { + return Promise.resolve(++i); + }; + let wasm_js_import = new WebAssembly.Suspending(js_import); + // void test() { + // for (i = 0; i < 5; ++i) { + // g = g + await import(); + // } + // } + let instance = wasmEvalText(`(module + (import "m" "import" (func $import (param externref) (result i32))) + (global (export "g") (mut i32) (i32.const 0)) + (func (export "test") (param externref) + (local i32) + i32.const 5 + local.set 1 + loop + local.get 0 + call $import + global.get 0 + i32.add + global.set 0 + local.get 1 + i32.const 1 + i32.sub + local.tee 1 + br_if 0 + end + ) + )`, {m: {import: wasm_js_import}}); + let wrapped_export = WebAssembly.promising(instance.exports.test); + let export_promise = wrapped_export(); + assert_equals(0, instance.exports.g.value); + assert_true(export_promise instanceof Promise); + await export_promise; + assert_equals(15, instance.exports.g.value); +}, "Suspend/resume in a loop"); + +promise_test(async () => { + function js_import() { + return 42 + }; + let wasm_js_import = new WebAssembly.Suspending(js_import); + let instance = wasmEvalText(`(module + (import "m" "import" (func $import (param externref) (result i32))) + (global (export "g") (mut i32) (i32.const 0)) + (func (export "test") (param externref) (result i32) + local.get 0 + call $import + global.set 0 + global.get 0 + ) + )`, {m: {import: wasm_js_import}}); + let wrapped_export = WebAssembly.promising(instance.exports.test); + await wrapped_export(); + assert_equals(42, instance.exports.g.value); +}, "Do not suspend if the import's return value is not a Promise"); + +test(t => { + let tag = new WebAssembly.Tag({parameters: []}); + function js_import() { + return Promise.resolve(); + }; + let wasm_js_import = new WebAssembly.Suspending(js_import); + function js_throw() { + throw new Error(); + } + + let instance = wasmEvalText(`(module + (import "m" "import" (func $import (param externref) (result i32))) + (import "m" "js_throw" (func $js_throw)) + (func (export "test") (param externref) (result i32) + local.get 0 + call $import + call $js_throw + ) + )`, {m: {import: wasm_js_import, js_throw}}); + let wrapped_export = WebAssembly.promising(instance.exports.test); + let export_promise = wrapped_export(); + assert_true(export_promise instanceof Promise); + promise_rejects(t, new Error(), export_promise); +}, "Throw after the first suspension"); + +// TODO: Use wasm exception handling to check that the exception can be caught in wasm. + +test(t => { + let tag = new WebAssembly.Tag({parameters: ['i32']}); + function js_import() { + return Promise.reject(new Error()); + }; + let wasm_js_import = new WebAssembly.Suspending(js_import); + + let instance = wasmEvalText(`(module + (import "m" "import" (func $import (param externref) (result i32))) + (func (export "test") (param externref) (result i32) + local.get 0 + call $import + ) + )`, {m: {import: wasm_js_import, tag: tag}}); + let wrapped_export = WebAssembly.promising(instance.exports.test); + let export_promise = wrapped_export(); + assert_true(export_promise instanceof Promise); + promise_rejects(t, new Error(), export_promise); +}, "Rejecting promise"); + +async function TestNestedSuspenders(suspend) { + // Nest two suspenders. The call chain looks like: + // outer (wasm) -> outer (js) -> inner (wasm) -> inner (js) + // If 'suspend' is true, the inner JS function returns a Promise, which + // suspends the inner wasm function, which returns a Promise, which suspends + // the outer wasm function, which returns a Promise. The inner Promise + // resolves first, which resumes the inner continuation. Then the outer + // promise resolves which resumes the outer continuation. + // If 'suspend' is false, the inner and outer JS functions return a regular + // value and no computation is suspended. + + let inner = new WebAssembly.Suspending( + () => suspend ? Promise.resolve(42) : 43, + ); + + let export_inner; + let outer = new WebAssembly.Suspending( + () => suspend ? export_inner() : 42, + ); + + let instance = wasmEvalText(`(module + (import "m" "inner" (func $inner (param externref) (result i32))) + (import "m" "outer" (func $outer (param externref) (result i32))) + (func (export "outer") (param externref) (result i32) + local.get 0 + call $outer + ) + (func (export "inner") (param externref) (result i32) + local.get 0 + call $inner + ) + )`, {m: {inner, outer}}); + export_inner = WebAssembly.promising(instance.exports.inner); + let export_outer = WebAssembly.promising(instance.exports.outer); + let result = export_outer(); + assert_true(result instanceof Promise); + assert_equals(42, await result); +} + +promise_test(async () => { + return TestNestedSuspenders(true); +}, "Test nested suspenders with suspension"); + +promise_test(async () => { + return TestNestedSuspenders(false); +}, "Test nested suspenders with no suspension"); + + +test(t => { + let instance = wasmEvalText(`(module + (func (export "test") (result i32) + call 0 + ) + )`); + let wrapper = WebAssembly.promising(instance.exports.test); + promise_rejects(t, new InternalError(), wrapper()); +}, "Stack overflow"); + +// TODO: Test suspension with funcref. + +test(t => { + // The call stack of this test looks like: + // export1 -> import1 -> export2 -> import2 + // Where export1 is "promising" and import2 is "suspending". Returning a + // promise from import2 should trap because of the JS import in the middle. + let instance; + function import1() { + // import1 -> export2 (unwrapped) + instance.exports.export2(); + } + function import2() { + return Promise.resolve(0); + } + import2 = new WebAssembly.Suspending(import2); + instance = wasmEvalText(`(module + (import "m" "import1" (func $import1 (result i32))) + (import "m" "import2" (func $import2 (result i32))) + (func (export "export1") (result i32) + ;; export1 -> import1 (unwrapped) + call $import1 + ) + (func (export "export2") (result i32) + ;; export2 -> import2 (suspending) + call $import2 + ) + )`, + {'m': {'import1': import1, 'import2': import2}}); + // export1 (promising) + let wrapper = WebAssembly.promising(instance.exports.export1); + promise_rejects(t, new WebAssembly.RuntimeError(), wrapper()); +}, "Test that trying to suspend JS frames traps"); + +tests.then(() => print('Done')); diff --git a/js/src/jit-test/tests/wasm/js-promise-integration/js-promise-integration.old.js b/js/src/jit-test/tests/wasm/js-promise-integration/js-promise-integration.old.js new file mode 100644 index 0000000000..cc743eeaaa --- /dev/null +++ b/js/src/jit-test/tests/wasm/js-promise-integration/js-promise-integration.old.js @@ -0,0 +1,406 @@ +// Old version of JS promise integration API +// Modified https://github.com/WebAssembly/js-promise-integration/tree/main/test/js-api/js-promise-integration + +var tests = Promise.resolve(); +function test(fn, n) { + + tests = tests.then(() => { + let t = {res: null}; + print("# " + n); + fn(t); + return t.res; + }); +} +function promise_test(fn, n) { + tests = tests.then(() => { + print("# " + n); + return fn(); + }); +} +function assert_true(f) { assertEq(f, true); } +function assert_equals(a, b) { assertEq(a, b); } +function assert_array_equals(a, b) { + assert_equals(a.length, a.length); + for (let i = 0; i < a.length; i++) { + assert_equals(a[i], b[i]); + } +} +function assert_throws(ex, fn) { + try { + fn(); assertEq(false, true); + } catch(e) { + assertEq(e instanceof ex, true); + } +} +function promise_rejects(t, obj, p) { + t.res = p.then(() => { + assertEq(true, false); + }, (e) => { + assertEq(e instanceof obj.constructor, true); + }); +} + +function ToPromising(wasm_export) { + let sig = wasm_export.type(); + assert_true(sig.parameters.length > 0); + assert_equals('externref', sig.parameters[0]); + let wrapper_sig = { + parameters: sig.parameters.slice(1), + results: ['externref'] + }; + return new WebAssembly.Function( + wrapper_sig, wasm_export, {promising: 'first'}); +} + +test(() => { + function js_import(i) {} + + let import_wrapper = new WebAssembly.Function( + {parameters: ['externref', 'i32'], results: []}, + js_import, + {suspending: 'first'}); + let instance = wasmEvalText(`(module + (import "m" "import" (func (param externref i32))) + (func (export "export") (param externref i32) (result i32) + local.get 1 + ) + (func (export "void_export") (param externref)) + )`, {'m': {'import': import_wrapper}}); + let export_wrapper = ToPromising(instance.exports.export); + + // Bad flag value. + assert_throws(TypeError, () => new WebAssembly.Function( + {parameters: ['externref', 'i32'], results: []}, + js_import, + {suspending: 'foo'})); + + assert_throws(TypeError, () => new WebAssembly.Function( + {parameters: ['i32'], results: ['externref']}, + instance.exports.export, + {promising: 'foo'})); + + // Signature mismatch. + assert_throws(Error /*TypeError*/, () => new WebAssembly.Function( + {parameters: ['externref'], results: []}, + new WebAssembly.Function( + {parameters: [], results: ['i32']}, js_import), + {suspending: 'first'})); + + assert_throws(TypeError, () => new WebAssembly.Function( + {parameters: ['externref', 'i32'], results: ['i32']}, + instance.exports.export, + {promising: 'first'})); + + // Check the wrapper signatures. + // let export_sig = export_wrapper.type(); + // assert_array_equals(['i32'], export_sig.parameters); + // assert_array_equals(['externref'], export_sig.results); + + let import_sig = import_wrapper.type(); + assert_array_equals(['externref', 'i32'], import_sig.parameters); + assert_array_equals([], import_sig.results); + // let void_export_wrapper = ToPromising(instance.exports.void_export); + // let void_export_sig = void_export_wrapper.type(); + // assert_array_equals([], void_export_sig.parameters); + // assert_array_equals(['externref'], void_export_sig.results); +}, "Test import and export type checking"); + +promise_test(async () => { + let js_import = new WebAssembly.Function( + {parameters: ['externref'], results: ['i32']}, + () => Promise.resolve(42), + {suspending: 'first'}); + let instance = wasmEvalText(`(module + (import "m" "import" (func $import (param externref) (result i32))) + (func (export "test") (param externref) (result i32) + local.get 0 + call $import + ) + )`, {m: {import: js_import}}); + let wrapped_export = ToPromising(instance.exports.test); + let export_promise = wrapped_export(); + assert_true(export_promise instanceof Promise); + assert_equals(42, await export_promise); +}, "Suspend once"); + +promise_test(async () => { + let i = 0; + function js_import() { + return Promise.resolve(++i); + }; + let wasm_js_import = new WebAssembly.Function( + {parameters: ['externref'], results: ['i32']}, + js_import, + {suspending: 'first'}); + // void test() { + // for (i = 0; i < 5; ++i) { + // g = g + await import(); + // } + // } + let instance = wasmEvalText(`(module + (import "m" "import" (func $import (param externref) (result i32))) + (global (export "g") (mut i32) (i32.const 0)) + (func (export "test") (param externref) + (local i32) + i32.const 5 + local.set 1 + loop + local.get 0 + call $import + global.get 0 + i32.add + global.set 0 + local.get 1 + i32.const 1 + i32.sub + local.tee 1 + br_if 0 + end + ) + )`, {m: {import: wasm_js_import}}); + let wrapped_export = ToPromising(instance.exports.test); + let export_promise = wrapped_export(); + assert_equals(0, instance.exports.g.value); + assert_true(export_promise instanceof Promise); + await export_promise; + assert_equals(15, instance.exports.g.value); +}, "Suspend/resume in a loop"); + +promise_test(async () => { + function js_import() { + return 42 + }; + let wasm_js_import = new WebAssembly.Function( + {parameters: ['externref'], results: ['i32']}, + js_import, + {suspending: 'first'}); + let instance = wasmEvalText(`(module + (import "m" "import" (func $import (param externref) (result i32))) + (global (export "g") (mut i32) (i32.const 0)) + (func (export "test") (param externref) (result i32) + local.get 0 + call $import + global.set 0 + global.get 0 + ) + )`, {m: {import: wasm_js_import}}); + let wrapped_export = ToPromising(instance.exports.test); + await wrapped_export(); + assert_equals(42, instance.exports.g.value); +}, "Do not suspend if the import's return value is not a Promise"); + +test(t => { + let tag = new WebAssembly.Tag({parameters: []}); + function js_import() { + return Promise.resolve(); + }; + let wasm_js_import = new WebAssembly.Function( + {parameters: ['externref'], results: ['i32']}, + js_import, + {suspending: 'first'}); + function js_throw() { + throw new Error(); + } + + let instance = wasmEvalText(`(module + (import "m" "import" (func $import (param externref) (result i32))) + (import "m" "js_throw" (func $js_throw)) + (func (export "test") (param externref) (result i32) + local.get 0 + call $import + call $js_throw + ) + )`, {m: {import: wasm_js_import, js_throw}}); + let wrapped_export = ToPromising(instance.exports.test); + let export_promise = wrapped_export(); + assert_true(export_promise instanceof Promise); + promise_rejects(t, new Error(), export_promise); +}, "Throw after the first suspension"); + +// TODO: Use wasm exception handling to check that the exception can be caught in wasm. + +test(t => { + let tag = new WebAssembly.Tag({parameters: ['i32']}); + function js_import() { + return Promise.reject(new Error()); + }; + let wasm_js_import = new WebAssembly.Function( + {parameters: ['externref'], results: ['i32']}, + js_import, + {suspending: 'first'}); + + let instance = wasmEvalText(`(module + (import "m" "import" (func $import (param externref) (result i32))) + (func (export "test") (param externref) (result i32) + local.get 0 + call $import + ) + )`, {m: {import: wasm_js_import, tag: tag}}); + let wrapped_export = ToPromising(instance.exports.test); + let export_promise = wrapped_export(); + assert_true(export_promise instanceof Promise); + promise_rejects(t, new Error(), export_promise); +}, "Rejecting promise"); + +async function TestNestedSuspenders(suspend) { + // Nest two suspenders. The call chain looks like: + // outer (wasm) -> outer (js) -> inner (wasm) -> inner (js) + // If 'suspend' is true, the inner JS function returns a Promise, which + // suspends the inner wasm function, which returns a Promise, which suspends + // the outer wasm function, which returns a Promise. The inner Promise + // resolves first, which resumes the inner continuation. Then the outer + // promise resolves which resumes the outer continuation. + // If 'suspend' is false, the inner and outer JS functions return a regular + // value and no computation is suspended. + + let inner = new WebAssembly.Function( + {parameters: ['externref'], results: ['i32']}, + () => suspend ? Promise.resolve(42) : 43, + {suspending: 'first'}); + + let export_inner; + let outer = new WebAssembly.Function( + {parameters: ['externref'], results: ['i32']}, + () => suspend ? export_inner() : 42, + {suspending: 'first'}); + + let instance = wasmEvalText(`(module + (import "m" "inner" (func $inner (param externref) (result i32))) + (import "m" "outer" (func $outer (param externref) (result i32))) + (func (export "outer") (param externref) (result i32) + local.get 0 + call $outer + ) + (func (export "inner") (param externref) (result i32) + local.get 0 + call $inner + ) + )`, {m: {inner, outer}}); + export_inner = ToPromising(instance.exports.inner); + let export_outer = ToPromising(instance.exports.outer); + let result = export_outer(); + assert_true(result instanceof Promise); + assert_equals(42, await result); +} + +promise_test(async () => { + return TestNestedSuspenders(true); +}, "Test nested suspenders with suspension"); + +promise_test(async () => { + return TestNestedSuspenders(false); +}, "Test nested suspenders with no suspension"); + +test(() => { + let js_import = new WebAssembly.Function( + {parameters: ['externref'], results: ['i32']}, + () => Promise.resolve(42), + {suspending: 'first'}); + let instance = wasmEvalText(`(module + (import "m" "import" (func $import (param externref) (result i32))) + (func (export "test") (param externref) (result i32) + local.get 0 + call $import + ) + (func (export "return_suspender") (param externref) (result externref) + local.get 0 + ) + )`, {m: {import: js_import}}); + let suspender = ToPromising(instance.exports.return_suspender)(); + for (s of [suspender, null, undefined, {}]) { + assert_throws(WebAssembly.RuntimeError, () => instance.exports.test(s)); + } +}, "Call import with an invalid suspender"); + +test(t => { + let instance = wasmEvalText(`(module + (func (export "test") (param externref) (result i32) + local.get 0 + call 0 + ) + )`); + let wrapper = ToPromising(instance.exports.test); + promise_rejects(t, new InternalError(), wrapper()); +}, "Stack overflow"); + +test (() => { + let js_import = new WebAssembly.Function( + {parameters: ['externref'], results: ['i32']}, + () => Promise.resolve(42), + {suspending: 'first'}); + let instance = wasmEvalText(`(module + (import "m" "import" (func $import (param externref) (result i32))) + (func (export "test") (param externref) (result i32) + local.get 0 + call $import + ) + (func (export "return_suspender") (param externref) (result externref) + local.get 0 + ) + )`, {m: {import: js_import}}); + let suspender = ToPromising(instance.exports.return_suspender)(); + for (s of [suspender, null, undefined, {}]) { + assert_throws(WebAssembly.RuntimeError, () => instance.exports.test(s)); + } +}, "Pass an invalid suspender"); + +// TODO: Test suspension with funcref. + +test(t => { + // The call stack of this test looks like: + // export1 -> import1 -> export2 -> import2 + // Where export1 is "promising" and import2 is "suspending". Returning a + // promise from import2 should trap because of the JS import in the middle. + let instance; + function import1() { + // import1 -> export2 (unwrapped) + instance.exports.export2(); + } + function import2() { + return Promise.resolve(0); + } + import2 = new WebAssembly.Function( + {parameters: ['externref'], results: ['i32']}, + import2, + {suspending: 'first'}); + instance = wasmEvalText(`(module + (import "m" "import1" (func $import1 (result i32))) + (import "m" "import2" (func $import2 (param externref) (result i32))) + (global (mut externref) (ref.null extern)) + (func (export "export1") (param externref) (result i32) + ;; export1 -> import1 (unwrapped) + local.get 0 + global.set 0 + call $import1 + ) + (func (export "export2") (result i32) + ;; export2 -> import2 (suspending) + global.get 0 + call $import2 + ) + )`, + {'m': {'import1': import1, 'import2': import2}}); + // export1 (promising) + let wrapper = new WebAssembly.Function( + {parameters: [], results: ['externref']}, + instance.exports.export1, + {promising: 'first'}); + promise_rejects(t, new WebAssembly.RuntimeError(), wrapper()); +}, "Test that trying to suspend JS frames traps"); + +"Invalid test. Skipping..." || test(() => { + let js_import = new WebAssembly.Function( + {parameters: ['externref'], results: ['i32']}, + () => 42, + {suspending: 'first'}); + let instance = wasmEvalText(`(module + (import "m" "import" (func $import (param externref) (result i32))) + (func (export "test") (param externref) (result i32) + local.get 0 + call $import + ) + )`, {m: {import: js_import}}); + assert_equals(42, instance.exports.test(null)); +}, "Pass an invalid suspender to the import and return a non-promise"); + +tests.then(() => print('Done')); diff --git a/js/src/jit-test/tests/wasm/js-promise-integration/multi.js b/js/src/jit-test/tests/wasm/js-promise-integration/multi.js new file mode 100644 index 0000000000..7713637642 --- /dev/null +++ b/js/src/jit-test/tests/wasm/js-promise-integration/multi.js @@ -0,0 +1,36 @@ +// Multiple promises at the same time. + +function js_import() { + return Promise.resolve(42); +} +var wasm_js_import = new WebAssembly.Function( + { parameters: ['externref'], results: ['i32'] }, + js_import, + { suspending: 'first' }); + +var ins = wasmEvalText(`(module + (import "m" "import" (func $f (param externref) (result i32))) + (func (export "test") (param externref) (result i32) + local.get 0 + call $f + ) +)`, {"m": {import: wasm_js_import}}); + +let wrapped_export = new WebAssembly.Function( + { + parameters: [], + results: ['externref'] + }, + ins.exports.test, { promising: 'first' }); + +Promise.resolve().then(() => { + wrapped_export().then(i => { + assertEq(42, i) + }); +}); + +Promise.resolve().then(() => { + wrapped_export().then(i => { + assertEq(42, i) + }); +}); diff --git a/js/src/jit-test/tests/wasm/regress/bug1866545.js b/js/src/jit-test/tests/wasm/regress/bug1866545.js new file mode 100644 index 0000000000..6c6a92c0ab --- /dev/null +++ b/js/src/jit-test/tests/wasm/regress/bug1866545.js @@ -0,0 +1,25 @@ +// Tests stack alignment during tail calls (in Ion). + +var ins = wasmEvalText(` + (module + (func $trap + (param $i i32) (param $arr i32) + unreachable + ) + (func $second + (return_call $trap + (i32.const 33) + (i32.const 66) + ) + ) + (func (export "test") + (call $second) + ) + ) +`); + +assertErrorMessage( + () => ins.exports.test(), + WebAssembly.RuntimeError, + "unreachable executed", +); diff --git a/js/src/jit-test/tests/wasm/regress/bug1891658.js b/js/src/jit-test/tests/wasm/regress/bug1891658.js new file mode 100644 index 0000000000..304ea0f5ea --- /dev/null +++ b/js/src/jit-test/tests/wasm/regress/bug1891658.js @@ -0,0 +1,10 @@ +// Tests OOM during wasmLosslessInvoke. + +var ins = wasmEvalText('(module (func (export "f")(result i32) i32.const 1))'); + +oomAtAllocation(1); +try { + wasmLosslessInvoke(ins.exports.f); +} catch (e) { + assertEq(e, "out of memory"); +} diff --git a/js/src/jit-test/tests/wasm/tail-calls/bug1891422.js b/js/src/jit-test/tests/wasm/tail-calls/bug1891422.js new file mode 100644 index 0000000000..c5c43d006f --- /dev/null +++ b/js/src/jit-test/tests/wasm/tail-calls/bug1891422.js @@ -0,0 +1,27 @@ +// |jit-test| --more-compartments; skip-variant-if: --setpref=wasm_test_serialization=true, true; skip-variant-if: --wasm-compiler=ion, true + +a = newGlobal({ newCompartment: true }); +a.b = this; +a.eval(`Debugger(b).onExceptionUnwind = function () {};`); + +var ins0 = wasmEvalText(`(module + (func $fac-acc (export "e") (param i64 i64) + unreachable + ) +)`); +var ins = wasmEvalText(`(module + (import "" "e" (func $fac-acc (param i64 i64))) + (type $tz (func (param i64))) + (table $t 1 1 funcref) + (func $f (export "fac") (param i64) + local.get 0 + i32.const 0 + return_call_indirect $t (type $tz) + ) + (elem $t (i32.const 0) $fac-acc) +)`, {"": {e: ins0.exports.e}}); + + +assertErrorMessage(() => { + ins.exports.fac(5n); +}, WebAssembly.RuntimeError, /indirect call signature mismatch/); diff --git a/js/src/jit-test/tests/wasm/testing/bug1894586.js b/js/src/jit-test/tests/wasm/testing/bug1894586.js new file mode 100644 index 0000000000..eb19cc0a69 --- /dev/null +++ b/js/src/jit-test/tests/wasm/testing/bug1894586.js @@ -0,0 +1,13 @@ +var it = 100; +function f() { + if (--it < 0) { + return; + } + wasmDumpIon( + wasmTextToBinary( + "(type $x (struct))(global $g (ref null $x) ref.null $x)(func $h)" + ) + ); + oomTest(f); +} +f(); diff --git a/js/src/jit/ABIFunctionList-inl.h b/js/src/jit/ABIFunctionList-inl.h index eb2123f7a2..a1a992e77c 100644 --- a/js/src/jit/ABIFunctionList-inl.h +++ b/js/src/jit/ABIFunctionList-inl.h @@ -21,6 +21,7 @@ #include "builtin/Object.h" // js::ObjectClassToString #include "builtin/RegExp.h" // js::RegExpPrototypeOptimizableRaw, // js::RegExpInstanceOptimizableRaw +#include "builtin/Sorting.h" // js::ArraySortData #include "builtin/TestingFunctions.h" // js::FuzzilliHash* #include "irregexp/RegExpAPI.h" @@ -45,11 +46,12 @@ #include "proxy/Proxy.h" // js::ProxyGetProperty -#include "vm/ArgumentsObject.h" // js::ArgumentsObject::finishForIonPure -#include "vm/Interpreter.h" // js::TypeOfObject -#include "vm/NativeObject.h" // js::NativeObject -#include "vm/RegExpShared.h" // js::ExecuteRegExpAtomRaw -#include "wasm/WasmBuiltins.h" // js::wasm::* +#include "vm/ArgumentsObject.h" // js::ArgumentsObject::finishForIonPure +#include "vm/Interpreter.h" // js::TypeOfObject +#include "vm/NativeObject.h" // js::NativeObject +#include "vm/RegExpShared.h" // js::ExecuteRegExpAtomRaw +#include "vm/TypedArrayObject.h" // js::TypedArraySortFromJit +#include "wasm/WasmBuiltins.h" // js::wasm::* #include "builtin/Boolean-inl.h" // js::EmulatesUndefined @@ -103,7 +105,8 @@ namespace jit { _(js::ArgumentsObject::finishForIonPure) \ _(js::ArgumentsObject::finishInlineForIonPure) \ _(js::ArrayShiftMoveElements) \ - _(js::ArraySortData::sortWithComparator) \ + _(js::ArraySortData::sortArrayWithComparator) \ + _(js::ArraySortData::sortTypedArrayWithComparator) \ _(js::ArraySortFromJit) \ _(js::ecmaAtan2) \ _(js::ecmaHypot) \ @@ -175,6 +178,7 @@ namespace jit { _(js::jit::StringTrimEndIndex) \ _(js::jit::StringTrimStartIndex) \ _(js::jit::TypeOfNameObject) \ + _(js::jit::TypeOfEqObject) \ _(js::jit::WrapObjectPure) \ ABIFUNCTION_FUZZILLI_LIST(_) \ _(js::MapIteratorObject::next) \ @@ -189,6 +193,7 @@ namespace jit { _(js::RegExpPrototypeOptimizableRaw) \ _(js::SetIteratorObject::next) \ _(js::StringToNumberPure) \ + _(js::TypedArraySortFromJit) \ _(js::TypeOfObject) \ _(mozilla::SIMD::memchr16) \ _(mozilla::SIMD::memchr2x16) \ diff --git a/js/src/jit/Bailouts.cpp b/js/src/jit/Bailouts.cpp index 3730d8997a..1d2657c399 100644 --- a/js/src/jit/Bailouts.cpp +++ b/js/src/jit/Bailouts.cpp @@ -54,9 +54,11 @@ class js::jit::BailoutStack { # pragma pack(pop) #endif +#if !defined(JS_CODEGEN_NONE) // Make sure the compiler doesn't add extra padding on 32-bit platforms. static_assert((sizeof(BailoutStack) % 8) == 0, "BailoutStack should be 8-byte aligned."); +#endif BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator& activations, BailoutStack* bailout) diff --git a/js/src/jit/BaselineCacheIRCompiler.cpp b/js/src/jit/BaselineCacheIRCompiler.cpp index 92490ef8b8..29cada7037 100644 --- a/js/src/jit/BaselineCacheIRCompiler.cpp +++ b/js/src/jit/BaselineCacheIRCompiler.cpp @@ -427,7 +427,7 @@ bool BaselineCacheIRCompiler::emitGuardSpecificAtom(StringOperandId strId, Address atomAddr(stubAddress(expectedOffset)); - Label done; + Label done, notCachedAtom; masm.branchPtr(Assembler::Equal, atomAddr, str, &done); // The pointers are not equal, so if the input string is also an atom it @@ -435,6 +435,11 @@ bool BaselineCacheIRCompiler::emitGuardSpecificAtom(StringOperandId strId, masm.branchTest32(Assembler::NonZero, Address(str, JSString::offsetOfFlags()), Imm32(JSString::ATOM_BIT), failure->label()); + masm.tryFastAtomize(str, scratch, scratch, ¬CachedAtom); + masm.branchPtr(Assembler::Equal, atomAddr, scratch, &done); + masm.jump(failure->label()); + masm.bind(¬CachedAtom); + // Check the length. masm.loadPtr(atomAddr, scratch); masm.loadStringLength(scratch, scratch); @@ -1464,9 +1469,13 @@ bool BaselineCacheIRCompiler::emitHasClassResult(ObjOperandId objId, void BaselineCacheIRCompiler::emitAtomizeString(Register str, Register temp, Label* failure) { - Label isAtom; + Label isAtom, notCachedAtom; masm.branchTest32(Assembler::NonZero, Address(str, JSString::offsetOfFlags()), Imm32(JSString::ATOM_BIT), &isAtom); + masm.tryFastAtomize(str, temp, str, ¬CachedAtom); + masm.jump(&isAtom); + masm.bind(¬CachedAtom); + { LiveRegisterSet save(GeneralRegisterSet::Volatile(), liveVolatileFloatRegs()); @@ -2032,6 +2041,7 @@ bool BaselineCacheIRCompiler::init(CacheKind kind) { break; case CacheKind::GetProp: case CacheKind::TypeOf: + case CacheKind::TypeOfEq: case CacheKind::ToPropertyKey: case CacheKind::GetIterator: case CacheKind::OptimizeSpreadCall: diff --git a/js/src/jit/BaselineCodeGen.cpp b/js/src/jit/BaselineCodeGen.cpp index 8ab65458ea..ae930a40eb 100644 --- a/js/src/jit/BaselineCodeGen.cpp +++ b/js/src/jit/BaselineCodeGen.cpp @@ -4544,6 +4544,18 @@ bool BaselineCodeGen<Handler>::emit_TypeofExpr() { } template <typename Handler> +bool BaselineCodeGen<Handler>::emit_TypeofEq() { + frame.popRegsAndSync(1); + + if (!emitNextIC()) { + return false; + } + + frame.push(R0); + return true; +} + +template <typename Handler> bool BaselineCodeGen<Handler>::emit_ThrowMsg() { prepareVMCall(); pushUint8BytecodeOperandArg(R2.scratchReg()); diff --git a/js/src/jit/BaselineDebugModeOSR.cpp b/js/src/jit/BaselineDebugModeOSR.cpp index 37b01fe93a..9a3b67ff4e 100644 --- a/js/src/jit/BaselineDebugModeOSR.cpp +++ b/js/src/jit/BaselineDebugModeOSR.cpp @@ -475,8 +475,9 @@ static void UndoRecompileBaselineScriptsForDebugMode( for (UniqueScriptOSREntryIter iter(entries); !iter.done(); ++iter) { const DebugModeOSREntry& entry = iter.entry(); JSScript* script = entry.script; - BaselineScript* baselineScript = script->baselineScript(); if (entry.recompiled()) { + BaselineScript* baselineScript = + script->jitScript()->clearBaselineScript(cx->gcContext(), script); script->jitScript()->setBaselineScript(script, entry.oldBaselineScript); BaselineScript::Destroy(cx->gcContext(), baselineScript); } diff --git a/js/src/jit/BaselineIC.cpp b/js/src/jit/BaselineIC.cpp index 705dcb8e46..88ff52e16e 100644 --- a/js/src/jit/BaselineIC.cpp +++ b/js/src/jit/BaselineIC.cpp @@ -32,6 +32,7 @@ #include "vm/JSFunction.h" #include "vm/JSScript.h" #include "vm/Opcodes.h" +#include "vm/TypeofEqOperand.h" // TypeofEqOperand #ifdef MOZ_VTUNE # include "vtune/VTuneWrapper.h" #endif @@ -356,6 +357,8 @@ class MOZ_STATIC_CLASS OpToFallbackKindTable { setKind(JSOp::Typeof, BaselineICFallbackKind::TypeOf); setKind(JSOp::TypeofExpr, BaselineICFallbackKind::TypeOf); + setKind(JSOp::TypeofEq, BaselineICFallbackKind::TypeOfEq); + setKind(JSOp::ToPropertyKey, BaselineICFallbackKind::ToPropertyKey); setKind(JSOp::Iter, BaselineICFallbackKind::GetIterator); @@ -429,6 +432,7 @@ bool ICSupportsPolymorphicTypeData(JSOp op) { switch (kind) { case BaselineICFallbackKind::ToBool: case BaselineICFallbackKind::TypeOf: + case BaselineICFallbackKind::TypeOfEq: return true; default: return false; @@ -1143,7 +1147,7 @@ bool DoGetNameFallback(JSContext* cx, BaselineFrame* frame, static_assert(JSOpLength_GetGName == JSOpLength_GetName, "Otherwise our check for JSOp::Typeof isn't ok"); - if (JSOp(pc[JSOpLength_GetGName]) == JSOp::Typeof) { + if (IsTypeOfNameOp(JSOp(pc[JSOpLength_GetGName]))) { if (!GetEnvironmentName<GetNameMode::TypeOf>(cx, envChain, name, res)) { return false; } @@ -2056,6 +2060,45 @@ bool FallbackICCodeCompiler::emit_TypeOf() { } // +// TypeOfEq_Fallback +// + +bool DoTypeOfEqFallback(JSContext* cx, BaselineFrame* frame, + ICFallbackStub* stub, HandleValue val, + MutableHandleValue res) { + stub->incrementEnteredCount(); + MaybeNotifyWarp(frame->outerScript(), stub); + FallbackICSpew(cx, stub, "TypeOfEq"); + + jsbytecode* pc = StubOffsetToPc(stub, frame->script()); + auto operand = TypeofEqOperand::fromRawValue(GET_UINT8(pc)); + JSType type = operand.type(); + JSOp compareOp = operand.compareOp(); + + TryAttachStub<TypeOfEqIRGenerator>("TypeOfEq", cx, frame, stub, val, type, + compareOp); + + bool result = js::TypeOfValue(val) == type; + if (compareOp == JSOp::Ne) { + result = !result; + } + res.setBoolean(result); + return true; +} + +bool FallbackICCodeCompiler::emit_TypeOfEq() { + EmitRestoreTailCallReg(masm); + + masm.pushValue(R0); + masm.push(ICStubReg); + pushStubPayload(masm, R0.scratchReg()); + + using Fn = bool (*)(JSContext*, BaselineFrame*, ICFallbackStub*, HandleValue, + MutableHandleValue); + return tailCallVM<Fn, DoTypeOfEqFallback>(masm); +} + +// // ToPropertyKey_Fallback // diff --git a/js/src/jit/BaselineIC.h b/js/src/jit/BaselineIC.h index 560955e27a..2b11702494 100644 --- a/js/src/jit/BaselineIC.h +++ b/js/src/jit/BaselineIC.h @@ -412,6 +412,10 @@ extern bool DoTypeOfFallback(JSContext* cx, BaselineFrame* frame, ICFallbackStub* stub, HandleValue val, MutableHandleValue res); +extern bool DoTypeOfEqFallback(JSContext* cx, BaselineFrame* frame, + ICFallbackStub* stub, HandleValue val, + MutableHandleValue res); + extern bool DoToPropertyKeyFallback(JSContext* cx, BaselineFrame* frame, ICFallbackStub* stub, HandleValue val, MutableHandleValue res); diff --git a/js/src/jit/BaselineICList.h b/js/src/jit/BaselineICList.h index 7ff39357b5..4856283d20 100644 --- a/js/src/jit/BaselineICList.h +++ b/js/src/jit/BaselineICList.h @@ -35,6 +35,7 @@ namespace jit { _(OptimizeSpreadCall) \ _(InstanceOf) \ _(TypeOf) \ + _(TypeOfEq) \ _(ToPropertyKey) \ _(Rest) \ _(BinaryArith) \ diff --git a/js/src/jit/BranchHinting.cpp b/js/src/jit/BranchHinting.cpp new file mode 100644 index 0000000000..01c311267f --- /dev/null +++ b/js/src/jit/BranchHinting.cpp @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: set ts=8 sts=2 et sw=2 tw=80: + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "jit/BranchHinting.h" + +#include "jit/IonAnalysis.h" +#include "jit/JitSpewer.h" +#include "jit/MIRGenerator.h" +#include "jit/MIRGraph.h" + +using namespace js; +using namespace js::jit; + +// Implementation of the branch hinting proposal +// Some control instructions (if and br_if) can have a hint of the form +// Likely or unlikely. That means a specific branch will be likely/unlikely +// to be executed at runtime. + +// In a first pass, we tag the basic blocks if we have a hint. +// In a Mir to Mir transformation, we read the hints and do something with it: +// - Unlikely blocks are pushed to the end of the function. +// Because of Ion's structure, we don't do that for blocks inside a loop. +// - TODO: do something for likely blocks. +// - TODO: register allocator can be tuned depending on the hints. +bool jit::BranchHinting(MIRGenerator* mir, MIRGraph& graph) { + JitSpew(JitSpew_BranchHint, "Beginning BranchHinting pass"); + + // Move towards the end all blocks marked as unlikely + mozilla::Vector<MBasicBlock*, 0> toBeMoved; + + for (MBasicBlock* block : graph) { + // If this block has a return instruction, it's safe to push it + // to the end of the graph. + // If the block doesn't contain a return, a backedge outside a loop will be + // created, which would break ReversePostOrder assertions. + // Avoid moving a block if it's in the middle of a loop as well. + if (block->branchHintingUnlikely() && block->loopDepth() == 0 && + block->hasLastIns() && block->lastIns()->is<js::jit::MWasmReturn>()) { + if (!toBeMoved.append(block)) { + return false; + } + } + } + + for (MBasicBlock* block : toBeMoved) { +#ifdef JS_JITSPEW + JitSpew(JitSpew_BranchHint, "Moving block%u to the end", block->id()); +#endif + graph.moveBlockToEnd(block); + } + + if (!toBeMoved.empty()) { + // Renumber blocks after moving them around. + RenumberBlocks(graph); + } + + return true; +} diff --git a/js/src/jit/BranchHinting.h b/js/src/jit/BranchHinting.h new file mode 100644 index 0000000000..97665fd2c5 --- /dev/null +++ b/js/src/jit/BranchHinting.h @@ -0,0 +1,21 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: set ts=8 sts=2 et sw=2 tw=80: + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jit_BranchHinting_h +#define jit_BranchHinting_h + +// This file represents the wasm Branch Hinting optimization pass + +namespace js::jit { + +class MIRGenerator; +class MIRGraph; + +[[nodiscard]] bool BranchHinting(MIRGenerator* mir, MIRGraph& graph); + +} // namespace js::jit + +#endif /* jit_BranchHinting_h */ diff --git a/js/src/jit/CacheIR.cpp b/js/src/jit/CacheIR.cpp index 03eae14140..4de24905b8 100644 --- a/js/src/jit/CacheIR.cpp +++ b/js/src/jit/CacheIR.cpp @@ -49,7 +49,8 @@ #include "vm/ProxyObject.h" #include "vm/RegExpObject.h" #include "vm/SelfHosting.h" -#include "vm/ThrowMsgKind.h" // ThrowCondition +#include "vm/ThrowMsgKind.h" // ThrowCondition +#include "vm/TypeofEqOperand.h" // TypeofEqOperand #include "vm/Watchtower.h" #include "wasm/WasmInstance.h" @@ -109,6 +110,7 @@ size_t js::jit::NumInputsForCacheKind(CacheKind kind) { return 0; case CacheKind::GetProp: case CacheKind::TypeOf: + case CacheKind::TypeOfEq: case CacheKind::ToPropertyKey: case CacheKind::GetIterator: case CacheKind::ToBool: @@ -3170,6 +3172,11 @@ AttachDecision GetPropIRGenerator::tryAttachTypedArrayElement( auto* tarr = &obj->as<TypedArrayObject>(); + if (tarr->type() == Scalar::Float16) { + // TODO: See Bug 1835034 for JIT support for Float16Array. + return AttachDecision::NoAction; + } + bool handleOOB = false; int64_t indexInt64; if (!ValueIsInt64Index(idVal_, &indexInt64) || indexInt64 < 0 || @@ -4530,6 +4537,7 @@ OperandId IRGenerator::emitNumericGuard(ValOperandId valId, const Value& v, return writer.truncateDoubleToUInt32(numId); } + case Scalar::Float16: case Scalar::Float32: case Scalar::Float64: { if (v.isNumber()) { @@ -5061,6 +5069,11 @@ AttachDecision SetPropIRGenerator::tryAttachSetTypedArrayElement( auto* tarr = &obj->as<TypedArrayObject>(); Scalar::Type elementType = tarr->type(); + if (elementType == Scalar::Float16) { + // TODO: See Bug 1835034 for JIT support for Float16Array. + return AttachDecision::NoAction; + } + // Don't attach if the input type doesn't match the guard added below. if (!ValueCanConvertToNumeric(elementType, rhsVal_)) { return AttachDecision::NoAction; @@ -5800,6 +5813,77 @@ AttachDecision TypeOfIRGenerator::tryAttachObject(ValOperandId valId) { return AttachDecision::Attach; } +TypeOfEqIRGenerator::TypeOfEqIRGenerator(JSContext* cx, HandleScript script, + jsbytecode* pc, ICState state, + HandleValue value, JSType type, + JSOp compareOp) + : IRGenerator(cx, script, pc, CacheKind::TypeOfEq, state), + val_(value), + type_(type), + compareOp_(compareOp) {} + +void TypeOfEqIRGenerator::trackAttached(const char* name) { + stubName_ = name ? name : "NotAttached"; +#ifdef JS_CACHEIR_SPEW + if (const CacheIRSpewer::Guard& sp = CacheIRSpewer::Guard(*this, name)) { + sp.valueProperty("val", val_); + sp.jstypeProperty("type", type_); + sp.opcodeProperty("compareOp", compareOp_); + } +#endif +} + +AttachDecision TypeOfEqIRGenerator::tryAttachStub() { + MOZ_ASSERT(cacheKind_ == CacheKind::TypeOfEq); + + AutoAssertNoPendingException aanpe(cx_); + + ValOperandId valId(writer.setInputOperandId(0)); + + TRY_ATTACH(tryAttachPrimitive(valId)); + TRY_ATTACH(tryAttachObject(valId)); + + MOZ_ASSERT_UNREACHABLE("Failed to attach TypeOfEq"); + return AttachDecision::NoAction; +} + +AttachDecision TypeOfEqIRGenerator::tryAttachPrimitive(ValOperandId valId) { + if (!val_.isPrimitive()) { + return AttachDecision::NoAction; + } + + // Note: we don't use GuardIsNumber for int32 values because it's less + // efficient in Warp (unboxing to double instead of int32). + if (val_.isDouble()) { + writer.guardIsNumber(valId); + } else { + writer.guardNonDoubleType(valId, val_.type()); + } + + bool result = js::TypeOfValue(val_) == type_; + if (compareOp_ == JSOp::Ne) { + result = !result; + } + writer.loadBooleanResult(result); + writer.returnFromIC(); + writer.setTypeData(TypeData(JSValueType(val_.type()))); + trackAttached("TypeOfEq.Primitive"); + return AttachDecision::Attach; +} + +AttachDecision TypeOfEqIRGenerator::tryAttachObject(ValOperandId valId) { + if (!val_.isObject()) { + return AttachDecision::NoAction; + } + + ObjOperandId objId = writer.guardToObject(valId); + writer.loadTypeOfEqObjectResult(objId, TypeofEqOperand(type_, compareOp_)); + writer.returnFromIC(); + writer.setTypeData(TypeData(JSValueType(val_.type()))); + trackAttached("TypeOfEq.Object"); + return AttachDecision::Attach; +} + GetIteratorIRGenerator::GetIteratorIRGenerator(JSContext* cx, HandleScript script, jsbytecode* pc, ICState state, @@ -9127,6 +9211,7 @@ static bool AtomicsMeetsPreconditions(TypedArrayObject* typedArray, case Scalar::BigUint64: break; + case Scalar::Float16: case Scalar::Float32: case Scalar::Float64: case Scalar::Uint8Clamped: @@ -10308,7 +10393,7 @@ AttachDecision CallIRGenerator::tryAttachFunCall(HandleFunction callee) { writer.guardNotClassConstructor(thisObjId); if (isScripted) { - writer.guardFunctionHasJitEntry(thisObjId, /*isConstructing =*/false); + writer.guardFunctionHasJitEntry(thisObjId); writer.callScriptedFunction(thisObjId, argcId, targetFlags, ClampFixedArgc(argc_)); } else { @@ -11268,7 +11353,7 @@ AttachDecision CallIRGenerator::tryAttachFunApply(HandleFunction calleeFunc) { if (isScripted) { // Guard that function is scripted. - writer.guardFunctionHasJitEntry(thisObjId, /*constructing =*/false); + writer.guardFunctionHasJitEntry(thisObjId); writer.callScriptedFunction(thisObjId, argcId, targetFlags, fixedArgc); } else { // Guard that function is native. @@ -12034,7 +12119,7 @@ void CallIRGenerator::emitCallScriptedGuards(ObjOperandId calleeObjId, } else { // Guard that object is a scripted function writer.guardClass(calleeObjId, GuardClassKind::JSFunction); - writer.guardFunctionHasJitEntry(calleeObjId, isConstructing); + writer.guardFunctionHasJitEntry(calleeObjId); if (isConstructing) { // If callee is not a constructor, we have to throw. diff --git a/js/src/jit/CacheIR.h b/js/src/jit/CacheIR.h index 132070d535..b33a5117c3 100644 --- a/js/src/jit/CacheIR.h +++ b/js/src/jit/CacheIR.h @@ -182,6 +182,7 @@ class TypedOperandId : public OperandId { _(HasOwn) \ _(CheckPrivateField) \ _(TypeOf) \ + _(TypeOfEq) \ _(ToPropertyKey) \ _(InstanceOf) \ _(GetIterator) \ diff --git a/js/src/jit/CacheIRCompiler.cpp b/js/src/jit/CacheIRCompiler.cpp index 9a26b0816c..ceb14f0ecb 100644 --- a/js/src/jit/CacheIRCompiler.cpp +++ b/js/src/jit/CacheIRCompiler.cpp @@ -44,6 +44,7 @@ #include "vm/GeneratorObject.h" #include "vm/GetterSetter.h" #include "vm/Interpreter.h" +#include "vm/TypeofEqOperand.h" // TypeofEqOperand #include "vm/Uint8Clamped.h" #include "builtin/Boolean-inl.h" @@ -1055,6 +1056,15 @@ void CacheIRStubInfo::replaceStubRawWord(uint8_t* stubData, uint32_t offset, *addr = newWord; } +void CacheIRStubInfo::replaceStubRawValueBits(uint8_t* stubData, + uint32_t offset, uint64_t oldBits, + uint64_t newBits) const { + MOZ_ASSERT(uint64_t(stubData + offset) % sizeof(uint64_t) == 0); + uint64_t* addr = reinterpret_cast<uint64_t*>(stubData + offset); + MOZ_ASSERT(*addr == oldBits); + *addr = newBits; +} + template <class Stub, StubField::Type type> typename MapStubFieldToType<type>::WrappedType& CacheIRStubInfo::getStubField( Stub* stub, uint32_t offset) const { @@ -2838,7 +2848,7 @@ bool CacheIRCompiler::emitStringToAtom(StringOperandId stringId) { masm.branchTest32(Assembler::NonZero, Address(str, JSString::offsetOfFlags()), Imm32(JSString::ATOM_BIT), &done); - masm.lookupStringInAtomCacheLastLookups(str, scratch, str, &vmCall); + masm.tryFastAtomize(str, scratch, str, &vmCall); masm.jump(&done); masm.bind(&vmCall); @@ -4670,8 +4680,7 @@ bool CacheIRCompiler::emitGuardNoAllocationMetadataBuilder( return true; } -bool CacheIRCompiler::emitGuardFunctionHasJitEntry(ObjOperandId funId, - bool constructing) { +bool CacheIRCompiler::emitGuardFunctionHasJitEntry(ObjOperandId funId) { JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); Register fun = allocator.useRegister(masm, funId); @@ -4680,7 +4689,7 @@ bool CacheIRCompiler::emitGuardFunctionHasJitEntry(ObjOperandId funId, return false; } - masm.branchIfFunctionHasNoJitEntry(fun, constructing, failure->label()); + masm.branchIfFunctionHasNoJitEntry(fun, failure->label()); return true; } @@ -4694,8 +4703,7 @@ bool CacheIRCompiler::emitGuardFunctionHasNoJitEntry(ObjOperandId funId) { return false; } - masm.branchIfFunctionHasJitEntry(obj, /*isConstructing =*/false, - failure->label()); + masm.branchIfFunctionHasJitEntry(obj, failure->label()); return true; } @@ -6565,6 +6573,7 @@ bool CacheIRCompiler::emitStoreTypedArrayElement(ObjOperandId objId, valInt32.emplace(allocator.useRegister(masm, Int32OperandId(rhsId))); break; + case Scalar::Float16: case Scalar::Float32: case Scalar::Float64: allocator.ensureDoubleRegister(masm, NumberOperandId(rhsId), @@ -7057,6 +7066,7 @@ bool CacheIRCompiler::emitStoreDataViewValueResult( valInt32.emplace(allocator.useRegister(masm, Int32OperandId(valueId))); break; + case Scalar::Float16: case Scalar::Float32: case Scalar::Float64: allocator.ensureDoubleRegister(masm, NumberOperandId(valueId), @@ -7400,6 +7410,69 @@ bool CacheIRCompiler::emitLoadTypeOfObjectResult(ObjOperandId objId) { return true; } +bool CacheIRCompiler::emitLoadTypeOfEqObjectResult(ObjOperandId objId, + TypeofEqOperand operand) { + JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); + AutoOutputRegister output(*this); + Register obj = allocator.useRegister(masm, objId); + AutoScratchRegisterMaybeOutput scratch(allocator, masm, output); + JSType type = operand.type(); + JSOp compareOp = operand.compareOp(); + bool result; + + Label slowCheck, isObject, isCallable, isUndefined, done; + masm.typeOfObject(obj, scratch, &slowCheck, &isObject, &isCallable, + &isUndefined); + + masm.bind(&isCallable); + result = type == JSTYPE_FUNCTION; + if (compareOp == JSOp::Ne) { + result = !result; + } + masm.moveValue(BooleanValue(result), output.valueReg()); + masm.jump(&done); + + masm.bind(&isUndefined); + result = type == JSTYPE_UNDEFINED; + if (compareOp == JSOp::Ne) { + result = !result; + } + masm.moveValue(BooleanValue(result), output.valueReg()); + masm.jump(&done); + + masm.bind(&isObject); + result = type == JSTYPE_OBJECT; + if (compareOp == JSOp::Ne) { + result = !result; + } + masm.moveValue(BooleanValue(result), output.valueReg()); + masm.jump(&done); + + { + masm.bind(&slowCheck); + LiveRegisterSet save(GeneralRegisterSet::Volatile(), + liveVolatileFloatRegs()); + save.takeUnchecked(output.valueReg()); + save.takeUnchecked(scratch); + masm.PushRegsInMask(save); + + using Fn = bool (*)(JSObject* obj, TypeofEqOperand operand); + masm.setupUnalignedABICall(scratch); + masm.passABIArg(obj); + masm.move32(Imm32(TypeofEqOperand(type, compareOp).rawValue()), scratch); + masm.passABIArg(scratch); + masm.callWithABI<Fn, TypeOfEqObject>(); + masm.storeCallBoolResult(scratch); + + masm.PopRegsInMask(save); + + masm.tagValue(JSVAL_TYPE_BOOLEAN, scratch, output.valueReg()); + } + + masm.bind(&done); + return true; +} + bool CacheIRCompiler::emitLoadInt32TruthyResult(ValOperandId inputId) { JitSpew(JitSpew_Codegen, "%s", __FUNCTION__); AutoOutputRegister output(*this); diff --git a/js/src/jit/CacheIRCompiler.h b/js/src/jit/CacheIRCompiler.h index 69b1dd34ac..67e90419a2 100644 --- a/js/src/jit/CacheIRCompiler.h +++ b/js/src/jit/CacheIRCompiler.h @@ -1420,6 +1420,9 @@ class CacheIRStubInfo { void replaceStubRawWord(uint8_t* stubData, uint32_t offset, uintptr_t oldWord, uintptr_t newWord) const; + + void replaceStubRawValueBits(uint8_t* stubData, uint32_t offset, + uint64_t oldBits, uint64_t newBits) const; }; template <typename T> diff --git a/js/src/jit/CacheIRGenerator.h b/js/src/jit/CacheIRGenerator.h index 2e15b2d8a6..778a49071e 100644 --- a/js/src/jit/CacheIRGenerator.h +++ b/js/src/jit/CacheIRGenerator.h @@ -460,6 +460,23 @@ class MOZ_RAII TypeOfIRGenerator : public IRGenerator { AttachDecision tryAttachStub(); }; +class MOZ_RAII TypeOfEqIRGenerator : public IRGenerator { + HandleValue val_; + JSType type_; + JSOp compareOp_; + + AttachDecision tryAttachPrimitive(ValOperandId valId); + AttachDecision tryAttachObject(ValOperandId valId); + void trackAttached(const char* name /* must be a C string literal */); + + public: + TypeOfEqIRGenerator(JSContext* cx, HandleScript, jsbytecode* pc, + ICState state, HandleValue value, JSType type, + JSOp compareOp); + + AttachDecision tryAttachStub(); +}; + class MOZ_RAII GetIteratorIRGenerator : public IRGenerator { HandleValue val_; diff --git a/js/src/jit/CacheIROps.yaml b/js/src/jit/CacheIROps.yaml index 2f3097dfd8..d5d34b4a6a 100644 --- a/js/src/jit/CacheIROps.yaml +++ b/js/src/jit/CacheIROps.yaml @@ -750,7 +750,6 @@ cost_estimate: 1 args: fun: ObjId - constructing: BoolImm - name: GuardFunctionHasNoJitEntry shared: true @@ -2621,6 +2620,14 @@ args: obj: ObjId +- name: LoadTypeOfEqObjectResult + shared: true + transpile: true + cost_estimate: 4 + args: + obj: ObjId + operand: TypeofEqOperandImm + - name: DoubleAddResult shared: true transpile: true diff --git a/js/src/jit/CacheIRReader.h b/js/src/jit/CacheIRReader.h index 59483424a3..a27fd3bb9a 100644 --- a/js/src/jit/CacheIRReader.h +++ b/js/src/jit/CacheIRReader.h @@ -18,6 +18,7 @@ #include "jit/CompactBuffer.h" #include "js/ScalarType.h" #include "js/Value.h" +#include "vm/TypeofEqOperand.h" // TypeofEqOperand #include "wasm/WasmValType.h" enum class JSOp : uint8_t; @@ -112,6 +113,9 @@ class MOZ_RAII CacheIRReader { Scalar::Type scalarType() { return Scalar::Type(buffer_.readByte()); } JSWhyMagic whyMagic() { return JSWhyMagic(buffer_.readByte()); } JSOp jsop() { return JSOp(buffer_.readByte()); } + TypeofEqOperand typeofEqOperand() { + return TypeofEqOperand::fromRawValue(buffer_.readByte()); + } int32_t int32Immediate() { return int32_t(buffer_.readFixedUint32_t()); } uint32_t uint32Immediate() { return buffer_.readFixedUint32_t(); } void* pointer() { return buffer_.readRawPointer(); } diff --git a/js/src/jit/CacheIRSpewer.cpp b/js/src/jit/CacheIRSpewer.cpp index 613e0f7d85..fbc8a50b04 100644 --- a/js/src/jit/CacheIRSpewer.cpp +++ b/js/src/jit/CacheIRSpewer.cpp @@ -71,6 +71,10 @@ class MOZ_RAII CacheIROpsJitSpewer { void spewJSOpImm(const char* name, JSOp op) { out_.printf("%s JSOp::%s", name, CodeName(op)); } + void spewTypeofEqOperandImm(const char* name, TypeofEqOperand operand) { + out_.printf("%s %s %s", name, JSTypeToString(operand.type()), + CodeName(operand.compareOp())); + } void spewStaticStringImm(const char* name, const char* str) { out_.printf("%s \"%s\"", name, str); } @@ -223,6 +227,9 @@ class MOZ_RAII CacheIROpsJSONSpewer { void spewJSOpImm(const char* name, JSOp op) { spewArgImpl(name, "JSOp", CodeName(op)); } + void spewTypeofEqOperandImm(const char* name, TypeofEqOperand operand) { + spewArgImpl(name, "TypeofEqOperand", uint8_t(operand.rawValue())); + } void spewStaticStringImm(const char* name, const char* str) { spewArgImpl(name, "String", str); } @@ -430,6 +437,15 @@ void CacheIRSpewer::opcodeProperty(const char* name, const JSOp op) { j.endStringProperty(); } +void CacheIRSpewer::jstypeProperty(const char* name, const JSType type) { + MOZ_ASSERT(enabled()); + JSONPrinter& j = json_.ref(); + + j.beginStringProperty(name); + output_.put(JSTypeToString(type)); + j.endStringProperty(); +} + void CacheIRSpewer::cacheIRSequence(CacheIRReader& reader) { MOZ_ASSERT(enabled()); JSONPrinter& j = json_.ref(); diff --git a/js/src/jit/CacheIRSpewer.h b/js/src/jit/CacheIRSpewer.h index fba33ba990..6ceb1bb106 100644 --- a/js/src/jit/CacheIRSpewer.h +++ b/js/src/jit/CacheIRSpewer.h @@ -53,6 +53,7 @@ class CacheIRSpewer { void beginCache(const IRGenerator& generator); void valueProperty(const char* name, const Value& v); void opcodeProperty(const char* name, const JSOp op); + void jstypeProperty(const char* name, const JSType type); void cacheIRSequence(CacheIRReader& reader); void attached(const char* name); void endCache(); @@ -101,6 +102,10 @@ class CacheIRSpewer { sp_.opcodeProperty(name, op); } + void jstypeProperty(const char* name, const JSType type) const { + sp_.jstypeProperty(name, type); + } + explicit operator bool() const { return sp_.enabled(); } }; }; diff --git a/js/src/jit/CacheIRWriter.h b/js/src/jit/CacheIRWriter.h index 6a32885d7c..d888012134 100644 --- a/js/src/jit/CacheIRWriter.h +++ b/js/src/jit/CacheIRWriter.h @@ -43,6 +43,7 @@ #include "vm/Opcodes.h" #include "vm/RealmFuses.h" #include "vm/Shape.h" +#include "vm/TypeofEqOperand.h" // TypeofEqOperand #include "wasm/WasmConstants.h" #include "wasm/WasmValType.h" @@ -257,6 +258,9 @@ class MOZ_RAII CacheIRWriter : public JS::CustomAutoRooter { static_assert(sizeof(JSOp) == sizeof(uint8_t), "JSOp must fit in a byte"); buffer_.writeByte(uint8_t(op)); } + void writeTypeofEqOperandImm(TypeofEqOperand operand) { + buffer_.writeByte(operand.rawValue()); + } void writeGuardClassKindImm(GuardClassKind kind) { static_assert(sizeof(GuardClassKind) == sizeof(uint8_t), "GuardClassKind must fit in a byte"); diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index 559ac50cc7..ef4cd5d851 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -77,6 +77,7 @@ #include "vm/StringType.h" #include "vm/TypedArrayObject.h" #include "wasm/WasmCodegenConstants.h" +#include "wasm/WasmPI.h" #include "wasm/WasmValType.h" #ifdef MOZ_VTUNE # include "vtune/VTuneWrapper.h" @@ -972,6 +973,7 @@ void CodeGenerator::visitOutOfLineICFallback(OutOfLineICFallback* ool) { } case CacheKind::Call: case CacheKind::TypeOf: + case CacheKind::TypeOfEq: case CacheKind::ToBool: case CacheKind::GetIntrinsic: case CacheKind::NewArray: @@ -2328,18 +2330,37 @@ void CreateDependentString::generate(MacroAssembler& masm, masm.addToCharPtr(temp1_, temp2_, encoding_); masm.storeNonInlineStringChars(temp1_, string_); masm.storeDependentStringBase(base, string_); - masm.movePtr(base, temp1_); + + // Ensure that the depended-on string is flagged as such, so we don't + // convert it into a forwarded atom + masm.load32(Address(base, JSString::offsetOfFlags()), temp2_); + Label skipDependedOn; + masm.branchTest32(Assembler::NonZero, temp2_, Imm32(JSString::ATOM_BIT), + &skipDependedOn); + masm.or32(Imm32(JSString::DEPENDED_ON_BIT), temp2_); + masm.store32(temp2_, Address(base, JSString::offsetOfFlags())); + masm.bind(&skipDependedOn); // Follow any base pointer if the input is itself a dependent string. // Watch for undepended strings, which have a base pointer but don't // actually share their characters with it. Label noBase; - masm.load32(Address(base, JSString::offsetOfFlags()), temp2_); + masm.movePtr(base, temp1_); masm.and32(Imm32(JSString::TYPE_FLAGS_MASK), temp2_); masm.branchTest32(Assembler::Zero, temp2_, Imm32(JSString::DEPENDENT_BIT), &noBase); masm.loadDependentStringBase(base, temp1_); masm.storeDependentStringBase(temp1_, string_); +#ifdef DEBUG + Label isAppropriatelyMarked; + masm.branchTest32(Assembler::NonZero, + Address(temp1_, JSString::offsetOfFlags()), + Imm32(JSString::ATOM_BIT | JSString::DEPENDED_ON_BIT), + &isAppropriatelyMarked); + masm.assumeUnreachable("Base chain missing DEPENDED_ON_BIT"); + masm.bind(&isAppropriatelyMarked); +#endif + masm.bind(&noBase); // Post-barrier the base store, whether it was the direct or indirect @@ -5495,21 +5516,10 @@ void CodeGenerator::visitAssertCanElidePostWriteBarrier( } template <typename LCallIns> -void CodeGenerator::emitCallNative(LCallIns* call, JSNative native) { - MCallBase* mir = call->mir(); - - uint32_t unusedStack = UnusedStackBytesForCall(mir->paddedNumStackArgs()); - - // Registers used for callWithABI() argument-passing. - const Register argContextReg = ToRegister(call->getArgContextReg()); - const Register argUintNReg = ToRegister(call->getArgUintNReg()); - const Register argVpReg = ToRegister(call->getArgVpReg()); - - // Misc. temporary registers. - const Register tempReg = ToRegister(call->getTempReg()); - - DebugOnly<uint32_t> initialStack = masm.framePushed(); - +void CodeGenerator::emitCallNative(LCallIns* call, JSNative native, + Register argContextReg, Register argUintNReg, + Register argVpReg, Register tempReg, + uint32_t unusedStack) { masm.checkStackAlignment(); // Native functions have the signature: @@ -5524,17 +5534,21 @@ void CodeGenerator::emitCallNative(LCallIns* call, JSNative native) { // Push a Value containing the callee object: natives are allowed to access // their callee before setting the return value. The StackPointer is moved // to &vp[0]. + // + // Also reserves the space for |NativeExitFrameLayout::{lo,hi}CalleeResult_|. if constexpr (std::is_same_v<LCallIns, LCallClassHook>) { Register calleeReg = ToRegister(call->getCallee()); masm.Push(TypedOrValueRegister(MIRType::Object, AnyRegister(calleeReg))); + // Enter the callee realm. if (call->mir()->maybeCrossRealm()) { masm.switchToObjectRealm(calleeReg, tempReg); } } else { - WrappedFunction* target = call->getSingleTarget(); + WrappedFunction* target = call->mir()->getSingleTarget(); masm.Push(ObjectValue(*target->rawNativeJSFunction())); + // Enter the callee realm. if (call->mir()->maybeCrossRealm()) { masm.movePtr(ImmGCPtr(target->rawNativeJSFunction()), tempReg); masm.switchToObjectRealm(tempReg, tempReg); @@ -5543,12 +5557,17 @@ void CodeGenerator::emitCallNative(LCallIns* call, JSNative native) { // Preload arguments into registers. masm.loadJSContext(argContextReg); - masm.move32(Imm32(call->mir()->numActualArgs()), argUintNReg); masm.moveStackPtrTo(argVpReg); + // Initialize |NativeExitFrameLayout::argc_|. masm.Push(argUintNReg); // Construct native exit frame. + // + // |buildFakeExitFrame| initializes |NativeExitFrameLayout::exit_| and + // |enterFakeExitFrameForNative| initializes |NativeExitFrameLayout::footer_|. + // + // The NativeExitFrameLayout is now fully initialized. uint32_t safepointOffset = masm.buildFakeExitFrame(tempReg); masm.enterFakeExitFrameForNative(argContextReg, tempReg, call->mir()->isConstructing()); @@ -5581,6 +5600,7 @@ void CodeGenerator::emitCallNative(LCallIns* call, JSNative native) { // Test for failure. masm.branchIfFalseBool(ReturnReg, masm.failureLabel()); + // Exit the callee realm. if (call->mir()->maybeCrossRealm()) { masm.switchToRealm(gen->realm->realmPtr(), ReturnReg); } @@ -5593,10 +5613,44 @@ void CodeGenerator::emitCallNative(LCallIns* call, JSNative native) { // Until C++ code is instrumented against Spectre, prevent speculative // execution from returning any private data. if (JitOptions.spectreJitToCxxCalls && !call->mir()->ignoresReturnValue() && - mir->hasLiveDefUses()) { + call->mir()->hasLiveDefUses()) { masm.speculationBarrier(); } +#ifdef DEBUG + // Native constructors are guaranteed to return an Object value. + if (call->mir()->isConstructing()) { + Label notPrimitive; + masm.branchTestPrimitive(Assembler::NotEqual, JSReturnOperand, + ¬Primitive); + masm.assumeUnreachable("native constructors don't return primitives"); + masm.bind(¬Primitive); + } +#endif +} + +template <typename LCallIns> +void CodeGenerator::emitCallNative(LCallIns* call, JSNative native) { + uint32_t unusedStack = + UnusedStackBytesForCall(call->mir()->paddedNumStackArgs()); + + // Registers used for callWithABI() argument-passing. + const Register argContextReg = ToRegister(call->getArgContextReg()); + const Register argUintNReg = ToRegister(call->getArgUintNReg()); + const Register argVpReg = ToRegister(call->getArgVpReg()); + + // Misc. temporary registers. + const Register tempReg = ToRegister(call->getTempReg()); + + DebugOnly<uint32_t> initialStack = masm.framePushed(); + + // Initialize the argc register. + masm.move32(Imm32(call->mir()->numActualArgs()), argUintNReg); + + // Create the exit frame and call the native. + emitCallNative(call, native, argContextReg, argUintNReg, argVpReg, tempReg, + unusedStack); + // The next instruction is removing the footer of the exit frame, so there // is no need for leaveFakeExitFrame. @@ -5962,7 +6016,7 @@ void JitRuntime::generateIonGenericCallStub(MacroAssembler& masm, masm.switchToObjectRealm(calleeReg, scratch); // Load jitCodeRaw for callee if it exists. - masm.branchIfFunctionHasNoJitEntry(calleeReg, isConstructing, &noJitEntry); + masm.branchIfFunctionHasNoJitEntry(calleeReg, &noJitEntry); // **************************** // * Functions with jit entry * @@ -6736,7 +6790,7 @@ void CodeGenerator::emitApplyGeneric(T* apply) { } // Guard that calleereg is an interpreted function with a JSScript. - masm.branchIfFunctionHasNoJitEntry(calleereg, constructing, &invoke); + masm.branchIfFunctionHasNoJitEntry(calleereg, &invoke); // Guard that callee allows the [[Call]] or [[Construct]] operation required. if (constructing) { @@ -6841,15 +6895,35 @@ void CodeGenerator::emitApplyGeneric(T* apply) { } template <typename T> -void CodeGenerator::emitCallInvokeNativeFunction(T* apply) { - pushArg(masm.getStackPointer()); // argv. - pushArg(ToRegister(apply->getArgc())); // argc. - pushArg(Imm32(apply->mir()->ignoresReturnValue())); // ignoresReturnValue. - pushArg(Imm32(apply->mir()->isConstructing())); // isConstructing. +void CodeGenerator::emitAlignStackForApplyNative(T* apply, Register argc) { + static_assert(JitStackAlignment % ABIStackAlignment == 0, + "aligning on JIT stack subsumes ABI alignment"); - using Fn = - bool (*)(JSContext*, bool, bool, uint32_t, Value*, MutableHandleValue); - callVM<Fn, jit::InvokeNativeFunction>(apply); + // Align the arguments on the JitStackAlignment. + if (JitStackValueAlignment > 1) { + MOZ_ASSERT(JitStackValueAlignment == 2, + "Stack padding adds exactly one Value"); + MOZ_ASSERT(frameSize() % JitStackValueAlignment == 0, + "Stack padding assumes that the frameSize is correct"); + + Assembler::Condition cond; + if constexpr (T::isConstructing()) { + // If the number of arguments is even, then we do not need any padding. + // + // Also see emitAllocateSpaceForApply(). + cond = Assembler::Zero; + } else { + // If the number of arguments is odd, then we do not need any padding. + // + // Also see emitAllocateSpaceForConstructAndPushNewTarget(). + cond = Assembler::NonZero; + } + + Label noPaddingNeeded; + masm.branchTestPtr(cond, argc, Imm32(1), &noPaddingNeeded); + masm.pushValue(MagicValue(JS_ARG_POISON)); + masm.bind(&noPaddingNeeded); + } } template <typename T> @@ -6859,11 +6933,19 @@ void CodeGenerator::emitPushNativeArguments(T* apply) { Register scratch = ToRegister(apply->getTempForArgCopy()); uint32_t extraFormals = apply->numExtraFormals(); + // Align stack. + emitAlignStackForApplyNative(apply, argc); + + // Push newTarget. + if constexpr (T::isConstructing()) { + masm.pushValue(JSVAL_TYPE_OBJECT, ToRegister(apply->getNewTarget())); + } + // Push arguments. Label noCopy; masm.branchTestPtr(Assembler::Zero, argc, argc, &noCopy); { - // Use scratch register to calculate stack space (no padding needed). + // Use scratch register to calculate stack space. masm.movePtr(argc, scratch); // Reserve space for copying the arguments. @@ -6885,6 +6967,13 @@ void CodeGenerator::emitPushNativeArguments(T* apply) { argvDstOffset); } masm.bind(&noCopy); + + // Push |this|. + if constexpr (T::isConstructing()) { + masm.pushValue(MagicValue(JS_IS_CONSTRUCTING)); + } else { + masm.pushValue(ToValue(apply, T::ThisIndex)); + } } template <typename T> @@ -6904,6 +6993,14 @@ void CodeGenerator::emitPushArrayAsNativeArguments(T* apply) { // The array length is our argc. masm.load32(Address(elements, ObjectElements::offsetOfLength()), tmpArgc); + // Align stack. + emitAlignStackForApplyNative(apply, tmpArgc); + + // Push newTarget. + if constexpr (T::isConstructing()) { + masm.pushValue(JSVAL_TYPE_OBJECT, ToRegister(apply->getNewTarget())); + } + // Skip the copy of arguments if there are none. Label noCopy; masm.branchTestPtr(Assembler::Zero, tmpArgc, tmpArgc, &noCopy); @@ -6919,8 +7016,15 @@ void CodeGenerator::emitPushArrayAsNativeArguments(T* apply) { } masm.bind(&noCopy); - // Set argc in preparation for emitCallInvokeNativeFunction. + // Set argc in preparation for calling the native function. masm.load32(Address(elements, ObjectElements::offsetOfLength()), argc); + + // Push |this|. + if constexpr (T::isConstructing()) { + masm.pushValue(MagicValue(JS_IS_CONSTRUCTING)); + } else { + masm.pushValue(ToValue(apply, T::ThisIndex)); + } } void CodeGenerator::emitPushArguments(LApplyArgsNative* apply) { @@ -6944,6 +7048,7 @@ void CodeGenerator::emitPushArguments(LApplyArgsObjNative* apply) { Register argsObj = ToRegister(apply->getArgsObj()); Register tmpArgc = ToRegister(apply->getTempObject()); Register scratch = ToRegister(apply->getTempForArgCopy()); + Register scratch2 = ToRegister(apply->getTempExtra()); // NB: argc and argsObj are mapped to the same register. MOZ_ASSERT(argc == argsObj); @@ -6951,11 +7056,14 @@ void CodeGenerator::emitPushArguments(LApplyArgsObjNative* apply) { // Load argc into tmpArgc. masm.loadArgumentsObjectLength(argsObj, tmpArgc); + // Align stack. + emitAlignStackForApplyNative(apply, tmpArgc); + // Push arguments. Label noCopy, epilogue; masm.branchTestPtr(Assembler::Zero, tmpArgc, tmpArgc, &noCopy); { - // Use scratch register to calculate stack space (no padding needed). + // Use scratch register to calculate stack space. masm.movePtr(tmpArgc, scratch); // Reserve space for copying the arguments. @@ -6970,56 +7078,65 @@ void CodeGenerator::emitPushArguments(LApplyArgsObjNative* apply) { size_t argvSrcOffset = ArgumentsData::offsetOfArgs(); size_t argvDstOffset = 0; - // Stash away |tmpArgc| and adjust argvDstOffset accordingly. - masm.push(tmpArgc); - argvDstOffset += sizeof(void*); + Register argvIndex = scratch2; + masm.move32(tmpArgc, argvIndex); // Copy the values. - emitCopyValuesForApply(argvSrcBase, tmpArgc, scratch, argvSrcOffset, + emitCopyValuesForApply(argvSrcBase, argvIndex, scratch, argvSrcOffset, argvDstOffset); - - // Set argc in preparation for emitCallInvokeNativeFunction. - masm.pop(argc); - masm.jump(&epilogue); } masm.bind(&noCopy); - { - // Set argc in preparation for emitCallInvokeNativeFunction. - masm.movePtr(ImmWord(0), argc); - } - masm.bind(&epilogue); + + // Set argc in preparation for calling the native function. + masm.movePtr(tmpArgc, argc); + + // Push |this|. + masm.pushValue(ToValue(apply, LApplyArgsObjNative::ThisIndex)); } template <typename T> void CodeGenerator::emitApplyNative(T* apply) { - MOZ_ASSERT(apply->mir()->getSingleTarget()->isNativeWithoutJitEntry()); - - constexpr bool isConstructing = T::isConstructing(); - MOZ_ASSERT(isConstructing == apply->mir()->isConstructing(), + MOZ_ASSERT(T::isConstructing() == apply->mir()->isConstructing(), "isConstructing condition must be consistent"); - // Push newTarget. - if constexpr (isConstructing) { - masm.pushValue(JSVAL_TYPE_OBJECT, ToRegister(apply->getNewTarget())); + WrappedFunction* target = apply->mir()->getSingleTarget(); + MOZ_ASSERT(target->isNativeWithoutJitEntry()); + + JSNative native = target->native(); + if (apply->mir()->ignoresReturnValue() && target->hasJitInfo()) { + const JSJitInfo* jitInfo = target->jitInfo(); + if (jitInfo->type() == JSJitInfo::IgnoresReturnValueNative) { + native = jitInfo->ignoresReturnValueMethod; + } } - // Push arguments. + // Push arguments, including newTarget and |this|. emitPushArguments(apply); - // Push |this|. - if constexpr (isConstructing) { - masm.pushValue(MagicValue(JS_IS_CONSTRUCTING)); - } else { - masm.pushValue(ToValue(apply, T::ThisIndex)); - } + // Registers used for callWithABI() argument-passing. + Register argContextReg = ToRegister(apply->getTempObject()); + Register argUintNReg = ToRegister(apply->getArgc()); + Register argVpReg = ToRegister(apply->getTempForArgCopy()); + Register tempReg = ToRegister(apply->getTempExtra()); + + // No unused stack for variadic calls. + uint32_t unusedStack = 0; + + // Pushed arguments don't change the pushed frames amount. + MOZ_ASSERT(masm.framePushed() == frameSize()); - // Push callee. - masm.pushValue(JSVAL_TYPE_OBJECT, ToRegister(apply->getFunction())); + // Create the exit frame and call the native. + emitCallNative(apply, native, argContextReg, argUintNReg, argVpReg, tempReg, + unusedStack); - // Call the native function. - emitCallInvokeNativeFunction(apply); + // The exit frame is still on the stack. + MOZ_ASSERT(masm.framePushed() == frameSize() + NativeExitFrameLayout::Size()); + + // The next instruction is removing the exit frame, so there is no need for + // leaveFakeExitFrame. // Pop arguments and continue. + masm.setFramePushed(frameSize()); emitRestoreStackPointerFromFP(); } @@ -9303,6 +9420,475 @@ void CodeGenerator::visitWasmCall(LWasmCall* lir) { } } +#ifdef ENABLE_WASM_JSPI +void CodeGenerator::callWasmUpdateSuspenderState( + wasm::UpdateSuspenderStateAction kind, Register suspender) { + masm.Push(InstanceReg); + int32_t framePushedAfterInstance = masm.framePushed(); + + masm.move32(Imm32(uint32_t(kind)), ScratchReg); + + masm.setupWasmABICall(); + masm.passABIArg(InstanceReg); + masm.passABIArg(suspender); + masm.passABIArg(ScratchReg); + int32_t instanceOffset = masm.framePushed() - framePushedAfterInstance; + masm.callWithABI(wasm::BytecodeOffset(0), + wasm::SymbolicAddress::UpdateSuspenderState, + mozilla::Some(instanceOffset)); + + masm.Pop(InstanceReg); +} +#endif // ENABLE_WASM_JSPI + +void CodeGenerator::visitWasmStackSwitchToSuspendable( + LWasmStackSwitchToSuspendable* lir) { +#ifdef ENABLE_WASM_JSPI + const Register SuspenderReg = lir->suspender()->toRegister().gpr(); + const Register FnReg = lir->fn()->toRegister().gpr(); + const Register DataReg = lir->data()->toRegister().gpr(); + const Register SuspenderDataReg = ABINonArgReg3; + +# ifdef JS_CODEGEN_ARM64 + vixl::UseScratchRegisterScope temps(&masm); + const Register ScratchReg = temps.AcquireX().asUnsized(); +# elif !defined(JS_CODEGEN_X64) +# error "NYI: scratch register" +# endif + + masm.Push(SuspenderReg); + masm.Push(FnReg); + masm.Push(DataReg); + + callWasmUpdateSuspenderState(wasm::UpdateSuspenderStateAction::Enter, + SuspenderReg); + masm.Pop(DataReg); + masm.Pop(FnReg); + masm.Pop(SuspenderReg); + + masm.Push(SuspenderReg); + int32_t framePushedAtSuspender = masm.framePushed(); + masm.Push(InstanceReg); + + wasm::CallSiteDesc desc(wasm::CallSiteDesc::Kind::StackSwitch); + CodeLabel returnCallsite; + + // Aligning stack before trampoline call. + uint32_t reserve = ComputeByteAlignment( + masm.framePushed() - sizeof(wasm::Frame), WasmStackAlignment); + masm.reserveStack(reserve); + + masm.loadPrivate(Address(SuspenderReg, NativeObject::getFixedSlotOffset( + wasm::SuspenderObjectDataSlot)), + SuspenderDataReg); + + // Switch stacks to suspendable, keep original FP to maintain + // frames chain between main and suspendable stack segments. + masm.storeStackPtr( + Address(SuspenderDataReg, wasm::SuspenderObjectData::offsetOfMainSP())); + masm.storePtr( + FramePointer, + Address(SuspenderDataReg, wasm::SuspenderObjectData::offsetOfMainFP())); + + masm.loadStackPtr(Address( + SuspenderDataReg, wasm::SuspenderObjectData::offsetOfSuspendableSP())); + + masm.assertStackAlignment(WasmStackAlignment); + + // The FramePointer is not changed for SwitchToSuspendable. + uint32_t framePushed = masm.framePushed(); + + // On different stack, reset framePushed. FramePointer is not valid here. + masm.setFramePushed(0); + + // Pass the suspender and data params through the wasm function ABI registers. + WasmABIArgGenerator abi; + ABIArg arg; + arg = abi.next(MIRType::Pointer); + MOZ_RELEASE_ASSERT(arg.kind() == ABIArg::GPR); + masm.movePtr(SuspenderReg, arg.gpr()); + arg = abi.next(MIRType::Pointer); + MOZ_RELEASE_ASSERT(arg.kind() == ABIArg::GPR); + masm.movePtr(DataReg, arg.gpr()); + unsigned reserveBeforeCall = abi.stackBytesConsumedSoFar(); + + MOZ_ASSERT(masm.framePushed() == 0); + unsigned argDecrement = + StackDecrementForCall(WasmStackAlignment, 0, reserveBeforeCall); + masm.reserveStack(argDecrement); + + masm.storePtr(InstanceReg, Address(masm.getStackPointer(), + WasmCallerInstanceOffsetBeforeCall)); + // Get wasm instance pointer for callee. + size_t instanceSlotOffset = FunctionExtended::offsetOfExtendedSlot( + FunctionExtended::WASM_INSTANCE_SLOT); + masm.loadPtr(Address(FnReg, instanceSlotOffset), InstanceReg); + + masm.storePtr(InstanceReg, Address(masm.getStackPointer(), + WasmCalleeInstanceOffsetBeforeCall)); + masm.loadWasmPinnedRegsFromInstance(); + + masm.assertStackAlignment(WasmStackAlignment); + + const Register ReturnAddressReg = ScratchReg; + + // Save future of suspendable stack exit frame pointer. + masm.computeEffectiveAddress( + Address(masm.getStackPointer(), -int32_t(sizeof(wasm::Frame))), + ScratchReg); + masm.storePtr( + ScratchReg, + Address(SuspenderDataReg, + wasm::SuspenderObjectData::offsetOfSuspendableExitFP())); + + masm.mov(&returnCallsite, ReturnAddressReg); + + // Call wasm function fast. +# ifdef JS_USE_LINK_REGISTER + masm.mov(ReturnAddressReg, lr); +# else + masm.Push(ReturnAddressReg); +# endif + // Get funcUncheckedCallEntry() from the function's + // WASM_FUNC_UNCHECKED_ENTRY_SLOT extended slot. + size_t uncheckedEntrySlotOffset = FunctionExtended::offsetOfExtendedSlot( + FunctionExtended::WASM_FUNC_UNCHECKED_ENTRY_SLOT); + masm.loadPtr(Address(FnReg, uncheckedEntrySlotOffset), ScratchReg); + masm.jump(ScratchReg); + + // About to use valid FramePointer -- restore framePushed. + masm.setFramePushed(framePushed); + + // For IsPlausibleStackMapKey check for the following callsite. + masm.wasmTrapInstruction(); + + // Callsite for return from main stack. + masm.bind(&returnCallsite); + masm.append(desc, *returnCallsite.target()); + masm.addCodeLabel(returnCallsite); + + masm.assertStackAlignment(WasmStackAlignment); + + markSafepointAt(returnCallsite.target()->offset(), lir); + lir->safepoint()->setFramePushedAtStackMapBase(framePushed); + lir->safepoint()->setWasmSafepointKind(WasmSafepointKind::StackSwitch); + // Rooting SuspenderReg. + masm.propagateOOM( + lir->safepoint()->addWasmAnyRefSlot(true, framePushedAtSuspender)); + + masm.freeStackTo(framePushed); + + masm.freeStack(reserve); + masm.Pop(InstanceReg); + masm.Pop(SuspenderReg); + + // Using SuspenderDataReg and DataReg as temps. + masm.switchToWasmInstanceRealm(SuspenderDataReg, DataReg); + + callWasmUpdateSuspenderState(wasm::UpdateSuspenderStateAction::Leave, + SuspenderReg); +#else + MOZ_CRASH("NYI"); +#endif // ENABLE_WASM_JSPI +} + +void CodeGenerator::visitWasmStackSwitchToMain(LWasmStackSwitchToMain* lir) { +#ifdef ENABLE_WASM_JSPI + const Register SuspenderReg = lir->suspender()->toRegister().gpr(); + const Register FnReg = lir->fn()->toRegister().gpr(); + const Register DataReg = lir->data()->toRegister().gpr(); + const Register SuspenderDataReg = ABINonArgReg3; + +# ifdef JS_CODEGEN_ARM64 + vixl::UseScratchRegisterScope temps(&masm); + const Register ScratchReg = temps.AcquireX().asUnsized(); +# elif !defined(JS_CODEGEN_X64) +# error "NYI: scratch register" +# endif + + masm.Push(SuspenderReg); + masm.Push(FnReg); + masm.Push(DataReg); + + callWasmUpdateSuspenderState(wasm::UpdateSuspenderStateAction::Suspend, + SuspenderReg); + + masm.Pop(DataReg); + masm.Pop(FnReg); + masm.Pop(SuspenderReg); + + masm.Push(SuspenderReg); + int32_t framePushedAtSuspender = masm.framePushed(); + masm.Push(InstanceReg); + + wasm::CallSiteDesc desc(wasm::CallSiteDesc::Kind::StackSwitch); + CodeLabel returnCallsite; + + // Aligning stack before trampoline call. + uint32_t reserve = ComputeByteAlignment( + masm.framePushed() - sizeof(wasm::Frame), WasmStackAlignment); + masm.reserveStack(reserve); + + masm.loadPrivate(Address(SuspenderReg, NativeObject::getFixedSlotOffset( + wasm::SuspenderObjectDataSlot)), + SuspenderDataReg); + + // Switch stacks to main. + masm.storeStackPtr(Address( + SuspenderDataReg, wasm::SuspenderObjectData::offsetOfSuspendableSP())); + masm.storePtr(FramePointer, + Address(SuspenderDataReg, + wasm::SuspenderObjectData::offsetOfSuspendableFP())); + + masm.loadStackPtr( + Address(SuspenderDataReg, wasm::SuspenderObjectData::offsetOfMainSP())); + masm.loadPtr( + Address(SuspenderDataReg, wasm::SuspenderObjectData::offsetOfMainFP()), + FramePointer); + + // Set main_ra field to returnCallsite. + masm.mov(&returnCallsite, ScratchReg); + masm.storePtr( + ScratchReg, + Address(SuspenderDataReg, + wasm::SuspenderObjectData::offsetOfSuspendedReturnAddress())); + + masm.assertStackAlignment(WasmStackAlignment); + + // The FramePointer is pointing to the same + // place as before switch happened. + uint32_t framePushed = masm.framePushed(); + + // On different stack, reset framePushed. FramePointer is not valid here. + masm.setFramePushed(0); + + // Pass the suspender and data params through the wasm function ABI registers. + WasmABIArgGenerator abi; + ABIArg arg; + arg = abi.next(MIRType::Pointer); + MOZ_RELEASE_ASSERT(arg.kind() == ABIArg::GPR); + masm.movePtr(SuspenderReg, arg.gpr()); + arg = abi.next(MIRType::Pointer); + MOZ_RELEASE_ASSERT(arg.kind() == ABIArg::GPR); + masm.movePtr(DataReg, arg.gpr()); + unsigned reserveBeforeCall = abi.stackBytesConsumedSoFar(); + + MOZ_ASSERT(masm.framePushed() == 0); + unsigned argDecrement = + StackDecrementForCall(WasmStackAlignment, 0, reserveBeforeCall); + masm.reserveStack(argDecrement); + + masm.storePtr(InstanceReg, Address(masm.getStackPointer(), + WasmCallerInstanceOffsetBeforeCall)); + + // Get wasm instance pointer for callee. + size_t instanceSlotOffset = FunctionExtended::offsetOfExtendedSlot( + FunctionExtended::WASM_INSTANCE_SLOT); + masm.loadPtr(Address(FnReg, instanceSlotOffset), InstanceReg); + + masm.storePtr(InstanceReg, Address(masm.getStackPointer(), + WasmCalleeInstanceOffsetBeforeCall)); + masm.loadWasmPinnedRegsFromInstance(); + + masm.assertStackAlignment(WasmStackAlignment); + + const Register ReturnAddressReg = ScratchReg; + + // Load InstanceReg from suspendable stack exit frame. + masm.loadPtr(Address(SuspenderDataReg, + wasm::SuspenderObjectData::offsetOfSuspendableExitFP()), + ScratchReg); + masm.loadPtr( + Address(ScratchReg, wasm::FrameWithInstances::callerInstanceOffset()), + ScratchReg); + masm.storePtr(ScratchReg, Address(masm.getStackPointer(), + WasmCallerInstanceOffsetBeforeCall)); + + // Load RA from suspendable stack exit frame. + masm.loadPtr(Address(SuspenderDataReg, + wasm::SuspenderObjectData::offsetOfSuspendableExitFP()), + ScratchReg); + masm.loadPtr(Address(ScratchReg, wasm::Frame::returnAddressOffset()), + ReturnAddressReg); + + // Call wasm function fast. +# ifdef JS_USE_LINK_REGISTER + masm.mov(ReturnAddressReg, lr); +# else + masm.Push(ReturnAddressReg); +# endif + // Get funcUncheckedCallEntry() from the function's + // WASM_FUNC_UNCHECKED_ENTRY_SLOT extended slot. + size_t uncheckedEntrySlotOffset = FunctionExtended::offsetOfExtendedSlot( + FunctionExtended::WASM_FUNC_UNCHECKED_ENTRY_SLOT); + masm.loadPtr(Address(FnReg, uncheckedEntrySlotOffset), ScratchReg); + masm.jump(ScratchReg); + + // About to use valid FramePointer -- restore framePushed. + masm.setFramePushed(framePushed); + + // For IsPlausibleStackMapKey check for the following callsite. + masm.wasmTrapInstruction(); + + // Callsite for return from suspendable stack. + masm.bind(&returnCallsite); + masm.append(desc, *returnCallsite.target()); + masm.addCodeLabel(returnCallsite); + + masm.assertStackAlignment(WasmStackAlignment); + + markSafepointAt(returnCallsite.target()->offset(), lir); + lir->safepoint()->setFramePushedAtStackMapBase(framePushed); + lir->safepoint()->setWasmSafepointKind(WasmSafepointKind::StackSwitch); + // Rooting SuspenderReg. + masm.propagateOOM( + lir->safepoint()->addWasmAnyRefSlot(true, framePushedAtSuspender)); + + masm.freeStackTo(framePushed); + + masm.freeStack(reserve); + masm.Pop(InstanceReg); + masm.Pop(SuspenderReg); + + // Using SuspenderDataReg and DataReg as temps. + masm.switchToWasmInstanceRealm(SuspenderDataReg, DataReg); + + callWasmUpdateSuspenderState(wasm::UpdateSuspenderStateAction::Resume, + SuspenderReg); +#else + MOZ_CRASH("NYI"); +#endif // ENABLE_WASM_JSPI +} + +void CodeGenerator::visitWasmStackContinueOnSuspendable( + LWasmStackContinueOnSuspendable* lir) { +#ifdef ENABLE_WASM_JSPI + const Register SuspenderReg = lir->suspender()->toRegister().gpr(); + const Register SuspenderDataReg = ABINonArgReg3; + +# ifdef JS_CODEGEN_ARM64 + vixl::UseScratchRegisterScope temps(&masm); + const Register ScratchReg = temps.AcquireX().asUnsized(); +# elif !defined(JS_CODEGEN_X64) +# error "NYI: scratch register" +# endif + + masm.Push(SuspenderReg); + int32_t framePushedAtSuspender = masm.framePushed(); + masm.Push(InstanceReg); + + wasm::CallSiteDesc desc(wasm::CallSiteDesc::Kind::StackSwitch); + CodeLabel returnCallsite; + + // Aligning stack before trampoline call. + uint32_t reserve = ComputeByteAlignment( + masm.framePushed() - sizeof(wasm::Frame), WasmStackAlignment); + masm.reserveStack(reserve); + + masm.loadPrivate(Address(SuspenderReg, NativeObject::getFixedSlotOffset( + wasm::SuspenderObjectDataSlot)), + SuspenderDataReg); + masm.storeStackPtr( + Address(SuspenderDataReg, wasm::SuspenderObjectData::offsetOfMainSP())); + masm.storePtr( + FramePointer, + Address(SuspenderDataReg, wasm::SuspenderObjectData::offsetOfMainFP())); + + // Adjust exit frame FP. + masm.loadPtr(Address(SuspenderDataReg, + wasm::SuspenderObjectData::offsetOfSuspendableExitFP()), + ScratchReg); + masm.storePtr(FramePointer, + Address(ScratchReg, wasm::Frame::callerFPOffset())); + + // Adjust exit frame RA. + const Register TempReg = SuspenderDataReg; + masm.Push(TempReg); + masm.mov(&returnCallsite, TempReg); + masm.storePtr(TempReg, + Address(ScratchReg, wasm::Frame::returnAddressOffset())); + masm.Pop(TempReg); + // Adjust exit frame caller instance slot. + masm.storePtr( + InstanceReg, + Address(ScratchReg, wasm::FrameWithInstances::callerInstanceOffset())); + + // Switch stacks to suspendable. + masm.loadStackPtr(Address( + SuspenderDataReg, wasm::SuspenderObjectData::offsetOfSuspendableSP())); + masm.loadPtr(Address(SuspenderDataReg, + wasm::SuspenderObjectData::offsetOfSuspendableFP()), + FramePointer); + + masm.assertStackAlignment(WasmStackAlignment); + + // The FramePointer is pointing to the same + // place as before switch happened. + uint32_t framePushed = masm.framePushed(); + + // On different stack, reset framePushed. FramePointer is not valid here. + masm.setFramePushed(0); + + // Restore shadow stack area and instance slots. + WasmABIArgGenerator abi; + unsigned reserveBeforeCall = abi.stackBytesConsumedSoFar(); + MOZ_ASSERT(masm.framePushed() == 0); + unsigned argDecrement = + StackDecrementForCall(WasmStackAlignment, 0, reserveBeforeCall); + masm.reserveStack(argDecrement); + + masm.storePtr(InstanceReg, Address(masm.getStackPointer(), + WasmCallerInstanceOffsetBeforeCall)); + masm.storePtr(InstanceReg, Address(masm.getStackPointer(), + WasmCalleeInstanceOffsetBeforeCall)); + + masm.assertStackAlignment(WasmStackAlignment); + + const Register ReturnAddressReg = ScratchReg; + + // Pretend we just returned from the function. + masm.loadPtr( + Address(SuspenderDataReg, + wasm::SuspenderObjectData::offsetOfSuspendedReturnAddress()), + ReturnAddressReg); + masm.jump(ReturnAddressReg); + + // About to use valid FramePointer -- restore framePushed. + masm.setFramePushed(framePushed); + + // For IsPlausibleStackMapKey check for the following callsite. + masm.wasmTrapInstruction(); + + // Callsite for return from suspendable stack. + masm.bind(&returnCallsite); + masm.append(desc, *returnCallsite.target()); + masm.addCodeLabel(returnCallsite); + + masm.assertStackAlignment(WasmStackAlignment); + + markSafepointAt(returnCallsite.target()->offset(), lir); + lir->safepoint()->setFramePushedAtStackMapBase(framePushed); + lir->safepoint()->setWasmSafepointKind(WasmSafepointKind::StackSwitch); + // Rooting SuspenderReg. + masm.propagateOOM( + lir->safepoint()->addWasmAnyRefSlot(true, framePushedAtSuspender)); + + masm.freeStackTo(framePushed); + + masm.freeStack(reserve); + masm.Pop(InstanceReg); + masm.Pop(SuspenderReg); + + // Using SuspenderDataReg and ABINonArgReg2 as temps. + masm.switchToWasmInstanceRealm(SuspenderDataReg, ABINonArgReg2); + + callWasmUpdateSuspenderState(wasm::UpdateSuspenderStateAction::Leave, + SuspenderReg); +#else + MOZ_CRASH("NYI"); +#endif // ENABLE_WASM_JSPI +} + void CodeGenerator::visitWasmCallLandingPrePad(LWasmCallLandingPrePad* lir) { LBlock* block = lir->block(); MWasmCallLandingPrePad* mir = lir->mir(); @@ -11319,6 +11905,7 @@ void CodeGenerator::visitCompareSInline(LCompareSInline* lir) { masm.bind(¬PointerEqual); Label setNotEqualResult; + if (str->isAtom()) { // Atoms cannot be equal to each other if they point to different strings. Imm32 atomBit(JSString::ATOM_BIT); @@ -11336,8 +11923,27 @@ void CodeGenerator::visitCompareSInline(LCompareSInline* lir) { } // Strings of different length can never be equal. - masm.branch32(Assembler::Equal, Address(input, JSString::offsetOfLength()), - Imm32(str->length()), &compareChars); + masm.branch32(Assembler::NotEqual, + Address(input, JSString::offsetOfLength()), + Imm32(str->length()), &setNotEqualResult); + + if (str->isAtom()) { + Label forwardedPtrEqual; + masm.tryFastAtomize(input, output, output, &compareChars); + + // We now have two atoms. Just check pointer equality. + masm.branchPtr(Assembler::Equal, output, ImmGCPtr(str), + &forwardedPtrEqual); + + masm.move32(Imm32(op == JSOp::Ne || op == JSOp::StrictNe), output); + masm.jump(ool->rejoin()); + + masm.bind(&forwardedPtrEqual); + masm.move32(Imm32(op == JSOp::Eq || op == JSOp::StrictEq), output); + masm.jump(ool->rejoin()); + } else { + masm.jump(&compareChars); + } masm.bind(&setNotEqualResult); masm.move32(Imm32(op == JSOp::Ne || op == JSOp::StrictNe), output); @@ -12506,6 +13112,14 @@ void CodeGenerator::visitSubstr(LSubstr* lir) { masm.storeDependentStringBase(string, output); auto initializeDependentString = [&](CharEncoding encoding) { + masm.loadPtr(Address(string, JSString::offsetOfFlags()), temp0); + Label skipDependedOn; + masm.branchTest32(Assembler::NonZero, temp0, Imm32(JSString::ATOM_BIT), + &skipDependedOn); + masm.or32(Imm32(JSString::DEPENDED_ON_BIT), temp0); + masm.store32(temp0, Address(string, JSString::offsetOfFlags())); + masm.bind(&skipDependedOn); + uint32_t flags = JSString::INIT_DEPENDENT_FLAGS; if (encoding == CharEncoding::Latin1) { flags |= JSString::LATIN1_CHARS_BIT; @@ -15325,6 +15939,7 @@ static bool CreateStackMapFromLSafepoint(LSafepoint& safepoint, GeneralRegisterForwardIterator refRegsIter(refRegs); switch (safepoint.wasmSafepointKind()) { case WasmSafepointKind::LirCall: + case WasmSafepointKind::StackSwitch: case WasmSafepointKind::CodegenCall: { size_t spilledNumWords = nRegisterDumpBytes / sizeof(void*); regDumpWords += spilledNumWords; @@ -16317,9 +16932,26 @@ void CodeGenerator::emitMaybeAtomizeSlot(LInstruction* ins, Register stringReg, OutOfLineAtomizeSlot* ool = new (alloc()) OutOfLineAtomizeSlot(ins, stringReg, slotAddr, dest); addOutOfLineCode(ool, ins->mirRaw()->toInstruction()); + masm.branchTest32(Assembler::NonZero, + Address(stringReg, JSString::offsetOfFlags()), + Imm32(JSString::ATOM_BIT), ool->rejoin()); + masm.branchTest32(Assembler::Zero, Address(stringReg, JSString::offsetOfFlags()), - Imm32(JSString::ATOM_BIT), ool->entry()); + Imm32(JSString::ATOM_REF_BIT), ool->entry()); + masm.loadPtr(Address(stringReg, JSAtomRefString::offsetOfAtom()), stringReg); + + if (dest.hasValue()) { + masm.moveValue( + TypedOrValueRegister(MIRType::String, AnyRegister(stringReg)), + dest.valueReg()); + } else { + MOZ_ASSERT(dest.typedReg().gpr() == stringReg); + } + + emitPreBarrier(slotAddr); + masm.storeTypedOrValue(dest, slotAddr); + masm.bind(ool->rejoin()); } @@ -20474,7 +21106,7 @@ void CodeGenerator::visitToHashableString(LToHashableString* ins) { Address(input, JSString::offsetOfFlags()), Imm32(JSString::ATOM_BIT), &isAtom); - masm.lookupStringInAtomCacheLastLookups(input, output, output, ool->entry()); + masm.tryFastAtomize(input, output, output, ool->entry()); masm.jump(ool->rejoin()); masm.bind(&isAtom); masm.movePtr(input, output); diff --git a/js/src/jit/CodeGenerator.h b/js/src/jit/CodeGenerator.h index 282771a79e..c883569193 100644 --- a/js/src/jit/CodeGenerator.h +++ b/js/src/jit/CodeGenerator.h @@ -109,6 +109,11 @@ class CodeGenerator final : public CodeGeneratorSpecific { const StoreOutputTo& out); template <typename LCallIns> + void emitCallNative(LCallIns* call, JSNative native, Register argContextReg, + Register argUintNReg, Register argVpReg, Register tempReg, + uint32_t unusedStack); + + template <typename LCallIns> void emitCallNative(LCallIns* call, JSNative native); public: @@ -204,6 +209,11 @@ class CodeGenerator final : public CodeGeneratorSpecific { wasm::BytecodeOffset bytecodeOffset); void visitOutOfLineWasmNewArray(OutOfLineWasmNewArray* ool); +#ifdef ENABLE_WASM_JSPI + void callWasmUpdateSuspenderState(wasm::UpdateSuspenderStateAction kind, + Register suspender); +#endif + private: void emitPostWriteBarrier(const LAllocation* obj); void emitPostWriteBarrier(Register objreg); @@ -248,7 +258,7 @@ class CodeGenerator final : public CodeGeneratorSpecific { template <typename T> void emitApplyNative(T* apply); template <typename T> - void emitCallInvokeNativeFunction(T* apply); + void emitAlignStackForApplyNative(T* apply, Register argc); template <typename T> void emitPushNativeArguments(T* apply); template <typename T> diff --git a/js/src/jit/CompileInfo.h b/js/src/jit/CompileInfo.h index 1980a3d905..eff46d6574 100644 --- a/js/src/jit/CompileInfo.h +++ b/js/src/jit/CompileInfo.h @@ -146,6 +146,7 @@ class CompileInfo { hadReorderingBailout_(false), hadBoundsCheckBailout_(false), hadUnboxFoldingBailout_(false), + branchHintingEnabled_(false), mayReadFrameArgsDirectly_(false), anyFormalIsForwarded_(false), inlineScriptTree_(nullptr), @@ -339,6 +340,12 @@ class CompileInfo { bool hadBoundsCheckBailout() const { return hadBoundsCheckBailout_; } bool hadUnboxFoldingBailout() const { return hadUnboxFoldingBailout_; } + bool branchHintingEnabled() const { + return compilingWasm() && branchHintingEnabled_; + } + + void setBranchHinting(bool value) { branchHintingEnabled_ = value; } + bool mayReadFrameArgsDirectly() const { return mayReadFrameArgsDirectly_; } bool anyFormalIsForwarded() const { return anyFormalIsForwarded_; } @@ -370,6 +377,8 @@ class CompileInfo { bool hadBoundsCheckBailout_; bool hadUnboxFoldingBailout_; + bool branchHintingEnabled_; + bool mayReadFrameArgsDirectly_; bool anyFormalIsForwarded_; diff --git a/js/src/jit/GenerateCacheIRFiles.py b/js/src/jit/GenerateCacheIRFiles.py index d71c70b753..9baf3b7a27 100644 --- a/js/src/jit/GenerateCacheIRFiles.py +++ b/js/src/jit/GenerateCacheIRFiles.py @@ -79,6 +79,8 @@ arg_writer_info = { "DoubleField": ("double", "writeDoubleField"), "AllocSiteField": ("gc::AllocSite*", "writeAllocSiteField"), "JSOpImm": ("JSOp", "writeJSOpImm"), + "JSTypeImm": ("JSType", "writeJSTypeImm"), + "TypeofEqOperandImm": ("TypeofEqOperand", "writeTypeofEqOperandImm"), "BoolImm": ("bool", "writeBoolImm"), "ByteImm": ("uint32_t", "writeByteImm"), # uint32_t to enable fits-in-byte asserts. "GuardClassKindImm": ("GuardClassKind", "writeGuardClassKindImm"), @@ -182,6 +184,8 @@ arg_reader_info = { "DoubleField": ("uint32_t", "Offset", "reader.stubOffset()"), "AllocSiteField": ("uint32_t", "Offset", "reader.stubOffset()"), "JSOpImm": ("JSOp", "", "reader.jsop()"), + "JSTypeImm": ("JSType", "", "reader.jstype()"), + "TypeofEqOperandImm": ("TypeofEqOperand", "", "reader.typeofEqOperand()"), "BoolImm": ("bool", "", "reader.readBool()"), "ByteImm": ("uint8_t", "", "reader.readByte()"), "GuardClassKindImm": ("GuardClassKind", "", "reader.guardClassKind()"), @@ -275,6 +279,8 @@ arg_spewer_method = { "DoubleField": "spewField", "AllocSiteField": "spewField", "JSOpImm": "spewJSOpImm", + "JSTypeImm": "spewJSTypeImm", + "TypeofEqOperandImm": "spewTypeofEqOperandImm", "BoolImm": "spewBoolImm", "ByteImm": "spewByteImm", "GuardClassKindImm": "spewGuardClassKindImm", @@ -420,6 +426,8 @@ arg_length = { "ScalarTypeImm": 1, "UnaryMathFunctionImm": 1, "JSOpImm": 1, + "JSTypeImm": 1, + "TypeofEqOperandImm": 1, "ValueTypeImm": 1, "GuardClassKindImm": 1, "ArrayBufferViewKindImm": 1, diff --git a/js/src/jit/InterpreterEntryTrampoline.cpp b/js/src/jit/InterpreterEntryTrampoline.cpp index 2e662af559..4dc196476c 100644 --- a/js/src/jit/InterpreterEntryTrampoline.cpp +++ b/js/src/jit/InterpreterEntryTrampoline.cpp @@ -40,19 +40,18 @@ void EntryTrampolineMap::updateScriptsAfterMovingGC(void) { } #ifdef JSGC_HASH_TABLE_CHECKS -void EntryTrampoline::checkTrampolineAfterMovingGC() { +void EntryTrampoline::checkTrampolineAfterMovingGC() const { JitCode* trampoline = entryTrampoline_; CheckGCThingAfterMovingGC(trampoline); } void EntryTrampolineMap::checkScriptsAfterMovingGC() { - for (jit::EntryTrampolineMap::Enum r(*this); !r.empty(); r.popFront()) { - BaseScript* script = r.front().key(); + gc::CheckTableAfterMovingGC(*this, [](const auto& entry) { + BaseScript* script = entry.key(); CheckGCThingAfterMovingGC(script); - r.front().value().checkTrampolineAfterMovingGC(); - auto ptr = lookup(script); - MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front()); - } + entry.value().checkTrampolineAfterMovingGC(); + return script; + }); } #endif diff --git a/js/src/jit/InterpreterEntryTrampoline.h b/js/src/jit/InterpreterEntryTrampoline.h index 4f49f3fe13..2c7d658043 100644 --- a/js/src/jit/InterpreterEntryTrampoline.h +++ b/js/src/jit/InterpreterEntryTrampoline.h @@ -58,7 +58,7 @@ class EntryTrampoline { } #ifdef JSGC_HASH_TABLE_CHECKS - void checkTrampolineAfterMovingGC(); + void checkTrampolineAfterMovingGC() const; #endif }; diff --git a/js/src/jit/Ion.cpp b/js/src/jit/Ion.cpp index e209ace846..03965d3d60 100644 --- a/js/src/jit/Ion.cpp +++ b/js/src/jit/Ion.cpp @@ -20,6 +20,7 @@ #include "jit/BacktrackingAllocator.h" #include "jit/BaselineFrame.h" #include "jit/BaselineJIT.h" +#include "jit/BranchHinting.h" #include "jit/CodeGenerator.h" #include "jit/CompileInfo.h" #include "jit/EdgeCaseAnalysis.h" @@ -1223,6 +1224,19 @@ bool OptimizeMIR(MIRGenerator* mir) { } } + if (mir->branchHintingEnabled()) { + JitSpewCont(JitSpew_BranchHint, "\n"); + if (!BranchHinting(mir, graph)) { + return false; + } + gs.spewPass("BranchHinting"); + AssertBasicGraphCoherency(graph); + + if (mir->shouldCancel("BranchHinting")) { + return false; + } + } + // LICM can hoist instructions from conditional branches and // trigger bailouts. Disable it if bailing out of a hoisted // instruction has previously invalidated this script. diff --git a/js/src/jit/IonCacheIRCompiler.cpp b/js/src/jit/IonCacheIRCompiler.cpp index 948cb38011..89fa96c758 100644 --- a/js/src/jit/IonCacheIRCompiler.cpp +++ b/js/src/jit/IonCacheIRCompiler.cpp @@ -564,6 +564,7 @@ bool IonCacheIRCompiler::init() { } case CacheKind::Call: case CacheKind::TypeOf: + case CacheKind::TypeOfEq: case CacheKind::ToBool: case CacheKind::GetIntrinsic: case CacheKind::NewArray: @@ -677,6 +678,7 @@ void IonCacheIRCompiler::assertFloatRegisterAvailable(FloatRegister reg) { break; case CacheKind::Call: case CacheKind::TypeOf: + case CacheKind::TypeOfEq: case CacheKind::ToBool: case CacheKind::GetIntrinsic: case CacheKind::NewArray: diff --git a/js/src/jit/IonIC.cpp b/js/src/jit/IonIC.cpp index 55f3bbea6c..9ecbf1fd24 100644 --- a/js/src/jit/IonIC.cpp +++ b/js/src/jit/IonIC.cpp @@ -73,6 +73,7 @@ Register IonIC::scratchRegisterForEntryJump() { return asOptimizeGetIteratorIC()->temp(); case CacheKind::Call: case CacheKind::TypeOf: + case CacheKind::TypeOfEq: case CacheKind::ToBool: case CacheKind::GetIntrinsic: case CacheKind::NewArray: @@ -364,7 +365,7 @@ bool IonGetNameIC::update(JSContext* cx, HandleScript outerScript, return false; } - if (JSOp(*GetNextPc(pc)) == JSOp::Typeof) { + if (IsTypeOfNameOp(JSOp(*GetNextPc(pc)))) { return FetchName<GetNameMode::TypeOf>(cx, obj, holder, name, prop, res); } diff --git a/js/src/jit/IonTypes.h b/js/src/jit/IonTypes.h index 5c7818e533..0bae1261c0 100644 --- a/js/src/jit/IonTypes.h +++ b/js/src/jit/IonTypes.h @@ -734,6 +734,9 @@ static inline MIRType ScalarTypeToMIRType(Scalar::Type type) { return MIRType::Int32; case Scalar::Int64: return MIRType::Int64; + case Scalar::Float16: + // TODO: See Bug 1835034 for JIT support for Float16Array + MOZ_CRASH("NYI"); case Scalar::Float32: return MIRType::Float32; case Scalar::Float64: diff --git a/js/src/jit/JitFrames.cpp b/js/src/jit/JitFrames.cpp index 45ac1f5def..69c259994e 100644 --- a/js/src/jit/JitFrames.cpp +++ b/js/src/jit/JitFrames.cpp @@ -11,6 +11,7 @@ #include <algorithm> #include "builtin/ModuleObject.h" +#include "builtin/Sorting.h" #include "gc/GC.h" #include "jit/BaselineFrame.h" #include "jit/BaselineIC.h" @@ -35,6 +36,7 @@ #include "wasm/WasmBuiltins.h" #include "wasm/WasmInstance.h" +#include "builtin/Sorting-inl.h" #include "debugger/DebugAPI-inl.h" #include "jit/JSJitFrameIter-inl.h" #include "vm/GeckoProfiler-inl.h" @@ -97,6 +99,7 @@ static void UnwindTrampolineNativeFrame(JSRuntime* rt, TrampolineNative native = TrampolineNativeForFrame(rt, layout); switch (native) { case TrampolineNative::ArraySort: + case TrampolineNative::TypedArraySort: layout->getFrameData<ArraySortData>()->freeMallocData(); break; case TrampolineNative::Count: @@ -225,13 +228,8 @@ static void OnLeaveIonFrame(JSContext* cx, const InlineFrameIterator& frame, RematerializedFrame* rematFrame = nullptr; { JS::AutoSaveExceptionState savedExc(cx); - - // We can run recover instructions without invalidating because we're - // already leaving the frame. - MaybeReadFallback::FallbackConsequence consequence = - MaybeReadFallback::Fallback_DoNothing; rematFrame = act->getRematerializedFrame(cx, frame.frame(), frame.frameNo(), - consequence); + IsLeavingFrame::Yes); if (!rematFrame) { return; } @@ -1431,6 +1429,7 @@ static void TraceTrampolineNativeFrame(JSTracer* trc, TrampolineNative native = TrampolineNativeForFrame(trc->runtime(), layout); switch (native) { case TrampolineNative::ArraySort: + case TrampolineNative::TypedArraySort: layout->getFrameData<ArraySortData>()->trace(trc); break; case TrampolineNative::Count: @@ -1503,6 +1502,11 @@ static void TraceJitActivation(JSTracer* trc, JitActivation* activation) { uint8_t* nextPC = frames.resumePCinCurrentFrame(); MOZ_ASSERT(nextPC != 0); wasm::WasmFrameIter& wasmFrameIter = frames.asWasm(); +#ifdef ENABLE_WASM_JSPI + if (wasmFrameIter.stackSwitched()) { + highestByteVisitedInPrevWasmFrame = 0; + } +#endif wasm::Instance* instance = wasmFrameIter.instance(); wasm::TraceInstanceEdge(trc, instance, "WasmFrameIter instance"); highestByteVisitedInPrevWasmFrame = instance->traceFrame( @@ -1516,6 +1520,9 @@ void TraceJitActivations(JSContext* cx, JSTracer* trc) { ++activations) { TraceJitActivation(trc, activations->asJit()); } +#ifdef ENABLE_WASM_JSPI + cx->wasm().promiseIntegration.traceRoots(trc); +#endif } void TraceWeakJitActivationsInSweepingZones(JSContext* cx, JSTracer* trc) { diff --git a/js/src/jit/JitRuntime.h b/js/src/jit/JitRuntime.h index 383efca437..2603bde523 100644 --- a/js/src/jit/JitRuntime.h +++ b/js/src/jit/JitRuntime.h @@ -43,6 +43,7 @@ namespace js { class AutoLockHelperThreadState; class GCMarker; +enum class ArraySortKind; namespace jit { @@ -307,7 +308,8 @@ class JitRuntime { void generateTrampolineNatives(MacroAssembler& masm, TrampolineNativeJitEntryOffsets& offsets, PerfSpewerRangeRecorder& rangeRecorder); - uint32_t generateArraySortTrampoline(MacroAssembler& masm); + uint32_t generateArraySortTrampoline(MacroAssembler& masm, + ArraySortKind kind); void bindLabelToOffset(Label* label, uint32_t offset) { MOZ_ASSERT(!trampolineCode_); diff --git a/js/src/jit/JitScript.cpp b/js/src/jit/JitScript.cpp index 62a14a70b6..df7557b7ac 100644 --- a/js/src/jit/JitScript.cpp +++ b/js/src/jit/JitScript.cpp @@ -703,9 +703,12 @@ void jit::JitSpewBaselineICStats(JSScript* script, const char* dumpReason) { } #endif +using StubHashMap = HashMap<ICCacheIRStub*, ICCacheIRStub*, + DefaultHasher<ICCacheIRStub*>, SystemAllocPolicy>; + static void MarkActiveICScriptsAndCopyStubs( JSContext* cx, const JitActivationIterator& activation, - ICStubSpace& newStubSpace) { + ICStubSpace& newStubSpace, StubHashMap& alreadyClonedStubs) { for (OnlyJSJitFrameIter iter(activation); !iter.done(); ++iter) { const JSJitFrameIter& frame = iter.frame(); switch (frame.type()) { @@ -721,8 +724,15 @@ static void MarkActiveICScriptsAndCopyStubs( auto* layout = reinterpret_cast<BaselineStubFrameLayout*>(frame.fp()); if (layout->maybeStubPtr() && !layout->maybeStubPtr()->isFallback()) { ICCacheIRStub* stub = layout->maybeStubPtr()->toCacheIRStub(); - ICCacheIRStub* newStub = stub->clone(cx->runtime(), newStubSpace); - layout->setStubPtr(newStub); + auto lookup = alreadyClonedStubs.lookupForAdd(stub); + if (!lookup) { + ICCacheIRStub* newStub = stub->clone(cx->runtime(), newStubSpace); + AutoEnterOOMUnsafeRegion oomUnsafe; + if (!alreadyClonedStubs.add(lookup, stub, newStub)) { + oomUnsafe.crash("MarkActiveICScriptsAndCopyStubs"); + } + } + layout->setStubPtr(lookup->value()); // If this is a trial-inlining call site, also preserve the callee // ICScript. Inlined constructor calls invoke CreateThisFromIC (which @@ -772,10 +782,12 @@ void jit::MarkActiveICScriptsAndCopyStubs(Zone* zone, if (zone->isAtomsZone()) { return; } + StubHashMap alreadyClonedStubs; JSContext* cx = TlsContext.get(); for (JitActivationIterator iter(cx); !iter.done(); ++iter) { if (iter->compartment()->zone() == zone) { - MarkActiveICScriptsAndCopyStubs(cx, iter, newStubSpace); + MarkActiveICScriptsAndCopyStubs(cx, iter, newStubSpace, + alreadyClonedStubs); } } } diff --git a/js/src/jit/JitSpewer.cpp b/js/src/jit/JitSpewer.cpp index 11e3165240..4eb31b2089 100644 --- a/js/src/jit/JitSpewer.cpp +++ b/js/src/jit/JitSpewer.cpp @@ -360,6 +360,7 @@ static void PrintHelpAndExit(int status = 0) { " pools Literal Pools (ARM only for now)\n" " cacheflush Instruction Cache flushes (ARM only for now)\n" " range Range Analysis\n" + " branch-hint Wasm Branch Hinting\n" " wasmbce Wasm Bounds Check Elimination\n" " shapeguards Redundant shape guard elimination\n" " gcbarriers Redundant GC barrier elimination\n" @@ -432,6 +433,8 @@ void jit::CheckLogging() { EnableChannel(JitSpew_Range); } else if (IsFlag(found, "wasmbce")) { EnableChannel(JitSpew_WasmBCE); + } else if (IsFlag(found, "branch-hint")) { + EnableChannel(JitSpew_BranchHint); } else if (IsFlag(found, "licm")) { EnableChannel(JitSpew_LICM); } else if (IsFlag(found, "flac")) { diff --git a/js/src/jit/JitSpewer.h b/js/src/jit/JitSpewer.h index bfc92c74f2..2b332d117c 100644 --- a/js/src/jit/JitSpewer.h +++ b/js/src/jit/JitSpewer.h @@ -41,6 +41,8 @@ namespace jit { _(Range) \ /* Information during LICM */ \ _(LICM) \ + /* Information during Branch Hinting */ \ + _(BranchHint) \ /* Info about fold linear constants */ \ _(FLAC) \ /* Effective address analysis info */ \ diff --git a/js/src/jit/LIR.h b/js/src/jit/LIR.h index 30a35b0dea..1b1b107557 100644 --- a/js/src/jit/LIR.h +++ b/js/src/jit/LIR.h @@ -1422,6 +1422,8 @@ enum class WasmSafepointKind : uint8_t { // For resumable wasm traps where registers will be spilled by the trap // handler. Trap, + // For stack switch call. + StackSwitch, }; class LSafepoint : public TempObject { diff --git a/js/src/jit/LIROps.yaml b/js/src/jit/LIROps.yaml index 880e756f74..dccb455302 100644 --- a/js/src/jit/LIROps.yaml +++ b/js/src/jit/LIROps.yaml @@ -358,6 +358,25 @@ - name: InterruptCheck mir_op: true +- name: WasmStackSwitchToMain + operands: + suspender: WordSized + fn: WordSized + data: WordSized + call_instruction: true + +- name: WasmStackSwitchToSuspendable + operands: + suspender: WordSized + fn: WordSized + data: WordSized + call_instruction: true + +- name: WasmStackContinueOnSuspendable + operands: + suspender: WordSized + call_instruction: true + - name: WasmInterruptCheck operands: instance: WordSized diff --git a/js/src/jit/Lowering.cpp b/js/src/jit/Lowering.cpp index f7b898f240..f84ed576b4 100644 --- a/js/src/jit/Lowering.cpp +++ b/js/src/jit/Lowering.cpp @@ -654,7 +654,6 @@ void LIRGenerator::visitApplyArgs(MApplyArgs* apply) { static_assert(CallTempReg2 != JSReturnReg_Type); static_assert(CallTempReg2 != JSReturnReg_Data); - auto function = useFixedAtStart(apply->getFunction(), CallTempReg3); auto argc = useFixedAtStart(apply->getArgc(), CallTempReg0); auto thisValue = useBoxFixedAtStart(apply->getThis(), CallTempReg4, CallTempReg5); @@ -665,9 +664,13 @@ void LIRGenerator::visitApplyArgs(MApplyArgs* apply) { LInstruction* lir; if (target && target->isNativeWithoutJitEntry()) { + auto temp = tempFixed(CallTempReg3); + lir = new (alloc()) - LApplyArgsNative(function, argc, thisValue, tempObj, tempCopy); + LApplyArgsNative(argc, thisValue, tempObj, tempCopy, temp); } else { + auto function = useFixedAtStart(apply->getFunction(), CallTempReg3); + lir = new (alloc()) LApplyArgsGeneric(function, argc, thisValue, tempObj, tempCopy); } @@ -686,7 +689,6 @@ void LIRGenerator::visitApplyArgsObj(MApplyArgsObj* apply) { static_assert(CallTempReg2 != JSReturnReg_Type); static_assert(CallTempReg2 != JSReturnReg_Data); - auto function = useFixedAtStart(apply->getFunction(), CallTempReg3); auto argsObj = useFixedAtStart(apply->getArgsObj(), CallTempReg0); auto thisValue = useBoxFixedAtStart(apply->getThis(), CallTempReg4, CallTempReg5); @@ -697,9 +699,13 @@ void LIRGenerator::visitApplyArgsObj(MApplyArgsObj* apply) { LInstruction* lir; if (target && target->isNativeWithoutJitEntry()) { + auto temp = tempFixed(CallTempReg3); + lir = new (alloc()) - LApplyArgsObjNative(function, argsObj, thisValue, tempObj, tempCopy); + LApplyArgsObjNative(argsObj, thisValue, tempObj, tempCopy, temp); } else { + auto function = useFixedAtStart(apply->getFunction(), CallTempReg3); + lir = new (alloc()) LApplyArgsObj(function, argsObj, thisValue, tempObj, tempCopy); } @@ -718,7 +724,6 @@ void LIRGenerator::visitApplyArray(MApplyArray* apply) { static_assert(CallTempReg2 != JSReturnReg_Type); static_assert(CallTempReg2 != JSReturnReg_Data); - auto function = useFixedAtStart(apply->getFunction(), CallTempReg3); auto elements = useFixedAtStart(apply->getElements(), CallTempReg0); auto thisValue = useBoxFixedAtStart(apply->getThis(), CallTempReg4, CallTempReg5); @@ -729,9 +734,13 @@ void LIRGenerator::visitApplyArray(MApplyArray* apply) { LInstruction* lir; if (target && target->isNativeWithoutJitEntry()) { + auto temp = tempFixed(CallTempReg3); + lir = new (alloc()) - LApplyArrayNative(function, elements, thisValue, tempObj, tempCopy); + LApplyArrayNative(elements, thisValue, tempObj, tempCopy, temp); } else { + auto function = useFixedAtStart(apply->getFunction(), CallTempReg3); + lir = new (alloc()) LApplyArrayGeneric(function, elements, thisValue, tempObj, tempCopy); } @@ -754,7 +763,6 @@ void LIRGenerator::visitConstructArgs(MConstructArgs* mir) { static_assert(CallTempReg2 != JSReturnReg_Type); static_assert(CallTempReg2 != JSReturnReg_Data); - auto function = useFixedAtStart(mir->getFunction(), CallTempReg3); auto argc = useFixedAtStart(mir->getArgc(), CallTempReg0); auto newTarget = useFixedAtStart(mir->getNewTarget(), CallTempReg1); auto temp = tempFixed(CallTempReg2); @@ -763,11 +771,13 @@ void LIRGenerator::visitConstructArgs(MConstructArgs* mir) { LInstruction* lir; if (target && target->isNativeWithoutJitEntry()) { - auto temp2 = tempFixed(CallTempReg4); + auto temp2 = tempFixed(CallTempReg3); + auto temp3 = tempFixed(CallTempReg4); - lir = new (alloc()) - LConstructArgsNative(function, argc, newTarget, temp, temp2); + lir = + new (alloc()) LConstructArgsNative(argc, newTarget, temp, temp2, temp3); } else { + auto function = useFixedAtStart(mir->getFunction(), CallTempReg3); auto thisValue = useBoxFixedAtStart(mir->getThis(), CallTempReg4, CallTempReg5); @@ -792,7 +802,6 @@ void LIRGenerator::visitConstructArray(MConstructArray* mir) { static_assert(CallTempReg2 != JSReturnReg_Type); static_assert(CallTempReg2 != JSReturnReg_Data); - auto function = useFixedAtStart(mir->getFunction(), CallTempReg3); auto elements = useFixedAtStart(mir->getElements(), CallTempReg0); auto newTarget = useFixedAtStart(mir->getNewTarget(), CallTempReg1); auto temp = tempFixed(CallTempReg2); @@ -801,11 +810,13 @@ void LIRGenerator::visitConstructArray(MConstructArray* mir) { LInstruction* lir; if (target && target->isNativeWithoutJitEntry()) { - auto temp2 = tempFixed(CallTempReg4); + auto temp2 = tempFixed(CallTempReg3); + auto temp3 = tempFixed(CallTempReg4); lir = new (alloc()) - LConstructArrayNative(function, elements, newTarget, temp, temp2); + LConstructArrayNative(elements, newTarget, temp, temp2, temp3); } else { + auto function = useFixedAtStart(mir->getFunction(), CallTempReg3); auto thisValue = useBoxFixedAtStart(mir->getThis(), CallTempReg4, CallTempReg5); @@ -6351,6 +6362,48 @@ void LIRGenerator::visitWasmStackResult(MWasmStackResult* ins) { add(lir, ins); } +void LIRGenerator::visitWasmStackSwitchToSuspendable( + MWasmStackSwitchToSuspendable* ins) { +#ifdef ENABLE_WASM_JSPI + auto* lir = new (alloc()) LWasmStackSwitchToSuspendable( + useFixedAtStart(ins->suspender(), ABINonArgReg0), + useFixedAtStart(ins->fn(), ABINonArgReg1), + useFixedAtStart(ins->data(), ABINonArgReg2)); + + add(lir, ins); + assignWasmSafepoint(lir); +#else + MOZ_CRASH("NYI"); +#endif +} + +void LIRGenerator::visitWasmStackSwitchToMain(MWasmStackSwitchToMain* ins) { +#ifdef ENABLE_WASM_JSPI + auto* lir = new (alloc()) + LWasmStackSwitchToMain(useFixedAtStart(ins->suspender(), ABINonArgReg0), + useFixedAtStart(ins->fn(), ABINonArgReg1), + useFixedAtStart(ins->data(), ABINonArgReg2)); + + add(lir, ins); + assignWasmSafepoint(lir); +#else + MOZ_CRASH("NYI"); +#endif +} + +void LIRGenerator::visitWasmStackContinueOnSuspendable( + MWasmStackContinueOnSuspendable* ins) { +#ifdef ENABLE_WASM_JSPI + auto* lir = new (alloc()) LWasmStackContinueOnSuspendable( + useFixedAtStart(ins->suspender(), ABINonArgReg0)); + + add(lir, ins); + assignWasmSafepoint(lir); +#else + MOZ_CRASH("NYI"); +#endif +} + template <class MWasmCallT> void LIRGenerator::visitWasmCall(MWasmCallT ins) { bool needsBoundsCheck = true; diff --git a/js/src/jit/MIR.cpp b/js/src/jit/MIR.cpp index a74406567b..f826fbd987 100644 --- a/js/src/jit/MIR.cpp +++ b/js/src/jit/MIR.cpp @@ -1122,11 +1122,16 @@ MConstant::MConstant(TempAllocator& alloc, const js::Value& vp) case MIRType::Double: payload_.d = vp.toDouble(); break; - case MIRType::String: - MOZ_ASSERT(!IsInsideNursery(vp.toString())); - MOZ_ASSERT(vp.toString()->isLinear()); + case MIRType::String: { + JSString* str = vp.toString(); + if (str->isAtomRef()) { + str = str->atom(); + } + MOZ_ASSERT(!IsInsideNursery(str)); + MOZ_ASSERT(str->isAtom()); payload_.str = vp.toString(); break; + } case MIRType::Symbol: payload_.sym = vp.toSymbol(); break; @@ -4310,11 +4315,56 @@ static JSType TypeOfName(JSLinearString* str) { return JSTYPE_LIMIT; } -static mozilla::Maybe<std::pair<MTypeOfName*, JSType>> IsTypeOfCompare( - MCompare* ins) { +struct TypeOfCompareInput { + // The `typeof expr` side of the comparison. + // MTypeOfName for JSOp::Typeof/JSOp::TypeofExpr, and + // MTypeOf for JSOp::TypeofEq (same pointer as typeOf). + MDefinition* typeOfSide; + + // The actual `typeof` operation. + MTypeOf* typeOf; + + // The string side of the comparison. + JSType type; + + // True if the comparison uses raw JSType (Generated for JSOp::TypeofEq). + bool isIntComparison; + + TypeOfCompareInput(MDefinition* typeOfSide, MTypeOf* typeOf, JSType type, + bool isIntComparison) + : typeOfSide(typeOfSide), + typeOf(typeOf), + type(type), + isIntComparison(isIntComparison) {} +}; + +static mozilla::Maybe<TypeOfCompareInput> IsTypeOfCompare(MCompare* ins) { if (!IsEqualityOp(ins->jsop())) { return mozilla::Nothing(); } + + if (ins->compareType() == MCompare::Compare_Int32) { + auto* lhs = ins->lhs(); + auto* rhs = ins->rhs(); + + if (ins->type() != MIRType::Boolean || lhs->type() != MIRType::Int32 || + rhs->type() != MIRType::Int32) { + return mozilla::Nothing(); + } + + // NOTE: The comparison is generated inside JIT, and typeof should always + // be in the LHS. + if (!lhs->isTypeOf() || !rhs->isConstant()) { + return mozilla::Nothing(); + } + + auto* typeOf = lhs->toTypeOf(); + auto* constant = rhs->toConstant(); + + JSType type = JSType(constant->toInt32()); + return mozilla::Some(TypeOfCompareInput(typeOf, typeOf, type, true)); + } + if (ins->compareType() != MCompare::Compare_String) { return mozilla::Nothing(); } @@ -4335,21 +4385,21 @@ static mozilla::Maybe<std::pair<MTypeOfName*, JSType>> IsTypeOfCompare( auto* typeOfName = lhs->isTypeOfName() ? lhs->toTypeOfName() : rhs->toTypeOfName(); - MOZ_ASSERT(typeOfName->input()->isTypeOf()); + auto* typeOf = typeOfName->input()->toTypeOf(); auto* constant = lhs->isConstant() ? lhs->toConstant() : rhs->toConstant(); JSType type = TypeOfName(&constant->toString()->asLinear()); - return mozilla::Some(std::pair(typeOfName, type)); + return mozilla::Some(TypeOfCompareInput(typeOfName, typeOf, type, false)); } bool MCompare::tryFoldTypeOf(bool* result) { - auto typeOfPair = IsTypeOfCompare(this); - if (!typeOfPair) { + auto typeOfCompare = IsTypeOfCompare(this); + if (!typeOfCompare) { return false; } - auto [typeOfName, type] = *typeOfPair; - auto* typeOf = typeOfName->input()->toTypeOf(); + auto* typeOf = typeOfCompare->typeOf; + JSType type = typeOfCompare->type; switch (type) { case JSTYPE_BOOLEAN: @@ -4639,12 +4689,12 @@ bool MCompare::evaluateConstantOperands(TempAllocator& alloc, bool* result) { } MDefinition* MCompare::tryFoldTypeOf(TempAllocator& alloc) { - auto typeOfPair = IsTypeOfCompare(this); - if (!typeOfPair) { + auto typeOfCompare = IsTypeOfCompare(this); + if (!typeOfCompare) { return this; } - auto [typeOfName, type] = *typeOfPair; - auto* typeOf = typeOfName->input()->toTypeOf(); + auto* typeOf = typeOfCompare->typeOf; + JSType type = typeOfCompare->type; auto* input = typeOf->input(); MOZ_ASSERT(input->type() == MIRType::Value || @@ -4676,10 +4726,15 @@ MDefinition* MCompare::tryFoldTypeOf(TempAllocator& alloc) { // In that case it'd more efficient to emit MTypeOf compared to MTypeOfIs. We // don't yet handle that case, because it'd require a separate optimization // pass to correctly detect it. - if (typeOfName->hasOneUse()) { + if (typeOfCompare->typeOfSide->hasOneUse()) { return MTypeOfIs::New(alloc, input, jsop(), type); } + if (typeOfCompare->isIntComparison) { + // Already optimized. + return this; + } + MConstant* cst = MConstant::New(alloc, Int32Value(type)); block()->insertBefore(this, cst); diff --git a/js/src/jit/MIR.h b/js/src/jit/MIR.h index c672092f04..853bf365e2 100644 --- a/js/src/jit/MIR.h +++ b/js/src/jit/MIR.h @@ -42,6 +42,7 @@ #include "js/ScalarType.h" // js::Scalar::Type #include "js/Value.h" #include "js/Vector.h" +#include "util/DifferentialTesting.h" #include "vm/BigIntType.h" #include "vm/EnvironmentObject.h" #include "vm/FunctionFlags.h" // js::FunctionFlags @@ -11895,7 +11896,13 @@ class MWasmNewStructObject : public MBinaryInstruction, TRIVIAL_NEW_WRAPPERS NAMED_OPERANDS((0, instance), (1, typeDefData)) - AliasSet getAliasSet() const override { return AliasSet::None(); } + AliasSet getAliasSet() const override { + if (js::SupportDifferentialTesting()) { + // Consider allocations effectful for differential testing. + return MDefinition::getAliasSet(); + } + return AliasSet::None(); + } bool isOutline() const { return isOutline_; } bool zeroFields() const { return zeroFields_; } gc::AllocKind allocKind() const { return allocKind_; } @@ -11923,7 +11930,13 @@ class MWasmNewArrayObject : public MTernaryInstruction, TRIVIAL_NEW_WRAPPERS NAMED_OPERANDS((0, instance), (1, numElements), (2, typeDefData)) - AliasSet getAliasSet() const override { return AliasSet::None(); } + AliasSet getAliasSet() const override { + if (js::SupportDifferentialTesting()) { + // Consider allocations effectful for differential testing. + return MDefinition::getAliasSet(); + } + return AliasSet::None(); + } uint32_t elemSize() const { return elemSize_; } bool zeroFields() const { return zeroFields_; } wasm::BytecodeOffset bytecodeOffset() const { return bytecodeOffset_; } diff --git a/js/src/jit/MIRGenerator.h b/js/src/jit/MIRGenerator.h index 45b33618d0..fc3388793c 100644 --- a/js/src/jit/MIRGenerator.h +++ b/js/src/jit/MIRGenerator.h @@ -158,6 +158,7 @@ class MIRGenerator final { public: void disableLICM() { disableLICM_ = true; } bool licmEnabled() const; + bool branchHintingEnabled() const; private: uint64_t minWasmMemory0Length_; diff --git a/js/src/jit/MIRGraph.cpp b/js/src/jit/MIRGraph.cpp index 29b5897a09..47b0ce9b6c 100644 --- a/js/src/jit/MIRGraph.cpp +++ b/js/src/jit/MIRGraph.cpp @@ -47,6 +47,10 @@ bool MIRGenerator::licmEnabled() const { !outerInfo().hadLICMInvalidation(); } +bool MIRGenerator::branchHintingEnabled() const { + return outerInfo().branchHintingEnabled(); +} + mozilla::GenericErrorResult<AbortReason> MIRGenerator::abort(AbortReason r) { if (JitSpewEnabled(JitSpew_IonAbort)) { switch (r) { diff --git a/js/src/jit/MIRGraph.h b/js/src/jit/MIRGraph.h index 18c0bf68a4..4de20a36fa 100644 --- a/js/src/jit/MIRGraph.h +++ b/js/src/jit/MIRGraph.h @@ -61,6 +61,9 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock> { // This block will unconditionally bail out. bool alwaysBails_ = false; + // Will be used for branch hinting in wasm. + wasm::BranchHint branchHint_ = wasm::BranchHint::Invalid; + // Pushes a copy of a local variable or argument. void pushVariable(uint32_t slot) { push(slots_[slot]); } @@ -375,6 +378,15 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock> { uint32_t id() const { return id_; } uint32_t numPredecessors() const { return predecessors_.length(); } + bool branchHintingUnlikely() const { + return branchHint_ == wasm::BranchHint::Unlikely; + } + bool branchHintingLikely() const { + return branchHint_ == wasm::BranchHint::Likely; + } + + void setBranchHinting(wasm::BranchHint value) { branchHint_ = value; } + uint32_t domIndex() const { MOZ_ASSERT(!isDead()); return domIndex_; diff --git a/js/src/jit/MIROps.yaml b/js/src/jit/MIROps.yaml index 78ab989221..96a41cc1ca 100644 --- a/js/src/jit/MIROps.yaml +++ b/js/src/jit/MIROps.yaml @@ -3352,6 +3352,25 @@ - name: Rotate gen_boilerplate: false +- name: WasmStackSwitchToMain + operands: + suspender: Object + fn: Object + data: WasmAnyRef + type_policy: none + +- name: WasmStackSwitchToSuspendable + operands: + suspender: Object + fn: Object + data: WasmAnyRef + type_policy: none + +- name: WasmStackContinueOnSuspendable + operands: + suspender: Object + type_policy: none + - name: WasmBinarySimd128 gen_boilerplate: false diff --git a/js/src/jit/MacroAssembler-inl.h b/js/src/jit/MacroAssembler-inl.h index e1df31eff9..90bf54bf00 100644 --- a/js/src/jit/MacroAssembler-inl.h +++ b/js/src/jit/MacroAssembler-inl.h @@ -484,17 +484,13 @@ void MacroAssembler::branchIfNotFunctionIsNonBuiltinCtor(Register fun, branch32(Assembler::NotEqual, scratch, Imm32(expected), label); } -void MacroAssembler::branchIfFunctionHasNoJitEntry(Register fun, - bool isConstructing, - Label* label) { - uint16_t flags = FunctionFlags::HasJitEntryFlags(isConstructing); +void MacroAssembler::branchIfFunctionHasNoJitEntry(Register fun, Label* label) { + uint16_t flags = FunctionFlags::HasJitEntryFlags(); branchTestFunctionFlags(fun, flags, Assembler::Zero, label); } -void MacroAssembler::branchIfFunctionHasJitEntry(Register fun, - bool isConstructing, - Label* label) { - uint16_t flags = FunctionFlags::HasJitEntryFlags(isConstructing); +void MacroAssembler::branchIfFunctionHasJitEntry(Register fun, Label* label) { + uint16_t flags = FunctionFlags::HasJitEntryFlags(); branchTestFunctionFlags(fun, flags, Assembler::NonZero, label); } diff --git a/js/src/jit/MacroAssembler.cpp b/js/src/jit/MacroAssembler.cpp index 9fc4b96830..a5d2073fb9 100644 --- a/js/src/jit/MacroAssembler.cpp +++ b/js/src/jit/MacroAssembler.cpp @@ -1310,7 +1310,7 @@ void MacroAssembler::loadStringChars(Register str, Register dest, MOZ_ASSERT(encoding == CharEncoding::TwoByte); static constexpr uint32_t Mask = JSString::LINEAR_BIT | JSString::LATIN1_CHARS_BIT; - static_assert(Mask < 1024, + static_assert(Mask < 2048, "Mask should be a small, near-null value to ensure we " "block speculative execution when it's used as string " "pointer"); @@ -1344,7 +1344,7 @@ void MacroAssembler::loadNonInlineStringChars(Register str, Register dest, static constexpr uint32_t Mask = JSString::LINEAR_BIT | JSString::INLINE_CHARS_BIT | JSString::LATIN1_CHARS_BIT; - static_assert(Mask < 1024, + static_assert(Mask < 2048, "Mask should be a small, near-null value to ensure we " "block speculative execution when it's used as string " "pointer"); @@ -2659,11 +2659,15 @@ void MacroAssembler::loadMegamorphicSetPropCache(Register dest) { movePtr(ImmPtr(runtime()->addressOfMegamorphicSetPropCache()), dest); } -void MacroAssembler::lookupStringInAtomCacheLastLookups(Register str, - Register scratch, - Register output, - Label* fail) { - Label found; +void MacroAssembler::tryFastAtomize(Register str, Register scratch, + Register output, Label* fail) { + Label found, done, notAtomRef; + + branchTest32(Assembler::Zero, Address(str, JSString::offsetOfFlags()), + Imm32(JSString::ATOM_REF_BIT), ¬AtomRef); + loadPtr(Address(str, JSAtomRefString::offsetOfAtom()), output); + jump(&done); + bind(¬AtomRef); uintptr_t cachePtr = uintptr_t(runtime()->addressOfStringToAtomCache()); void* offset = (void*)(cachePtr + StringToAtomCache::offsetOfLastLookups()); @@ -2682,6 +2686,7 @@ void MacroAssembler::lookupStringInAtomCacheLastLookups(Register str, bind(&found); size_t atomOffset = StringToAtomCache::LastLookup::offsetOfAtom(); loadPtr(Address(scratch, atomOffset), output); + bind(&done); } void MacroAssembler::loadAtomHash(Register id, Register outHash, Label* done) { @@ -2741,7 +2746,7 @@ void MacroAssembler::loadAtomOrSymbolAndHash(ValueOperand value, Register outId, loadAtomHash(outId, outHash, &done); bind(&nonAtom); - lookupStringInAtomCacheLastLookups(outId, outHash, outId, cacheMiss); + tryFastAtomize(outId, outHash, outId, cacheMiss); jump(&atom); bind(&done); @@ -3382,7 +3387,7 @@ void MacroAssembler::guardSpecificAtom(Register str, JSAtom* atom, Register scratch, const LiveRegisterSet& volatileRegs, Label* fail) { - Label done; + Label done, notCachedAtom; branchPtr(Assembler::Equal, str, ImmGCPtr(atom), &done); // The pointers are not equal, so if the input string is also an atom it @@ -3390,6 +3395,12 @@ void MacroAssembler::guardSpecificAtom(Register str, JSAtom* atom, branchTest32(Assembler::NonZero, Address(str, JSString::offsetOfFlags()), Imm32(JSString::ATOM_BIT), fail); + // Try to do a cheap atomize on the string and repeat the above test + tryFastAtomize(str, scratch, scratch, ¬CachedAtom); + branchPtr(Assembler::Equal, scratch, ImmGCPtr(atom), &done); + jump(fail); + bind(¬CachedAtom); + // Check the length. branch32(Assembler::NotEqual, Address(str, JSString::offsetOfLength()), Imm32(atom->length()), fail); @@ -6551,6 +6562,14 @@ void MacroAssembler::branchWasmRefIsSubtypeExn(Register ref, branchTestPtr(Assembler::Zero, ref, ref, nullLabel); } + // The only value that can inhabit 'noexn' is null. So, early out if we got + // not-null. + if (destType.isNoExn()) { + jump(failLabel); + bind(&fallthrough); + return; + } + // There are no other possible types except exnref, so succeed! jump(successLabel); bind(&fallthrough); @@ -7921,10 +7940,15 @@ void MacroAssembler::typedArrayElementSize(Register obj, Register output) { branchPtr(Assembler::Below, output, ImmPtr(classForType(Scalar::BigInt64)), &one); + static_assert(ValidateSizeRange(Scalar::BigInt64, Scalar::Float16), + "element size is eight in [BigInt64, Float16)"); + branchPtr(Assembler::Below, output, ImmPtr(classForType(Scalar::Float16)), + &eight); + static_assert( - ValidateSizeRange(Scalar::BigInt64, Scalar::MaxTypedArrayViewType), - "element size is eight in [BigInt64, MaxTypedArrayViewType)"); - // Fall through for BigInt64 and BigUint64 + ValidateSizeRange(Scalar::Float16, Scalar::MaxTypedArrayViewType), + "element size is two in [Float16, MaxTypedArrayViewType)"); + jump(&two); bind(&eight); move32(Imm32(8), output); @@ -7993,10 +8017,16 @@ void MacroAssembler::resizableTypedArrayElementShiftBy(Register obj, branchPtr(Assembler::Below, scratch, ImmPtr(classForType(Scalar::BigInt64)), &zero); + static_assert(ValidateSizeRange(Scalar::BigInt64, Scalar::Float16), + "element shift is three in [BigInt64, Float16)"); + branchPtr(Assembler::Below, scratch, ImmPtr(classForType(Scalar::Float16)), + &three); + static_assert( - ValidateSizeRange(Scalar::BigInt64, Scalar::MaxTypedArrayViewType), - "element shift is three in [BigInt64, MaxTypedArrayViewType)"); - // Fall through for BigInt64 and BigUint64 + ValidateSizeRange(Scalar::Float16, Scalar::MaxTypedArrayViewType), + "element shift is one in [Float16, MaxTypedArrayViewType)"); + branchPtr(Assembler::Below, scratch, ImmPtr(classForType(Scalar::Float16)), + &one); bind(&three); rshiftPtr(Imm32(3), output); diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index 114aaa47d7..b4ad95b86b 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -1727,10 +1727,8 @@ class MacroAssembler : public MacroAssemblerSpecific { Register scratch, Label* label); - inline void branchIfFunctionHasNoJitEntry(Register fun, bool isConstructing, - Label* label); - inline void branchIfFunctionHasJitEntry(Register fun, bool isConstructing, - Label* label); + inline void branchIfFunctionHasNoJitEntry(Register fun, Label* label); + inline void branchIfFunctionHasJitEntry(Register fun, Label* label); inline void branchIfScriptHasJitScript(Register script, Label* label); inline void branchIfScriptHasNoJitScript(Register script, Label* label); @@ -5602,8 +5600,8 @@ class MacroAssembler : public MacroAssemblerSpecific { void setIsDefinitelyTypedArrayConstructor(Register obj, Register output); void loadMegamorphicCache(Register dest); - void lookupStringInAtomCacheLastLookups(Register str, Register scratch, - Register output, Label* fail); + void tryFastAtomize(Register str, Register scratch, Register output, + Label* fail); void loadMegamorphicSetPropCache(Register dest); void loadAtomOrSymbolAndHash(ValueOperand value, Register outId, diff --git a/js/src/jit/RangeAnalysis.cpp b/js/src/jit/RangeAnalysis.cpp index bd8380a690..3a7abd8f3e 100644 --- a/js/src/jit/RangeAnalysis.cpp +++ b/js/src/jit/RangeAnalysis.cpp @@ -23,6 +23,7 @@ #include "util/CheckedArithmetic.h" #include "util/Unicode.h" #include "vm/ArgumentsObject.h" +#include "vm/Float16.h" #include "vm/TypedArrayObject.h" #include "vm/Uint8Clamped.h" @@ -1758,6 +1759,7 @@ static Range* GetArrayBufferViewRange(TempAllocator& alloc, Scalar::Type type) { case Scalar::BigUint64: case Scalar::Int64: case Scalar::Simd128: + case Scalar::Float16: case Scalar::Float32: case Scalar::Float64: case Scalar::MaxTypedArrayViewType: diff --git a/js/src/jit/TrampolineNatives.cpp b/js/src/jit/TrampolineNatives.cpp index e22023f8dd..a0d7c979c1 100644 --- a/js/src/jit/TrampolineNatives.cpp +++ b/js/src/jit/TrampolineNatives.cpp @@ -14,6 +14,7 @@ #include "jit/PerfSpewer.h" #include "js/CallArgs.h" #include "js/experimental/JitInfo.h" +#include "vm/TypedArrayObject.h" #include "jit/MacroAssembler-inl.h" #include "vm/Activation-inl.h" @@ -42,7 +43,8 @@ void js::jit::SetTrampolineNativeJitEntry(JSContext* cx, JSFunction* fun, fun->setTrampolineNativeJitEntry(entry); } -uint32_t JitRuntime::generateArraySortTrampoline(MacroAssembler& masm) { +uint32_t JitRuntime::generateArraySortTrampoline(MacroAssembler& masm, + ArraySortKind kind) { AutoCreatedBy acb(masm, "JitRuntime::generateArraySortTrampoline"); const uint32_t offset = startTrampolineCode(masm); @@ -108,11 +110,12 @@ uint32_t JitRuntime::generateArraySortTrampoline(MacroAssembler& masm) { // Trampoline control flow looks like this: // - // call ArraySortFromJit + // call ArraySortFromJit or TypedArraySortFromJit // goto checkReturnValue // call_comparator: // call comparator - // call ArraySortData::sortWithComparator + // call ArraySortData::sortArrayWithComparator or + // ArraySortData::sortTypedArrayWithComparator // checkReturnValue: // check return value, jump to call_comparator if needed // return rval @@ -125,7 +128,7 @@ uint32_t JitRuntime::generateArraySortTrampoline(MacroAssembler& masm) { masm.enterFakeExitFrame(cxReg, scratchReg, ExitFrameType::Bare); }; - // Call ArraySortFromJit. + // Call {Typed}ArraySortFromJit. using Fn1 = ArraySortResult (*)(JSContext* cx, jit::TrampolineNativeFrameLayout* frame); masm.loadJSContext(temp0); @@ -133,8 +136,16 @@ uint32_t JitRuntime::generateArraySortTrampoline(MacroAssembler& masm) { masm.setupAlignedABICall(); masm.passABIArg(temp0); masm.passABIArg(FramePointer); - masm.callWithABI<Fn1, ArraySortFromJit>( - ABIType::General, CheckUnsafeCallWithABI::DontCheckHasExitFrame); + switch (kind) { + case ArraySortKind::Array: + masm.callWithABI<Fn1, ArraySortFromJit>( + ABIType::General, CheckUnsafeCallWithABI::DontCheckHasExitFrame); + break; + case ArraySortKind::TypedArray: + masm.callWithABI<Fn1, TypedArraySortFromJit>( + ABIType::General, CheckUnsafeCallWithABI::DontCheckHasExitFrame); + break; + } // Check return value. Label checkReturnValue; @@ -192,15 +203,23 @@ uint32_t JitRuntime::generateArraySortTrampoline(MacroAssembler& masm) { masm.bind(&callDone); masm.storeValue(JSReturnOperand, Address(FramePointer, RvalOffset)); - // Call ArraySortData::sortWithComparator. + // Call ArraySortData::sort{Typed}ArrayWithComparator. using Fn2 = ArraySortResult (*)(ArraySortData* data); masm.moveStackPtrTo(temp2); masm.loadJSContext(temp0); pushExitFrame(temp0, temp1); masm.setupAlignedABICall(); masm.passABIArg(temp2); - masm.callWithABI<Fn2, ArraySortData::sortWithComparator>( - ABIType::General, CheckUnsafeCallWithABI::DontCheckHasExitFrame); + switch (kind) { + case ArraySortKind::Array: + masm.callWithABI<Fn2, ArraySortData::sortArrayWithComparator>( + ABIType::General, CheckUnsafeCallWithABI::DontCheckHasExitFrame); + break; + case ArraySortKind::TypedArray: + masm.callWithABI<Fn2, ArraySortData::sortTypedArrayWithComparator>( + ABIType::General, CheckUnsafeCallWithABI::DontCheckHasExitFrame); + break; + } // Check return value. masm.bind(&checkReturnValue); @@ -231,8 +250,13 @@ uint32_t JitRuntime::generateArraySortTrampoline(MacroAssembler& masm) { void JitRuntime::generateTrampolineNatives( MacroAssembler& masm, TrampolineNativeJitEntryOffsets& offsets, PerfSpewerRangeRecorder& rangeRecorder) { - offsets[TrampolineNative::ArraySort] = generateArraySortTrampoline(masm); + offsets[TrampolineNative::ArraySort] = + generateArraySortTrampoline(masm, ArraySortKind::Array); rangeRecorder.recordOffset("Trampoline: ArraySort"); + + offsets[TrampolineNative::TypedArraySort] = + generateArraySortTrampoline(masm, ArraySortKind::TypedArray); + rangeRecorder.recordOffset("Trampoline: TypedArraySort"); } bool jit::CallTrampolineNativeJitCode(JSContext* cx, TrampolineNative native, diff --git a/js/src/jit/TrampolineNatives.h b/js/src/jit/TrampolineNatives.h index f71a3b707d..6151a78fda 100644 --- a/js/src/jit/TrampolineNatives.h +++ b/js/src/jit/TrampolineNatives.h @@ -32,7 +32,9 @@ class CallArgs; } // namespace JS // List of all trampoline natives. -#define TRAMPOLINE_NATIVE_LIST(_) _(ArraySort) +#define TRAMPOLINE_NATIVE_LIST(_) \ + _(ArraySort) \ + _(TypedArraySort) namespace js { namespace jit { diff --git a/js/src/jit/TypePolicy.cpp b/js/src/jit/TypePolicy.cpp index bf3cb68eea..7d677bfb06 100644 --- a/js/src/jit/TypePolicy.cpp +++ b/js/src/jit/TypePolicy.cpp @@ -183,124 +183,99 @@ bool AllDoublePolicy::staticAdjustInputs(TempAllocator& alloc, bool ComparePolicy::adjustInputs(TempAllocator& alloc, MInstruction* def) const { - MOZ_ASSERT(def->isCompare()); - MCompare* compare = def->toCompare(); - - // Convert Float32 operands to doubles - for (size_t i = 0; i < 2; i++) { - MDefinition* in = def->getOperand(i); - if (in->type() == MIRType::Float32) { - MInstruction* replace = MToDouble::New(alloc, in); - def->block()->insertBefore(def, replace); - def->replaceOperand(i, replace); - } - } - - auto replaceOperand = [&](size_t index, auto* replace) { - def->block()->insertBefore(def, replace); - def->replaceOperand(index, replace); - return replace->typePolicy()->adjustInputs(alloc, replace); - }; - - if (compare->compareType() == MCompare::Compare_Undefined || - compare->compareType() == MCompare::Compare_Null) { - // Nothing to do for undefined and null, lowering handles all types. - return true; - } - - if (compare->compareType() == MCompare::Compare_UIntPtr) { - MOZ_ASSERT(compare->lhs()->type() == MIRType::IntPtr); - MOZ_ASSERT(compare->rhs()->type() == MIRType::IntPtr); - return true; - } - - // Compare_BigInt_Int32 specialization is done for "BigInt <cmp> Int32". - // Compare_BigInt_Double specialization is done for "BigInt <cmp> Double". - // Compare_BigInt_String specialization is done for "BigInt <cmp> String". - if (compare->compareType() == MCompare::Compare_BigInt_Int32 || - compare->compareType() == MCompare::Compare_BigInt_Double || - compare->compareType() == MCompare::Compare_BigInt_String) { - if (MDefinition* in = def->getOperand(0); in->type() != MIRType::BigInt) { - auto* replace = - MUnbox::New(alloc, in, MIRType::BigInt, MUnbox::Infallible); - if (!replaceOperand(0, replace)) { - return false; - } + auto convertOperand = [&](size_t index, MIRType expected) { + MDefinition* operand = def->getOperand(index); + if (operand->type() == expected) { + return true; } - - MDefinition* in = def->getOperand(1); - MInstruction* replace = nullptr; - if (compare->compareType() == MCompare::Compare_BigInt_Int32) { - if (in->type() != MIRType::Int32) { - replace = MToNumberInt32::New( - alloc, in, IntConversionInputKind::NumbersOrBoolsOnly); - } - } else if (compare->compareType() == MCompare::Compare_BigInt_Double) { - if (in->type() != MIRType::Double) { - replace = MToDouble::New(alloc, in, MToFPInstruction::NumbersOnly); - } - } else { - MOZ_ASSERT(compare->compareType() == MCompare::Compare_BigInt_String); - if (in->type() != MIRType::String) { - replace = MUnbox::New(alloc, in, MIRType::String, MUnbox::Infallible); - } - } - - if (replace) { - if (!replaceOperand(1, replace)) { - return false; - } - } - - return true; - } - - // Convert all inputs to the right input type - MIRType type = compare->inputType(); - MOZ_ASSERT(type == MIRType::Int32 || type == MIRType::Double || - type == MIRType::Float32 || type == MIRType::Object || - type == MIRType::String || type == MIRType::Symbol || - type == MIRType::BigInt); - for (size_t i = 0; i < 2; i++) { - MDefinition* in = def->getOperand(i); - if (in->type() == type) { - continue; - } - - MInstruction* replace; - - switch (type) { + switch (expected) { case MIRType::Double: - replace = MToDouble::New(alloc, in, MToFPInstruction::NumbersOnly); - break; - case MIRType::Float32: - replace = MToFloat32::New(alloc, in, MToFPInstruction::NumbersOnly); + replace = MToDouble::New(alloc, operand); break; - case MIRType::Int32: { - IntConversionInputKind convert = IntConversionInputKind::NumbersOnly; - replace = MToNumberInt32::New(alloc, in, convert); + case MIRType::Int32: + replace = MToNumberInt32::New(alloc, operand); break; - } - case MIRType::Object: - replace = MUnbox::New(alloc, in, MIRType::Object, MUnbox::Infallible); + case MIRType::Float32: + replace = MToFloat32::New(alloc, operand); break; case MIRType::String: - replace = MUnbox::New(alloc, in, MIRType::String, MUnbox::Infallible); + replace = + MUnbox::New(alloc, operand, MIRType::String, MUnbox::Fallible); break; case MIRType::Symbol: - replace = MUnbox::New(alloc, in, MIRType::Symbol, MUnbox::Infallible); + replace = + MUnbox::New(alloc, operand, MIRType::Symbol, MUnbox::Fallible); + break; + case MIRType::Object: + replace = + MUnbox::New(alloc, operand, MIRType::Object, MUnbox::Fallible); break; case MIRType::BigInt: - replace = MUnbox::New(alloc, in, MIRType::BigInt, MUnbox::Infallible); + replace = + MUnbox::New(alloc, operand, MIRType::BigInt, MUnbox::Fallible); break; default: - MOZ_CRASH("Unknown compare specialization"); + MOZ_CRASH("Unsupported MIRType"); } + replace->setBailoutKind(BailoutKind::TypePolicy); + def->block()->insertBefore(def, replace); + def->replaceOperand(index, replace); + return replace->typePolicy()->adjustInputs(alloc, replace); + }; - if (!replaceOperand(i, replace)) { - return false; - } + MOZ_ASSERT(def->isCompare()); + MCompare* compare = def->toCompare(); + switch (compare->compareType()) { + case MCompare::Compare_Undefined: + case MCompare::Compare_Null: + MOZ_ASSERT(compare->rhs()->type() == MIRType::Undefined || + compare->rhs()->type() == MIRType::Null); + // IF the operand is float32, we must convert it to a double. + if (compare->lhs()->type() == MIRType::Float32) { + MInstruction* replace = MToDouble::New(alloc, compare->lhs()); + def->block()->insertBefore(def, replace); + def->replaceOperand(0, replace); + return replace->typePolicy()->adjustInputs(alloc, replace); + } + // GVN and lowering handle all other types. + return true; + case MCompare::Compare_Int32: + return convertOperand(0, MIRType::Int32) && + convertOperand(1, MIRType::Int32); + case MCompare::Compare_UIntPtr: + MOZ_ASSERT(compare->lhs()->type() == MIRType::IntPtr); + MOZ_ASSERT(compare->rhs()->type() == MIRType::IntPtr); + return true; + case MCompare::Compare_Double: + return convertOperand(0, MIRType::Double) && + convertOperand(1, MIRType::Double); + case MCompare::Compare_Float32: + return convertOperand(0, MIRType::Float32) && + convertOperand(1, MIRType::Float32); + case MCompare::Compare_String: + return convertOperand(0, MIRType::String) && + convertOperand(1, MIRType::String); + case MCompare::Compare_Symbol: + return convertOperand(0, MIRType::Symbol) && + convertOperand(1, MIRType::Symbol); + case MCompare::Compare_Object: + return convertOperand(0, MIRType::Object) && + convertOperand(1, MIRType::Object); + case MCompare::Compare_BigInt: + return convertOperand(0, MIRType::BigInt) && + convertOperand(1, MIRType::BigInt); + case MCompare::Compare_BigInt_Int32: + return convertOperand(0, MIRType::BigInt) && + convertOperand(1, MIRType::Int32); + case MCompare::Compare_BigInt_Double: + return convertOperand(0, MIRType::BigInt) && + convertOperand(1, MIRType::Double); + case MCompare::Compare_BigInt_String: + return convertOperand(0, MIRType::BigInt) && + convertOperand(1, MIRType::String); + default: + MOZ_CRASH("Unexpected compare type"); } return true; diff --git a/js/src/jit/VMFunctionList-inl.h b/js/src/jit/VMFunctionList-inl.h index 99b98f17ed..aae6b866e2 100644 --- a/js/src/jit/VMFunctionList-inl.h +++ b/js/src/jit/VMFunctionList-inl.h @@ -173,6 +173,7 @@ namespace jit { _(DoToBoolFallback, js::jit::DoToBoolFallback) \ _(DoToPropertyKeyFallback, js::jit::DoToPropertyKeyFallback) \ _(DoTrialInlining, js::jit::DoTrialInlining) \ + _(DoTypeOfEqFallback, js::jit::DoTypeOfEqFallback) \ _(DoTypeOfFallback, js::jit::DoTypeOfFallback) \ _(DoUnaryArithFallback, js::jit::DoUnaryArithFallback, 1) \ _(EnterWith, js::jit::EnterWith) \ @@ -211,7 +212,6 @@ namespace jit { _(InterpretResume, js::jit::InterpretResume) \ _(InterruptCheck, js::jit::InterruptCheck) \ _(InvokeFunction, js::jit::InvokeFunction) \ - _(InvokeNativeFunction, js::jit::InvokeNativeFunction) \ _(IonBinaryArithICUpdate, js::jit::IonBinaryArithIC::update) \ _(IonBindNameICUpdate, js::jit::IonBindNameIC::update) \ _(IonCheckPrivateFieldICUpdate, js::jit::IonCheckPrivateFieldIC::update) \ diff --git a/js/src/jit/VMFunctions.cpp b/js/src/jit/VMFunctions.cpp index 3ec85a72c2..7d729351b7 100644 --- a/js/src/jit/VMFunctions.cpp +++ b/js/src/jit/VMFunctions.cpp @@ -38,6 +38,7 @@ #include "vm/SelfHosting.h" #include "vm/StaticStrings.h" #include "vm/TypedArrayObject.h" +#include "vm/TypeofEqOperand.h" // TypeofEqOperand #include "vm/Watchtower.h" #include "wasm/WasmGcObject.h" @@ -545,39 +546,6 @@ bool InvokeFunction(JSContext* cx, HandleObject obj, bool constructing, return Call(cx, fval, thisv, args, rval); } -bool InvokeNativeFunction(JSContext* cx, bool constructing, - bool ignoresReturnValue, uint32_t argc, Value* argv, - MutableHandleValue rval) { - // Ensure argv array is rooted - we may GC in here. - size_t numValues = argc + 2 + constructing; - RootedExternalValueArray argvRoot(cx, numValues, argv); - - // Data in the argument vector is arranged for a JIT -> C++ call. - CallArgs callArgs = CallArgsFromSp(argc + constructing, argv + numValues, - constructing, ignoresReturnValue); - - // This function is only called when the callee is a native function. - MOZ_ASSERT(callArgs.callee().as<JSFunction>().isNativeWithoutJitEntry()); - - if (constructing) { - MOZ_ASSERT(callArgs.thisv().isMagic(JS_IS_CONSTRUCTING)); - - if (!ConstructFromStack(cx, callArgs)) { - return false; - } - - MOZ_ASSERT(callArgs.rval().isObject(), - "native constructors don't return primitives"); - } else { - if (!CallFromStack(cx, callArgs)) { - return false; - } - } - - rval.set(callArgs.rval()); - return true; -} - void* GetContextSensitiveInterpreterStub() { return TlsContext.get()->runtime()->jitRuntime()->interpreterStub().value; } @@ -2280,6 +2248,15 @@ JSString* TypeOfNameObject(JSObject* obj, JSRuntime* rt) { return TypeName(type, *rt->commonNames); } +bool TypeOfEqObject(JSObject* obj, TypeofEqOperand operand) { + AutoUnsafeCallWithABI unsafe; + bool result = js::TypeOfObject(obj) == operand.type(); + if (operand.compareOp() == JSOp::Ne) { + result = !result; + } + return result; +} + bool GetPrototypeOf(JSContext* cx, HandleObject target, MutableHandleValue rval) { MOZ_ASSERT(target->hasDynamicPrototype()); diff --git a/js/src/jit/VMFunctions.h b/js/src/jit/VMFunctions.h index b5ac5d700b..e769fd306a 100644 --- a/js/src/jit/VMFunctions.h +++ b/js/src/jit/VMFunctions.h @@ -19,6 +19,7 @@ #include "gc/AllocKind.h" #include "js/ScalarType.h" #include "js/TypeDecls.h" +#include "vm/TypeofEqOperand.h" class JSJitInfo; class JSLinearString; @@ -354,10 +355,6 @@ struct LastArg<HeadType, TailTypes...> { uint32_t argc, Value* argv, MutableHandleValue rval); -[[nodiscard]] bool InvokeNativeFunction(JSContext* cx, bool constructing, - bool ignoresReturnValue, uint32_t argc, - Value* argv, MutableHandleValue rval); - bool InvokeFromInterpreterStub(JSContext* cx, InterpreterStubExitFrameLayout* frame); void* GetContextSensitiveInterpreterStub(); @@ -585,6 +582,8 @@ bool SetPropertyMegamorphic(JSContext* cx, HandleObject obj, HandleId id, JSString* TypeOfNameObject(JSObject* obj, JSRuntime* rt); +bool TypeOfEqObject(JSObject* obj, TypeofEqOperand operand); + bool GetPrototypeOf(JSContext* cx, HandleObject target, MutableHandleValue rval); diff --git a/js/src/jit/WarpBuilder.cpp b/js/src/jit/WarpBuilder.cpp index cad28fa535..4ca882c4b1 100644 --- a/js/src/jit/WarpBuilder.cpp +++ b/js/src/jit/WarpBuilder.cpp @@ -21,6 +21,7 @@ #include "vm/GeneratorObject.h" #include "vm/Interpreter.h" #include "vm/Opcodes.h" +#include "vm/TypeofEqOperand.h" // TypeofEqOperand #include "gc/ObjectKind-inl.h" #include "vm/BytecodeIterator-inl.h" @@ -1564,6 +1565,30 @@ bool WarpBuilder::build_TypeofExpr(BytecodeLocation loc) { return build_Typeof(loc); } +bool WarpBuilder::build_TypeofEq(BytecodeLocation loc) { + auto operand = loc.getTypeofEqOperand(); + JSType type = operand.type(); + JSOp compareOp = operand.compareOp(); + MDefinition* input = current->pop(); + + if (const auto* typesSnapshot = getOpSnapshot<WarpPolymorphicTypes>(loc)) { + auto* typeOf = MTypeOf::New(alloc(), input); + typeOf->setObservedTypes(typesSnapshot->list()); + current->add(typeOf); + + auto* typeInt = MConstant::New(alloc(), Int32Value(type)); + current->add(typeInt); + + auto* ins = MCompare::New(alloc(), typeOf, typeInt, compareOp, + MCompare::Compare_Int32); + current->add(ins); + current->push(ins); + return true; + } + + return buildIC(loc, CacheKind::TypeOfEq, {input}); +} + bool WarpBuilder::build_Arguments(BytecodeLocation loc) { auto* snapshot = getOpSnapshot<WarpArguments>(loc); MOZ_ASSERT(info().needsArgsObj()); @@ -3402,6 +3427,23 @@ bool WarpBuilder::buildIC(BytecodeLocation loc, CacheKind kind, current->push(ins); return true; } + case CacheKind::TypeOfEq: { + MOZ_ASSERT(numInputs == 1); + auto operand = loc.getTypeofEqOperand(); + JSType type = operand.type(); + JSOp compareOp = operand.compareOp(); + auto* typeOf = MTypeOf::New(alloc(), getInput(0)); + current->add(typeOf); + + auto* typeInt = MConstant::New(alloc(), Int32Value(type)); + current->add(typeInt); + + auto* ins = MCompare::New(alloc(), typeOf, typeInt, compareOp, + MCompare::Compare_Int32); + current->add(ins); + current->push(ins); + return true; + } case CacheKind::NewObject: { auto* templateConst = constant(NullValue()); MNewObject* ins = MNewObject::NewVM( @@ -3482,6 +3524,7 @@ bool WarpBuilder::buildBailoutForColdIC(BytecodeLocation loc, CacheKind kind) { case CacheKind::CheckPrivateField: case CacheKind::InstanceOf: case CacheKind::OptimizeGetIterator: + case CacheKind::TypeOfEq: resultType = MIRType::Boolean; break; case CacheKind::SetProp: diff --git a/js/src/jit/WarpCacheIRTranspiler.cpp b/js/src/jit/WarpCacheIRTranspiler.cpp index fdaafd00b3..2e4a4b9613 100644 --- a/js/src/jit/WarpCacheIRTranspiler.cpp +++ b/js/src/jit/WarpCacheIRTranspiler.cpp @@ -25,6 +25,7 @@ #include "jit/WarpSnapshot.h" #include "js/ScalarType.h" // js::Scalar::Type #include "vm/BytecodeLocation.h" +#include "vm/TypeofEqOperand.h" // TypeofEqOperand #include "wasm/WasmCode.h" #include "gc/ObjectKind-inl.h" @@ -1117,10 +1118,9 @@ bool WarpCacheIRTranspiler::emitGuardNoDenseElements(ObjOperandId objId) { return true; } -bool WarpCacheIRTranspiler::emitGuardFunctionHasJitEntry(ObjOperandId funId, - bool constructing) { +bool WarpCacheIRTranspiler::emitGuardFunctionHasJitEntry(ObjOperandId funId) { MDefinition* fun = getOperand(funId); - uint16_t expectedFlags = FunctionFlags::HasJitEntryFlags(constructing); + uint16_t expectedFlags = FunctionFlags::HasJitEntryFlags(); uint16_t unexpectedFlags = 0; auto* ins = @@ -1134,8 +1134,7 @@ bool WarpCacheIRTranspiler::emitGuardFunctionHasJitEntry(ObjOperandId funId, bool WarpCacheIRTranspiler::emitGuardFunctionHasNoJitEntry(ObjOperandId funId) { MDefinition* fun = getOperand(funId); uint16_t expectedFlags = 0; - uint16_t unexpectedFlags = - FunctionFlags::HasJitEntryFlags(/*isConstructing=*/false); + uint16_t unexpectedFlags = FunctionFlags::HasJitEntryFlags(); auto* ins = MGuardFunctionFlags::New(alloc(), fun, expectedFlags, unexpectedFlags); @@ -1626,6 +1625,22 @@ bool WarpCacheIRTranspiler::emitLoadTypeOfObjectResult(ObjOperandId objId) { return true; } +bool WarpCacheIRTranspiler::emitLoadTypeOfEqObjectResult( + ObjOperandId objId, TypeofEqOperand operand) { + MDefinition* obj = getOperand(objId); + auto* typeOf = MTypeOf::New(alloc(), obj); + add(typeOf); + + auto* typeInt = MConstant::New(alloc(), Int32Value(operand.type())); + add(typeInt); + + auto* ins = MCompare::New(alloc(), typeOf, typeInt, operand.compareOp(), + MCompare::Compare_Int32); + add(ins); + pushResult(ins); + return true; +} + bool WarpCacheIRTranspiler::emitLoadEnclosingEnvironment( ObjOperandId objId, ObjOperandId resultId) { MDefinition* env = getOperand(objId); diff --git a/js/src/jit/WarpOracle.cpp b/js/src/jit/WarpOracle.cpp index 624ebfcedf..d0c6d30d8c 100644 --- a/js/src/jit/WarpOracle.cpp +++ b/js/src/jit/WarpOracle.cpp @@ -510,6 +510,11 @@ AbortReasonOr<WarpScriptSnapshot*> WarpScriptOracle::createScriptSnapshot() { break; } + case JSOp::String: + if (!loc.atomizeString(cx_, script_)) { + return abort(AbortReason::Alloc); + } + break; case JSOp::GetName: case JSOp::GetGName: case JSOp::GetProp: @@ -578,6 +583,7 @@ AbortReasonOr<WarpScriptSnapshot*> WarpScriptOracle::createScriptSnapshot() { case JSOp::OptimizeSpreadCall: case JSOp::Typeof: case JSOp::TypeofExpr: + case JSOp::TypeofEq: case JSOp::NewObject: case JSOp::NewInit: case JSOp::NewArray: @@ -613,7 +619,6 @@ AbortReasonOr<WarpScriptSnapshot*> WarpScriptOracle::createScriptSnapshot() { case JSOp::Int32: case JSOp::Double: case JSOp::BigInt: - case JSOp::String: case JSOp::Symbol: case JSOp::Pop: case JSOp::PopN: @@ -1209,6 +1214,10 @@ bool WarpScriptOracle::replaceNurseryAndAllocSitePointers( // If the stub data contains weak pointers then trigger a read barrier. This // is necessary as these will now be strong references in the snapshot. // + // If the stub data contains strings then atomize them. This ensures we don't + // try to access potentially unstable characters from a background thread and + // also facilitates certain optimizations. + // // Also asserts non-object fields don't contain nursery pointers. uint32_t field = 0; @@ -1270,11 +1279,17 @@ bool WarpScriptOracle::replaceNurseryAndAllocSitePointers( break; } case StubField::Type::String: { -#ifdef DEBUG - JSString* str = - stubInfo->getStubField<StubField::Type::String>(stub, offset); + uintptr_t oldWord = stubInfo->getStubRawWord(stub, offset); + JSString* str = reinterpret_cast<JSString*>(oldWord); MOZ_ASSERT(!IsInsideNursery(str)); -#endif + JSAtom* atom = AtomizeString(cx_, str); + if (!atom) { + return false; + } + if (atom != str) { + uintptr_t newWord = reinterpret_cast<uintptr_t>(atom); + stubInfo->replaceStubRawWord(stubDataCopy, offset, oldWord, newWord); + } break; } case StubField::Type::Id: { @@ -1287,10 +1302,19 @@ bool WarpScriptOracle::replaceNurseryAndAllocSitePointers( break; } case StubField::Type::Value: { -#ifdef DEBUG - Value v = stubInfo->getStubField<StubField::Type::Value>(stub, offset); + Value v = + stubInfo->getStubField<StubField::Type::Value>(stub, offset).get(); MOZ_ASSERT_IF(v.isGCThing(), !IsInsideNursery(v.toGCThing())); -#endif + if (v.isString()) { + Value newVal; + JSAtom* atom = AtomizeString(cx_, v.toString()); + if (!atom) { + return false; + } + newVal.setString(atom); + stubInfo->replaceStubRawValueBits(stubDataCopy, offset, v.asRawBits(), + newVal.asRawBits()); + } break; } case StubField::Type::AllocSite: { diff --git a/js/src/jit/arm64/MacroAssembler-arm64.cpp b/js/src/jit/arm64/MacroAssembler-arm64.cpp index e3ec2494ff..511df5b4b2 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.cpp +++ b/js/src/jit/arm64/MacroAssembler-arm64.cpp @@ -569,6 +569,7 @@ void MacroAssemblerCompat::wasmLoadImpl(const wasm::MemoryAccessDesc& access, case Scalar::Uint8Clamped: case Scalar::BigInt64: case Scalar::BigUint64: + case Scalar::Float16: case Scalar::MaxTypedArrayViewType: MOZ_CRASH("unexpected array type"); } @@ -672,6 +673,7 @@ void MacroAssemblerCompat::wasmStoreImpl(const wasm::MemoryAccessDesc& access, case Scalar::Uint8Clamped: case Scalar::BigInt64: case Scalar::BigUint64: + case Scalar::Float16: case Scalar::MaxTypedArrayViewType: MOZ_CRASH("unexpected array type"); } diff --git a/js/src/jit/loong64/CodeGenerator-loong64.cpp b/js/src/jit/loong64/CodeGenerator-loong64.cpp index 76d3047680..7f873aaa9b 100644 --- a/js/src/jit/loong64/CodeGenerator-loong64.cpp +++ b/js/src/jit/loong64/CodeGenerator-loong64.cpp @@ -2357,9 +2357,15 @@ void CodeGenerator::visitEffectiveAddress(LEffectiveAddress* ins) { Register base = ToRegister(ins->base()); Register index = ToRegister(ins->index()); Register output = ToRegister(ins->output()); + int32_t shift = Imm32::ShiftOf(mir->scale()).value; - BaseIndex address(base, index, mir->scale(), mir->displacement()); - masm.computeEffectiveAddress(address, output); + if (shift) { + MOZ_ASSERT(shift <= 4); + masm.as_alsl_w(output, index, base, shift - 1); + } else { + masm.as_add_w(output, base, index); + } + masm.ma_add_w(output, output, Imm32(mir->displacement())); } void CodeGenerator::visitNegI(LNegI* ins) { diff --git a/js/src/jit/moz.build b/js/src/jit/moz.build index c49b4fcd9f..f5de984478 100644 --- a/js/src/jit/moz.build +++ b/js/src/jit/moz.build @@ -26,6 +26,7 @@ UNIFIED_SOURCES += [ "BaselineIC.cpp", "BaselineJIT.cpp", "BitSet.cpp", + "BranchHinting.cpp", "BytecodeAnalysis.cpp", "CacheIR.cpp", "CacheIRCompiler.cpp", diff --git a/js/src/jit/shared/AtomicOperations-shared-jit.h b/js/src/jit/shared/AtomicOperations-shared-jit.h index ca66a6f9b9..d5303b2c60 100644 --- a/js/src/jit/shared/AtomicOperations-shared-jit.h +++ b/js/src/jit/shared/AtomicOperations-shared-jit.h @@ -23,6 +23,7 @@ #include <stdint.h> #include "jit/AtomicOperationsGenerated.h" +#include "vm/Float16.h" #include "vm/Uint8Clamped.h" namespace js { @@ -405,6 +406,14 @@ inline uint8_clamped js::jit::AtomicOperations::loadSafeWhenRacy( return uint8_clamped(loadSafeWhenRacy((uint8_t*)addr)); } +// Clang requires a specialization for float16. +template <> +inline float16 js::jit::AtomicOperations::loadSafeWhenRacy(float16* addr) { + float16 f16; + f16.val = loadSafeWhenRacy((uint16_t*)addr); + return f16; +} + } // namespace jit } // namespace js @@ -464,6 +473,13 @@ inline void js::jit::AtomicOperations::storeSafeWhenRacy(uint8_clamped* addr, storeSafeWhenRacy((uint8_t*)addr, (uint8_t)val); } +// Clang requires a specialization for float16. +template <> +inline void js::jit::AtomicOperations::storeSafeWhenRacy(float16* addr, + float16 val) { + storeSafeWhenRacy((uint16_t*)addr, val.val); +} + } // namespace jit } // namespace js diff --git a/js/src/jit/shared/LIR-shared.h b/js/src/jit/shared/LIR-shared.h index 74c11bd91b..e7e4b0730a 100644 --- a/js/src/jit/shared/LIR-shared.h +++ b/js/src/jit/shared/LIR-shared.h @@ -817,19 +817,19 @@ class LConstructArrayGeneric }; class LApplyArgsNative - : public LCallInstructionHelper<BOX_PIECES, BOX_PIECES + 2, 2> { + : public LCallInstructionHelper<BOX_PIECES, BOX_PIECES + 1, 3> { public: LIR_HEADER(ApplyArgsNative) - LApplyArgsNative(const LAllocation& func, const LAllocation& argc, - const LBoxAllocation& thisv, const LDefinition& tmpObjReg, - const LDefinition& tmpCopy) + LApplyArgsNative(const LAllocation& argc, const LBoxAllocation& thisv, + const LDefinition& tmpObjReg, const LDefinition& tmpCopy, + const LDefinition& tmpExtra) : LCallInstructionHelper(classOpcode) { - setOperand(0, func); - setOperand(1, argc); + setOperand(0, argc); setBoxOperand(ThisIndex, thisv); setTemp(0, tmpObjReg); setTemp(1, tmpCopy); + setTemp(2, tmpExtra); } static constexpr bool isConstructing() { return false; } @@ -838,94 +838,94 @@ class LApplyArgsNative uint32_t numExtraFormals() const { return mir()->numExtraFormals(); } - const LAllocation* getFunction() { return getOperand(0); } - const LAllocation* getArgc() { return getOperand(1); } + const LAllocation* getArgc() { return getOperand(0); } - static const size_t ThisIndex = 2; + static const size_t ThisIndex = 1; const LDefinition* getTempObject() { return getTemp(0); } const LDefinition* getTempForArgCopy() { return getTemp(1); } + const LDefinition* getTempExtra() { return getTemp(2); } }; class LApplyArgsObjNative - : public LCallInstructionHelper<BOX_PIECES, BOX_PIECES + 2, 2> { + : public LCallInstructionHelper<BOX_PIECES, BOX_PIECES + 1, 3> { public: LIR_HEADER(ApplyArgsObjNative) - LApplyArgsObjNative(const LAllocation& func, const LAllocation& argsObj, - const LBoxAllocation& thisv, const LDefinition& tmpObjReg, - const LDefinition& tmpCopy) + LApplyArgsObjNative(const LAllocation& argsObj, const LBoxAllocation& thisv, + const LDefinition& tmpObjReg, const LDefinition& tmpCopy, + const LDefinition& tmpExtra) : LCallInstructionHelper(classOpcode) { - setOperand(0, func); - setOperand(1, argsObj); + setOperand(0, argsObj); setBoxOperand(ThisIndex, thisv); setTemp(0, tmpObjReg); setTemp(1, tmpCopy); + setTemp(2, tmpExtra); } static constexpr bool isConstructing() { return false; } MApplyArgsObj* mir() const { return mir_->toApplyArgsObj(); } - const LAllocation* getFunction() { return getOperand(0); } - const LAllocation* getArgsObj() { return getOperand(1); } + const LAllocation* getArgsObj() { return getOperand(0); } - static const size_t ThisIndex = 2; + static const size_t ThisIndex = 1; const LDefinition* getTempObject() { return getTemp(0); } const LDefinition* getTempForArgCopy() { return getTemp(1); } + const LDefinition* getTempExtra() { return getTemp(2); } // argc is mapped to the same register as argsObj: argc becomes live as // argsObj is dying, all registers are calltemps. - const LAllocation* getArgc() { return getOperand(1); } + const LAllocation* getArgc() { return getOperand(0); } }; class LApplyArrayNative - : public LCallInstructionHelper<BOX_PIECES, BOX_PIECES + 2, 2> { + : public LCallInstructionHelper<BOX_PIECES, BOX_PIECES + 1, 3> { public: LIR_HEADER(ApplyArrayNative) - LApplyArrayNative(const LAllocation& func, const LAllocation& elements, - const LBoxAllocation& thisv, const LDefinition& tmpObjReg, - const LDefinition& tmpCopy) + LApplyArrayNative(const LAllocation& elements, const LBoxAllocation& thisv, + const LDefinition& tmpObjReg, const LDefinition& tmpCopy, + const LDefinition& tmpExtra) : LCallInstructionHelper(classOpcode) { - setOperand(0, func); - setOperand(1, elements); + setOperand(0, elements); setBoxOperand(ThisIndex, thisv); setTemp(0, tmpObjReg); setTemp(1, tmpCopy); + setTemp(2, tmpExtra); } static constexpr bool isConstructing() { return false; } MApplyArray* mir() const { return mir_->toApplyArray(); } - const LAllocation* getFunction() { return getOperand(0); } - const LAllocation* getElements() { return getOperand(1); } + const LAllocation* getElements() { return getOperand(0); } - static const size_t ThisIndex = 2; + static const size_t ThisIndex = 1; const LDefinition* getTempObject() { return getTemp(0); } const LDefinition* getTempForArgCopy() { return getTemp(1); } + const LDefinition* getTempExtra() { return getTemp(2); } // argc is mapped to the same register as elements: argc becomes live as // elements is dying, all registers are calltemps. - const LAllocation* getArgc() { return getOperand(1); } + const LAllocation* getArgc() { return getOperand(0); } }; -class LConstructArgsNative : public LCallInstructionHelper<BOX_PIECES, 3, 2> { +class LConstructArgsNative : public LCallInstructionHelper<BOX_PIECES, 2, 3> { public: LIR_HEADER(ConstructArgsNative) - LConstructArgsNative(const LAllocation& func, const LAllocation& argc, - const LAllocation& newTarget, - const LDefinition& tmpObjReg, const LDefinition& tmpCopy) + LConstructArgsNative(const LAllocation& argc, const LAllocation& newTarget, + const LDefinition& tmpObjReg, const LDefinition& tmpCopy, + const LDefinition& tmpExtra) : LCallInstructionHelper(classOpcode) { - setOperand(0, func); - setOperand(1, argc); - setOperand(2, newTarget); + setOperand(0, argc); + setOperand(1, newTarget); setTemp(0, tmpObjReg); setTemp(1, tmpCopy); + setTemp(2, tmpExtra); } static constexpr bool isConstructing() { return true; } @@ -934,44 +934,44 @@ class LConstructArgsNative : public LCallInstructionHelper<BOX_PIECES, 3, 2> { uint32_t numExtraFormals() const { return mir()->numExtraFormals(); } - const LAllocation* getFunction() { return getOperand(0); } - const LAllocation* getArgc() { return getOperand(1); } - const LAllocation* getNewTarget() { return getOperand(2); } + const LAllocation* getArgc() { return getOperand(0); } + const LAllocation* getNewTarget() { return getOperand(1); } const LDefinition* getTempObject() { return getTemp(0); } const LDefinition* getTempForArgCopy() { return getTemp(1); } + const LDefinition* getTempExtra() { return getTemp(2); } }; -class LConstructArrayNative : public LCallInstructionHelper<BOX_PIECES, 3, 2> { +class LConstructArrayNative : public LCallInstructionHelper<BOX_PIECES, 2, 3> { public: LIR_HEADER(ConstructArrayNative) - LConstructArrayNative(const LAllocation& func, const LAllocation& elements, + LConstructArrayNative(const LAllocation& elements, const LAllocation& newTarget, const LDefinition& tmpObjReg, - const LDefinition& tmpCopy) + const LDefinition& tmpCopy, const LDefinition& tmpExtra) : LCallInstructionHelper(classOpcode) { - setOperand(0, func); - setOperand(1, elements); - setOperand(2, newTarget); + setOperand(0, elements); + setOperand(1, newTarget); setTemp(0, tmpObjReg); setTemp(1, tmpCopy); + setTemp(2, tmpExtra); } static constexpr bool isConstructing() { return true; } MConstructArray* mir() const { return mir_->toConstructArray(); } - const LAllocation* getFunction() { return getOperand(0); } - const LAllocation* getElements() { return getOperand(1); } - const LAllocation* getNewTarget() { return getOperand(2); } + const LAllocation* getElements() { return getOperand(0); } + const LAllocation* getNewTarget() { return getOperand(1); } const LDefinition* getTempObject() { return getTemp(0); } const LDefinition* getTempForArgCopy() { return getTemp(1); } + const LDefinition* getTempExtra() { return getTemp(2); } // argc is mapped to the same register as elements: argc becomes live as // elements is dying, all registers are calltemps. - const LAllocation* getArgc() { return getOperand(1); } + const LAllocation* getArgc() { return getOperand(0); } }; // Takes in either an integer or boolean input and tests it for truthiness. diff --git a/js/src/jit/x64/CodeGenerator-x64.cpp b/js/src/jit/x64/CodeGenerator-x64.cpp index 86d4bca0e0..4a5a2c3b06 100644 --- a/js/src/jit/x64/CodeGenerator-x64.cpp +++ b/js/src/jit/x64/CodeGenerator-x64.cpp @@ -631,6 +631,7 @@ void CodeGeneratorX64::wasmStore(const wasm::MemoryAccessDesc& access, break; case Scalar::Int64: case Scalar::Simd128: + case Scalar::Float16: case Scalar::Float32: case Scalar::Float64: case Scalar::Uint8Clamped: diff --git a/js/src/jit/x64/Lowering-x64.cpp b/js/src/jit/x64/Lowering-x64.cpp index 9f9b1713c2..85673e6422 100644 --- a/js/src/jit/x64/Lowering-x64.cpp +++ b/js/src/jit/x64/Lowering-x64.cpp @@ -322,6 +322,7 @@ void LIRGenerator::visitWasmStore(MWasmStore* ins) { case Scalar::BigInt64: case Scalar::BigUint64: case Scalar::Uint8Clamped: + case Scalar::Float16: case Scalar::MaxTypedArrayViewType: MOZ_CRASH("unexpected array type"); } diff --git a/js/src/jit/x64/MacroAssembler-x64.cpp b/js/src/jit/x64/MacroAssembler-x64.cpp index ebc8c91eaa..c42fe844f6 100644 --- a/js/src/jit/x64/MacroAssembler-x64.cpp +++ b/js/src/jit/x64/MacroAssembler-x64.cpp @@ -1082,6 +1082,7 @@ void MacroAssembler::wasmLoad(const wasm::MemoryAccessDesc& access, } case Scalar::Int64: MOZ_CRASH("int64 loads must use load64"); + case Scalar::Float16: case Scalar::BigInt64: case Scalar::BigUint64: case Scalar::Uint8Clamped: @@ -1135,6 +1136,7 @@ void MacroAssembler::wasmLoadI64(const wasm::MemoryAccessDesc& access, FaultingCodeOffset(currentOffset())); movq(srcAddr, out.reg); break; + case Scalar::Float16: case Scalar::Float32: case Scalar::Float64: case Scalar::Simd128: @@ -1199,6 +1201,7 @@ void MacroAssembler::wasmStore(const wasm::MemoryAccessDesc& access, case Scalar::Uint8Clamped: case Scalar::BigInt64: case Scalar::BigUint64: + case Scalar::Float16: case Scalar::MaxTypedArrayViewType: MOZ_CRASH("unexpected array type"); } diff --git a/js/src/jit/x86-shared/CodeGenerator-x86-shared.cpp b/js/src/jit/x86-shared/CodeGenerator-x86-shared.cpp index 692e884f06..cd32a62084 100644 --- a/js/src/jit/x86-shared/CodeGenerator-x86-shared.cpp +++ b/js/src/jit/x86-shared/CodeGenerator-x86-shared.cpp @@ -408,6 +408,8 @@ void CodeGeneratorX86Shared::visitOutOfLineLoadTypedArrayOutOfBounds( case Scalar::BigInt64: case Scalar::BigUint64: case Scalar::Simd128: + // TODO: See Bug 1835034 for JIT support for Float16Array + case Scalar::Float16: case Scalar::MaxTypedArrayViewType: MOZ_CRASH("unexpected array type"); case Scalar::Float32: diff --git a/js/src/jit/x86-shared/Lowering-x86-shared.cpp b/js/src/jit/x86-shared/Lowering-x86-shared.cpp index 6d90f2f96b..e9786d4882 100644 --- a/js/src/jit/x86-shared/Lowering-x86-shared.cpp +++ b/js/src/jit/x86-shared/Lowering-x86-shared.cpp @@ -401,6 +401,7 @@ void LIRGenerator::visitAsmJSStoreHeap(MAsmJSStoreHeap* ins) { case Scalar::Uint8Clamped: case Scalar::BigInt64: case Scalar::BigUint64: + case Scalar::Float16: case Scalar::MaxTypedArrayViewType: MOZ_CRASH("unexpected array type"); } diff --git a/js/src/jit/x86/Lowering-x86.cpp b/js/src/jit/x86/Lowering-x86.cpp index e958e998c2..703ede44f5 100644 --- a/js/src/jit/x86/Lowering-x86.cpp +++ b/js/src/jit/x86/Lowering-x86.cpp @@ -475,6 +475,7 @@ void LIRGenerator::visitWasmStore(MWasmStore* ins) { case Scalar::Uint8Clamped: case Scalar::BigInt64: case Scalar::BigUint64: + case Scalar::Float16: case Scalar::MaxTypedArrayViewType: MOZ_CRASH("unexpected array type"); } diff --git a/js/src/jit/x86/MacroAssembler-x86.cpp b/js/src/jit/x86/MacroAssembler-x86.cpp index 232303b429..5c4f1e9901 100644 --- a/js/src/jit/x86/MacroAssembler-x86.cpp +++ b/js/src/jit/x86/MacroAssembler-x86.cpp @@ -1113,6 +1113,7 @@ void MacroAssembler::wasmLoad(const wasm::MemoryAccessDesc& access, case Scalar::Uint8Clamped: case Scalar::BigInt64: case Scalar::BigUint64: + case Scalar::Float16: case Scalar::MaxTypedArrayViewType: MOZ_CRASH("unexpected type"); } @@ -1197,6 +1198,7 @@ void MacroAssembler::wasmLoadI64(const wasm::MemoryAccessDesc& access, break; } + case Scalar::Float16: case Scalar::Float32: case Scalar::Float64: MOZ_CRASH("non-int64 loads should use load()"); @@ -1258,6 +1260,7 @@ void MacroAssembler::wasmStore(const wasm::MemoryAccessDesc& access, break; case Scalar::Int64: MOZ_CRASH("Should be handled in storeI64."); + case Scalar::Float16: case Scalar::MaxTypedArrayViewType: case Scalar::BigInt64: case Scalar::BigUint64: diff --git a/js/src/jsapi-tests/moz.build b/js/src/jsapi-tests/moz.build index f6cc3b3f70..ac9afbe814 100644 --- a/js/src/jsapi-tests/moz.build +++ b/js/src/jsapi-tests/moz.build @@ -50,6 +50,7 @@ UNIFIED_SOURCES += [ "testForceLexicalInitialization.cpp", "testForOfIterator.cpp", "testForwardSetProperty.cpp", + "testFractionToDouble.cpp", "testFreshGlobalEvalRedefinition.cpp", "testFrontendCompileStencil.cpp", "testFrontendErrors.cpp", @@ -74,6 +75,7 @@ UNIFIED_SOURCES += [ "testHashTable.cpp", "testIndexToString.cpp", "testInformalValueTypeName.cpp", + "testInt128.cpp", "testIntern.cpp", "testIntlAvailableLocales.cpp", "testIntString.cpp", diff --git a/js/src/jsapi-tests/testFractionToDouble.cpp b/js/src/jsapi-tests/testFractionToDouble.cpp new file mode 100644 index 0000000000..c3e6842863 --- /dev/null +++ b/js/src/jsapi-tests/testFractionToDouble.cpp @@ -0,0 +1,181 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifdef JS_HAS_TEMPORAL_API + +# include <cmath> +# include <stdint.h> + +# include "builtin/temporal/Int128.h" +# include "builtin/temporal/Temporal.h" +# include "jsapi-tests/tests.h" + +using namespace js::temporal; + +// Simple test using numerators and denominators where the result can be +// computed through standard double division. +BEGIN_TEST(testFraction_simple) { + int64_t numerators[] = { + 0, 1, 2, 10, 100, INT32_MIN, INT32_MAX, + }; + + int64_t denominators[] = { + 1, 2, 3, 10, 100, 1000, + }; + + for (auto numerator : numerators) { + for (auto denominator : denominators) { + double result = double(numerator) / double(denominator); + + CHECK_EQUAL(FractionToDouble(numerator, denominator), result); + CHECK_EQUAL(FractionToDouble(Int128{numerator}, Int128{denominator}), + result); + + CHECK_EQUAL(FractionToDouble(-numerator, denominator), + std::copysign(result, -numerator)); + CHECK_EQUAL(FractionToDouble(-Int128{numerator}, Int128{denominator}), + std::copysign(result, -numerator)); + } + } + + return true; +} +END_TEST(testFraction_simple) + +// Complex test with values exceeding Number.MAX_SAFE_INTEGER. +BEGIN_TEST(testFraction_complex) { + struct { + int64_t numerator; + int64_t denominator; + double result; + } values[] = { + // Number.MAX_SAFE_INTEGER + {9007199254740991, 2, 4503599627370495.5}, + {9007199254740992, 2, 4503599627370496}, + {9007199254740993, 2, 4503599627370496.5}, + + {INT64_MAX, 2, 4611686018427387903.5}, + {INT64_MIN, 2, -4611686018427387904.0}, + }; + + for (auto [numerator, denominator, result] : values) { + CHECK_EQUAL(FractionToDouble(numerator, denominator), result); + CHECK_EQUAL(FractionToDouble(Int128{numerator}, Int128{denominator}), + result); + } + + return true; +} +END_TEST(testFraction_complex) + +// Complex test with Int128 values exceeding Number.MAX_SAFE_INTEGER. +BEGIN_TEST(testFraction_complex_int128) { + struct { + Int128 numerator; + Int128 denominator; + double result; + } values[] = { + // Divide 1 by a growing divisor. + {Int128{1}, Int128{1'000}, 0.001}, + {Int128{1}, Int128{1'000'000}, 0.000'001}, + {Int128{1}, Int128{1'000'000'000}, 0.000'000'001}, + {Int128{1}, Int128{1'000'000'000'000}, 0.000'000'000'001}, + {Int128{1}, Int128{1'000'000'000'000'000}, 0.000'000'000'000'001}, + {Int128{1}, Int128{1'000'000'000'000'000'000}, 0.000'000'000'000'000'001}, + {Int128{1}, Int128{1'000'000'000'000'000'000} * Int128{1'000}, + 0.000'000'000'000'000'000'001}, + {Int128{1}, Int128{1'000'000'000'000'000'000} * Int128{1'000'000}, + 0.000'000'000'000'000'000'000'001}, + {Int128{1}, Int128{1'000'000'000'000'000'000} * Int128{1'000'000'000}, + 0.000'000'000'000'000'000'000'000'001}, + {Int128{1}, Int128{1'000'000'000'000'000'000} * Int128{1'000'000'000'000}, + 0.000'000'000'000'000'000'000'000'000'001}, + {Int128{1}, + Int128{1'000'000'000'000'000'000} * Int128{1'000'000'000'000'000}, + 0.000'000'000'000'000'000'000'000'000'000'001}, + {Int128{1}, + Int128{1'000'000'000'000'000'000} * Int128{1'000'000'000'000'000'000}, + 0.000'000'000'000'000'000'000'000'000'000'000'001}, + + // Divide a number not representable as an int64. + {Int128{0x8000'0000} << 64, Int128{1'000}, + 39614081257132168796771975.1680}, + {Int128{0x8000'0000} << 64, Int128{1'000'000}, + 39614081257132168796771.9751680}, + {Int128{0x8000'0000} << 64, Int128{1'000'000'000}, + 39614081257132168796.7719751680}, + {Int128{0x8000'0000} << 64, Int128{1'000'000'000'000}, + 39614081257132168.7967719751680}, + {Int128{0x8000'0000} << 64, Int128{1'000'000'000'000'000}, + 39614081257132.1687967719751680}, + {Int128{0x8000'0000} << 64, Int128{1'000'000'000'000'000'000}, + 39614081257.1321687967719751680}, + {Int128{0x8000'0000} << 64, + Int128{1'000'000'000'000'000'000} * Int128{1'000}, + 39614081.2571321687967719751680}, + {Int128{0x8000'0000} << 64, + Int128{1'000'000'000'000'000'000} * Int128{1'000'000}, + 39614.0812571321687967719751680}, + {Int128{0x8000'0000} << 64, + Int128{1'000'000'000'000'000'000} * Int128{1'000'000'000}, + 39.6140812571321687967719751680}, + {Int128{0x8000'0000} << 64, + Int128{1'000'000'000'000'000'000} * Int128{1'000'000'000'000}, + 0.0396140812571321687967719751680}, + {Int128{0x8000'0000} << 64, + Int128{1'000'000'000'000'000'000} * Int128{1'000'000'000'000'000}, + 0.0000396140812571321687967719751680}, + {Int128{0x8000'0000} << 64, + Int128{1'000'000'000'000'000'000} * Int128{1'000'000'000'000'000'000}, + 0.0000000396140812571321687967719751680}, + + // Test divisor which isn't a multiple of ten. + {Int128{0x8000'0000} << 64, Int128{2}, 19807040628566084398385987584.0}, + {Int128{0x8000'0000} << 64, Int128{3}, 13204693752377389598923991722.666}, + {Int128{0x8000'0000} << 64, Int128{3'333}, + 11885412918431493788410433.5937}, + {Int128{0x8000'0000} << 64, Int128{3'333'333}, + 11884225565562207195252.3120756}, + {Int128{0x8000'0000} << 64, Int128{3'333'333'333}, + 11884224378328073076.864399858}, + {Int128{0x8000'0000} << 64, Int128{3'333'333'333'333}, + 11884224377140839.0614693066343}, + {Int128{0x8000'0000} << 64, Int128{3'333'333'333'333'333}, + 11884224377139.6518274540302643}, + {Int128{0x8000'0000} << 64, Int128{3'333'333'333'333'333'333}, + 11884224377.1396506402200149881}, + {Int128{0x8000'0000} << 64, + (Int128{3'333'333'333'333'333'333} * Int128{1'000}) + Int128{333}, + 11884224.3771396506390327809728}, + {Int128{0x8000'0000} << 64, + (Int128{3'333'333'333'333'333'333} * Int128{1'000'000}) + + Int128{333'333}, + 11884.2243771396506390315937388}, + {Int128{0x8000'0000} << 64, + (Int128{3'333'333'333'333'333'333} * Int128{1'000'000'000}) + + Int128{333'333'333}, + 11.884224377139650639031592551588422437713965063903159255158842243}, + {Int128{0x8000'0000} << 64, + (Int128{3'333'333'333'333'333'333} * Int128{1'000'000'000'000}) + + Int128{333'333'333'333}, + 0.0118842243771396506390315925504}, + {Int128{0x8000'0000} << 64, + (Int128{3'333'333'333'333'333'333} * Int128{1'000'000'000'000'000}) + + Int128{333'333'333'333'333}, + 0.0000118842243771396506390315925504}, + {Int128{0x8000'0000} << 64, + (Int128{3'333'333'333'333'333'333} * Int128{1'000'000'000'000'000'000}) + + Int128{333'333'333'333'333'333}, + 0.0000000118842243771396506390315925504}, + }; + + for (auto [numerator, denominator, result] : values) { + CHECK_EQUAL(FractionToDouble(numerator, denominator), result); + } + + return true; +} +END_TEST(testFraction_complex_int128) + +#endif diff --git a/js/src/jsapi-tests/testFrontendJSON.cpp b/js/src/jsapi-tests/testFrontendJSON.cpp index b5315e6084..0960a8025a 100644 --- a/js/src/jsapi-tests/testFrontendJSON.cpp +++ b/js/src/jsapi-tests/testFrontendJSON.cpp @@ -472,6 +472,29 @@ BEGIN_FRONTEND_TEST(testParseJSONWithHandler) { checkedLast = true; } + { + const size_t failAt = 1; + MyHandler handler; + const char16_t* source; + +#define IMMEDIATE_FAIL(json) \ + handler.failAt.emplace(failAt); \ + source = json; \ + CHECK(!JS::ParseJSONWithHandler( \ + source, std::char_traits<char16_t>::length(source), &handler)); \ + CHECK(handler.events.length() == failAt); \ + handler.events.clear(); + + IMMEDIATE_FAIL(u"{"); + IMMEDIATE_FAIL(u"["); + IMMEDIATE_FAIL(u"\"string\""); + IMMEDIATE_FAIL(u"1"); + IMMEDIATE_FAIL(u"true"); + IMMEDIATE_FAIL(u"null"); + +#undef IMMEDIATE_FAIL + } + return true; } diff --git a/js/src/jsapi-tests/testInt128.cpp b/js/src/jsapi-tests/testInt128.cpp new file mode 100644 index 0000000000..134d2ab684 --- /dev/null +++ b/js/src/jsapi-tests/testInt128.cpp @@ -0,0 +1,576 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifdef JS_HAS_TEMPORAL_API + +# include "mozilla/TextUtils.h" + +# include <array> +# include <climits> +# include <limits> +# include <optional> +# include <stdint.h> +# include <utility> + +# include "builtin/temporal/Int128.h" +# include "jsapi-tests/tests.h" + +using Int128 = js::temporal::Int128; +using Uint128 = js::temporal::Uint128; + +// Simple Uint128 parser. +template <char... DIGITS> +constexpr Uint128 operator""_u128() { + static_assert(sizeof...(DIGITS) > 0); + + constexpr auto digits = std::array{DIGITS...}; + + constexpr auto isBinaryDigit = [](auto c) { + return (c >= '0' && c <= '1') || c == '\''; + }; + + constexpr auto isOctalDigit = [](auto c) { + return (c >= '0' && c <= '7') || c == '\''; + }; + + constexpr auto isDigit = [](auto c) { + return mozilla::IsAsciiDigit(c) || c == '\''; + }; + + constexpr auto isHexDigit = [](auto c) { + return mozilla::IsAsciiHexDigit(c) || c == '\''; + }; + + constexpr auto isBinary = [isBinaryDigit](auto zero, auto prefix, + auto... rest) { + return zero == '0' && (prefix == 'b' || prefix == 'B') && + (isBinaryDigit(rest) && ...); + }; + + constexpr auto isHex = [isHexDigit](auto zero, auto prefix, auto... rest) { + return zero == '0' && (prefix == 'x' || prefix == 'X') && + (isHexDigit(rest) && ...); + }; + + constexpr auto binary = [digits]() -> std::optional<Uint128> { + auto value = Uint128{}; + for (size_t i = 2; i < digits.size(); ++i) { + auto digit = digits[i]; + if (digit == '\'') { + continue; + } + + // Detect overflow. + if (((value << 1) >> 1) != value) { + return std::nullopt; + } + value = (value << 1) | Uint128{uint64_t(digit - '0')}; + } + return value; + }; + + constexpr auto octal = [digits]() -> std::optional<Uint128> { + auto value = Uint128{}; + for (size_t i = 1; i < digits.size(); ++i) { + auto digit = digits[i]; + if (digit == '\'') { + continue; + } + + // Detect overflow. + if (((value << 3) >> 3) != value) { + return std::nullopt; + } + value = (value << 3) | Uint128{uint64_t(digit - '0')}; + } + return value; + }; + + constexpr auto decimal = [digits]() -> std::optional<Uint128> { + auto value = Uint128{}; + for (size_t i = 0; i < digits.size(); ++i) { + auto digit = digits[i]; + if (digit == '\'') { + continue; + } + + // NB: Overflow check not implemented. + value = (value * Uint128{10}) + Uint128{uint64_t(digit - '0')}; + } + return value; + }; + + constexpr auto hexadecimal = [digits]() -> std::optional<Uint128> { + auto value = Uint128{}; + for (size_t i = 2; i < digits.size(); ++i) { + auto digit = digits[i]; + if (digit == '\'') { + continue; + } + + // Detect overflow. + if (((value << 4) >> 4) != value) { + return std::nullopt; + } + value = + (value << 4) | Uint128{uint64_t(digit >= 'a' ? (digit - 'a') + 10 + : digit >= 'A' ? (digit - 'A') + 10 + : digit - '0')}; + } + return value; + }; + + if constexpr (digits.size() > 2 && digits[0] == '0' && + !mozilla::IsAsciiDigit(digits[1])) { + if constexpr (isBinary(DIGITS...)) { + if constexpr (constexpr auto value = binary()) { + return *value; + } else { + static_assert(false, "binary literal too large"); + } + } else if constexpr (isHex(DIGITS...)) { + if constexpr (constexpr auto value = hexadecimal()) { + return *value; + } else { + static_assert(false, "hexadecimal literal too large"); + } + } else { + static_assert(false, "invalid prefix literal"); + } + } else if constexpr (digits.size() > 1 && digits[0] == '0') { + if constexpr ((isOctalDigit(DIGITS) && ...)) { + if constexpr (constexpr auto value = octal()) { + return *value; + } else { + static_assert(false, "octal literal too large"); + } + } else { + static_assert(false, "invalid octal literal"); + } + } else if constexpr ((isDigit(DIGITS) && ...)) { + if constexpr (constexpr auto value = decimal()) { + return *value; + } else { + static_assert(false, "decimal literal too large"); + } + } else { + static_assert(false, "invalid literal"); + } +} + +template <char... DIGITS> +constexpr Int128 operator""_i128() { + return Int128{operator""_u128 < DIGITS... > ()}; +} + +template <typename T, size_t N, size_t... ISeq> +static constexpr auto to_array_impl(const T (&elements)[N], + std::index_sequence<ISeq...>) { + return std::array<T, N>{{elements[ISeq]...}}; +} + +// No std::to_array because we don't yet compile with C++20. +template <typename T, size_t N> +static constexpr auto to_array(const T (&elements)[N]) { + return to_array_impl(elements, std::make_index_sequence<N>{}); +} + +class ConversionFixture : public JSAPIRuntimeTest { + public: + virtual ~ConversionFixture() = default; + + template <typename T, typename U, size_t N> + bool testConversion(const std::array<U, N>& values); +}; + +template <typename T, typename U, size_t N> +bool ConversionFixture::testConversion(const std::array<U, N>& values) { + for (auto v : values) { + // Conversion to signed int. + CHECK_EQUAL(int64_t(T{v}), int64_t(v)); + CHECK_EQUAL(int32_t(T{v}), int32_t(v)); + CHECK_EQUAL(int16_t(T{v}), int16_t(v)); + CHECK_EQUAL(int8_t(T{v}), int8_t(v)); + + // Conversion to unsigned int. + CHECK_EQUAL(uint64_t(T{v}), uint64_t(v)); + CHECK_EQUAL(uint32_t(T{v}), uint32_t(v)); + CHECK_EQUAL(uint16_t(T{v}), uint16_t(v)); + CHECK_EQUAL(uint8_t(T{v}), uint8_t(v)); + + // Conversion to double. + CHECK_EQUAL(double(T{v}), double(v)); + + // Conversion to bool. + CHECK_EQUAL(bool(T{v}), bool(v)); + } + return true; +} + +BEGIN_FIXTURE_TEST(ConversionFixture, testInt128_conversion) { + auto values = to_array<int64_t>({ + INT64_MIN, + INT64_MIN + 1, + int64_t(INT32_MIN) - 1, + INT32_MIN, + INT32_MIN + 1, + -1, + 0, + 1, + INT32_MAX - 1, + INT32_MAX, + int64_t(INT32_MAX) + 1, + INT64_MAX - 1, + INT64_MAX, + }); + + CHECK(testConversion<Int128>(values)); + + return true; +} +END_FIXTURE_TEST(ConversionFixture, testInt128_conversion) + +BEGIN_FIXTURE_TEST(ConversionFixture, testUint128_conversion) { + auto values = to_array<uint64_t>({ + 0, + 1, + UINT32_MAX - 1, + UINT32_MAX, + uint64_t(UINT32_MAX) + 1, + UINT64_MAX - 1, + UINT64_MAX, + }); + + CHECK(testConversion<Uint128>(values)); + + return true; +} +END_FIXTURE_TEST(ConversionFixture, testUint128_conversion) + +class OperatorFixture : public JSAPIRuntimeTest { + public: + virtual ~OperatorFixture() = default; + + template <typename T, typename U, size_t N> + bool testOperator(const std::array<U, N>& values); +}; + +template <typename T, typename U, size_t N> +bool OperatorFixture::testOperator(const std::array<U, N>& values) { + // Unary operators. + for (auto x : values) { + // Sign operators. + CHECK_EQUAL(U(+T{x}), +x); + CHECK_EQUAL(U(-T{x}), -x); + + // Bitwise operators. + CHECK_EQUAL(U(~T{x}), ~x); + + // Increment/Decrement operators. + auto y = T{x}; + CHECK_EQUAL(U(++y), x + 1); + CHECK_EQUAL(U(y), x + 1); + + y = T{x}; + CHECK_EQUAL(U(y++), x); + CHECK_EQUAL(U(y), x + 1); + + y = T{x}; + CHECK_EQUAL(U(--y), x - 1); + CHECK_EQUAL(U(y), x - 1); + + y = T{x}; + CHECK_EQUAL(U(y--), x); + CHECK_EQUAL(U(y), x - 1); + } + + // Binary operators. + for (auto x : values) { + for (auto y : values) { + // Comparison operators. + CHECK_EQUAL((T{x} == T{y}), (x == y)); + CHECK_EQUAL((T{x} != T{y}), (x != y)); + CHECK_EQUAL((T{x} < T{y}), (x < y)); + CHECK_EQUAL((T{x} <= T{y}), (x <= y)); + CHECK_EQUAL((T{x} > T{y}), (x > y)); + CHECK_EQUAL((T{x} >= T{y}), (x >= y)); + + // Add/Sub/Mul operators. + CHECK_EQUAL(U(T{x} + T{y}), (x + y)); + CHECK_EQUAL(U(T{x} - T{y}), (x - y)); + CHECK_EQUAL(U(T{x} * T{y}), (x * y)); + + // Division operators. + if (y != 0) { + CHECK_EQUAL(U(T{x} / T{y}), (x / y)); + CHECK_EQUAL(U(T{x} % T{y}), (x % y)); + } + + // Shift operators. + if (y >= 0) { + CHECK_EQUAL(U(T{x} << y), (x << y)); + CHECK_EQUAL(U(T{x} >> y), (x >> y)); + } + + // Bitwise operators. + CHECK_EQUAL(U(T{x} & T{y}), (x & y)); + CHECK_EQUAL(U(T{x} | T{y}), (x | y)); + CHECK_EQUAL(U(T{x} ^ T{y}), (x ^ y)); + } + } + + // Compound assignment operators. + for (auto x : values) { + for (auto y : values) { + auto z = T{x}; + z += T{y}; + CHECK_EQUAL(U(z), x + y); + + z = T{x}; + z -= T{y}; + CHECK_EQUAL(U(z), x - y); + + z = T{x}; + z *= T{y}; + CHECK_EQUAL(U(z), x * y); + + if (y != 0) { + z = T{x}; + z /= T{y}; + CHECK_EQUAL(U(z), x / y); + + z = T{x}; + z %= T{y}; + CHECK_EQUAL(U(z), x % y); + } + + if (y >= 0) { + z = T{x}; + z <<= y; + CHECK_EQUAL(U(z), x << y); + + z = T{x}; + z >>= y; + CHECK_EQUAL(U(z), x >> y); + } + + z = T{x}; + z &= T{y}; + CHECK_EQUAL(U(z), x & y); + + z = T{x}; + z |= T{y}; + CHECK_EQUAL(U(z), x | y); + + z = T{x}; + z ^= T{y}; + CHECK_EQUAL(U(z), x ^ y); + } + } + return true; +} + +BEGIN_FIXTURE_TEST(OperatorFixture, testInt128_operator) { + auto values = to_array<int64_t>({ + -3, + -2, + -1, + 0, + 1, + 2, + 3, + 63, + }); + + CHECK(testOperator<Int128>(values)); + + // Values larger than INT64_MAX. + CHECK((Int128{INT64_MAX} * Int128{2}) == + (Int128{INT64_MAX} + Int128{INT64_MAX})); + CHECK((Int128{INT64_MAX} * Int128{3}) == + (Int128{INT64_MAX} * Int128{4} - Int128{INT64_MAX})); + CHECK((Int128{INT64_MAX} * Int128{2}) == (Int128{INT64_MAX} << 1)); + CHECK((Int128{INT64_MAX} * Int128{8}) == (Int128{INT64_MAX} << 3)); + CHECK((Int128{INT64_MAX} * Int128{8} / Int128{2}) == + (Int128{INT64_MAX} << 2)); + CHECK((Int128{INT64_MAX} * Int128{23} % Int128{13}) == (Int128{5})); + + // Values smaller than INT64_MIN. + CHECK((Int128{INT64_MIN} * Int128{2}) == + (Int128{INT64_MIN} + Int128{INT64_MIN})); + CHECK((Int128{INT64_MIN} * Int128{3}) == + (Int128{INT64_MIN} * Int128{4} - Int128{INT64_MIN})); + CHECK((Int128{INT64_MIN} * Int128{2}) == (Int128{INT64_MIN} << 1)); + CHECK((Int128{INT64_MIN} * Int128{8}) == (Int128{INT64_MIN} << 3)); + CHECK((Int128{INT64_MIN} * Int128{8} / Int128{2}) == + (Int128{INT64_MIN} << 2)); + CHECK((Int128{INT64_MIN} * Int128{23} % Int128{13}) == (Int128{-2})); + + return true; +} +END_FIXTURE_TEST(OperatorFixture, testInt128_operator) + +BEGIN_FIXTURE_TEST(OperatorFixture, testUint128_operator) { + auto values = to_array<uint64_t>({ + 0, + 1, + 2, + 3, + 5, + 63, + }); + + CHECK(testOperator<Uint128>(values)); + + // Values larger than UINT64_MAX. + CHECK((Uint128{UINT64_MAX} * Uint128{2}) == + (Uint128{UINT64_MAX} + Uint128{UINT64_MAX})); + CHECK((Uint128{UINT64_MAX} * Uint128{3}) == + (Uint128{UINT64_MAX} * Uint128{4} - Uint128{UINT64_MAX})); + CHECK((Uint128{UINT64_MAX} * Uint128{2}) == (Uint128{UINT64_MAX} << 1)); + CHECK((Uint128{UINT64_MAX} * Uint128{8}) == (Uint128{UINT64_MAX} << 3)); + CHECK((Uint128{UINT64_MAX} * Uint128{8} / Uint128{2}) == + (Uint128{UINT64_MAX} << 2)); + CHECK((Uint128{UINT64_MAX} * Uint128{23} % Uint128{13}) == (Uint128{7})); + + return true; +} +END_FIXTURE_TEST(OperatorFixture, testUint128_operator) + +BEGIN_TEST(testInt128_literal) { + CHECK_EQUAL(int64_t(0x7fff'ffff'ffff'ffff_i128), INT64_MAX); + CHECK_EQUAL(int64_t(-0x8000'0000'0000'0000_i128), INT64_MIN); + + CHECK(std::numeric_limits<Int128>::max() == + 0x7fff'ffff'ffff'ffff'ffff'ffff'ffff'ffff_i128); + CHECK(std::numeric_limits<Int128>::min() == + -0x8000'0000'0000'0000'0000'0000'0000'0000_i128); + + auto x = (Int128{INT64_MAX} + Int128{1}) * Int128{3}; + CHECK(x == 27670116110564327424_i128); + CHECK(x == 0x1'8000'0000'0000'0000_i128); + + auto y = Int128{0} - (Int128{5} * Int128{INT64_MAX}); + CHECK(y == -46116860184273879035_i128); + CHECK(y == -0x2'7fff'ffff'ffff'fffb_i128); + + // NB: This shift expression overflows. + auto z = Int128{0x1122'3344} << 100; + CHECK(z == 0x1223'3440'0000'0000'0000'0000'0000'0000_i128); + CHECK(z == 0221063210000000000000000000000000000000000_i128); + CHECK(z == 24108894070078995479046745700448600064_i128); + CHECK( + z == + 0b10010001000110011010001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000_i128); + + z >>= 80; + CHECK(z == 0X1223'3440'0000_i128); + CHECK(z == 0442146420000000_i128); + CHECK(z == 19942409764864_i128); + CHECK(z == 0B100100010001100110100010000000000000000000000_i128); + + auto v = Int128{INT64_MAX} * Int128{INT64_MAX}; + CHECK(v == 0x3fff'ffff'ffff'ffff'0000'0000'0000'0001_i128); + CHECK((v + v) == 0x7fff'ffff'ffff'fffe'0000'0000'0000'0002_i128); + CHECK((v * v) == 0x7fff'ffff'ffff'fffe'0000'0000'0000'0001_i128); + CHECK((v * -v) == -0x7fff'ffff'ffff'fffe'0000'0000'0000'0001_i128); + CHECK((-v * v) == -0x7fff'ffff'ffff'fffe'0000'0000'0000'0001_i128); + CHECK((-v * -v) == 0x7fff'ffff'ffff'fffe'0000'0000'0000'0001_i128); + + auto w = Int128{INT64_MIN} * Int128{INT64_MIN}; + CHECK(w == 0x4000'0000'0000'0000'0000'0000'0000'0000_i128); + CHECK((w + w) == -0x8000'0000'0000'0000'0000'0000'0000'0000_i128); + CHECK((w * w) == 0_i128); + + CHECK((Int128{1} << 120) == 0x100'0000'0000'0000'0000'0000'0000'0000_i128); + + return true; +} +END_TEST(testInt128_literal) + +BEGIN_TEST(testUint128_literal) { + CHECK_EQUAL(uint64_t(0xffff'ffff'ffff'ffff_u128), UINT64_MAX); + + CHECK(std::numeric_limits<Uint128>::max() == + 0xffff'ffff'ffff'ffff'ffff'ffff'ffff'ffff_u128); + + auto x = (Uint128{UINT64_MAX} + Uint128{3}) * Uint128{3}; + CHECK(x == 55340232221128654854_u128); + CHECK(x == 0x3'0000'0000'0000'0006_u128); + + // NB: This shift expression overflows. + auto z = Uint128{0x1122'3344} << 100; + CHECK(z == 0x1223'3440'0000'0000'0000'0000'0000'0000_u128); + CHECK(z == 0221063210000000000000000000000000000000000_u128); + CHECK(z == 24108894070078995479046745700448600064_u128); + CHECK( + z == + 0b10010001000110011010001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000_u128); + + z >>= 80; + CHECK(z == 0X1223'3440'0000_u128); + CHECK(z == 0442146420000000_u128); + CHECK(z == 19942409764864_u128); + CHECK(z == 0B100100010001100110100010000000000000000000000_u128); + + auto v = Uint128{UINT64_MAX} * Uint128{UINT64_MAX}; + CHECK(v == 0xffff'ffff'ffff'fffe'0000'0000'0000'0001_u128); + CHECK((v + v) == 0xffff'ffff'ffff'fffc'0000'0000'0000'0002_u128); + CHECK((v * v) == 0xffff'ffff'ffff'fffc'0000'0000'0000'0001_u128); + CHECK((v * -v) == 0x3'ffff'ffff'ffff'ffff_u128); + CHECK((-v * v) == 0x3'ffff'ffff'ffff'ffff_u128); + CHECK((-v * -v) == 0xffff'ffff'ffff'fffc'0000'0000'0000'0001_u128); + + CHECK((Uint128{1} << 120) == 0x100'0000'0000'0000'0000'0000'0000'0000_u128); + + return true; +} +END_TEST(testUint128_literal) + +BEGIN_TEST(testInt128_division) { + auto x = Int128{INT64_MAX} * Int128{4}; + CHECK((x / Int128{2}) == 0xffff'ffff'ffff'fffe_i128); + CHECK((x / Int128{2}) == (x >> 1)); + + auto y = Int128{INT64_MAX} * Int128{16}; + CHECK((y / Int128{2}) == 0x3'ffff'ffff'ffff'fff8_i128); + CHECK((y / Int128{2}) == (y >> 1)); + + CHECK((0x1122'3344'5566'7788'aabb'ccdd'ff12'3456_i128 / 7_i128) == + 0x272'999c'0c33'35a5'cf3f'6668'db4b'be55_i128); + CHECK((0x1122'3344'5566'7788'aabb'ccdd'ff12'3456_i128 / + 0x1'2345'6789'abcd'ef11'abcd'ef11_i128) == 0xf0f0f0f_i128); + CHECK((7_i128 / 0x1122'3344'5566'7788'aabb'ccdd'ff12'3456_i128) == 0_i128); + + CHECK((0x1122'3344'5566'7788'aabb'ccdd'ff12'3456_i128 % 7_i128) == 3_i128); + CHECK((0x1122'3344'5566'7788'aabb'ccdd'ff12'3456_i128 % + 0x1'2345'6789'abcd'ef11'abcd'ef11_i128) == + 0x1122'3353'7d8e'9fb0'dc00'3357_i128); + CHECK((7_i128 % 0x1122'3344'5566'7788'aabb'ccdd'ff12'3456_i128) == 7_i128); + + return true; +} +END_TEST(testInt128_division) + +BEGIN_TEST(testInt128_abs) { + CHECK((0_i128).abs() == 0_u128); + + CHECK((0x1122'3344_i128).abs() == 0x1122'3344_u128); + CHECK((-0x1122'3344_i128).abs() == 0x1122'3344_u128); + + CHECK((0x1111'2222'3333'4444'5555'6666'7777'8888_i128).abs() == + 0x1111'2222'3333'4444'5555'6666'7777'8888_u128); + CHECK((-0x1111'2222'3333'4444'5555'6666'7777'8888_i128).abs() == + 0x1111'2222'3333'4444'5555'6666'7777'8888_u128); + + CHECK(std::numeric_limits<Int128>::min().abs() == + 0x8000'0000'0000'0000'0000'0000'0000'0000_u128); + CHECK(std::numeric_limits<Int128>::max().abs() == + 0x7fff'ffff'ffff'ffff'ffff'ffff'ffff'ffff_u128); + + return true; +} +END_TEST(testInt128_abs) + +#endif diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 8dda64d4f1..a3dea6895d 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -1976,6 +1976,12 @@ JS_PUBLIC_API void JS::SetHostEnsureCanAddPrivateElementHook( cx->runtime()->canAddPrivateElement = op; } +JS_PUBLIC_API bool JS::SetBrittleMode(JSContext* cx, bool setting) { + bool wasBrittle = cx->brittleMode; + cx->brittleMode = setting; + return wasBrittle; +} + /*** Standard internal methods **********************************************/ JS_PUBLIC_API bool JS_GetPrototype(JSContext* cx, HandleObject obj, diff --git a/js/src/jsdate.cpp b/js/src/jsdate.cpp index a6f8b42040..685886d1b0 100644 --- a/js/src/jsdate.cpp +++ b/js/src/jsdate.cpp @@ -1060,7 +1060,11 @@ done: #undef NEED_NDIGITS } -int FixupNonFullYear(int year) { +/** + * Non-ISO years < 100 get fixed up, to allow 2-digit year formats. + * year < 50 becomes 2000-2049, 50-99 becomes 1950-1999. + */ +int FixupYear(int year) { if (year < 50) { year += 2000; } else if (year >= 50 && year < 100) { @@ -1203,9 +1207,7 @@ static bool TryParseDashedDatePrefix(const CharT* s, size_t length, return false; } - if (yearDigits < 4) { - year = FixupNonFullYear(year); - } + year = FixupYear(year); *indexOut = i; *yearOut = year; @@ -1295,9 +1297,7 @@ static bool TryParseDashedNumericDatePrefix(const CharT* s, size_t length, return false; } - if (year < 100) { - year = FixupNonFullYear(year); - } + year = FixupYear(year); *indexOut = i; *yearOut = year; @@ -1750,7 +1750,7 @@ static bool ParseDate(DateTimeInfo::ForceUTC forceUTC, const CharT* s, // (again, for Chrome parity) year = 2001; } else { - year = FixupNonFullYear(mon); + year = FixupYear(mon); mon = 1; } } @@ -1810,13 +1810,7 @@ static bool ParseDate(DateTimeInfo::ForceUTC forceUTC, const CharT* s, } } - // If the year is greater than or equal to 50 and less than 100, it is - // considered to be the number of years after 1900. If the year is less - // than 50 it is considered to be the number of years after 2000, - // otherwise it is considered to be the number of years after 0. - if (!seenFullYear) { - year = FixupNonFullYear(year); - } + year = FixupYear(year); if (negativeYear) { year = -year; @@ -3669,8 +3663,8 @@ static bool ToDateString(JSContext* cx, const CallArgs& args, ClippedTime t) { if (!locale) { return false; } - return FormatDate(cx, ForceUTC(cx->realm()), locale, - t.toDouble(), FormatSpec::DateTime, args.rval()); + return FormatDate(cx, ForceUTC(cx->realm()), locale, t.toDouble(), + FormatSpec::DateTime, args.rval()); } static bool DateNoArguments(JSContext* cx, const CallArgs& args) { diff --git a/js/src/jsmath.cpp b/js/src/jsmath.cpp index 2bbfb04d92..d4fedaee47 100644 --- a/js/src/jsmath.cpp +++ b/js/src/jsmath.cpp @@ -27,6 +27,7 @@ #include "js/Prefs.h" #include "js/PropertySpec.h" #include "util/DifferentialTesting.h" +#include "vm/Float16.h" #include "vm/JSContext.h" #include "vm/Realm.h" #include "vm/Time.h" @@ -299,6 +300,34 @@ static bool math_fround(JSContext* cx, unsigned argc, Value* vp) { return RoundFloat32(cx, args[0], args.rval()); } +#ifdef NIGHTLY_BUILD +static bool math_f16round(JSContext* cx, unsigned argc, Value* vp) { + // http://tc39.es/proposal-float16array/#sec-function-properties-of-the-math-object + CallArgs args = CallArgsFromVp(argc, vp); + + if (args.length() == 0) { + args.rval().setNaN(); + return true; + } + + // 1. Let n be ? ToNumber(x). + double d; + if (!ToNumber(cx, args[0], &d)) { + return false; + } + // 2. If n is NaN, return NaN. + // 3. If n is one of +0𝔽, -0𝔽, +∞𝔽, or -∞𝔽, return n. + // 4. Let n16 be the result of converting n to IEEE 754-2019 binary16 format + // using roundTiesToEven mode. + js::float16 f16 = js::float16(d); + // 5. Let n64 be the result of converting n16 to IEEE 754-2019 binary64 + // format. + // 6. Return the ECMAScript Number value corresponding to n64. + args.rval().setDouble(f16.toDouble()); + return true; +} +#endif + double js::math_log_impl(double x) { AutoUnsafeCallWithABI unsafe; return fdlibm_log(x); @@ -1030,6 +1059,10 @@ static const JSFunctionSpec math_static_methods[] = { JS_INLINABLE_FN("floor", math_floor, 1, 0, MathFloor), JS_INLINABLE_FN("imul", math_imul, 2, 0, MathImul), JS_INLINABLE_FN("fround", math_fround, 1, 0, MathFRound), +#ifdef NIGHTLY_BUILD + // TODO: See Bug 1835034 for JIT support + JS_FN("f16round", math_f16round, 1, 0), +#endif JS_INLINABLE_FN("log", math_log, 1, 0, MathLog), JS_INLINABLE_FN("max", math_max, 2, 0, MathMax), JS_INLINABLE_FN("min", math_min, 2, 0, MathMin), @@ -1052,8 +1085,7 @@ static const JSFunctionSpec math_static_methods[] = { JS_INLINABLE_FN("hypot", math_hypot, 2, 0, MathHypot), JS_INLINABLE_FN("trunc", math_trunc, 1, 0, MathTrunc), JS_INLINABLE_FN("sign", math_sign, 1, 0, MathSign), - JS_INLINABLE_FN("cbrt", math_cbrt, 1, 0, MathCbrt), - JS_FS_END}; + JS_INLINABLE_FN("cbrt", math_cbrt, 1, 0, MathCbrt), JS_FS_END}; static const JSPropertySpec math_static_properties[] = { JS_DOUBLE_PS("E", M_E, JSPROP_READONLY | JSPROP_PERMANENT), diff --git a/js/src/jspubtd.h b/js/src/jspubtd.h index c3c5d38bd6..64f2329c69 100644 --- a/js/src/jspubtd.h +++ b/js/src/jspubtd.h @@ -11,6 +11,8 @@ * JS public API typedefs. */ +#include "mozilla/Assertions.h" // MOZ_ASSERT_UNREACHABLE + #include "jstypes.h" #include "js/ProtoKey.h" @@ -39,7 +41,7 @@ enum JSType { JSTYPE_NUMBER, /* number */ JSTYPE_BOOLEAN, /* boolean */ JSTYPE_SYMBOL, /* symbol */ - JSTYPE_BIGINT, /* BigInt */ + JSTYPE_BIGINT, /* bigint */ #ifdef ENABLE_RECORD_TUPLE JSTYPE_RECORD, /* record */ JSTYPE_TUPLE, /* tuple */ @@ -47,6 +49,36 @@ enum JSType { JSTYPE_LIMIT }; +inline const char* JSTypeToString(JSType type) { + switch (type) { + case JSTYPE_UNDEFINED: + return "undefined"; + case JSTYPE_OBJECT: + return "object"; + case JSTYPE_FUNCTION: + return "function"; + case JSTYPE_STRING: + return "string"; + case JSTYPE_NUMBER: + return "number"; + case JSTYPE_BOOLEAN: + return "boolean"; + case JSTYPE_SYMBOL: + return "symbol"; + case JSTYPE_BIGINT: + return "bigint"; +#ifdef ENABLE_RECORD_TUPLE + case JSTYPE_RECORD: + return "record"; + case JSTYPE_TUPLE: + return "tuple"; +#endif + default: + MOZ_ASSERT_UNREACHABLE("Unknown JSType"); + } + return ""; +} + /* Dense index into cached prototypes and class atoms for standard objects. */ enum JSProtoKey { #define PROTOKEY_AND_INITIALIZER(name, clasp) JSProto_##name, diff --git a/js/src/moz.build b/js/src/moz.build index 63d0d75509..90dca3e7f7 100644 --- a/js/src/moz.build +++ b/js/src/moz.build @@ -594,7 +594,6 @@ selfhosted_inputs = [ "builtin/RegExpLocalReplaceOpt.h.js", "builtin/String.js", "builtin/Set.js", - "builtin/Sorting.js", "builtin/TypedArray.js", "builtin/WeakMap.js", "builtin/WeakSet.js", diff --git a/js/src/old-configure.in b/js/src/old-configure.in index b9152f974d..d985695fb5 100644 --- a/js/src/old-configure.in +++ b/js/src/old-configure.in @@ -54,8 +54,9 @@ dnl ======================================================== if test "$COMPILE_ENVIRONMENT"; then -# Run some logic to figure out exe extensions (mostly for mingw's sake) -AC_EXEEXT +# This prevents mingw from adding .exe when generating executable. Internal use +# only. +ac_exeext=.out # Note: # In Mozilla, we use the names $target, $host and $build incorrectly, but are diff --git a/js/src/proxy/CrossCompartmentWrapper.cpp b/js/src/proxy/CrossCompartmentWrapper.cpp index c32c72dc17..d3ec13186a 100644 --- a/js/src/proxy/CrossCompartmentWrapper.cpp +++ b/js/src/proxy/CrossCompartmentWrapper.cpp @@ -576,9 +576,6 @@ void js::RemapDeadWrapper(JSContext* cx, HandleObject wobj, // invariant that the wrapper in the map points directly to the key. MOZ_ASSERT(Wrapper::wrappedObject(wobj) == newTarget); - // Update the incremental weakmap marking state. - wobj->zone()->afterAddDelegate(wobj); - // Update the entry in the compartment's wrapper map to point to the old // wrapper, which has now been updated (via reuse or swap). if (!wcompartment->putWrapper(cx, newTarget, wobj)) { diff --git a/js/src/rust/Cargo.toml b/js/src/rust/Cargo.toml index 6624747fe9..667ca72165 100644 --- a/js/src/rust/Cargo.toml +++ b/js/src/rust/Cargo.toml @@ -21,4 +21,4 @@ mozilla-central-workspace-hack = { version = "0.1", features = ["jsrust"], optio jsrust_shared = { path = "./shared" } # Workaround for https://github.com/rust-lang/rust/issues/58393 mozglue-static = { path = "../../../mozglue/static/rust" } -wast = "201.0.0" +wast = "205.0.0" diff --git a/js/src/shell/ShellModuleObjectWrapper.cpp b/js/src/shell/ShellModuleObjectWrapper.cpp index 4e8c234e61..7a047ebaf4 100644 --- a/js/src/shell/ShellModuleObjectWrapper.cpp +++ b/js/src/shell/ShellModuleObjectWrapper.cpp @@ -85,6 +85,7 @@ using mozilla::Span; DEFINE_NATIVE_CLASS_IMPL(CLASS) DEFINE_CLASS(ModuleRequestObject) +DEFINE_NATIVE_CLASS(ImportAttribute) DEFINE_NATIVE_CLASS(ImportEntry) DEFINE_NATIVE_CLASS(ExportEntry) DEFINE_NATIVE_CLASS(RequestedModule) @@ -281,6 +282,17 @@ bool SpanToArrayFilter(JSContext* cx, JS::Handle<JSObject*> owner, return true; } +template <class T> +bool SpanToNullableArrayFilter(JSContext* cx, JS::Handle<JSObject*> owner, + Span<const typename T::Target> from, + JS::MutableHandle<JS::Value> to) { + if (from.Length() == 0) { + to.setNull(); + return true; + } + return SpanToArrayFilter<T>(cx, owner, from, to); +} + template <class T, typename RawGetterT, typename FilterT> bool ShellModuleNativeWrapperGetter(JSContext* cx, const JS::CallArgs& args, RawGetterT rawGetter, FilterT filter) { @@ -313,14 +325,22 @@ bool ShellModuleNativeWrapperGetter(JSContext* cx, const JS::CallArgs& args, cx, args); \ } +DEFINE_GETTER_FUNCTIONS(ImportAttribute, key, StringOrNullValue, IdentFilter); +DEFINE_GETTER_FUNCTIONS(ImportAttribute, value, StringOrNullValue, IdentFilter); + +static const JSPropertySpec ShellImportAttributeWrapper_accessors[] = { + JS_PSG("key", ShellImportAttributeWrapper_keyGetter, 0), + JS_PSG("value", ShellImportAttributeWrapper_valueGetter, 0), JS_PS_END}; + DEFINE_GETTER_FUNCTIONS(ModuleRequestObject, specifier, StringOrNullValue, IdentFilter) -DEFINE_GETTER_FUNCTIONS(ModuleRequestObject, attributes, ObjectOrNullValue, - IdentFilter) +DEFINE_NATIVE_GETTER_FUNCTIONS( + ModuleRequestObject, attributes, + SpanToNullableArrayFilter<ShellImportAttributeWrapper>); static const JSPropertySpec ShellModuleRequestObjectWrapper_accessors[] = { JS_PSG("specifier", ShellModuleRequestObjectWrapper_specifierGetter, 0), - JS_PSG("assertions", ShellModuleRequestObjectWrapper_attributesGetter, 0), + JS_PSG("attributes", ShellModuleRequestObjectWrapper_attributesGetter, 0), JS_PS_END}; DEFINE_GETTER_FUNCTIONS(ImportEntry, moduleRequest, ObjectOrNullValue, @@ -469,6 +489,8 @@ static const JSPropertySpec ShellModuleObjectWrapper_accessors[] = { DEFINE_CREATE(ModuleRequestObject, ShellModuleRequestObjectWrapper_accessors, nullptr) +DEFINE_NATIVE_CREATE(ImportAttribute, ShellImportAttributeWrapper_accessors, + nullptr) DEFINE_NATIVE_CREATE(ImportEntry, ShellImportEntryWrapper_accessors, nullptr) DEFINE_NATIVE_CREATE(ExportEntry, ShellExportEntryWrapper_accessors, nullptr) DEFINE_NATIVE_CREATE(RequestedModule, ShellRequestedModuleWrapper_accessors, diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 178c394e1d..0acc38e282 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -123,10 +123,10 @@ #include "js/CompilationAndEvaluation.h" #include "js/CompileOptions.h" // JS::ReadOnlyCompileOptions, JS::CompileOptions, JS::OwningCompileOptions, JS::DecodeOptions, JS::InstantiateOptions #include "js/ContextOptions.h" // JS::ContextOptions{,Ref} -#include "js/Debug.h" -#include "js/Equality.h" // JS::SameValue -#include "js/ErrorReport.h" // JS::PrintError -#include "js/Exception.h" // JS::StealPendingExceptionStack +#include "js/Debug.h" // JS::dbg::ShouldAvoidSideEffects +#include "js/Equality.h" // JS::SameValue +#include "js/ErrorReport.h" // JS::PrintError +#include "js/Exception.h" // JS::StealPendingExceptionStack #include "js/experimental/CodeCoverage.h" // js::EnableCodeCoverage #include "js/experimental/CompileScript.h" // JS::NewFrontendContext, JS::DestroyFrontendContext, JS::HadFrontendErrors, JS::ConvertFrontendErrorsToRuntimeErrors, JS::CompileGlobalScriptToStencil, JS::CompileModuleScriptToStencil #include "js/experimental/CTypes.h" // JS::InitCTypesClass @@ -2599,13 +2599,19 @@ static bool Evaluate(JSContext* cx, unsigned argc, Value* vp) { return false; } - JSObject* obj = &v.toObject(); - if (obj->isUnqualifiedVarObj()) { - JS_ReportErrorASCII( - cx, - "\"envChainObject\" passed to evaluate() should not be an " - "unqualified variables object"); - return false; + RootedObject obj(cx, &v.toObject()); + { + // This may be a CCW, so try to unwrap before checking + // if it is an unqualified variables object. We still append + // the original object to the environment chain however. + JSObject* unwrappedObj = js::UncheckedUnwrap(obj, cx); + if (unwrappedObj->isUnqualifiedVarObj()) { + JS_ReportErrorASCII( + cx, + "\"envChainObject\" passed to evaluate() should not be an " + "unqualified variables object"); + return false; + } } if (!envChain.append(obj)) { @@ -4566,7 +4572,7 @@ static void WatchdogMain(JSContext* cx) { */ sc->watchdogTimeout = Nothing(); { - UnlockGuard<Mutex> unlock(guard); + UnlockGuard unlock(guard); CancelExecution(cx); } @@ -5416,8 +5422,9 @@ static bool RegisterModule(JSContext* cx, unsigned argc, Value* vp) { return false; } + Rooted<UniquePtr<ImportAttributeVector>> attributes(cx); RootedObject moduleRequest( - cx, ModuleRequestObject::create(cx, specifier, nullptr)); + cx, ModuleRequestObject::create(cx, specifier, &attributes)); if (!moduleRequest) { return false; } @@ -9135,6 +9142,59 @@ static bool DecompressLZ4(JSContext* cx, unsigned argc, Value* vp) { return true; } +static bool SideEffectfulResolveObject_enumerate( + JSContext* cx, JS::HandleObject obj, JS::MutableHandleIdVector properties, + bool enumerableOnly) { + return properties.append(NameToId(cx->names().test)); +} + +static bool SideEffectfulResolveObject_resolve(JSContext* cx, HandleObject obj, + HandleId id, bool* resolvedp) { + *resolvedp = false; + if (JS::dbg::ShouldAvoidSideEffects(cx)) { + return false; + } + + if (id == NameToId(cx->names().test)) { + RootedValue value(cx, JS::NumberValue(42)); + if (!JS_DefinePropertyById(cx, obj, id, value, JSPROP_ENUMERATE)) { + return false; + } + *resolvedp = true; + } + + return true; +} + +static const JSClassOps SideEffectfulResolveObject_classOps = { + nullptr, // addProperty + nullptr, // delProperty + nullptr, // enumerate + SideEffectfulResolveObject_enumerate, // newEnumerate + SideEffectfulResolveObject_resolve, // resolve + nullptr, // mayResolve + nullptr, // finalize + nullptr, // call + nullptr, // construct + nullptr, +}; + +static const JSClass SideEffectfulResolveObject_class = { + "SideEffectfulResolveObject", 0, &SideEffectfulResolveObject_classOps}; + +static bool CreateSideEffectfulResolveObject(JSContext* cx, unsigned argc, + JS::Value* vp) { + CallArgs args = CallArgsFromVp(argc, vp); + + RootedObject obj(cx, JS_NewObject(cx, &SideEffectfulResolveObject_class)); + if (!obj) { + return false; + } + + args.rval().setObject(*obj); + return true; +} + // clang-format off static const JSFunctionSpecWithHelp shell_functions[] = { JS_FN_HELP("options", Options, 0, 0, @@ -9750,16 +9810,6 @@ JS_FN_HELP("createUserArrayBuffer", CreateUserArrayBuffer, 1, 0, " or only when there are no other JavaScript frames on the stack\n" " below it (false). If omitted, this is treated as 'true'."), -#ifdef JS_HAS_INTL_API - JS_FN_HELP("addIntlExtras", AddIntlExtras, 1, 0, -"addIntlExtras(obj)", -"Adds various not-yet-standardized Intl functions as properties on the\n" -"provided object (this should generally be Intl itself). The added\n" -"functions and their behavior are experimental: don't depend upon them\n" -"unless you're willing to update your code if these experimental APIs change\n" -"underneath you."), -#endif // JS_HAS_INTL_API - #ifndef __wasi__ JS_FN_HELP("wasmCompileInSeparateProcess", WasmCompileInSeparateProcess, 1, 0, "wasmCompileInSeparateProcess(buffer)", @@ -9814,6 +9864,11 @@ JS_FN_HELP("createUserArrayBuffer", CreateUserArrayBuffer, 1, 0, "decompressLZ4(bytes)", " Return a decompressed copy of bytes using LZ4."), + JS_FN_HELP("createSideEffectfulResolveObject", CreateSideEffectfulResolveObject, 0, 0, +"createSideEffectfulResolveObject()", +" Return an object with a property 'obj.test == 42', backed by a resolve hook " +" with the Debugger shouldAvoidSideEffects flag integration."), + JS_FS_HELP_END }; // clang-format on @@ -9911,6 +9966,20 @@ TestAssertRecoveredOnBailout, " Returns an array of queued jobs."), #endif +#ifdef JS_HAS_INTL_API + // One of the extras is AddMozDateTimeFormatConstructor, which is not fuzzing + // safe, since it doesn't validate the custom format pattern. + // + // See https://bugzilla.mozilla.org/show_bug.cgi?id=1887585#c1 + JS_FN_HELP("addIntlExtras", AddIntlExtras, 1, 0, +"addIntlExtras(obj)", +"Adds various not-yet-standardized Intl functions as properties on the\n" +"provided object (this should generally be Intl itself). The added\n" +"functions and their behavior are experimental: don't depend upon them\n" +"unless you're willing to update your code if these experimental APIs change\n" +"underneath you."), +#endif // JS_HAS_INTL_API + JS_FS_HELP_END }; // clang-format on @@ -11340,13 +11409,6 @@ static int Shell(JSContext* cx, OptionParser* op) { nocgc.emplace(cx); } - if (op->getBoolOption("fuzzing-safe")) { - fuzzingSafe = true; - } else { - fuzzingSafe = - (getenv("MOZ_FUZZING_SAFE") && getenv("MOZ_FUZZING_SAFE")[0] != '0'); - } - #ifdef DEBUG if (op->getBoolOption("differential-testing")) { JS::SetSupportDifferentialTesting(true); @@ -11422,15 +11484,20 @@ static int Shell(JSContext* cx, OptionParser* op) { fflush(stdout); fflush(stderr); // Send return code to parent and reset edge counters. - struct { - int status; - uint32_t execHash; - uint32_t execHashInputs; - } s; - s.status = (result & 0xff) << 8; - s.execHash = cx->executionHash; - s.execHashInputs = cx->executionHashInputs; - MOZ_RELEASE_ASSERT(write(REPRL_CWFD, &s, 12) == 12); + int status = (result & 0xff) << 8; + if (js::SupportDifferentialTesting()) { + struct { + int status; + uint32_t execHash; + uint32_t execHashInputs; + } s; + s.status = status; + s.execHash = cx->executionHash; + s.execHashInputs = cx->executionHashInputs; + MOZ_RELEASE_ASSERT(write(REPRL_CWFD, &s, 12) == 12); + } else { + MOZ_RELEASE_ASSERT(write(REPRL_CWFD, &status, 4) == 4); + } __sanitizer_cov_reset_edgeguards(); cx->executionHash = 1; cx->executionHashInputs = 0; @@ -11605,7 +11672,13 @@ static bool SetJSPrefToTrueForBool(const char* name) { FOR_EACH_JS_PREF(CHECK_PREF) #undef CHECK_PREF - // Nothing matched, return false + // Nothing matched. If --fuzzing-safe is used, return true after printing a + // message, to continue execution without breaking fuzzing when a pref is + // removed. + if (fuzzingSafe) { + fprintf(stderr, "Warning: Ignoring unknown pref name: %s\n", name); + return true; + } fprintf(stderr, "Invalid pref name: %s\n", name); return false; } @@ -11625,7 +11698,13 @@ static bool SetJSPrefToValue(const char* name, size_t nameLen, FOR_EACH_JS_PREF(CHECK_PREF) #undef CHECK_PREF - // Nothing matched, return false + // Nothing matched. If --fuzzing-safe is used, return true after printing a + // message, to continue execution without breaking fuzzing when a pref is + // removed. + if (fuzzingSafe) { + fprintf(stderr, "Warning: Ignoring unknown pref name: %s\n", name); + return true; + } fprintf(stderr, "Invalid pref name: %s\n", name); return false; } @@ -12043,10 +12122,9 @@ bool InitOptionParser(OptionParser& op) { "Enable resizable ArrayBuffers and growable SharedArrayBuffers") || !op.addBoolOption('\0', "enable-uint8array-base64", "Enable Uint8Array base64/hex methods") || + !op.addBoolOption('\0', "enable-float16array", "Enable Float16Array") || !op.addBoolOption('\0', "enable-top-level-await", "Enable top-level await") || - !op.addBoolOption('\0', "enable-class-static-blocks", - "(no-op) Enable class static blocks") || !op.addBoolOption('\0', "enable-import-assertions", "Enable import attributes with old assert syntax") || !op.addBoolOption('\0', "enable-import-attributes", @@ -12092,10 +12170,6 @@ bool InitOptionParser(OptionParser& op) { "Range analysis (default: on, off to disable)") || !op.addStringOption('\0', "ion-sink", "on/off", "Sink code motion (default: off, on to enable)") || - !op.addStringOption('\0', "ion-optimization-levels", "on/off", - "No-op for fuzzing") || - !op.addStringOption('\0', "ion-loop-unrolling", "on/off", - "(NOP for fuzzers)") || !op.addStringOption( '\0', "ion-instruction-reordering", "on/off", "Instruction reordering (default: off, on to enable)") || @@ -12134,8 +12208,6 @@ bool InitOptionParser(OptionParser& op) { "Wait for COUNT calls or iterations before compiling " "at the normal optimization level (default: 1000)", -1) || - !op.addIntOption('\0', "ion-full-warmup-threshold", "COUNT", - "No-op for fuzzing", -1) || !op.addStringOption( '\0', "ion-regalloc", "[mode]", "Specify Ion register allocation:\n" @@ -12199,9 +12271,6 @@ bool InitOptionParser(OptionParser& op) { "Whether monomorphic inlining is used instead of trial inlining " "always, never, or based on heuristics (default)") || !op.addBoolOption( - '\0', "non-writable-jitcode", - "(NOP for fuzzers) Allocate JIT code as non-writable memory.") || - !op.addBoolOption( '\0', "no-sse3", "Pretend CPU does not support SSE3 instructions and above " "to test JIT codegen (no-op on platforms other than x86 and x64).") || @@ -12262,9 +12331,6 @@ bool InitOptionParser(OptionParser& op) { "Disable GC parallel marking") || !op.addBoolOption('\0', "enable-parallel-marking", "Enable GC parallel marking") || - !op.addIntOption( - '\0', "marking-threads", "COUNT", - "Set the number of threads used for parallel marking to COUNT.", 0) || !op.addStringOption('\0', "nursery-strings", "on/off", "Allocate strings in the nursery") || !op.addStringOption('\0', "nursery-bigints", "on/off", @@ -12391,10 +12457,21 @@ bool InitOptionParser(OptionParser& op) { op.setArgTerminatesOptions("script", true); op.setArgCapturesRest("scriptArgs"); + // If --fuzzing-safe is used, print a warning for unknown shell flags instead + // of aborting execution. + op.setIgnoresUnknownOptions("fuzzing-safe", true); + return true; } bool SetGlobalOptionsPreJSInit(const OptionParser& op) { + if (op.getBoolOption("fuzzing-safe")) { + fuzzingSafe = true; + } else { + fuzzingSafe = + (getenv("MOZ_FUZZING_SAFE") && getenv("MOZ_FUZZING_SAFE")[0] != '0'); + } + for (MultiStringRange args = op.getMultiStringOption("setpref"); !args.empty(); args.popFront()) { if (!SetJSPref(args.front())) { @@ -12434,6 +12511,9 @@ bool SetGlobalOptionsPreJSInit(const OptionParser& op) { if (op.getBoolOption("enable-uint8array-base64")) { JS::Prefs::setAtStartup_experimental_uint8array_base64(true); } + if (op.getBoolOption("enable-float16array")) { + JS::Prefs::setAtStartup_experimental_float16array(true); + } #endif #ifdef ENABLE_JSON_PARSE_WITH_SOURCE JS::Prefs::setAtStartup_experimental_json_parse_with_source( @@ -12666,7 +12746,6 @@ bool SetContextOptions(JSContext* cx, const OptionParser& op) { op.getBoolOption("enable-import-assertions"); enableImportAttributes = op.getBoolOption("enable-import-attributes") || enableImportAttributesAssertSyntax; - JS::ContextOptionsRef(cx) .setSourcePragmas(enableSourcePragmas) .setAsyncStack(enableAsyncStacks) @@ -13302,11 +13381,6 @@ bool SetContextGCOptions(JSContext* cx, const OptionParser& op) { } JS_SetGCParameter(cx, JSGC_PARALLEL_MARKING_ENABLED, parallelMarking); - int32_t markingThreads = op.getIntOption("marking-threads"); - if (markingThreads > 0) { - JS_SetGCParameter(cx, JSGC_MARKING_THREAD_COUNT, markingThreads); - } - JS_SetGCParameter(cx, JSGC_SLICE_TIME_BUDGET_MS, 5); JS_SetGCParameter(cx, JSGC_PER_ZONE_GC_ENABLED, true); diff --git a/js/src/shell/jsoptparse.cpp b/js/src/shell/jsoptparse.cpp index 5632598d7d..b2805fb415 100644 --- a/js/src/shell/jsoptparse.cpp +++ b/js/src/shell/jsoptparse.cpp @@ -44,6 +44,12 @@ void OptionParser::setArgTerminatesOptions(const char* name, bool enabled) { findArgument(name)->setTerminatesOptions(enabled); } +void OptionParser::setIgnoresUnknownOptions(const char* name, bool enabled) { + auto* opt = findOption(name); + MOZ_ASSERT(opt); + opt->setIgnoresUnknownOptions(enabled); +} + void OptionParser::setArgCapturesRest(const char* name) { MOZ_ASSERT(restArgument == -1, "only one argument may be set to capture the rest"); @@ -349,10 +355,15 @@ OptionParser::Result OptionParser::handleArg(size_t argc, char** argv, OptionParser::Result OptionParser::parseArgs(int inputArgc, char** argv) { MOZ_ASSERT(inputArgc >= 0); size_t argc = inputArgc; + // Permit a "no more options" capability, like |--| offers in many shell // interfaces. bool optionsAllowed = true; + // Whether unknown options should report a warning instead of an error. This + // is enabled by setIgnoresUnknownOptions and used for --fuzzing-safe. + bool ignoreUnknownOptions = false; + for (size_t i = 1; i < argc; ++i) { char* arg = argv[i]; Result r; @@ -370,6 +381,11 @@ OptionParser::Result OptionParser::parseArgs(int inputArgc, char** argv) { /* Long option. */ opt = findOption(arg + 2); if (!opt) { + if (ignoreUnknownOptions) { + fprintf(stderr, "Warning: Ignoring unknown shell flag: %s\n", + arg); + continue; + } return error("Invalid long option: %s", arg); } } @@ -384,6 +400,10 @@ OptionParser::Result OptionParser::parseArgs(int inputArgc, char** argv) { } } + if (opt->getIgnoresUnknownOptions()) { + ignoreUnknownOptions = true; + } + r = handleOption(opt, argc, argv, &i, &optionsAllowed); } else { /* Argument. */ diff --git a/js/src/shell/jsoptparse.h b/js/src/shell/jsoptparse.h index 17e4878969..34f46fed48 100644 --- a/js/src/shell/jsoptparse.h +++ b/js/src/shell/jsoptparse.h @@ -69,21 +69,23 @@ struct Option { const char* help; OptionKind kind; char shortflag; - bool terminatesOptions; + bool terminatesOptions = false; + bool ignoresUnknownOptions = false; Option(OptionKind kind, char shortflag, const char* longflag, const char* help) - : longflag(longflag), - help(help), - kind(kind), - shortflag(shortflag), - terminatesOptions(false) {} + : longflag(longflag), help(help), kind(kind), shortflag(shortflag) {} virtual ~Option() = 0; void setTerminatesOptions(bool enabled) { terminatesOptions = enabled; } bool getTerminatesOptions() const { return terminatesOptions; } + void setIgnoresUnknownOptions(bool enabled) { + ignoresUnknownOptions = enabled; + } + bool getIgnoresUnknownOptions() const { return ignoresUnknownOptions; } + virtual bool isValued() const { return false; } /* Only some valued options are variadic (like MultiStringOptions). */ @@ -293,6 +295,7 @@ class OptionParser { void setDescription(const char* description) { descr = description; } void setHelpOption(char shortflag, const char* longflag, const char* help); void setArgTerminatesOptions(const char* name, bool enabled); + void setIgnoresUnknownOptions(const char* name, bool enabled); void setArgCapturesRest(const char* name); /* Arguments: no further arguments may be added after a variadic argument. */ diff --git a/js/src/shell/jsrtfuzzing/jsrtfuzzing.cpp b/js/src/shell/jsrtfuzzing/jsrtfuzzing.cpp index 0b6f505fb6..ac6d706547 100644 --- a/js/src/shell/jsrtfuzzing/jsrtfuzzing.cpp +++ b/js/src/shell/jsrtfuzzing/jsrtfuzzing.cpp @@ -11,8 +11,13 @@ #include <stdio.h> // fflush, fprintf, fputs -#include "FuzzerDefs.h" -#include "FuzzingInterface.h" +#ifdef LIBFUZZER +# include "FuzzerDefs.h" +#endif +#ifdef AFLFUZZ +# include "FuzzingInterface.h" +#endif + #include "jsapi.h" // JS_ClearPendingException, JS_IsExceptionPending #include "js/CompilationAndEvaluation.h" // JS::Evaluate @@ -69,7 +74,7 @@ int js::shell::FuzzJSRuntimeStart(JSContext* cx, int* argc, char*** argv) { #ifdef LIBFUZZER fuzzer::FuzzerDriver(&shell::sArgc, &shell::sArgv, FuzzJSRuntimeFuzz); #elif AFLFUZZ - MOZ_CRASH("AFL is unsupported for JS runtime fuzzing integration"); + afl_interface_raw(FuzzJSRuntimeFuzz); #endif return 0; } diff --git a/js/src/shell/moz.build b/js/src/shell/moz.build index ed8551f1ec..f9ee1521d4 100644 --- a/js/src/shell/moz.build +++ b/js/src/shell/moz.build @@ -26,9 +26,10 @@ UNIFIED_SOURCES += [ if CONFIG["FUZZING_INTERFACES"]: UNIFIED_SOURCES += ["jsrtfuzzing/jsrtfuzzing.cpp"] - USE_LIBS += [ - "static:fuzzer", - ] + if CONFIG["LIBFUZZER"]: + USE_LIBS += ["static:fuzzer"] + else: + USE_LIBS += ["static:fuzzer-interface"] if CONFIG["FUZZING_JS_FUZZILLI"]: OS_LIBS += ["rt"] diff --git a/js/src/tests/jstests.list b/js/src/tests/jstests.list index dbe3bd555e..0ee852b157 100644 --- a/js/src/tests/jstests.list +++ b/js/src/tests/jstests.list @@ -388,6 +388,10 @@ fails-if(!xulRuntime.shell) script test262/built-ins/TypedArrayConstructors/inte fails-if(!xulRuntime.shell) script test262/language/expressions/class/subclass-builtins/subclass-SharedArrayBuffer.js fails-if(!xulRuntime.shell) script test262/language/statements/class/subclass-builtins/subclass-SharedArrayBuffer.js +# https://github.com/tc39/test262/pull/3955 +# https://bugzilla.mozilla.org/show_bug.cgi?id=1892186 +skip script test262/language/module-code/top-level-await/async-module-does-not-block-sibling-modules.js + ################################################## # Test262 tests skipped due to SpiderMonkey bugs # @@ -631,6 +635,26 @@ skip script test262/built-ins/RegExp/unicode_full_case_folding.js skip script test262/intl402/Locale/likely-subtags.js skip script test262/intl402/Locale/prototype/minimize/removing-likely-subtags-first-adds-likely-subtags.js +# Failures in AsyncFromSyncIteratorPrototype, see bug 1877862. +skip script test262/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined-poisoned-return.js +skip script test262/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined-return-object.js +skip script test262/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined-return-not-object.js +skip script test262/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-null.js +skip script test262/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined.js +skip script test262/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-result-poisoned-wrapper.js +skip script test262/built-ins/AsyncFromSyncIteratorPrototype/throw/iterator-result-rejected-promise-close.js +skip script test262/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined-get-return-undefined.js +skip script test262/built-ins/AsyncFromSyncIteratorPrototype/next/next-result-poisoned-wrapper.js +skip script test262/built-ins/AsyncFromSyncIteratorPrototype/next/for-await-iterator-next-rejected-promise-close.js +skip script test262/built-ins/AsyncFromSyncIteratorPrototype/next/yield-iterator-next-rejected-promise-close.js +skip script test262/built-ins/AsyncFromSyncIteratorPrototype/next/for-await-next-rejected-promise-close.js +skip script test262/built-ins/AsyncFromSyncIteratorPrototype/next/iterator-result-poisoned-wrapper.js +skip script test262/built-ins/AsyncFromSyncIteratorPrototype/next/yield-next-rejected-promise-close.js + +# https://github.com/tc39/proposal-redeclarable-global-eval-vars +skip script test262/language/global-code/script-decl-lex-var-declared-via-eval.js +skip script test262/annexB/language/eval-code/direct/script-decl-lex-no-collision.js + ########################################################### # Tests disabled due to issues in test262 importer script # @@ -672,6 +696,9 @@ skip script test262/staging/Temporal/Regex/old/timezone.js skip script test262/language/statements/class/decorator/syntax/class-valid/decorator-member-expr-private-identifier.js skip script test262/language/expressions/class/decorator/syntax/class-valid/decorator-member-expr-private-identifier.js +# These don't expect Float16Array to be enabled, see https://github.com/tc39/test262/issues/4029 +skip script test262/harness/testTypedArray.js +skip script test262/harness/testTypedArray-conversions.js ############################################## # Enable Iterator Helpers tests in the shell # @@ -1035,6 +1062,19 @@ shell-option(--enable-iterator-helpers) script non262/Iterator/prototype/take/na shell-option(--enable-iterator-helpers) script non262/Iterator/prototype/take/take.js shell-option(--enable-iterator-helpers) script non262/Iterator/prototype/take/take-more-than-available.js +############################################## +# Temporal # +############################################## + +# https://github.com/tc39/proposal-temporal/pull/2762 +# https://github.com/tc39/proposal-temporal/pull/2759 +skip script test262/built-ins/Temporal/ZonedDateTime/prototype/since/wrapping-at-end-of-month.js +skip script test262/built-ins/Temporal/ZonedDateTime/prototype/until/wrapping-at-end-of-month.js +skip script test262/built-ins/Temporal/PlainDate/prototype/since/wrapping-at-end-of-month.js +skip script test262/built-ins/Temporal/PlainDate/prototype/until/wrapping-at-end-of-month.js +skip script test262/built-ins/Temporal/PlainDateTime/prototype/since/wrapping-at-end-of-month.js +skip script test262/built-ins/Temporal/PlainDateTime/prototype/until/wrapping-at-end-of-month.js + ############################################## # Temporal Intl tests # @@ -1054,6 +1094,7 @@ skip script test262/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/time skip script test262/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/resolved-time-zone.js skip script test262/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/options-undefined.js skip script test262/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/calendar-mismatch.js +skip script test262/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/dateStyle.js skip script test262/intl402/Temporal/PlainMonthDay/prototype/with/fields-missing-properties.js skip script test262/intl402/Temporal/PlainMonthDay/from/reference-date-noniso-calendar.js skip script test262/intl402/Temporal/PlainMonthDay/from/fields-missing-properties.js @@ -1095,6 +1136,11 @@ skip script test262/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/cust skip script test262/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/offset-time-zone-not-supported.js skip script test262/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/calendar-mismatch.js skip script test262/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/options-timeZone.js +skip script test262/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/dateStyle.js +skip script test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js +skip script test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/non-iso-week-of-year.js +skip script test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js +skip script test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/non-iso-week-of-year.js skip script test262/intl402/Temporal/PlainDate/from/infinity-throws-rangeerror.js skip script test262/intl402/Temporal/PlainDate/compare/infinity-throws-rangeerror.js @@ -1114,7 +1160,12 @@ skip script test262/intl402/Temporal/PlainDate/prototype/toLocaleString/options- skip script test262/intl402/Temporal/PlainDate/prototype/toLocaleString/resolved-time-zone.js skip script test262/intl402/Temporal/PlainDate/prototype/toLocaleString/options-undefined.js skip script test262/intl402/Temporal/PlainDate/prototype/toLocaleString/calendar-mismatch.js +skip script test262/intl402/Temporal/PlainDate/prototype/toLocaleString/dateStyle.js skip script test262/intl402/Temporal/PlainDate/prototype/with/cross-era-boundary.js +skip script test262/intl402/Temporal/PlainDate/prototype/weekOfYear/gregory-iso-weekofyear.js +skip script test262/intl402/Temporal/PlainDate/prototype/weekOfYear/non-iso-week-of-year.js +skip script test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/gregory-iso-weekofyear.js +skip script test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/non-iso-week-of-year.js skip script test262/intl402/Temporal/TimeZone/prototype/getPossibleInstantsFor/infinity-throws-rangeerror.js skip script test262/intl402/Temporal/TimeZone/prototype/getInstantFor/infinity-throws-rangeerror.js @@ -1157,13 +1208,19 @@ skip script test262/intl402/Temporal/PlainDateTime/prototype/toLocaleString/time skip script test262/intl402/Temporal/PlainDateTime/prototype/toLocaleString/resolved-time-zone.js skip script test262/intl402/Temporal/PlainDateTime/prototype/toLocaleString/options-undefined.js skip script test262/intl402/Temporal/PlainDateTime/prototype/toLocaleString/calendar-mismatch.js +skip script test262/intl402/Temporal/PlainDateTime/prototype/toLocaleString/dateStyle.js skip script test262/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-always.js skip script test262/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-auto.js skip script test262/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-never.js +skip script test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js +skip script test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/non-iso-week-of-year.js +skip script test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/non-iso-week-of-year.js +skip script test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js skip script test262/intl402/Temporal/Instant/prototype/toLocaleString/locales-undefined.js skip script test262/intl402/Temporal/Instant/prototype/toLocaleString/options-conflict.js skip script test262/intl402/Temporal/Instant/prototype/toLocaleString/options-undefined.js +skip script test262/intl402/Temporal/Instant/prototype/toLocaleString/dateStyle.js skip script test262/intl402/Temporal/PlainYearMonth/from/argument-object.js skip script test262/intl402/Temporal/PlainYearMonth/from/infinity-throws-rangeerror.js @@ -1183,6 +1240,7 @@ skip script test262/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/tim skip script test262/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/options-undefined.js skip script test262/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/resolved-time-zone.js skip script test262/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/calendar-mismatch.js +skip script test262/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/dateStyle.js skip script test262/intl402/Temporal/Calendar/calendar-case-insensitive.js skip script test262/intl402/Temporal/Calendar/from/basic.js @@ -1296,6 +1354,14 @@ skip script test262/intl402/Temporal/Calendar/prototype/era/argument-duplicate-c skip script test262/intl402/Temporal/Calendar/prototype/era/argument-constructor-in-calendar-fields.js skip script test262/intl402/Temporal/Calendar/prototype/era/argument-proto-in-calendar-fields.js skip script test262/intl402/Temporal/Calendar/prototype/monthDayFromFields/fields-underspecified.js +skip script test262/intl402/Temporal/Calendar/prototype/weekOfYear/gregory-iso-weekofyear.js +skip script test262/intl402/Temporal/Calendar/prototype/weekOfYear/non-iso-week-of-year.js +skip script test262/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-iso-string.js +skip script test262/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation-invalid-key.js +skip script test262/intl402/Temporal/Calendar/prototype/yearOfWeek/non-iso-week-of-year.js +skip script test262/intl402/Temporal/Calendar/prototype/yearOfWeek/gregory-iso-weekofyear.js +skip script test262/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-iso-string.js +skip script test262/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation-invalid-key.js skip script test262/staging/Temporal/ZonedDateTime/old/construction-and-properties.js skip script test262/staging/Intl402/Temporal/old/date-time-format.js @@ -1331,58 +1397,3 @@ skip script test262/intl402/Temporal/TimeZone/from/iana-legacy-names.js skip script test262/intl402/Temporal/TimeZone/from/etc-timezone.js skip script test262/intl402/Temporal/TimeZone/from/argument-valid.js skip script test262/intl402/Temporal/TimeZone/from/timezone-case-insensitive.js - -# New Temporal failures, see bug 1878340 -skip script test262/built-ins/Temporal/Duration/out-of-range.js -skip script test262/built-ins/Temporal/Duration/compare/argument-duration-out-of-range.js -skip script test262/built-ins/Temporal/Duration/compare/relativeto-plaindate-add24hourdaystonormalizedtimeduration-out-of-range.js -skip script test262/built-ins/Temporal/Duration/prototype/subtract/argument-duration-out-of-range.js -skip script test262/built-ins/Temporal/Duration/prototype/subtract/result-out-of-range-1.js -skip script test262/built-ins/Temporal/Duration/prototype/subtract/normalized-time-duration-to-days-loop-arbitrarily.js -skip script test262/built-ins/Temporal/Duration/prototype/subtract/result-out-of-range-2.js -skip script test262/built-ins/Temporal/Duration/prototype/subtract/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js -skip script test262/built-ins/Temporal/Duration/prototype/subtract/argument-duration-precision-exact-numerical-values.js -skip script test262/built-ins/Temporal/Duration/prototype/toString/throws-when-rounded-duration-is-invalid.js -skip script test262/built-ins/Temporal/Duration/prototype/round/result-out-of-range.js -skip script test262/built-ins/Temporal/Duration/prototype/round/normalized-time-duration-to-days-loop-arbitrarily.js -skip script test262/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js -skip script test262/built-ins/Temporal/Duration/prototype/round/out-of-range-when-converting-from-normalized-duration.js -skip script test262/built-ins/Temporal/Duration/prototype/add/argument-duration-out-of-range.js -skip script test262/built-ins/Temporal/Duration/prototype/add/result-out-of-range-1.js -skip script test262/built-ins/Temporal/Duration/prototype/add/normalized-time-duration-to-days-loop-arbitrarily.js -skip script test262/built-ins/Temporal/Duration/prototype/add/result-out-of-range-2.js -skip script test262/built-ins/Temporal/Duration/prototype/add/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js -skip script test262/built-ins/Temporal/Duration/prototype/add/argument-duration-precision-exact-numerical-values.js -skip script test262/built-ins/Temporal/Duration/prototype/total/precision-exact-mathematical-values-7.js -skip script test262/built-ins/Temporal/Duration/prototype/total/precision-exact-mathematical-values-6.js -skip script test262/built-ins/Temporal/Duration/prototype/total/normalized-time-duration-to-days-loop-arbitrarily.js -skip script test262/built-ins/Temporal/Duration/prototype/total/relativeto-plaindate-add24hourdaystonormalizedtimeduration-out-of-range.js -skip script test262/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js -skip script test262/built-ins/Temporal/Duration/from/argument-duration-out-of-range.js -skip script test262/built-ins/Temporal/PlainTime/prototype/subtract/argument-duration-out-of-range.js -skip script test262/built-ins/Temporal/PlainTime/prototype/add/argument-duration-out-of-range.js -skip script test262/built-ins/Temporal/ZonedDateTime/prototype/until/normalized-time-duration-to-days-range-errors.js -skip script test262/built-ins/Temporal/ZonedDateTime/prototype/until/normalized-time-duration-to-days-loop-arbitrarily.js -skip script test262/built-ins/Temporal/ZonedDateTime/prototype/since/normalized-time-duration-to-days-range-errors.js -skip script test262/built-ins/Temporal/ZonedDateTime/prototype/since/normalized-time-duration-to-days-loop-arbitrarily.js -skip script test262/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/precision-exact-mathematical-values-2.js - -############################################## -# AsyncFromSyncIteratorPrototype tests # -############################################## - -# Failures in AsyncFromSyncIteratorPrototype, see bug 1877862. -skip script test262/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined-poisoned-return.js -skip script test262/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined-return-object.js -skip script test262/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined-return-not-object.js -skip script test262/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-null.js -skip script test262/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined.js -skip script test262/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-result-poisoned-wrapper.js -skip script test262/built-ins/AsyncFromSyncIteratorPrototype/throw/iterator-result-rejected-promise-close.js -skip script test262/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-undefined-get-return-undefined.js -skip script test262/built-ins/AsyncFromSyncIteratorPrototype/next/next-result-poisoned-wrapper.js -skip script test262/built-ins/AsyncFromSyncIteratorPrototype/next/for-await-iterator-next-rejected-promise-close.js -skip script test262/built-ins/AsyncFromSyncIteratorPrototype/next/yield-iterator-next-rejected-promise-close.js -skip script test262/built-ins/AsyncFromSyncIteratorPrototype/next/for-await-next-rejected-promise-close.js -skip script test262/built-ins/AsyncFromSyncIteratorPrototype/next/iterator-result-poisoned-wrapper.js -skip script test262/built-ins/AsyncFromSyncIteratorPrototype/next/yield-next-rejected-promise-close.js diff --git a/js/src/tests/lib/jittests.py b/js/src/tests/lib/jittests.py index 7d79ba9f2a..fbd00c0c37 100755 --- a/js/src/tests/lib/jittests.py +++ b/js/src/tests/lib/jittests.py @@ -399,8 +399,10 @@ class JitTest: # We may have specified '-a' or '-d' twice: once via --jitflags, once # via the "|jit-test|" line. Remove dups because they are toggles. + # Note: |dict.fromkeys(flags)| is similar to |set(flags)| but it + # preserves order. cmd = prefix + [] - cmd += list(set(self.jitflags)) + cmd += list(dict.fromkeys(self.jitflags)) # Handle selfhosted XDR file. if self.selfhosted_xdr_mode != "off": cmd += [ @@ -603,7 +605,12 @@ def print_automation_format(ok, res, slog): print("INFO (warn-stderr) 2> " + line.strip()) -def print_test_summary(num_tests, failures, complete, doing, options): +def print_test_summary(num_tests, failures, complete, slow_tests, doing, options): + def test_details(res): + if options.show_failed: + return escape_cmdline(res.cmd) + return " ".join(res.test.jitflags + [res.test.relpath_tests]) + if failures: if options.write_failures: try: @@ -628,21 +635,15 @@ def print_test_summary(num_tests, failures, complete, doing, options): traceback.print_exc() sys.stderr.write("---\n") - def show_test(res): - if options.show_failed: - print(" " + escape_cmdline(res.cmd)) - else: - print(" " + " ".join(res.test.jitflags + [res.test.relpath_tests])) - print("FAILURES:") for res in failures: if not res.timed_out: - show_test(res) + print(" " + test_details(res)) print("TIMEOUTS:") for res in failures: if res.timed_out: - show_test(res) + print(" " + test_details(res)) else: print( "PASSED ALL" @@ -659,6 +660,23 @@ def print_test_summary(num_tests, failures, complete, doing, options): print("Passed: {:d}".format(num_tests - num_failures)) print("Failed: {:d}".format(num_failures)) + if num_tests != 0 and options.show_slow: + threshold = options.slow_test_threshold + fraction_fast = 1 - len(slow_tests) / num_tests + print( + "{:5.2f}% of tests ran in under {}s".format(fraction_fast * 100, threshold) + ) + + print("Slowest tests that took longer than {}s:".format(threshold)) + slow_tests.sort(key=lambda res: res.dt, reverse=True) + any = False + for i in range(min(len(slow_tests), 20)): + res = slow_tests[i] + print(" {:6.2f} {}".format(res.dt, test_details(res))) + any = True + if not any: + print("None") + return not failures @@ -684,11 +702,14 @@ def process_test_results(results, num_tests, pb, options, slog): complete = False output_dict = {} doing = "before starting" + slow_tests = [] if num_tests == 0: pb.finish(True) complete = True - return print_test_summary(num_tests, failures, complete, doing, options) + return print_test_summary( + num_tests, failures, complete, slow_tests, doing, options + ) try: for i, res in enumerate(results): @@ -742,6 +763,9 @@ def process_test_results(results, num_tests, pb, options, slog): "SKIP": 0, }, ) + + if res.dt > options.slow_test_threshold: + slow_tests.append(res) complete = True except KeyboardInterrupt: print( @@ -750,7 +774,7 @@ def process_test_results(results, num_tests, pb, options, slog): ) pb.finish(True) - return print_test_summary(num_tests, failures, complete, doing, options) + return print_test_summary(num_tests, failures, complete, slow_tests, doing, options) def run_tests(tests, num_tests, prefix, options, remote=False): diff --git a/js/src/tests/lib/manifest.py b/js/src/tests/lib/manifest.py index 834bcab088..a7590b1b04 100644 --- a/js/src/tests/lib/manifest.py +++ b/js/src/tests/lib/manifest.py @@ -31,22 +31,25 @@ class XULInfo: self.abi = abi self.os = os self.isdebug = isdebug - self.browserIsRemote = False def as_js(self): """Return JS that when executed sets up variables so that JS expression predicates on XUL build info evaluate properly.""" return ( - 'var xulRuntime = {{ OS: "{}", XPCOMABI: "{}", shell: true }};' + "var winWidget = {};" + "var gtkWidget = {};" + "var cocoaWidget = {};" + "var is64Bit = {};" + "var xulRuntime = {{ shell: true }};" "var release_or_beta = getBuildConfiguration('release_or_beta');" - "var isDebugBuild={}; var Android={}; " - "var browserIsRemote={}".format( - self.os, - self.abi, + "var isDebugBuild={}; var Android={}; ".format( + str(self.os == "WINNT").lower(), + str(self.os == "Darwin").lower(), + str(self.os == "Linux").lower(), + str("x86-" not in self.abi).lower(), str(self.isdebug).lower(), str(self.os == "Android").lower(), - str(self.browserIsRemote).lower(), ) ) @@ -258,7 +261,7 @@ def _parse_one(testcase, terms, xul_tester): pos += 1 elif parts[pos] == "silentfail": # silentfails use tons of memory, and Darwin doesn't support ulimit. - if xul_tester.test("xulRuntime.OS == 'Darwin'", testcase.options): + if xul_tester.test("cocoaWidget", testcase.options): testcase.expect = testcase.enable = False pos += 1 elif parts[pos].startswith("error:"): diff --git a/js/src/tests/lib/results.py b/js/src/tests/lib/results.py index 9c623b863f..42f8d7c163 100644 --- a/js/src/tests/lib/results.py +++ b/js/src/tests/lib/results.py @@ -372,6 +372,9 @@ class ResultsSink: else: self.list(completed) + if self.n != 0 and self.options.show_slow: + self.show_slow_tests() + if self.wptreport is not None: self.wptreport.suite_end() @@ -427,16 +430,28 @@ class ResultsSink: else: print("FAIL" + suffix) - if self.options.show_slow: - min_duration = self.options.slow_test_threshold - print("Slow tests (duration > {}s)".format(min_duration)) - slow_tests = sorted(self.slow_tests, key=lambda x: x.duration, reverse=True) - any = False - for test in slow_tests: - print("{:>5} {}".format(round(test.duration, 2), test.test)) - any = True - if not any: - print("None") + def show_slow_tests(self): + threshold = self.options.slow_test_threshold + fraction_fast = 1 - len(self.slow_tests) / self.n + self.log_info( + "{:5.2f}% of tests ran in under {}s".format(fraction_fast * 100, threshold) + ) + + self.log_info("Slowest tests that took longer than {}s:".format(threshold)) + slow_tests = sorted(self.slow_tests, key=lambda x: x.duration, reverse=True) + any = False + for i in range(min(len(slow_tests), 20)): + test = slow_tests[i] + self.log_info(" {:6.2f} {}".format(test.duration, test.test)) + any = True + if not any: + self.log_info("None") + + def log_info(self, message): + if self.options.format == "automation": + self.slog.log_info(message) + else: + print(message) def all_passed(self): return "REGRESSIONS" not in self.groups and "TIMEOUTS" not in self.groups diff --git a/js/src/tests/lib/structuredlog.py b/js/src/tests/lib/structuredlog.py index 2f2d317d02..b00914cc90 100644 --- a/js/src/tests/lib/structuredlog.py +++ b/js/src/tests/lib/structuredlog.py @@ -1,5 +1,5 @@ # produce mozlog-compatible log messages, following the spec at -# https://mozbase.readthedocs.io/en/latest/mozlog.html +# https://firefox-source-docs.mozilla.org/mozbase/mozlog.html import json import os @@ -54,3 +54,6 @@ class TestLogger(object): record["status"] = status record.update(**details) self._log_obj(record) + + def log_info(self, message): + self._log(action="log", level="INFO", message=message) diff --git a/js/src/tests/non262/Array/regress-157652.js b/js/src/tests/non262/Array/regress-157652.js index 32996ca629..fd48df3b1a 100644 --- a/js/src/tests/non262/Array/regress-157652.js +++ b/js/src/tests/non262/Array/regress-157652.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.XPCOMABI.match(/x86_64|aarch64|ppc64|ppc64le|s390x|mips64|loongarch64|riscv64/)||Android) -- No test results +// |reftest| skip-if(is64Bit||Android) -- No test results /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/js/src/tests/non262/Array/regress-330812.js b/js/src/tests/non262/Array/regress-330812.js index be700714c2..82715b29a9 100644 --- a/js/src/tests/non262/Array/regress-330812.js +++ b/js/src/tests/non262/Array/regress-330812.js @@ -1,4 +1,4 @@ -// |reftest| slow-if(xulRuntime.XPCOMABI.match(/x86_64|aarch64|ppc64|ppc64le|s390x|mips64|loongarch64|riscv64/)||Android) -- No test results +// |reftest| slow-if(is64Bit||Android) -- No test results /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/js/src/tests/non262/Date/15.9.5.5.js b/js/src/tests/non262/Date/15.9.5.5.js index 1a21b33a63..e047bafeb9 100644 --- a/js/src/tests/non262/Date/15.9.5.5.js +++ b/js/src/tests/non262/Date/15.9.5.5.js @@ -1,4 +1,4 @@ -// |reftest| random-if(xulRuntime.OS=="Linux") +// |reftest| random-if(gtkWidget) /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/js/src/tests/non262/Date/15.9.5.7.js b/js/src/tests/non262/Date/15.9.5.7.js index 0ce2df9a26..980ca514d1 100644 --- a/js/src/tests/non262/Date/15.9.5.7.js +++ b/js/src/tests/non262/Date/15.9.5.7.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.OS=="WINNT") -- Windows doesn't accept IANA names for the TZ env variable +// |reftest| skip-if(winWidget) -- Windows doesn't accept IANA names for the TZ env variable /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/js/src/tests/non262/Date/dashed-date.js b/js/src/tests/non262/Date/dashed-date.js index d7b4692e7f..58302713bc 100644 --- a/js/src/tests/non262/Date/dashed-date.js +++ b/js/src/tests/non262/Date/dashed-date.js @@ -8,8 +8,6 @@ const tests = [ ["24-APRIL-2023", "2023-04-24T00:00:00"], ["24-Apr-2033", "2033-04-24T00:00:00"], - ["24-Apr-0023", "0023-04-24T00:00:00"], - // dd-MMM-yy ["24-Apr-23", "2023-04-24T00:00:00"], ["24-Apr-33", "2033-04-24T00:00:00"], @@ -24,7 +22,12 @@ const tests = [ ["APRIL-24-2023", "2023-04-24T00:00:00"], ["Apr-24-2033", "2033-04-24T00:00:00"], - ["Apr-24-0023", "0023-04-24T00:00:00"], + // Year should get fixed up even with leading 0s + ["Apr-24-23", "2023-04-24T00:00:00"], + ["Apr-24-0023", "2023-04-24T00:00:00"], + ["24-Apr-0023", "2023-04-24T00:00:00"], + ["24-Apr-00023", "2023-04-24T00:00:00"], + ["24-Apr-000023", "2023-04-24T00:00:00"], // MMM-dd-yy ["Apr-24-23", "2023-04-24T00:00:00"], diff --git a/js/src/tests/non262/Date/parse-dashed-numeric-date.js b/js/src/tests/non262/Date/parse-dashed-numeric-date.js index b0bd1a35ec..b6a0d1e7f9 100644 --- a/js/src/tests/non262/Date/parse-dashed-numeric-date.js +++ b/js/src/tests/non262/Date/parse-dashed-numeric-date.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.OS=="WINNT") -- Windows doesn't accept IANA names for the TZ env variable +// |reftest| skip-if(winWidget) -- Windows doesn't accept IANA names for the TZ env variable /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -28,6 +28,7 @@ inTimeZone("MST", () => { // 1-12 for first number should be month "1-09-12": new Date(2012, Month.January, 9), + "1-09-0012": new Date(2012, Month.January, 9), "1-09-2012": new Date(2012, Month.January, 9), "12-09-12": new Date(2012, Month.December, 9), diff --git a/js/src/tests/non262/Date/parse-from-tostring-methods.js b/js/src/tests/non262/Date/parse-from-tostring-methods.js index b6bf577bb0..f9c17fac37 100644 --- a/js/src/tests/non262/Date/parse-from-tostring-methods.js +++ b/js/src/tests/non262/Date/parse-from-tostring-methods.js @@ -1,6 +1,4 @@ let dates = [ - "0041-09-23", "+000041-09-23", "-000041-09-23", - "0091-09-23", "+000091-09-23", "-000091-09-23", "0217-09-23", "+000217-09-23", "-000217-09-23", "2017-09-23", "+002017-09-23", "-002017-09-23", "+022017-09-23", "-022017-09-23", diff --git a/js/src/tests/non262/Date/parse-period.js b/js/src/tests/non262/Date/parse-period.js index 835512823e..edd18dc7eb 100644 --- a/js/src/tests/non262/Date/parse-period.js +++ b/js/src/tests/non262/Date/parse-period.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.OS=="WINNT") -- Windows doesn't accept IANA names for the TZ env variable +// |reftest| skip-if(winWidget) -- Windows doesn't accept IANA names for the TZ env variable /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,6 +9,7 @@ const tests = [ "Aug.. 15, 2015", "Aug.15.2015", "15.Aug.2015", + "15.Aug.0015", "Aug 15 2015 12:00 am.", "Sat. Aug 15 2015", "2015.08.15", diff --git a/js/src/tests/non262/Date/parse-time-zone.js b/js/src/tests/non262/Date/parse-time-zone.js index c239822b04..692aa3af10 100644 --- a/js/src/tests/non262/Date/parse-time-zone.js +++ b/js/src/tests/non262/Date/parse-time-zone.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.OS=="WINNT") -- Windows doesn't accept IANA names for the TZ env variable +// |reftest| skip-if(winWidget) -- Windows doesn't accept IANA names for the TZ env variable // bug 1676708 inTimeZone("Europe/London", () => { diff --git a/js/src/tests/non262/Date/parse-zulu-time.js b/js/src/tests/non262/Date/parse-zulu-time.js index a7bcd3bd00..2092ed400d 100644 --- a/js/src/tests/non262/Date/parse-zulu-time.js +++ b/js/src/tests/non262/Date/parse-zulu-time.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.OS=="WINNT") -- Windows doesn't accept IANA names for the TZ env variable +// |reftest| skip-if(winWidget) -- Windows doesn't accept IANA names for the TZ env variable /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/js/src/tests/non262/Date/reset-time-zone-cache-same-offset.js b/js/src/tests/non262/Date/reset-time-zone-cache-same-offset.js index 56c9fc262c..c7e3915c95 100644 --- a/js/src/tests/non262/Date/reset-time-zone-cache-same-offset.js +++ b/js/src/tests/non262/Date/reset-time-zone-cache-same-offset.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.OS=="WINNT") -- Windows doesn't accept IANA names for the TZ env variable +// |reftest| skip-if(winWidget) -- Windows doesn't accept IANA names for the TZ env variable const testCases = [ { diff --git a/js/src/tests/non262/Date/time-zone-etc_localetime.js b/js/src/tests/non262/Date/time-zone-etc_localetime.js index eaf8f7d940..f10056fb37 100644 --- a/js/src/tests/non262/Date/time-zone-etc_localetime.js +++ b/js/src/tests/non262/Date/time-zone-etc_localetime.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.OS=="WINNT"||!xulRuntime.shell) +// |reftest| skip-if(winWidget||!xulRuntime.shell) assertEq(/^(PST|PDT)$/.test(getTimeZone()), true, "The default time zone is set to PST8PDT for all jstests (when run in the shell)"); diff --git a/js/src/tests/non262/Date/time-zone-path.js b/js/src/tests/non262/Date/time-zone-path.js index 0181093bac..266fe53ec8 100644 --- a/js/src/tests/non262/Date/time-zone-path.js +++ b/js/src/tests/non262/Date/time-zone-path.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.OS=="WINNT"||!xulRuntime.shell||!this.hasOwnProperty("Intl")) +// |reftest| skip-if(winWidget||!xulRuntime.shell||!this.hasOwnProperty("Intl")) assertEq(/^(PST|PDT)$/.test(getTimeZone()), true, "The default time zone is set to PST8PDT for all jstests (when run in the shell)"); diff --git a/js/src/tests/non262/Date/time-zones-historic.js b/js/src/tests/non262/Date/time-zones-historic.js index 3117870687..e5649153b3 100644 --- a/js/src/tests/non262/Date/time-zones-historic.js +++ b/js/src/tests/non262/Date/time-zones-historic.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.OS=="WINNT"||!this.hasOwnProperty("Intl")) -- Windows doesn't accept IANA names for the TZ env variable; Requires ICU time zone support +// |reftest| skip-if(winWidget||!this.hasOwnProperty("Intl")) -- Windows doesn't accept IANA names for the TZ env variable; Requires ICU time zone support // bug 487897 inTimeZone("Europe/London", () => { diff --git a/js/src/tests/non262/Date/time-zones-imported.js b/js/src/tests/non262/Date/time-zones-imported.js index 8a13e34981..f09cf22e13 100644 --- a/js/src/tests/non262/Date/time-zones-imported.js +++ b/js/src/tests/non262/Date/time-zones-imported.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.OS=="WINNT"||!this.hasOwnProperty("Intl")) -- Windows doesn't accept IANA names for the TZ env variable; Requires ICU time zone support +// |reftest| skip-if(winWidget||!this.hasOwnProperty("Intl")) -- Windows doesn't accept IANA names for the TZ env variable; Requires ICU time zone support // Imported tests from es6draft and then adapted to use ICU/CLDR time zone display names. diff --git a/js/src/tests/non262/Date/time-zones-pedantic.js b/js/src/tests/non262/Date/time-zones-pedantic.js index c3445ed5fd..cd6d0c4490 100644 --- a/js/src/tests/non262/Date/time-zones-pedantic.js +++ b/js/src/tests/non262/Date/time-zones-pedantic.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.OS=="WINNT"||xulRuntime.OS=="Darwin") -- Skip on OS X in addition to Windows +// |reftest| skip-if(winWidget||cocoaWidget) -- Skip on OS X in addition to Windows // Contains the tests from "time-zones.js" which fail on OS X. diff --git a/js/src/tests/non262/Date/time-zones-posix.js b/js/src/tests/non262/Date/time-zones-posix.js index c2d7cc20c9..21e81e9808 100644 --- a/js/src/tests/non262/Date/time-zones-posix.js +++ b/js/src/tests/non262/Date/time-zones-posix.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.OS=="WINNT"&&!xulRuntime.shell) -- Windows browser in automation doesn't pick up new time zones correctly +// |reftest| skip-if(winWidget&&!xulRuntime.shell) -- Windows browser in automation doesn't pick up new time zones correctly // Repeats the test from "time-zones.js", but uses POSIX instead of IANA names // for the time zones. This allows to run these tests on Windows, too. diff --git a/js/src/tests/non262/Date/time-zones.js b/js/src/tests/non262/Date/time-zones.js index da2b328be7..550b1494b8 100644 --- a/js/src/tests/non262/Date/time-zones.js +++ b/js/src/tests/non262/Date/time-zones.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.OS=="WINNT") -- Windows doesn't accept IANA names for the TZ env variable +// |reftest| skip-if(winWidget) -- Windows doesn't accept IANA names for the TZ env variable // bug 158328 inTimeZone("Europe/London", () => { diff --git a/js/src/tests/non262/Date/toString-localized.js b/js/src/tests/non262/Date/toString-localized.js index 6baa535e5e..98bd3e54af 100644 --- a/js/src/tests/non262/Date/toString-localized.js +++ b/js/src/tests/non262/Date/toString-localized.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.OS=="WINNT"||!this.hasOwnProperty("Intl")) -- Windows doesn't accept IANA names for the TZ env variable; Requires ICU time zone support +// |reftest| skip-if(winWidget||!this.hasOwnProperty("Intl")) -- Windows doesn't accept IANA names for the TZ env variable; Requires ICU time zone support // Date.prototype.toString includes a localized time zone name comment. diff --git a/js/src/tests/non262/Intl/DateTimeFormat/tz-environment-variable.js b/js/src/tests/non262/Intl/DateTimeFormat/tz-environment-variable.js index 6128abb9d1..9b184fd2b2 100644 --- a/js/src/tests/non262/Intl/DateTimeFormat/tz-environment-variable.js +++ b/js/src/tests/non262/Intl/DateTimeFormat/tz-environment-variable.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty("Intl")||(xulRuntime.OS=="WINNT"&&!xulRuntime.shell)) -- Windows browser in automation doesn't pick up new time zones correctly +// |reftest| skip-if(!this.hasOwnProperty("Intl")||(winWidget&&!xulRuntime.shell)) -- Windows browser in automation doesn't pick up new time zones correctly // From bug 1330149: // diff --git a/js/src/tests/non262/Math/f16round.js b/js/src/tests/non262/Math/f16round.js new file mode 100644 index 0000000000..cf27346d37 --- /dev/null +++ b/js/src/tests/non262/Math/f16round.js @@ -0,0 +1,155 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!Math.f16round) + +// Some tests regarding conversion to Float16 +assertEq(Math.f16round(), NaN); + +// Special values +assertEq(Math.f16round(NaN), NaN); +assertEq(Math.f16round(-Infinity), -Infinity); +assertEq(Math.f16round(Infinity), Infinity); +assertEq(Math.f16round(-0), -0); +assertEq(Math.f16round(+0), +0); + +// Polyfill function for Float16 conversion, adapted from +// https://github.com/petamoriken/float16/. +// The original license is preseved below. +function toFloat16(num) { + // MIT License + + // Copyright (c) 2017-2024 Kenta Moriuchi + + // 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, sublicense, and/or sell + // copies of the Software, and to permit persons to whom the Software is + // furnished to do so, subject to the following conditions: + + // The above copyright notice and this permission notice shall be included in all + // copies or substantial portions of the Software. + + // 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. IN NO EVENT SHALL THE + // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + // SOFTWARE. + + const INVERSE_OF_EPSILON = 1 / Number.EPSILON; + + /** + * rounds to the nearest value; + * if the number falls midway, it is rounded to the nearest value with an even least significant digit + * @param {number} num + * @returns {number} + */ + function roundTiesToEven(num) { + return (num + INVERSE_OF_EPSILON) - INVERSE_OF_EPSILON; + } + + const FLOAT16_MIN_VALUE = 6.103515625e-05; + const FLOAT16_MAX_VALUE = 65504; + const FLOAT16_EPSILON = 0.0009765625; + + const FLOAT16_EPSILON_MULTIPLIED_BY_FLOAT16_MIN_VALUE = FLOAT16_EPSILON * FLOAT16_MIN_VALUE; + const FLOAT16_EPSILON_DEVIDED_BY_EPSILON = FLOAT16_EPSILON * INVERSE_OF_EPSILON; + + function roundToFloat16(num) { + const number = +num; + + // NaN, Infinity, -Infinity, 0, -0 + if (!isFinite(number) || number === 0) { + return number; + } + + // finite except 0, -0 + const sign = number > 0 ? 1 : -1; + const absolute = Math.abs(number); + + // small number + if (absolute < FLOAT16_MIN_VALUE) { + return sign * roundTiesToEven(absolute / FLOAT16_EPSILON_MULTIPLIED_BY_FLOAT16_MIN_VALUE) * FLOAT16_EPSILON_MULTIPLIED_BY_FLOAT16_MIN_VALUE; + } + + const temp = (1 + FLOAT16_EPSILON_DEVIDED_BY_EPSILON) * absolute; + const result = temp - (temp - absolute); + + // large number + if (result > FLOAT16_MAX_VALUE || isNaN(result)) { + return sign * Infinity; + } + + return sign * result; + } + + return roundToFloat16(num); +}; + +// A test on a certain range of numbers, including big numbers, so that +// we get a loss in precision for some of them. +for (var i = 0; i < 64; ++i) { + var p = Math.pow(2, i) + 1; + assertEq(Math.f16round(p), toFloat16(p)); + assertEq(Math.f16round(-p), toFloat16(-p)); +} + +/******************************************** +/* Tests on maximal Float16 / Double values * +/*******************************************/ +function maxValue(exponentWidth, significandWidth) { + var n = 0; + var maxExp = Math.pow(2, exponentWidth - 1) - 1; + for (var i = significandWidth; i >= 0; i--) + n += Math.pow(2, maxExp - i); + return n; +} + +var DBL_MAX = maxValue(11, 52); +assertEq(DBL_MAX, Number.MAX_VALUE); // sanity check + +// Finite as a double, too big for a float16 +assertEq(Math.f16round(DBL_MAX), Infinity); + +var FLT16_MAX = maxValue(5, 10); +assertEq(Math.f16round(FLT16_MAX), FLT16_MAX); +assertEq(Math.f16round(65519), FLT16_MAX); // round-nearest rounds down to FLT16_MAX +assertEq(Math.f16round(65520), Infinity); // no longer rounds down to FLT16_MAX + +/********************************************************* +/******* Tests on denormalizations and roundings ********* +/********************************************************/ +function minValue(exponentWidth, significandWidth) { + return Math.pow(2, -(Math.pow(2, exponentWidth - 1) - 2) - significandWidth); +} + +var DBL_MIN = Math.pow(2, -1074); +assertEq(DBL_MIN, Number.MIN_VALUE); // sanity check + +// Too small for a float16 +assertEq(Math.f16round(DBL_MIN), 0); + +var FLT16_MIN = minValue(5, 10); +assertEq(Math.f16round(FLT16_MIN), FLT16_MIN); + +assertEq(Math.f16round(FLT16_MIN / 2), 0); // halfway, round-nearest rounds down to 0 (even) + +// FLT16_MIN + a small amount rounds up to FLT16_MIN +// Constant taken from https://github.com/petamoriken/float16/ +assertEq(Math.f16round(2.980232238769531911744490042422139897126953655970282852649688720703125e-8), FLT16_MIN); + +assertEq(Math.f16round(-FLT16_MIN), -FLT16_MIN); +assertEq(Math.f16round(-FLT16_MIN / 2), -0); // halfway, round-nearest rounds up to -0 (even) +// -FLT16_MIN - a small amount rounds down to -FLT16_MIN +// Constant taken from https://github.com/petamoriken/float16/ +assertEq(Math.f16round(2.980232238769531911744490042422139897126953655970282852649688720703125e-8), FLT16_MIN); + +// Test some constants from https://github.com/petamoriken/float16/ +assertEq(Math.f16round(0.499994), 0.5); +assertEq(Math.f16round(1.337), 1.3369140625); + +// This will round incorrectly if the implementation first rounds to Float32, +// then to Float16 +assertEq(Math.f16round(1.00048828125000022204), 1.0009765625); + +reportCompare(0, 0, "ok"); diff --git a/js/src/tests/non262/RegExp/regress-617935.js b/js/src/tests/non262/RegExp/regress-617935.js index 3764d81b0e..77495151a5 100644 --- a/js/src/tests/non262/RegExp/regress-617935.js +++ b/js/src/tests/non262/RegExp/regress-617935.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!xulRuntime.shell&&(Android||xulRuntime.OS=="WINNT")) silentfail +// |reftest| skip-if(!xulRuntime.shell&&(Android||winWidget)) silentfail /* * Any copyright is dedicated to the Public Domain. * http://creativecommons.org/licenses/publicdomain/ diff --git a/gfx/cairo/libpixman/AUTHORS b/js/src/tests/non262/Temporal/PlainDate/browser.js index e69de29bb2..e69de29bb2 100644 --- a/gfx/cairo/libpixman/AUTHORS +++ b/js/src/tests/non262/Temporal/PlainDate/browser.js diff --git a/js/src/tests/non262/Temporal/PlainDate/from-with-modified-array-iterator-state.js b/js/src/tests/non262/Temporal/PlainDate/from-with-modified-array-iterator-state.js new file mode 100644 index 0000000000..ac0febc1e6 --- /dev/null +++ b/js/src/tests/non262/Temporal/PlainDate/from-with-modified-array-iterator-state.js @@ -0,0 +1,22 @@ +// |reftest| skip-if(!this.hasOwnProperty("Temporal")) + +const ArrayIteratorPrototype = Object.getPrototypeOf([][Symbol.iterator]()); + +// Modify the ArrayIteratorPrototype prototype chain to disable optimisations. +Object.setPrototypeOf(ArrayIteratorPrototype, {}); + +let calendar = new Temporal.Calendar("iso8601"); + +let dateLike = { + calendar, + day: 1, + month: 1, + year: 0, +}; + +let result = Temporal.PlainDate.from(dateLike); + +assertEq(result.toString(), "0000-01-01"); + +if (typeof reportCompare === "function") + reportCompare(true, true); diff --git a/third_party/rust/cssparser/docs/.nojekyll b/js/src/tests/non262/Temporal/PlainDate/shell.js index e69de29bb2..e69de29bb2 100644 --- a/third_party/rust/cssparser/docs/.nojekyll +++ b/js/src/tests/non262/Temporal/PlainDate/shell.js diff --git a/js/src/tests/non262/TypedArray/constructor-ArrayBuffer-species-wrap.js b/js/src/tests/non262/TypedArray/constructor-ArrayBuffer-species-wrap.js index d454804f94..93c63e2922 100644 --- a/js/src/tests/non262/TypedArray/constructor-ArrayBuffer-species-wrap.js +++ b/js/src/tests/non262/TypedArray/constructor-ArrayBuffer-species-wrap.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!xulRuntime.shell) +// |reftest| shell-option(--enable-float16array) skip-if(!xulRuntime.shell) let g = newGlobal(); diff --git a/js/src/tests/non262/TypedArray/constructor-ArrayBuffer-species.js b/js/src/tests/non262/TypedArray/constructor-ArrayBuffer-species.js index aa7830df67..9e27b2cd3d 100644 --- a/js/src/tests/non262/TypedArray/constructor-ArrayBuffer-species.js +++ b/js/src/tests/non262/TypedArray/constructor-ArrayBuffer-species.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) for (let ctor of typedArrayConstructors) { let arr = new ctor([1, 2, 3, 4, 5, 6, 7, 8]); diff --git a/js/src/tests/non262/TypedArray/constructor-byteoffsets-bounds.js b/js/src/tests/non262/TypedArray/constructor-byteoffsets-bounds.js index ce213038d4..da26828da4 100644 --- a/js/src/tests/non262/TypedArray/constructor-byteoffsets-bounds.js +++ b/js/src/tests/non262/TypedArray/constructor-byteoffsets-bounds.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) // Test bound checks around for |byteOffset| and |length| arguments. diff --git a/js/src/tests/non262/TypedArray/constructor-iterator-primitive.js b/js/src/tests/non262/TypedArray/constructor-iterator-primitive.js index 5a14d7d5a7..313aa5a750 100644 --- a/js/src/tests/non262/TypedArray/constructor-iterator-primitive.js +++ b/js/src/tests/non262/TypedArray/constructor-iterator-primitive.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) var BUGNUMBER = 1021835; var summary = "Returning non-object from @@iterator should throw"; diff --git a/js/src/tests/non262/TypedArray/constructor-length-too-large.js b/js/src/tests/non262/TypedArray/constructor-length-too-large.js index 7a7a785041..456b6db284 100644 --- a/js/src/tests/non262/TypedArray/constructor-length-too-large.js +++ b/js/src/tests/non262/TypedArray/constructor-length-too-large.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!xulRuntime.shell) +// |reftest| shell-option(--enable-float16array) skip-if(!xulRuntime.shell) // Test that all TypedArray constructor variants throw a RangeError when // attempting to create a too large array. diff --git a/js/src/tests/non262/TypedArray/constructor-non-detached.js b/js/src/tests/non262/TypedArray/constructor-non-detached.js index 9ec9329be8..b40c6cdcbe 100644 --- a/js/src/tests/non262/TypedArray/constructor-non-detached.js +++ b/js/src/tests/non262/TypedArray/constructor-non-detached.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) for (var constructor of typedArrayConstructors) { var buf = new constructor(); detachArrayBuffer(buf.buffer); diff --git a/js/src/tests/non262/TypedArray/constructor-typedarray-species-other-global.js b/js/src/tests/non262/TypedArray/constructor-typedarray-species-other-global.js index 872f46408a..281a764acb 100644 --- a/js/src/tests/non262/TypedArray/constructor-typedarray-species-other-global.js +++ b/js/src/tests/non262/TypedArray/constructor-typedarray-species-other-global.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // 22.2.4.3 TypedArray ( typedArray ) // Test [[Prototype]] of newly created typed array and its array buffer, and diff --git a/js/src/tests/non262/TypedArray/filter-validation.js b/js/src/tests/non262/TypedArray/filter-validation.js index 450b4fa2cf..513f1de7f4 100644 --- a/js/src/tests/non262/TypedArray/filter-validation.js +++ b/js/src/tests/non262/TypedArray/filter-validation.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/js/src/tests/non262/TypedArray/from-iterable-validation.js b/js/src/tests/non262/TypedArray/from-iterable-validation.js index 50d46bb81f..ad0015492c 100644 --- a/js/src/tests/non262/TypedArray/from-iterable-validation.js +++ b/js/src/tests/non262/TypedArray/from-iterable-validation.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/js/src/tests/non262/TypedArray/from-non-iterable-validation.js b/js/src/tests/non262/TypedArray/from-non-iterable-validation.js index 3276426b28..69d09ced9c 100644 --- a/js/src/tests/non262/TypedArray/from-non-iterable-validation.js +++ b/js/src/tests/non262/TypedArray/from-non-iterable-validation.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/js/src/tests/non262/TypedArray/large-arrays.js b/js/src/tests/non262/TypedArray/large-arrays.js index 56ce117494..5d65c21464 100644 --- a/js/src/tests/non262/TypedArray/large-arrays.js +++ b/js/src/tests/non262/TypedArray/large-arrays.js @@ -1,4 +1,4 @@ -// |reftest| slow skip-if(!xulRuntime.shell) +// |reftest| shell-option(--enable-float16array) slow skip-if(!xulRuntime.shell) // Test that we can access TypedArrays beyond the 4GB mark, if large buffers are // supported. diff --git a/js/src/tests/non262/TypedArray/map-validation.js b/js/src/tests/non262/TypedArray/map-validation.js index 1694ef50cb..8b5b2ab3e8 100644 --- a/js/src/tests/non262/TypedArray/map-validation.js +++ b/js/src/tests/non262/TypedArray/map-validation.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/js/src/tests/non262/TypedArray/of-validation.js b/js/src/tests/non262/TypedArray/of-validation.js index e7ab905195..e02eedf67e 100644 --- a/js/src/tests/non262/TypedArray/of-validation.js +++ b/js/src/tests/non262/TypedArray/of-validation.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/js/src/tests/non262/TypedArray/set-wrapped.js b/js/src/tests/non262/TypedArray/set-wrapped.js index 30a242bf0b..2b2ee813c8 100644 --- a/js/src/tests/non262/TypedArray/set-wrapped.js +++ b/js/src/tests/non262/TypedArray/set-wrapped.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Test %TypedArray%.prototype.set(typedArray, offset) when called with wrapped // typed array. diff --git a/js/src/tests/non262/TypedArray/shell.js b/js/src/tests/non262/TypedArray/shell.js index 2fb0ab8f1d..b31fa70f59 100644 --- a/js/src/tests/non262/TypedArray/shell.js +++ b/js/src/tests/non262/TypedArray/shell.js @@ -2,7 +2,7 @@ "use strict"; const { - Float32Array, Float64Array, Object, Reflect, SharedArrayBuffer, WeakMap, + Float16Array, Float32Array, Float64Array, Object, Reflect, SharedArrayBuffer, WeakMap, assertEq } = global; const { @@ -69,7 +69,7 @@ Uint32Array, Float32Array, Float64Array, - ]); + ].concat(Float16Array ?? [])); /** * All TypedArray constructors for shared memory. @@ -97,13 +97,13 @@ /** * Returns `true` if `constructor` is a TypedArray constructor for shared - * or unshared memory, with an underlying element type of either Float32 or - * Float64. + * or unshared memory, with an underlying element type of one of Float16, Float32 + * or Float64. */ function isFloatConstructor(constructor) { if (isSharedConstructor(constructor)) constructor = Reflect_apply(WeakMap_prototype_get, sharedConstructors, [constructor]); - return constructor == Float32Array || constructor == Float64Array; + return constructor == Float32Array || constructor == Float64Array || (Float16Array && constructor == Float16Array); } global.typedArrayConstructors = typedArrayConstructors; diff --git a/js/src/tests/non262/TypedArray/slice-memcpy.js b/js/src/tests/non262/TypedArray/slice-memcpy.js index a20010ed16..e40ff0e4cc 100644 --- a/js/src/tests/non262/TypedArray/slice-memcpy.js +++ b/js/src/tests/non262/TypedArray/slice-memcpy.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) const otherGlobal = newGlobal(); // Create with new ArrayBuffer and offset. diff --git a/js/src/tests/non262/TypedArray/slice-species.js b/js/src/tests/non262/TypedArray/slice-species.js index 8a03f2f6ee..df73c65cad 100644 --- a/js/src/tests/non262/TypedArray/slice-species.js +++ b/js/src/tests/non262/TypedArray/slice-species.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) for (var constructor of typedArrayConstructors) { // Basic tests for our SpeciesConstructor implementation. var undefConstructor = new constructor(2); diff --git a/js/src/tests/non262/TypedArray/slice-validation.js b/js/src/tests/non262/TypedArray/slice-validation.js index 28d50e36f4..cb8deb813b 100644 --- a/js/src/tests/non262/TypedArray/slice-validation.js +++ b/js/src/tests/non262/TypedArray/slice-validation.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/js/src/tests/non262/TypedArray/sort_basics.js b/js/src/tests/non262/TypedArray/sort_basics.js index 3338861507..685215eed6 100644 --- a/js/src/tests/non262/TypedArray/sort_basics.js +++ b/js/src/tests/non262/TypedArray/sort_basics.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Note: failed runs should include their "SEED" value in error messages, // setting "const SEED" to that value will recreate the data from any such run. const SEED = (Math.random() * 10) + 1; diff --git a/js/src/tests/non262/TypedArray/sort_byteoffset.js b/js/src/tests/non262/TypedArray/sort_byteoffset.js index b4e262c450..b8af8bda83 100644 --- a/js/src/tests/non262/TypedArray/sort_byteoffset.js +++ b/js/src/tests/non262/TypedArray/sort_byteoffset.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Ensure that when sorting TypedArrays we don't // ignore byte offsets (bug 1290579). diff --git a/js/src/tests/non262/TypedArray/sort_comparators.js b/js/src/tests/non262/TypedArray/sort_comparators.js index ca190948fc..6578bb066c 100644 --- a/js/src/tests/non262/TypedArray/sort_comparators.js +++ b/js/src/tests/non262/TypedArray/sort_comparators.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Ensure that sorts finish even if a comparator adds items // Note: the array is not expected to be properly sorted. let outsideArray = new Int32Array([1, 99, 2]); diff --git a/js/src/tests/non262/TypedArray/sort_modifications.js b/js/src/tests/non262/TypedArray/sort_modifications.js index 2a6ed49eb7..7098dedc95 100644 --- a/js/src/tests/non262/TypedArray/sort_modifications.js +++ b/js/src/tests/non262/TypedArray/sort_modifications.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) const TAConstructors = [ Int8Array, Uint8Array, @@ -10,7 +11,7 @@ const TAConstructors = [ Float64Array, BigInt64Array, BigUint64Array, -]; +].concat(this.Float16Array ?? []); // Use different size classes to catch any implementation-specific // optimisations. diff --git a/js/src/tests/non262/TypedArray/sort_modifications_concurrent.js b/js/src/tests/non262/TypedArray/sort_modifications_concurrent.js index 99493df800..60f58b0e0e 100644 --- a/js/src/tests/non262/TypedArray/sort_modifications_concurrent.js +++ b/js/src/tests/non262/TypedArray/sort_modifications_concurrent.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!xulRuntime.shell) +// |reftest| shell-option(--enable-float16array) skip-if(!xulRuntime.shell) if (helperThreadCount() === 0) { if (typeof reportCompare === "function") @@ -18,7 +18,7 @@ const TAConstructors = [ Float64Array, BigInt64Array, BigUint64Array, -]; +].concat(this.Float16Array ?? []); // Use different size classes to catch any implementation-specific // optimisations. @@ -46,6 +46,8 @@ function ToAtomicTA(TA) { return TA; case Uint8ClampedArray: return Uint8Array; + case globalThis.Float16Array: + return Uint16Array; case Float32Array: return Uint32Array; case Float64Array: diff --git a/js/src/tests/non262/TypedArray/subarray-validation.js b/js/src/tests/non262/TypedArray/subarray-validation.js index 4ad8c86095..76ae10fb6f 100644 --- a/js/src/tests/non262/TypedArray/subarray-validation.js +++ b/js/src/tests/non262/TypedArray/subarray-validation.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/js/src/tests/non262/TypedArray/subarray.js b/js/src/tests/non262/TypedArray/subarray.js index a7bfab0efd..7ae41a0c93 100644 --- a/js/src/tests/non262/TypedArray/subarray.js +++ b/js/src/tests/non262/TypedArray/subarray.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Bug 1291003 if (typeof detachArrayBuffer === "function") { for (let constructor of typedArrayConstructors) { diff --git a/js/src/tests/non262/TypedArray/toLocaleString-detached.js b/js/src/tests/non262/TypedArray/toLocaleString-detached.js index 0ba22cc68e..ce0fe3e640 100644 --- a/js/src/tests/non262/TypedArray/toLocaleString-detached.js +++ b/js/src/tests/non262/TypedArray/toLocaleString-detached.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) if (typeof detachArrayBuffer === "function") { const originalNumberToLocaleString = Number.prototype.toLocaleString; diff --git a/js/src/tests/non262/extensions/dataview.js b/js/src/tests/non262/extensions/dataview.js index b6514df26a..17faf8e57b 100644 --- a/js/src/tests/non262/extensions/dataview.js +++ b/js/src/tests/non262/extensions/dataview.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!xulRuntime.shell) +// |reftest| shell-option(--enable-float16array) skip-if(!xulRuntime.shell) /* * Any copyright is dedicated to the Public Domain. * http://creativecommons.org/licenses/publicdomain/ @@ -1638,6 +1638,16 @@ function test(sharedMem) { dv.setInt8(dv.byteLength - 10, 99); assertEq(dv.getInt8(dv.byteLength - 10), 99); + // get/setFloat16 + dv = new DataView(new ArrayBuffer(4)); + if (DataView.prototype.getFloat16) { + dv.setInt16(0, 18688); + assertEq(dv.getFloat16(0), 10); + dv.setFloat16(1, 10); + assertEq(dv.getFloat16(1), 10); + assertEq(dv.getInt16(1), 18688); + } + reportCompare(0, 0, 'done.'); } diff --git a/js/src/tests/non262/extensions/regress-336409-2.js b/js/src/tests/non262/extensions/regress-336409-2.js index 545350150b..c6ba2addcc 100644 --- a/js/src/tests/non262/extensions/regress-336409-2.js +++ b/js/src/tests/non262/extensions/regress-336409-2.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!Object.prototype.toSource||(!xulRuntime.shell&&((Android||(isDebugBuild&&xulRuntime.OS=="Linux")||xulRuntime.XPCOMABI.match(/x86_64/))))) slow -- can fail silently due to out of memory, bug 615011 - timeouts on slow debug Linux +// |reftest| skip-if(!Object.prototype.toSource||(!xulRuntime.shell&&((Android||(isDebugBuild&>kWidget)||is64Bit)))) slow -- can fail silently due to out of memory, bug 615011 - timeouts on slow debug Linux /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/js/src/tests/non262/extensions/regress-336410-2.js b/js/src/tests/non262/extensions/regress-336410-2.js index bd0952e9e6..8690d5f179 100644 --- a/js/src/tests/non262/extensions/regress-336410-2.js +++ b/js/src/tests/non262/extensions/regress-336410-2.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!Object.prototype.toSource||(!xulRuntime.shell&&((isDebugBuild&&xulRuntime.OS=="Linux")||Android||xulRuntime.XPCOMABI.match(/x86_64/)||xulRuntime.OS=="WINNT"))) slow -- can fail silently due to out of memory, bug 621348 - timeouts on slow debug Linux +// |reftest| skip-if(!Object.prototype.toSource||(!xulRuntime.shell&&((isDebugBuild&>kWidget)||Android||is64Bit||winWidget))) slow -- can fail silently due to out of memory, bug 621348 - timeouts on slow debug Linux /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/js/src/tests/non262/extensions/regress-342960.js b/js/src/tests/non262/extensions/regress-342960.js index d7d8f8a0c1..ad6f063d09 100644 --- a/js/src/tests/non262/extensions/regress-342960.js +++ b/js/src/tests/non262/extensions/regress-342960.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!Object.prototype.toSource||(!xulRuntime.shell&&(Android||xulRuntime.OS=="WINNT"||xulRuntime.OS=="Linux"))) silentfail slow -- bug 528464 +// |reftest| skip-if(!Object.prototype.toSource||(!xulRuntime.shell&&(Android||winWidget||gtkWidget))) silentfail slow -- bug 528464 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/js/src/tests/non262/extensions/regress-367589.js b/js/src/tests/non262/extensions/regress-367589.js index 29aa1b61b6..aa11846f20 100644 --- a/js/src/tests/non262/extensions/regress-367589.js +++ b/js/src/tests/non262/extensions/regress-367589.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.shell||(xulRuntime.OS=="WINNT"&&isDebugBuild)) slow +// |reftest| skip-if(xulRuntime.shell||(winWidget&&isDebugBuild)) slow /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/js/src/tests/non262/reflect-parse/declarations.js b/js/src/tests/non262/reflect-parse/declarations.js index 4962f4cee9..b65fda3536 100644 --- a/js/src/tests/non262/reflect-parse/declarations.js +++ b/js/src/tests/non262/reflect-parse/declarations.js @@ -49,11 +49,11 @@ assertDecl("function f(a,[x,y]) { function a() { } }", [ident("a"), arrPatt([assignElem("x"), assignElem("y")])], blockStmt([funDecl(ident("a"), [], blockStmt([]))]))); -// Bug 591450: this test currently crashes because of a bug in jsparse -// assertDecl("function f(a,[x,y],b,[w,z],c) { function b() { } }", -// funDecl(ident("f"), -// [ident("a"), arrPatt([ident("x"), ident("y")]), ident("b"), arrPatt([ident("w"), ident("z")]), ident("c")], -// blockStmt([funDecl(ident("b"), [], blockStmt([]))]))); +// Bug 591450: this test was crashing because of a bug in jsparse +assertDecl("function f(a,[x,y],b,[w,z],c) { function b() { } }", + funDecl(ident("f"), + [ident("a"), arrPatt([ident("x"), ident("y")]), ident("b"), arrPatt([ident("w"), ident("z")]), ident("c")], + blockStmt([funDecl(ident("b"), [], blockStmt([]))]))); // redeclarations (TOK_NAME nodes with lexdef) @@ -61,10 +61,9 @@ assertStmt("function f() { function g() { } function g() { } }", funDecl(ident("f"), [], blockStmt([funDecl(ident("g"), [], blockStmt([])), funDecl(ident("g"), [], blockStmt([]))]))); -// Fails due to parser quirks (bug 638577) -//assertStmt("function f() { function g() { } function g() { return 42 } }", -// funDecl(ident("f"), [], blockStmt([funDecl(ident("g"), [], blockStmt([])), -// funDecl(ident("g"), [], blockStmt([returnStmt(lit(42))]))]))); +assertStmt("function f() { function g() { } function g() { return 42 } }", + funDecl(ident("f"), [], blockStmt([funDecl(ident("g"), [], blockStmt([])), + funDecl(ident("g"), [], blockStmt([returnStmt(lit(42))]))]))); assertStmt("function f() { var x = 42; var x = 43; }", funDecl(ident("f"), [], blockStmt([varDecl([{ id: ident("x"), init: lit(42) }]), diff --git a/js/src/tests/non262/regress/regress-314401.js b/js/src/tests/non262/regress/regress-314401.js index e6a9b8f863..4d73ca439c 100644 --- a/js/src/tests/non262/regress/regress-314401.js +++ b/js/src/tests/non262/regress/regress-314401.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.shell||(xulRuntime.OS=="WINNT"&&isDebugBuild)) slow +// |reftest| skip-if(xulRuntime.shell||(winWidget&&isDebugBuild)) slow /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/js/src/tests/non262/regress/regress-341360.js b/js/src/tests/non262/regress/regress-341360.js index 1ff7192dda..aba2af501e 100644 --- a/js/src/tests/non262/regress/regress-341360.js +++ b/js/src/tests/non262/regress/regress-341360.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.shell||(xulRuntime.OS=="WINNT"&&isDebugBuild)) slow +// |reftest| skip-if(xulRuntime.shell||(winWidget&&isDebugBuild)) slow /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/js/src/tests/non262/regress/regress-351116.js b/js/src/tests/non262/regress/regress-351116.js index 477457735a..a645bd0bb0 100644 --- a/js/src/tests/non262/regress/regress-351116.js +++ b/js/src/tests/non262/regress/regress-351116.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.OS=="Linux"&&!xulRuntime.shell&&!xulRuntime.XPCOMABI.match(/x86_64/)&&isDebugBuild) -- bug 521549 +// |reftest| skip-if(gtkWidget&&!xulRuntime.shell&&!is64Bit&&isDebugBuild) -- bug 521549 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/js/src/tests/non262/regress/regress-418540.js b/js/src/tests/non262/regress/regress-418540.js index 855ec1e593..ff473ee9fd 100644 --- a/js/src/tests/non262/regress/regress-418540.js +++ b/js/src/tests/non262/regress/regress-418540.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.shell||(xulRuntime.OS=="WINNT"&&isDebugBuild)) slow +// |reftest| skip-if(xulRuntime.shell||(winWidget&&isDebugBuild)) slow /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/js/src/tests/non262/regress/regress-422348.js b/js/src/tests/non262/regress/regress-422348.js index 9a35e22d6a..7be60ba9f2 100644 --- a/js/src/tests/non262/regress/regress-422348.js +++ b/js/src/tests/non262/regress/regress-422348.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.XPCOMABI.match(/x86_64|aarch64|ppc64|ppc64le|s390x|mips64|loongarch64|riscv64/)) -- On 64-bit, takes forever rather than throwing +// |reftest| skip-if(is64Bit) -- On 64-bit, takes forever rather than throwing /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/js/src/tests/non262/regress/regress-425360.js b/js/src/tests/non262/regress/regress-425360.js index 6daf871022..f21dfc2843 100644 --- a/js/src/tests/non262/regress/regress-425360.js +++ b/js/src/tests/non262/regress/regress-425360.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(xulRuntime.shell||(xulRuntime.OS=="WINNT"&&isDebugBuild)) slow +// |reftest| skip-if(xulRuntime.shell||(winWidget&&isDebugBuild)) slow /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/js/src/tests/shell/os.js b/js/src/tests/shell/os.js index 06e08f683b..3ac3314320 100644 --- a/js/src/tests/shell/os.js +++ b/js/src/tests/shell/os.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!xulRuntime.shell||xulRuntime.OS=="WINNT") +// |reftest| skip-if(!xulRuntime.shell||winWidget) /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Any copyright is dedicated to the Public Domain. diff --git a/js/src/tests/test/expected/export/multi-header.js b/js/src/tests/test/expected/export/multi-header.js index 477395713d..ea6c25ca88 100644 --- a/js/src/tests/test/expected/export/multi-header.js +++ b/js/src/tests/test/expected/export/multi-header.js @@ -2,21 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -info: | - foo bar baz +author: Jeff Walden <jwalden+code@mit.edu> +esid: sec-let-and-const-declarations description: | Outside AsyncFunction, |await| is a perfectly cromulent LexicalDeclaration variable name. Therefore ASI doesn't apply, and so the |0| where a |=| was expected is a syntax error. -author: Jeff Walden <jwalden+code@mit.edu> negative: phase: early type: SyntaxError -flags: -- module -esid: sec-let-and-const-declarations features: - foobar +flags: +- module +info: | + foo bar baz ---*/ function f() { diff --git a/js/src/tests/test/expected/export/reftest-and-frontmatter-error.js b/js/src/tests/test/expected/export/reftest-and-frontmatter-error.js index 4966385662..8394ec7e51 100644 --- a/js/src/tests/test/expected/export/reftest-and-frontmatter-error.js +++ b/js/src/tests/test/expected/export/reftest-and-frontmatter-error.js @@ -1,17 +1,16 @@ // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. - /*--- esid: sec-let-and-const-declarations -features: [] -negative: - phase: runtime - type: SyntaxError description: | Outside AsyncFunction, |await| is a perfectly cromulent LexicalDeclaration variable name. Therefore ASI doesn't apply, and so the |0| where a |=| was expected is a syntax error. +negative: + phase: runtime + type: SyntaxError +features: [] ---*/ eval(` diff --git a/js/src/tests/test/expected/export/reftest-error-syntaxerror.js b/js/src/tests/test/expected/export/reftest-error-syntaxerror.js index 5cd5759f66..163c5b8a4d 100644 --- a/js/src/tests/test/expected/export/reftest-error-syntaxerror.js +++ b/js/src/tests/test/expected/export/reftest-error-syntaxerror.js @@ -1,18 +1,17 @@ // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. - /*--- -negative: - phase: early - type: SyntaxError author: Jeff Walden <jwalden+code@mit.edu> -features: [] +esid: sec-let-and-const-declarations description: | Outside AsyncFunction, |await| is a perfectly cromulent LexicalDeclaration variable name. Therefore ASI doesn't apply, and so the |0| where a |=| was expected is a syntax error. -esid: sec-let-and-const-declarations +features: [] +negative: + phase: early + type: SyntaxError ---*/ function f() { diff --git a/js/src/tests/test/expected/export/regular.js b/js/src/tests/test/expected/export/regular.js index b920a66a3c..4541ef37e5 100644 --- a/js/src/tests/test/expected/export/regular.js +++ b/js/src/tests/test/expected/export/regular.js @@ -3,11 +3,11 @@ /*--- author: Jeff Walden <jwalden+code@mit.edu> +esid: sec-let-and-const-declarations description: | '|await| is excluded from LexicalDeclaration by grammar parameter, in AsyncFunction. Therefore |let| followed by |await| inside AsyncFunction is an ASI opportunity, and this code must parse without error.' -esid: sec-let-and-const-declarations ---*/ async function f() { diff --git a/js/src/tests/test/expected/import/files/local/smTempBranch/language/export/escaped-foobarbaz.js b/js/src/tests/test/expected/import/files/local/smTempBranch/language/export/escaped-foobarbaz.js index 8f923637f3..f8a2afd775 100644 --- a/js/src/tests/test/expected/import/files/local/smTempBranch/language/export/escaped-foobarbaz.js +++ b/js/src/tests/test/expected/import/files/local/smTempBranch/language/export/escaped-foobarbaz.js @@ -6,8 +6,8 @@ esid: sec-grammar-notation description: > The `default` keyword must not contain Unicode escape sequences. -info: > - Terminal symbols of the lexical, RegExp, and numeric string grammars are shown +info: | + Terminal symbols are shown in fixed width font, both in the productions of the grammars and throughout this specification whenever the text directly refers to such a terminal symbol. These are to appear in a script exactly as written. All terminal symbol code points @@ -15,11 +15,11 @@ info: > from the Basic Latin range, as opposed to any similar-looking code points from other Unicode ranges. negative: - phase: early + phase: parse type: SyntaxError flags: [module] ---*/ -throw "Test262: This statement should not be evaluated."; +$DONOTEVALUATE(); export d\u0065fault 0; diff --git a/js/src/tests/test/expected/import/files/local/smTempBranch/shell.js b/js/src/tests/test/expected/import/files/local/smTempBranch/shell.js index ee1cf95742..9adb7aa914 100644 --- a/js/src/tests/test/expected/import/files/local/smTempBranch/shell.js +++ b/js/src/tests/test/expected/import/files/local/smTempBranch/shell.js @@ -1,20 +1,23 @@ +// GENERATED, DO NOT EDIT // file: assert.js // Copyright (C) 2017 Ecma International. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- description: | Collection of assertion functions used throughout test262 +defines: [assert] ---*/ + function assert(mustBeTrue, message) { if (mustBeTrue === true) { return; } if (message === undefined) { - message = 'Expected true but got ' + String(mustBeTrue); + message = 'Expected true but got ' + assert._toString(mustBeTrue); } - $ERROR(message); + throw new Test262Error(message); } assert._isSameValue = function (a, b) { @@ -28,7 +31,12 @@ assert._isSameValue = function (a, b) { }; assert.sameValue = function (actual, expected, message) { - if (assert._isSameValue(actual, expected)) { + try { + if (assert._isSameValue(actual, expected)) { + return; + } + } catch (error) { + throw new Test262Error(message + ' (_isSameValue operation threw) ' + error); return; } @@ -38,9 +46,9 @@ assert.sameValue = function (actual, expected, message) { message += ' '; } - message += 'Expected SameValue(«' + String(actual) + '», «' + String(expected) + '») to be true'; + message += 'Expected SameValue(«' + assert._toString(actual) + '», «' + assert._toString(expected) + '») to be true'; - $ERROR(message); + throw new Test262Error(message); }; assert.notSameValue = function (actual, unexpected, message) { @@ -54,14 +62,15 @@ assert.notSameValue = function (actual, unexpected, message) { message += ' '; } - message += 'Expected SameValue(«' + String(actual) + '», «' + String(unexpected) + '») to be false'; + message += 'Expected SameValue(«' + assert._toString(actual) + '», «' + assert._toString(unexpected) + '») to be false'; - $ERROR(message); + throw new Test262Error(message); }; assert.throws = function (expectedErrorConstructor, func, message) { + var expectedName, actualName; if (typeof func !== "function") { - $ERROR('assert.throws requires two arguments: the error constructor ' + + throw new Test262Error('assert.throws requires two arguments: the error constructor ' + 'and a function to run'); return; } @@ -76,23 +85,38 @@ assert.throws = function (expectedErrorConstructor, func, message) { } catch (thrown) { if (typeof thrown !== 'object' || thrown === null) { message += 'Thrown value was not an object!'; - $ERROR(message); + throw new Test262Error(message); } else if (thrown.constructor !== expectedErrorConstructor) { - message += 'Expected a ' + expectedErrorConstructor.name + ' but got a ' + thrown.constructor.name; - $ERROR(message); + expectedName = expectedErrorConstructor.name; + actualName = thrown.constructor.name; + if (expectedName === actualName) { + message += 'Expected a ' + expectedName + ' but got a different error constructor with the same name'; + } else { + message += 'Expected a ' + expectedName + ' but got a ' + actualName; + } + throw new Test262Error(message); } return; } message += 'Expected a ' + expectedErrorConstructor.name + ' to be thrown but no exception was thrown at all'; - $ERROR(message); + throw new Test262Error(message); }; -assert.throws.early = function(err, code) { - let wrappedCode = `function wrapperFn() { ${code} }`; - let ieval = eval; +assert._toString = function (value) { + try { + if (value === 0 && 1 / value === -Infinity) { + return '-0'; + } + + return String(value); + } catch (err) { + if (err.name === 'TypeError') { + return Object.prototype.toString.call(value); + } - assert.throws(err, () => { Function(wrappedCode); }, `Function: ${code}`); + throw err; + } }; // file: compareArray.js @@ -101,6 +125,7 @@ assert.throws.early = function(err, code) { /*--- description: | Compare the contents of two arrays +defines: [compareArray] ---*/ function compareArray(a, b) { @@ -109,16 +134,41 @@ function compareArray(a, b) { } for (var i = 0; i < a.length; i++) { - if (b[i] !== a[i]) { + if (!compareArray.isSameValue(b[i], a[i])) { return false; } } return true; } +compareArray.isSameValue = function(a, b) { + if (a === 0 && b === 0) return 1 / a === 1 / b; + if (a !== a && b !== b) return true; + + return a === b; +}; + +compareArray.format = function(arrayLike) { + return `[${[].map.call(arrayLike, String).join(', ')}]`; +}; + assert.compareArray = function(actual, expected, message) { - assert(compareArray(actual, expected), - `Expected [${actual.join(", ")}] and [${expected.join(", ")}] to have the same contents. ${message}`); + message = message === undefined ? '' : message; + + if (typeof message === 'symbol') { + message = message.toString(); + } + + assert(actual != null, `First argument shouldn't be nullish. ${message}`); + assert(expected != null, `Second argument shouldn't be nullish. ${message}`); + var format = compareArray.format; + var result = compareArray(actual, expected); + + // The following prevents actual and expected from being iterated and evaluated + // more than once unless absolutely necessary. + if (!result) { + assert(false, `Expected ${format(actual)} and ${format(expected)} to have the same contents. ${message}`); + } }; // file: propertyHelper.js @@ -128,8 +178,26 @@ assert.compareArray = function(actual, expected, message) { description: | Collection of functions used to safely verify the correctness of property descriptors. +defines: + - verifyProperty + - verifyEqualTo # deprecated + - verifyWritable # deprecated + - verifyNotWritable # deprecated + - verifyEnumerable # deprecated + - verifyNotEnumerable # deprecated + - verifyConfigurable # deprecated + - verifyNotConfigurable # deprecated ---*/ +// @ts-check + +/** + * @param {object} obj + * @param {string|symbol} name + * @param {PropertyDescriptor|undefined} desc + * @param {object} [options] + * @param {boolean} [options.restore] + */ function verifyProperty(obj, name, desc, options) { assert( arguments.length > 2, @@ -144,7 +212,7 @@ function verifyProperty(obj, name, desc, options) { assert.sameValue( originalDesc, undefined, - `obj['${nameStr}'] descriptor should be undefined` + "obj['" + nameStr + "'] descriptor should be undefined" ); // desc and originalDesc are both undefined, problem solved; @@ -153,51 +221,67 @@ function verifyProperty(obj, name, desc, options) { assert( Object.prototype.hasOwnProperty.call(obj, name), - `obj should have an own property ${nameStr}` + "obj should have an own property " + nameStr ); assert.notSameValue( desc, null, - `The desc argument should be an object or undefined, null` + "The desc argument should be an object or undefined, null" ); assert.sameValue( typeof desc, "object", - `The desc argument should be an object or undefined, ${String(desc)}` + "The desc argument should be an object or undefined, " + String(desc) ); + var names = Object.getOwnPropertyNames(desc); + for (var i = 0; i < names.length; i++) { + assert( + names[i] === "value" || + names[i] === "writable" || + names[i] === "enumerable" || + names[i] === "configurable" || + names[i] === "get" || + names[i] === "set", + "Invalid descriptor field: " + names[i], + ); + } + var failures = []; if (Object.prototype.hasOwnProperty.call(desc, 'value')) { - if (desc.value !== originalDesc.value) { - failures.push(`descriptor value should be ${desc.value}`); + if (!isSameValue(desc.value, originalDesc.value)) { + failures.push("descriptor value should be " + desc.value); + } + if (!isSameValue(desc.value, obj[name])) { + failures.push("object value should be " + desc.value); } } if (Object.prototype.hasOwnProperty.call(desc, 'enumerable')) { if (desc.enumerable !== originalDesc.enumerable || desc.enumerable !== isEnumerable(obj, name)) { - failures.push(`descriptor should ${desc.enumerable ? '' : 'not '}be enumerable`); + failures.push('descriptor should ' + (desc.enumerable ? '' : 'not ') + 'be enumerable'); } } if (Object.prototype.hasOwnProperty.call(desc, 'writable')) { if (desc.writable !== originalDesc.writable || desc.writable !== isWritable(obj, name)) { - failures.push(`descriptor should ${desc.writable ? '' : 'not '}be writable`); + failures.push('descriptor should ' + (desc.writable ? '' : 'not ') + 'be writable'); } } if (Object.prototype.hasOwnProperty.call(desc, 'configurable')) { if (desc.configurable !== originalDesc.configurable || desc.configurable !== isConfigurable(obj, name)) { - failures.push(`descriptor should ${desc.configurable ? '' : 'not '}be configurable`); + failures.push('descriptor should ' + (desc.configurable ? '' : 'not ') + 'be configurable'); } } - assert.sameValue(failures.length, 0, failures.join('; ')); + assert(!failures.length, failures.join('; ')); if (options && options.restore) { Object.defineProperty(obj, name, originalDesc); @@ -207,14 +291,15 @@ function verifyProperty(obj, name, desc, options) { } function isConfigurable(obj, name) { + var hasOwnProperty = Object.prototype.hasOwnProperty; try { delete obj[name]; } catch (e) { if (!(e instanceof TypeError)) { - $ERROR("Expected TypeError, got " + e); + throw new Test262Error("Expected TypeError, got " + e); } } - return !Object.prototype.hasOwnProperty.call(obj, name); + return !hasOwnProperty.call(obj, name); } function isEnumerable(obj, name) { @@ -237,14 +322,19 @@ function isEnumerable(obj, name) { Object.prototype.propertyIsEnumerable.call(obj, name); } -function isEqualTo(obj, name, expectedValue) { - var actualValue = obj[name]; +function isSameValue(a, b) { + if (a === 0 && b === 0) return 1 / a === 1 / b; + if (a !== a && b !== b) return true; - return assert._isSameValue(actualValue, expectedValue); + return a === b; } +var __isArray = Array.isArray; function isWritable(obj, name, verifyProp, value) { - var newValue = value || "unlikelyValue"; + var unlikelyValue = __isArray(obj) && name === "length" ? + Math.pow(2, 32) - 1 : + "unlikelyValue"; + var newValue = value || unlikelyValue; var hadValue = Object.prototype.hasOwnProperty.call(obj, name); var oldValue = obj[name]; var writeSucceeded; @@ -253,82 +343,103 @@ function isWritable(obj, name, verifyProp, value) { obj[name] = newValue; } catch (e) { if (!(e instanceof TypeError)) { - $ERROR("Expected TypeError, got " + e); + throw new Test262Error("Expected TypeError, got " + e); } } - writeSucceeded = isEqualTo(obj, verifyProp || name, newValue); + writeSucceeded = isSameValue(obj[verifyProp || name], newValue); // Revert the change only if it was successful (in other cases, reverting // is unnecessary and may trigger exceptions for certain property // configurations) if (writeSucceeded) { if (hadValue) { - obj[name] = oldValue; + obj[name] = oldValue; } else { - delete obj[name]; + delete obj[name]; } } return writeSucceeded; } +/** + * Deprecated; please use `verifyProperty` in new tests. + */ function verifyEqualTo(obj, name, value) { - if (!isEqualTo(obj, name, value)) { - $ERROR("Expected obj[" + String(name) + "] to equal " + value + + if (!isSameValue(obj[name], value)) { + throw new Test262Error("Expected obj[" + String(name) + "] to equal " + value + ", actually " + obj[name]); } } +/** + * Deprecated; please use `verifyProperty` in new tests. + */ function verifyWritable(obj, name, verifyProp, value) { if (!verifyProp) { assert(Object.getOwnPropertyDescriptor(obj, name).writable, "Expected obj[" + String(name) + "] to have writable:true."); } if (!isWritable(obj, name, verifyProp, value)) { - $ERROR("Expected obj[" + String(name) + "] to be writable, but was not."); + throw new Test262Error("Expected obj[" + String(name) + "] to be writable, but was not."); } } +/** + * Deprecated; please use `verifyProperty` in new tests. + */ function verifyNotWritable(obj, name, verifyProp, value) { if (!verifyProp) { assert(!Object.getOwnPropertyDescriptor(obj, name).writable, "Expected obj[" + String(name) + "] to have writable:false."); } if (isWritable(obj, name, verifyProp)) { - $ERROR("Expected obj[" + String(name) + "] NOT to be writable, but was."); + throw new Test262Error("Expected obj[" + String(name) + "] NOT to be writable, but was."); } } +/** + * Deprecated; please use `verifyProperty` in new tests. + */ function verifyEnumerable(obj, name) { assert(Object.getOwnPropertyDescriptor(obj, name).enumerable, "Expected obj[" + String(name) + "] to have enumerable:true."); if (!isEnumerable(obj, name)) { - $ERROR("Expected obj[" + String(name) + "] to be enumerable, but was not."); + throw new Test262Error("Expected obj[" + String(name) + "] to be enumerable, but was not."); } } +/** + * Deprecated; please use `verifyProperty` in new tests. + */ function verifyNotEnumerable(obj, name) { assert(!Object.getOwnPropertyDescriptor(obj, name).enumerable, "Expected obj[" + String(name) + "] to have enumerable:false."); if (isEnumerable(obj, name)) { - $ERROR("Expected obj[" + String(name) + "] NOT to be enumerable, but was."); + throw new Test262Error("Expected obj[" + String(name) + "] NOT to be enumerable, but was."); } } +/** + * Deprecated; please use `verifyProperty` in new tests. + */ function verifyConfigurable(obj, name) { assert(Object.getOwnPropertyDescriptor(obj, name).configurable, "Expected obj[" + String(name) + "] to have configurable:true."); if (!isConfigurable(obj, name)) { - $ERROR("Expected obj[" + String(name) + "] to be configurable, but was not."); + throw new Test262Error("Expected obj[" + String(name) + "] to be configurable, but was not."); } } +/** + * Deprecated; please use `verifyProperty` in new tests. + */ function verifyNotConfigurable(obj, name) { assert(!Object.getOwnPropertyDescriptor(obj, name).configurable, "Expected obj[" + String(name) + "] to have configurable:false."); if (isConfigurable(obj, name)) { - $ERROR("Expected obj[" + String(name) + "] NOT to be configurable, but was."); + throw new Test262Error("Expected obj[" + String(name) + "] NOT to be configurable, but was."); } } @@ -341,6 +452,7 @@ description: | - An error class to avoid false positives when testing for thrown exceptions - A function to explicitly throw an exception using the Test262Error class +defines: [Test262Error, $DONOTEVALUATE] ---*/ @@ -352,11 +464,14 @@ Test262Error.prototype.toString = function () { return "Test262Error: " + this.message; }; -var $ERROR; -$ERROR = function $ERROR(message) { +Test262Error.thrower = function (message) { throw new Test262Error(message); }; +function $DONOTEVALUATE() { + throw "Test262: This statement should not be evaluated."; +} + // file: test262-host.js // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -364,18 +479,36 @@ $ERROR = function $ERROR(message) { // https://github.com/tc39/test262/blob/main/INTERPRETING.md#host-defined-functions ;(function createHostObject(global) { + "use strict"; + + // Save built-in functions and constructors. var FunctionToString = global.Function.prototype.toString; var ReflectApply = global.Reflect.apply; - var NewGlobal = global.newGlobal; var Atomics = global.Atomics; + var Error = global.Error; var SharedArrayBuffer = global.SharedArrayBuffer; var Int32Array = global.Int32Array; + + // Save built-in shell functions. + var NewGlobal = global.newGlobal; var setSharedArrayBuffer = global.setSharedArrayBuffer; var getSharedArrayBuffer = global.getSharedArrayBuffer; var evalInWorker = global.evalInWorker; + var monotonicNow = global.monotonicNow; + var gc = global.gc; + var clearKeptObjects = global.clearKeptObjects; + + var hasCreateIsHTMLDDA = "createIsHTMLDDA" in global; var hasThreads = ("helperThreadCount" in global ? global.helperThreadCount() > 0 : true); - var hasMailbox = typeof setSharedArrayBuffer == "function" && typeof getSharedArrayBuffer == "function"; - var hasEvalInWorker = typeof evalInWorker == "function"; + var hasMailbox = typeof setSharedArrayBuffer === "function" && typeof getSharedArrayBuffer === "function"; + var hasEvalInWorker = typeof evalInWorker === "function"; + + if (!hasCreateIsHTMLDDA && !("document" in global && "all" in global.document)) + throw new Error("no [[IsHTMLDDA]] object available for testing"); + + var IsHTMLDDA = hasCreateIsHTMLDDA + ? global.createIsHTMLDDA() + : global.document.all; // The $262.agent framework is not appropriate for browsers yet, and some // test cases can't work in browsers (they block the main thread). @@ -394,6 +527,13 @@ $ERROR = function $ERROR(message) { detachArrayBuffer: global.detachArrayBuffer, evalScript: global.evaluateScript || global.evaluate, global, + IsHTMLDDA, + gc() { + gc(); + }, + clearKeptObjects() { + clearKeptObjects(); + }, agent: (function () { // SpiderMonkey complication: With run-time argument --no-threads @@ -407,19 +547,23 @@ $ERROR = function $ERROR(message) { // being run at all. if (!sabTestable) { + let {reportCompare, quit} = global; + + function notAvailable() { + // See comment above. + if (!hasThreads && shellCode) { + reportCompare(0, 0); + quit(0); + } + throw new Error("Agents not available"); + } + return { - _notAvailable() { - // See comment above. - if (!hasThreads && shellCode) { - global.reportCompare(0,0); - global.quit(0); - } - throw new Error("Agents not available"); - }, - start(script) { this._notAvailable() }, - broadcast(sab, id) { this._notAvailable() }, - getReport() { this._notAvailable() }, - sleep(s) { this._notAvailable() } + start(script) { notAvailable() }, + broadcast(sab, id) { notAvailable() }, + getReport() { notAvailable() }, + sleep(s) { notAvailable() }, + monotonicNow, } } @@ -442,102 +586,110 @@ $ERROR = function $ERROR(message) { var _worker_prefix = // BEGIN WORKER PREFIX -`if (typeof $262 == 'undefined') +`if (typeof $262 === 'undefined') $262 = {}; -$262.agent = (function () { +$262.agent = (function (global) { + var ReflectApply = global.Reflect.apply; + var StringCharCodeAt = global.String.prototype.charCodeAt; + var { + add: Atomics_add, + compareExchange: Atomics_compareExchange, + load: Atomics_load, + store: Atomics_store, + wait: Atomics_wait, + } = global.Atomics; + + var {getSharedArrayBuffer} = global; + var _ia = new Int32Array(getSharedArrayBuffer()); var agent = { receiveBroadcast(receiver) { var k; - while (((k = Atomics.load(_ia, ${_MSG_LOC})) & 1) == 0) + while (((k = Atomics_load(_ia, ${_MSG_LOC})) & 1) === 0) ; var received_sab = getSharedArrayBuffer(); - var received_id = Atomics.load(_ia, ${_ID_LOC}); - Atomics.add(_ia, ${_ACK_LOC}, 1); - while (Atomics.load(_ia, ${_MSG_LOC}) == k) + var received_id = Atomics_load(_ia, ${_ID_LOC}); + Atomics_add(_ia, ${_ACK_LOC}, 1); + while (Atomics_load(_ia, ${_MSG_LOC}) === k) ; receiver(received_sab, received_id); }, report(msg) { - while (Atomics.compareExchange(_ia, ${_LOCKTXT_LOC}, 0, 1) == 1) + while (Atomics_compareExchange(_ia, ${_LOCKTXT_LOC}, 0, 1) === 1) ; msg = "" + msg; var i = _ia[${_NEXT_LOC}]; _ia[i++] = msg.length; for ( let j=0 ; j < msg.length ; j++ ) - _ia[i++] = msg.charCodeAt(j); + _ia[i++] = ReflectApply(StringCharCodeAt, msg, [j]); _ia[${_NEXT_LOC}] = i; - Atomics.add(_ia, ${_NUMTXT_LOC}, 1); - Atomics.store(_ia, ${_LOCKTXT_LOC}, 0); + Atomics_add(_ia, ${_NUMTXT_LOC}, 1); + Atomics_store(_ia, ${_LOCKTXT_LOC}, 0); }, sleep(s) { - Atomics.wait(_ia, ${_SLEEP_LOC}, 0, s); + Atomics_wait(_ia, ${_SLEEP_LOC}, 0, s); }, - leaving() {} + leaving() {}, + + monotonicNow: global.monotonicNow, }; - Atomics.add(_ia, ${_RDY_LOC}, 1); + Atomics_add(_ia, ${_RDY_LOC}, 1); return agent; -})();`; +})(this);`; // END WORKER PREFIX - return { - _numWorkers: 0, - _numReports: 0, - _reportPtr: _FIRST, - - _bailIfNotAvailable() { - if (!sabTestable) { - // See comment above. - if (!hasThreads && shellCode) { - global.reportCompare(0,0); - global.quit(0); - } - throw new Error("Agents not available"); - } - }, + var _numWorkers = 0; + var _numReports = 0; + var _reportPtr = _FIRST; + var { + add: Atomics_add, + load: Atomics_load, + store: Atomics_store, + wait: Atomics_wait, + } = Atomics; + var StringFromCharCode = global.String.fromCharCode; + return { start(script) { - this._bailIfNotAvailable(); setSharedArrayBuffer(_ia.buffer); - var oldrdy = Atomics.load(_ia, _RDY_LOC); + var oldrdy = Atomics_load(_ia, _RDY_LOC); evalInWorker(_worker_prefix + script); - while (Atomics.load(_ia, _RDY_LOC) == oldrdy) + while (Atomics_load(_ia, _RDY_LOC) === oldrdy) ; - this._numWorkers++; + _numWorkers++; }, broadcast(sab, id) { - this._bailIfNotAvailable(); setSharedArrayBuffer(sab); - Atomics.store(_ia, _ID_LOC, id); - Atomics.store(_ia, _ACK_LOC, 0); - Atomics.add(_ia, _MSG_LOC, 1); - while (Atomics.load(_ia, _ACK_LOC) < this._numWorkers) + Atomics_store(_ia, _ID_LOC, id); + Atomics_store(_ia, _ACK_LOC, 0); + Atomics_add(_ia, _MSG_LOC, 1); + while (Atomics_load(_ia, _ACK_LOC) < _numWorkers) ; - Atomics.add(_ia, _MSG_LOC, 1); + Atomics_add(_ia, _MSG_LOC, 1); }, getReport() { - this._bailIfNotAvailable(); - if (this._numReports == Atomics.load(_ia, _NUMTXT_LOC)) + if (_numReports === Atomics_load(_ia, _NUMTXT_LOC)) return null; var s = ""; - var i = this._reportPtr; + var i = _reportPtr; var len = _ia[i++]; for ( let j=0 ; j < len ; j++ ) - s += String.fromCharCode(_ia[i++]); - this._reportPtr = i; - this._numReports++; + s += StringFromCharCode(_ia[i++]); + _reportPtr = i; + _numReports++; return s; }, sleep(s) { - this._bailIfNotAvailable(); - Atomics.wait(_ia, _SLEEP_LOC, 0, s); + Atomics_wait(_ia, _SLEEP_LOC, 0, s); }, + + monotonicNow, }; })() }; @@ -558,4 +710,14 @@ function $DONE(failure) { reportFailure(failure); else reportCompare(0, 0); + + if (typeof jsTestDriverEnd === "function") { + gDelayTestDriverEnd = false; + jsTestDriverEnd(); + } +} + +// Some tests in test262 leave promise rejections unhandled. +if ("ignoreUnhandledRejections" in this) { + ignoreUnhandledRejections(); } diff --git a/js/src/tests/test/expected/import/files/local/smTempBranch/temp42/bar.js b/js/src/tests/test/expected/import/files/local/smTempBranch/temp42/bar.js index c22331fd51..210c610046 100644 --- a/js/src/tests/test/expected/import/files/local/smTempBranch/temp42/bar.js +++ b/js/src/tests/test/expected/import/files/local/smTempBranch/temp42/bar.js @@ -1,2 +1,8 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +---*/ reportCompare(0, 0); diff --git a/js/src/tests/test/expected/import/files/local/smTempBranch/temp42/baz.js b/js/src/tests/test/expected/import/files/local/smTempBranch/temp42/baz.js index c22331fd51..210c610046 100644 --- a/js/src/tests/test/expected/import/files/local/smTempBranch/temp42/baz.js +++ b/js/src/tests/test/expected/import/files/local/smTempBranch/temp42/baz.js @@ -1,2 +1,8 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +---*/ reportCompare(0, 0); diff --git a/js/src/tests/test/expected/import/files/local/smTempBranch/temp42/foo.js b/js/src/tests/test/expected/import/files/local/smTempBranch/temp42/foo.js index c22331fd51..210c610046 100644 --- a/js/src/tests/test/expected/import/files/local/smTempBranch/temp42/foo.js +++ b/js/src/tests/test/expected/import/files/local/smTempBranch/temp42/foo.js @@ -1,2 +1,8 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +---*/ reportCompare(0, 0); diff --git a/js/src/tests/test/fixtures/export/reftest-and-frontmatter-error.js b/js/src/tests/test/fixtures/export/reftest-and-frontmatter-error.js index 38e98283d7..4355646c73 100644 --- a/js/src/tests/test/fixtures/export/reftest-and-frontmatter-error.js +++ b/js/src/tests/test/fixtures/export/reftest-and-frontmatter-error.js @@ -1,4 +1,6 @@ // |reftest| error:SyntaxError +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. /*--- esid: sec-let-and-const-declarations diff --git a/js/src/tests/test/fixtures/export/reftest-error-syntaxerror.js b/js/src/tests/test/fixtures/export/reftest-error-syntaxerror.js index 718778ddf7..974369a3b1 100644 --- a/js/src/tests/test/fixtures/export/reftest-error-syntaxerror.js +++ b/js/src/tests/test/fixtures/export/reftest-error-syntaxerror.js @@ -1,4 +1,6 @@ // |reftest| error:SyntaxError +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. /*--- author: Jeff Walden <jwalden+code@mit.edu> diff --git a/js/src/tests/test/fixtures/export/reportCompare.js b/js/src/tests/test/fixtures/export/reportCompare.js index 7b5af60053..3e22e016fb 100644 --- a/js/src/tests/test/fixtures/export/reportCompare.js +++ b/js/src/tests/test/fixtures/export/reportCompare.js @@ -36,3 +36,6 @@ reportCompare( true, true ); + +if (typeof reportCompare === "function") + reportCompare(true, true); diff --git a/js/src/tests/test/fixtures/import/files/bar.js b/js/src/tests/test/fixtures/import/files/bar.js index e69de29bb2..30a528ee66 100644 --- a/js/src/tests/test/fixtures/import/files/bar.js +++ b/js/src/tests/test/fixtures/import/files/bar.js @@ -0,0 +1,6 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +---*/ diff --git a/js/src/tests/test/fixtures/import/files/baz.js b/js/src/tests/test/fixtures/import/files/baz.js index e69de29bb2..30a528ee66 100644 --- a/js/src/tests/test/fixtures/import/files/baz.js +++ b/js/src/tests/test/fixtures/import/files/baz.js @@ -0,0 +1,6 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +---*/ diff --git a/js/src/tests/test/fixtures/import/files/foo.js b/js/src/tests/test/fixtures/import/files/foo.js index e69de29bb2..30a528ee66 100644 --- a/js/src/tests/test/fixtures/import/files/foo.js +++ b/js/src/tests/test/fixtures/import/files/foo.js @@ -0,0 +1,6 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-grammar-notation +---*/ diff --git a/js/src/tests/test/python.toml b/js/src/tests/test/python.toml new file mode 100644 index 0000000000..0be72db2d7 --- /dev/null +++ b/js/src/tests/test/python.toml @@ -0,0 +1,4 @@ +[DEFAULT] +subsuite = "mozbuild" + +["run.py"] diff --git a/js/src/tests/test/run.py b/js/src/tests/test/run.py index a6f7a94932..862045a083 100755 --- a/js/src/tests/test/run.py +++ b/js/src/tests/test/run.py @@ -1,19 +1,23 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Adapted from https://github.com/tc39/test262/blob/main/tools/generation/test/run.py import contextlib import os import shutil import subprocess +import sys import tempfile import unittest -testDir = os.path.dirname(os.path.relpath(__file__)) -OUT_DIR = os.path.join(testDir, "out") +import pytest +from mozunit import main + +testDir = os.path.dirname(os.path.abspath(__file__)) +OUT_DIR = os.path.abspath(os.path.join(testDir, "..", "out")) EXPECTED_DIR = os.path.join(testDir, "expected") ex = os.path.join(testDir, "..", "test262-export.py") importExec = os.path.join(testDir, "..", "test262-update.py") -test262Url = "git://github.com/tc39/test262.git" +test262Url = "https://github.com/tc39/test262.git" @contextlib.contextmanager @@ -29,8 +33,12 @@ class TestExport(unittest.TestCase): maxDiff = None def exportScript(self): - relpath = os.path.relpath(os.path.join(testDir, "fixtures", "export")) - sp = subprocess.Popen([ex, relpath, "--out", OUT_DIR], stdout=subprocess.PIPE) + abspath = os.path.abspath(os.path.join(testDir, "fixtures", "export")) + sp = subprocess.Popen( + [sys.executable, os.path.abspath(ex), abspath, "--out", OUT_DIR], + stdout=subprocess.PIPE, + cwd=os.path.join(testDir, ".."), + ) stdout, stderr = sp.communicate() return dict(stdout=stdout, stderr=stderr, returncode=sp.returncode) @@ -67,56 +75,57 @@ class TestExport(unittest.TestCase): ) # Run import script - print("%s --local %s --out %s" % (importExec, cloneDir, OUT_DIR)) + print( + "%s %s --local %s --out %s" + % (sys.executable, importExec, cloneDir, OUT_DIR) + ) sp = subprocess.Popen( - [importExec, "--local", cloneDir, "--out", OUT_DIR], + [sys.executable, importExec, "--local", cloneDir, "--out", OUT_DIR], stdout=subprocess.PIPE, stderr=subprocess.PIPE, + cwd=os.path.join(testDir, ".."), ) - stdoutdata, _ = sp.communicate() + stdoutdata, stderrdata = sp.communicate() - return stdoutdata, sp.returncode, cloneDir + return stdoutdata, stderrdata, sp.returncode, cloneDir - def isTestFile(self, filename): + def isTestFile(self, filename: str): return not ( filename.startswith(".") or filename.startswith("#") or filename.endswith("~") ) - def getFiles(self, path): - names = [] + def getFiles(self, path: str): + names: list[str] = [] for root, _, fileNames in os.walk(path): for fileName in filter(self.isTestFile, fileNames): names.append(os.path.join(root, fileName)) names.sort() return names - def compareTrees(self, targetName): - expectedPath = os.path.join(EXPECTED_DIR, targetName) - actualPath = OUT_DIR - + def compareTrees(self, expectedPath: str, actualPath: str): expectedFiles = self.getFiles(expectedPath) actualFiles = self.getFiles(actualPath) self.assertListEqual( - map(lambda x: os.path.relpath(x, expectedPath), expectedFiles), - map(lambda x: os.path.relpath(x, actualPath), actualFiles), + [os.path.relpath(x, expectedPath) for x in expectedFiles], + [os.path.relpath(x, actualPath) for x in actualFiles], ) for expectedFile, actualFile in zip(expectedFiles, actualFiles): with open(expectedFile) as expectedHandle: with open(actualFile) as actualHandle: self.assertMultiLineEqual( - expectedHandle.read(), actualHandle.read() + expectedHandle.read(), actualHandle.read(), expectedFile ) - def compareContents(self, output, filePath, folder): - with open(filePath, "rb") as file: + def compareContents(self, output: bytes, filePath: str, folder: str): + with open(filePath, "r") as file: expected = file.read() expected = expected.replace("{{folder}}", folder) - self.assertMultiLineEqual(output, expected) + self.assertMultiLineEqual(output.decode("utf-8"), expected) def tearDown(self): shutil.rmtree(OUT_DIR, ignore_errors=True) @@ -124,16 +133,25 @@ class TestExport(unittest.TestCase): def test_export(self): result = self.exportScript() self.assertEqual(result["returncode"], 0) - self.compareTrees("export") + expectedPath = os.path.join(EXPECTED_DIR, "export") + actualPath = os.path.join(OUT_DIR, "tests", "export") + self.compareTrees(expectedPath, actualPath) + @pytest.mark.skip(reason="test fetches from github") def test_import_local(self): - output, returncode, folder = self.importLocal() + stdoutdata, stderrdata, returncode, folder = self.importLocal() + self.assertEqual(stderrdata, b"") self.assertEqual(returncode, 0) - self.compareTrees(os.path.join("import", "files")) + self.compareTrees( + os.path.join(EXPECTED_DIR, "import", "files", "local"), + os.path.join(OUT_DIR, "local"), + ) self.compareContents( - output, os.path.join(testDir, "expected", "import", "output.txt"), folder + stdoutdata, + os.path.join(testDir, "expected", "import", "output.txt"), + folder, ) if __name__ == "__main__": - unittest.main() + main() diff --git a/js/src/tests/test262-export.py b/js/src/tests/test262-export.py index dc30776973..6c35ed9bc9 100755 --- a/js/src/tests/test262-export.py +++ b/js/src/tests/test262-export.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # This Source Code Form is subject to the terms of the Mozilla Public @@ -9,6 +9,7 @@ import os import re import shutil import sys +from typing import Any, Optional import yaml @@ -26,11 +27,11 @@ SUPPORT_FILES = set( ) FRONTMATTER_WRAPPER_PATTERN = re.compile( - r"/\*\---\n([\s]*)((?:\s|\S)*)[\n\s*]---\*/", flags=re.DOTALL + rb"/\*\---\n([\s]*)((?:\s|\S)*)[\n\s*]---\*/", flags=re.DOTALL ) -def convertTestFile(source, includes): +def convertTestFile(source: bytes, includes: "list[str]") -> bytes: """ Convert a jstest test to a compatible Test262 test file. """ @@ -42,7 +43,7 @@ def convertTestFile(source, includes): return source -def convertReportCompare(source): +def convertReportCompare(source: bytes) -> bytes: """ Captures all the reportCompare and convert them accordingly. @@ -53,35 +54,49 @@ def convertReportCompare(source): equivalent in Test262 """ - def replaceFn(matchobj): - actual = matchobj.group(1) - expected = matchobj.group(2) + def replaceFn(matchobj: "re.Match[bytes]") -> bytes: + actual: bytes = matchobj.group(2) + expected: bytes = matchobj.group(3) - if actual == expected and actual in ["0", "true", "null"]: - return "" + if actual == expected and actual in [b"0", b"true", b"null"]: + return b"" return matchobj.group() newSource = re.sub( - r".*reportCompare\s*\(\s*(\w*)\s*,\s*(\w*)\s*(,\s*\S*)?\s*\)\s*;*\s*", + rb".*(if \(typeof reportCompare === \"function\"\)\s*)?reportCompare\s*\(\s*(\w*)\s*,\s*(\w*)\s*(,\s*\S*)?\s*\)\s*;*\s*", replaceFn, source, ) - return re.sub(r"\breportCompare\b", "assert.sameValue", newSource) + return re.sub(rb"\breportCompare\b", b"assert.sameValue", newSource) -def fetchReftestEntries(reftest): +class ReftestEntry: + def __init__( + self, + features: "list[str]", + error: Optional[str], + module: bool, + info: Optional[str], + ): + self.features: list[str] = features + self.error: Optional[str] = error + self.module: bool = module + self.info: Optional[str] = info + + +def fetchReftestEntries(reftest: str) -> ReftestEntry: """ Collects and stores the entries from the reftest header. """ # TODO: fails, slow, skip, random, random-if - features = [] - error = None - comments = None - module = False + features: list[str] = [] + error: Optional[str] = None + comments: Optional[str] = None + module: bool = False # should capture conditions to skip matchesSkip = re.search(r"skip-if\((.*)\)", reftest) @@ -114,21 +129,22 @@ def fetchReftestEntries(reftest): if matchesComments: comments = matchesComments.group(1) - return {"features": features, "error": error, "module": module, "info": comments} + return ReftestEntry(features=features, error=error, module=module, info=comments) -def parseHeader(source): +def parseHeader(source: bytes) -> "tuple[bytes, Optional[ReftestEntry]]": """ Parse the source to return it with the extracted the header """ from lib.manifest import TEST_HEADER_PATTERN_INLINE # Bail early if we do not start with a single comment. - if not source.startswith("//"): - return (source, {}) + if not source.startswith(b"//"): + return (source, None) # Extract the token. - part, _, _ = source.partition("\n") + part, _, rest = source.partition(b"\n") + part = part.decode("utf-8") matches = TEST_HEADER_PATTERN_INLINE.match(part) if matches and matches.group(0): @@ -136,12 +152,12 @@ def parseHeader(source): # Remove the found header from the source; # Fetch and return the reftest entries - return (source.replace(reftest + "\n", ""), fetchReftestEntries(reftest)) + return (rest, fetchReftestEntries(reftest)) - return (source, {}) + return (source, None) -def extractMeta(source): +def extractMeta(source: bytes) -> "dict[str, Any]": """ Capture the frontmatter metadata as yaml if it exists. Returns a new dict if it doesn't. @@ -153,12 +169,12 @@ def extractMeta(source): indent, frontmatter_lines = match.groups() - unindented = re.sub("^%s" % indent, "", frontmatter_lines) + unindented = re.sub(b"^%s" % indent, b"", frontmatter_lines) return yaml.safe_load(unindented) -def updateMeta(source, includes): +def updateMeta(source: bytes, includes: "list[str]") -> bytes: """ Captures the reftest meta and a pre-existing meta if any and merge them into a single dict. @@ -179,7 +195,7 @@ def updateMeta(source, includes): return insertMeta(source, properData) -def cleanupMeta(meta): +def cleanupMeta(meta: "dict[str, Any]") -> "dict[str, Any]": """ Clean up all the frontmatter meta tags. This is not a lint tool, just a simple cleanup to remove trailing spaces and duplicate entries from lists. @@ -217,7 +233,11 @@ def cleanupMeta(meta): return meta -def mergeMeta(reftest, frontmatter, includes): +def mergeMeta( + reftest: "Optional[ReftestEntry]", + frontmatter: "dict[str, Any]", + includes: "list[str]", +) -> "dict[str, Any]": """ Merge the metadata from reftest and an existing frontmatter and populate required frontmatter fields properly. @@ -225,16 +245,22 @@ def mergeMeta(reftest, frontmatter, includes): # Merge the meta from reftest to the frontmatter - if "features" in reftest: - frontmatter.setdefault("features", []).extend(reftest.get("features", [])) + # Add the shell specific includes + if includes: + frontmatter["includes"] = list(includes) + + if not reftest: + return frontmatter + + frontmatter.setdefault("features", []).extend(reftest.features) # Only add the module flag if the value from reftest is truish - if reftest.get("module"): + if reftest.module: frontmatter.setdefault("flags", []).append("module") # Add any comments to the info tag - info = reftest.get("info") - if info: + if reftest.info: + info = reftest.info # Open some space in an existing info text if "info" in frontmatter: frontmatter["info"] += "\n\n \\%s" % info @@ -242,8 +268,8 @@ def mergeMeta(reftest, frontmatter, includes): frontmatter["info"] = info # Set the negative flags - if "error" in reftest: - error = reftest["error"] + if reftest.error: + error = reftest.error if "negative" not in frontmatter: frontmatter["negative"] = { # This code is assuming error tags are early errors, but they @@ -262,54 +288,50 @@ def mergeMeta(reftest, frontmatter, includes): % (error, frontmatter["negative"]["type"]) ) - # Add the shell specific includes - if includes: - frontmatter["includes"] = list(includes) - return frontmatter -def insertCopyrightLines(source): +def insertCopyrightLines(source: bytes) -> bytes: """ Insert the copyright lines into the file. """ from datetime import date - lines = [] + lines: list[bytes] = [] - if not re.match(r"\/\/\s+Copyright.*\. All rights reserved.", source): + if not re.match(rb"\/\/\s+Copyright.*\. All rights reserved.", source): year = date.today().year lines.append( - "// Copyright (C) %s Mozilla Corporation. All rights reserved." % year + b"// Copyright (C) %d Mozilla Corporation. All rights reserved." % year ) lines.append( - "// This code is governed by the BSD license found in the LICENSE file." + b"// This code is governed by the BSD license found in the LICENSE file." ) - lines.append("\n") + lines.append(b"\n") - return "\n".join(lines) + source + return b"\n".join(lines) + source -def insertMeta(source, frontmatter): +def insertMeta(source: bytes, frontmatter: "dict[str, Any]") -> bytes: """ Insert the formatted frontmatter into the file, use the current existing space if any """ - lines = [] + lines: list[bytes] = [] - lines.append("/*---") + lines.append(b"/*---") for key, value in frontmatter.items(): if key in ("description", "info"): - lines.append("%s: |" % key) + lines.append(b"%s: |" % key.encode("ascii")) lines.append( - " " + b" " + yaml.dump( value, encoding="utf8", ) .strip() - .replace("\n...", "") + .replace(b"\n...", b"") ) else: lines.append( @@ -318,19 +340,19 @@ def insertMeta(source, frontmatter): ).strip() ) - lines.append("---*/") + lines.append(b"---*/") match = FRONTMATTER_WRAPPER_PATTERN.search(source) if match: - return source.replace(match.group(0), "\n".join(lines)) + return source.replace(match.group(0), b"\n".join(lines)) else: - return "\n".join(lines) + source + return b"\n".join(lines) + source -def findAndCopyIncludes(dirPath, baseDir, includeDir): +def findAndCopyIncludes(dirPath: str, baseDir: str, includeDir: str) -> "list[str]": relPath = os.path.relpath(dirPath, baseDir) - includes = [] + includes: list[str] = [] # Recurse down all folders in the relative path until # we reach the base directory of shell.js include files. @@ -365,13 +387,11 @@ def findAndCopyIncludes(dirPath, baseDir, includeDir): return includes -def exportTest262(args): - outDir = os.path.abspath(args.out) - providedSrcs = args.src - includeShell = args.exportshellincludes - baseDir = os.getcwd() - +def exportTest262( + outDir: str, providedSrcs: "list[str]", includeShell: bool, baseDir: str +): # Create the output directory from scratch. + print(f"Generating output in {os.path.abspath(outDir)}") if os.path.isdir(outDir): shutil.rmtree(outDir) @@ -383,6 +403,8 @@ def exportTest262(args): # Go through each source path for providedSrc in providedSrcs: src = os.path.abspath(providedSrc) + if not os.path.isdir(src): + print(f"Did not find directory {src}") # the basename of the path will be used in case multiple "src" arguments # are passed in to create an output directory for each "src". basename = os.path.basename(src) @@ -463,6 +485,7 @@ if __name__ == "__main__": parser.add_argument( "src", nargs="+", help="Source folder with test files to export" ) - parser.set_defaults(func=exportTest262) args = parser.parse_args() - args.func(args) + exportTest262( + os.path.abspath(args.out), args.src, args.exportshellincludes, os.getcwd() + ) diff --git a/js/src/tests/test262-update.py b/js/src/tests/test262-update.py index d45d639ebb..deb4bdaaf4 100755 --- a/js/src/tests/test262-update.py +++ b/js/src/tests/test262-update.py @@ -25,6 +25,8 @@ UNSUPPORTED_FEATURES = set( "legacy-regexp", # Bug 1306461 "regexp-duplicate-named-groups", # Bug 1773135 "set-methods", # Bug 1805038 + "explicit-resource-management", # Bug 1569081 + "regexp-modifiers", ] ) FEATURE_CHECK_NEEDED = { @@ -39,6 +41,7 @@ FEATURE_CHECK_NEEDED = { "resizable-arraybuffer": "!ArrayBuffer.prototype.resize", # Bug 1670026 "uint8array-base64": "!Uint8Array.fromBase64", # Bug 1862220 "json-parse-with-source": "!JSON.hasOwnProperty('isRawJSON')", # Bug 1658310 + "Float16Array": "!this.hasOwnProperty('Float16Array')", } RELEASE_OR_BETA = set( [ @@ -54,6 +57,11 @@ SHELL_OPTIONS = { "resizable-arraybuffer": "--enable-arraybuffer-resizable", "uint8array-base64": "--enable-uint8array-base64", "json-parse-with-source": "--enable-json-parse-with-source", + "Float16Array": "--enable-float16array", +} + +INCLUDE_FEATURE_DETECTED_OPTIONAL_SHELL_OPTIONS = { + "testTypedArray.js": "Float16Array", } @@ -385,6 +393,19 @@ def convertTestFile(test262parser, testSource, testName, includeSet, strictTests ("shell-option({})".format(opt) for opt in sorted(shellOptions)) ) + # Optional shell options. Some tests use feature detection for additional + # test coverage. We want to get this extra coverage without having to skip + # these tests in browser builds. + if "includes" in testRec: + optionalShellOptions = ( + SHELL_OPTIONS[INCLUDE_FEATURE_DETECTED_OPTIONAL_SHELL_OPTIONS[include]] + for include in testRec["includes"] + if include in INCLUDE_FEATURE_DETECTED_OPTIONAL_SHELL_OPTIONS + ) + refTestOptions.extend( + ("shell-option({})".format(opt) for opt in sorted(optionalShellOptions)) + ) + # Includes for every test file in a directory is collected in a single # shell.js file per directory level. This is done to avoid adding all # test harness files to the top level shell.js file. @@ -552,7 +573,11 @@ def process_test262(test262Dir, test262OutDir, strictTests, externManifests): convert = convertFixtureFile(testSource, testName) else: convert = convertTestFile( - test262parser, testSource, testName, includeSet, strictTests + test262parser, + testSource, + testName, + includeSet, + strictTests, ) for newFileName, newSource, externRefTest in convert: @@ -587,7 +612,7 @@ def fetch_local_changes(inDir, outDir, srcDir, strictTests): # TODO: fail if it's in the default branch? or require a branch name? # Checks for unstaged or non committed files. A clean branch provides a clean status. status = subprocess.check_output( - ("git -C %s status --porcelain" % srcDir).split(" ") + ("git -C %s status --porcelain" % srcDir).split(" "), encoding="utf-8" ) if status.strip(): @@ -598,31 +623,35 @@ def fetch_local_changes(inDir, outDir, srcDir, strictTests): # Captures the branch name to be used on the output branchName = subprocess.check_output( - ("git -C %s rev-parse --abbrev-ref HEAD" % srcDir).split(" ") + ("git -C %s rev-parse --abbrev-ref HEAD" % srcDir).split(" "), encoding="utf-8" ).split("\n")[0] # Fetches the file names to import files = subprocess.check_output( - ("git -C %s diff main --diff-filter=ACMR --name-only" % srcDir).split(" ") + ("git -C %s diff main --diff-filter=ACMR --name-only" % srcDir).split(" "), + encoding="utf-8", ) # Fetches the deleted files to print an output log. This can be used to # set up the skip list, if necessary. deletedFiles = subprocess.check_output( - ("git -C %s diff main --diff-filter=D --name-only" % srcDir).split(" ") + ("git -C %s diff main --diff-filter=D --name-only" % srcDir).split(" "), + encoding="utf-8", ) # Fetches the modified files as well for logging to support maintenance # in the skip list. modifiedFiles = subprocess.check_output( - ("git -C %s diff main --diff-filter=M --name-only" % srcDir).split(" ") + ("git -C %s diff main --diff-filter=M --name-only" % srcDir).split(" "), + encoding="utf-8", ) # Fetches the renamed files for the same reason, this avoids duplicate # tests if running the new local folder and the general imported Test262 # files. renamedFiles = subprocess.check_output( - ("git -C %s diff main --diff-filter=R --summary" % srcDir).split(" ") + ("git -C %s diff main --diff-filter=R --summary" % srcDir).split(" "), + encoding="utf-8", ) # Print some friendly output diff --git a/js/src/tests/test262/GIT-INFO b/js/src/tests/test262/GIT-INFO index 0173bbb3c4..7798b62c2a 100644 --- a/js/src/tests/test262/GIT-INFO +++ b/js/src/tests/test262/GIT-INFO @@ -1,9 +1,5 @@ -commit 584048ed081d85f5eed6e884a7b40b6f4bcd67d7 -Author: Nicolò Ribaudo <nribaudo@igalia.com> -Date: Tue Jan 30 16:53:17 2024 +0100 +commit 79e9b39f3a576154b1bc39f9dbd95d25addc4ebf +Author: Emmanuel Ferdman <emmanuelferdman@gmail.com> +Date: Sun Apr 14 01:49:16 2024 +0300 - Add additional tests for out-of-range date-times - - - https://github.com/tc39/proposal-temporal/pull/2727#discussion_r1414066610 - - https://github.com/tc39/proposal-temporal/pull/2727#discussion_r1414065876 - - https://github.com/tc39/proposal-temporal/pull/2727#discussion_r1414067272 + Update the location of `2nd-param-non-object.js` diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/not-a-constructor.js index a3936a335e..5e62df950e 100644 --- a/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/not-a-constructor.js @@ -28,7 +28,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getYear(); -}, '`let date = new Date(Date.now()); new date.getYear()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/not-a-constructor.js index 906214fde4..b984983549 100644 --- a/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/not-a-constructor.js @@ -28,7 +28,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.setYear(); -}, '`let date = new Date(Date.now()); new date.setYear()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/not-a-constructor.js index bb6c5f412f..1ee58ec5ae 100644 --- a/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/not-a-constructor.js @@ -28,7 +28,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.toGMTString(); -}, '`let date = new Date(Date.now()); new date.toGMTString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/RegExp/prototype/compile/this-cross-realm-instance.js b/js/src/tests/test262/annexB/built-ins/RegExp/prototype/compile/this-cross-realm-instance.js index 5c4f9a8234..666bd56e9e 100644 --- a/js/src/tests/test262/annexB/built-ins/RegExp/prototype/compile/this-cross-realm-instance.js +++ b/js/src/tests/test262/annexB/built-ins/RegExp/prototype/compile/this-cross-realm-instance.js @@ -16,9 +16,7 @@ assert.throws( TypeError, function () { RegExp.prototype.compile.call(otherRealm_regexp); - }, - "`RegExp.prototype.compile.call(otherRealm_regexp)` throws TypeError" -); + }); assert.throws( other.TypeError, diff --git a/js/src/tests/test262/annexB/built-ins/RegExp/prototype/compile/this-subclass-instance.js b/js/src/tests/test262/annexB/built-ins/RegExp/prototype/compile/this-subclass-instance.js index 66f6e3f5a6..2bbe36f4c4 100644 --- a/js/src/tests/test262/annexB/built-ins/RegExp/prototype/compile/this-subclass-instance.js +++ b/js/src/tests/test262/annexB/built-ins/RegExp/prototype/compile/this-subclass-instance.js @@ -13,16 +13,12 @@ assert.throws( TypeError, function () { subclass_regexp.compile(); - }, - "`subclass_regexp.compile()` throws TypeError" -); + }); assert.throws( TypeError, function () { RegExp.prototype.compile.call(subclass_regexp); - }, - "`RegExp.prototype.compile.call(subclass_regexp)` throws TypeError" -); + }); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/not-a-constructor.js index ca59226cbf..7935bb3faa 100644 --- a/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/anchor/not-a-constructor.js @@ -28,7 +28,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.anchor(); -}, '`new String.prototype.anchor()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/big/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/big/not-a-constructor.js index f2e5f3bfc7..7f5ab46c7b 100644 --- a/js/src/tests/test262/annexB/built-ins/String/prototype/big/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/big/not-a-constructor.js @@ -24,7 +24,7 @@ assert.sameValue(isConstructor(String.prototype.big), false, 'isConstructor(Stri assert.throws(TypeError, () => { new String.prototype.big(); -}, '`new String.prototype.big()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/blink/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/not-a-constructor.js index 73d5488203..275fca49f8 100644 --- a/js/src/tests/test262/annexB/built-ins/String/prototype/blink/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/blink/not-a-constructor.js @@ -28,7 +28,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.blink(); -}, '`new String.prototype.blink()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/bold/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/not-a-constructor.js index 1f8a7a155d..bac9d503cd 100644 --- a/js/src/tests/test262/annexB/built-ins/String/prototype/bold/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/bold/not-a-constructor.js @@ -28,7 +28,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.bold(); -}, '`new String.prototype.bold()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/not-a-constructor.js index 64fa0c534d..5199152f24 100644 --- a/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fixed/not-a-constructor.js @@ -28,7 +28,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.fixed(); -}, '`new String.prototype.fixed()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/not-a-constructor.js index a5bfa4415c..93e7959b6e 100644 --- a/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontcolor/not-a-constructor.js @@ -28,7 +28,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.fontcolor(); -}, '`new String.prototype.fontcolor()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/not-a-constructor.js index d221a1348a..369d8a63ff 100644 --- a/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/fontsize/not-a-constructor.js @@ -28,7 +28,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.fontsize(); -}, '`new String.prototype.fontsize()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/italics/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/not-a-constructor.js index 4833d9b0e5..ee0efba295 100644 --- a/js/src/tests/test262/annexB/built-ins/String/prototype/italics/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/italics/not-a-constructor.js @@ -28,7 +28,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.italics(); -}, '`new String.prototype.italics()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/link/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/link/not-a-constructor.js index afd8d81733..7b0d604281 100644 --- a/js/src/tests/test262/annexB/built-ins/String/prototype/link/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/link/not-a-constructor.js @@ -28,7 +28,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.link(); -}, '`new String.prototype.link()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/small/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/small/not-a-constructor.js index a0a9aa6090..ca7d8b4c88 100644 --- a/js/src/tests/test262/annexB/built-ins/String/prototype/small/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/small/not-a-constructor.js @@ -28,7 +28,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.small(); -}, '`new String.prototype.small()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/strike/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/not-a-constructor.js index 5f7bc6cbd1..c772410ed8 100644 --- a/js/src/tests/test262/annexB/built-ins/String/prototype/strike/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/strike/not-a-constructor.js @@ -28,7 +28,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.strike(); -}, '`new String.prototype.strike()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sub/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/not-a-constructor.js index 3c8b054e9a..23a9dd69d9 100644 --- a/js/src/tests/test262/annexB/built-ins/String/prototype/sub/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sub/not-a-constructor.js @@ -24,7 +24,7 @@ assert.sameValue(isConstructor(String.prototype.sub), false, 'isConstructor(Stri assert.throws(TypeError, () => { new String.prototype.sub(); -}, '`new String.prototype.sub()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/not-a-constructor.js index 821d6473a4..35a5bd0121 100644 --- a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/not-a-constructor.js @@ -28,7 +28,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.substr(); -}, '`new String.prototype.substr()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/sup/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/not-a-constructor.js index 461a34d60e..e0de689e39 100644 --- a/js/src/tests/test262/annexB/built-ins/String/prototype/sup/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/sup/not-a-constructor.js @@ -24,7 +24,7 @@ assert.sameValue(isConstructor(String.prototype.sup), false, 'isConstructor(Stri assert.throws(TypeError, () => { new String.prototype.sup(); -}, '`new String.prototype.sup()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/TypedArrayConstructors/from/iterator-method-emulates-undefined.js b/js/src/tests/test262/annexB/built-ins/TypedArrayConstructors/from/iterator-method-emulates-undefined.js index 5e41a374eb..b121d08169 100644 --- a/js/src/tests/test262/annexB/built-ins/TypedArrayConstructors/from/iterator-method-emulates-undefined.js +++ b/js/src/tests/test262/annexB/built-ins/TypedArrayConstructors/from/iterator-method-emulates-undefined.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Alexey Shvayka. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/annexB/built-ins/escape/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/escape/not-a-constructor.js index 9fd1e0deb7..f1f3a0caa7 100644 --- a/js/src/tests/test262/annexB/built-ins/escape/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/escape/not-a-constructor.js @@ -24,7 +24,7 @@ assert.sameValue(isConstructor(escape), false, 'isConstructor(escape) must retur assert.throws(TypeError, () => { new escape(''); -}, '`new escape(\'\')` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/unescape/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/unescape/not-a-constructor.js index 71c32f22c2..79070d3c7d 100644 --- a/js/src/tests/test262/annexB/built-ins/unescape/not-a-constructor.js +++ b/js/src/tests/test262/annexB/built-ins/unescape/not-a-constructor.js @@ -24,7 +24,7 @@ assert.sameValue(isConstructor(unescape), false, 'isConstructor(unescape) must r assert.throws(TypeError, () => { new unescape(''); -}, '`new unescape(\'\')` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/comments/single-line-html-close-first-line-1.js b/js/src/tests/test262/annexB/language/comments/single-line-html-close-first-line-1.js new file mode 100644 index 0000000000..708e42e4ae --- /dev/null +++ b/js/src/tests/test262/annexB/language/comments/single-line-html-close-first-line-1.js @@ -0,0 +1,34 @@ +--> a comment + +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-html-like-comments +description: > + A SingleLineHTMLCloseComment is allowed in the first line +flags: [raw] +info: | + InputElementHashbangOrRegExp :: + WhiteSpace + LineTerminator + Comment + CommonToken + HashbangComment + RegularExpressionLiteral + HTMLCloseComment + + HTMLCloseComment :: + WhiteSpaceSequence[opt] SingleLineDelimitedCommentSequence[opt] --> SingleLineCommentChars[opt] +negative: + phase: runtime + type: Test262Error +---*/ + +// Because this test concerns the interpretation of non-executable character +// sequences within ECMAScript source code, special care must be taken to +// ensure that executable code is evaluated as expected. +// +// Express the intended behavior by intentionally throwing an error; this +// guarantees that test runners will only consider the test "passing" if +// executable sequences are correctly interpreted as such. +throw new Test262Error("This is not in a comment"); diff --git a/js/src/tests/test262/annexB/language/comments/single-line-html-close-first-line-2.js b/js/src/tests/test262/annexB/language/comments/single-line-html-close-first-line-2.js new file mode 100644 index 0000000000..0b68aa0f6f --- /dev/null +++ b/js/src/tests/test262/annexB/language/comments/single-line-html-close-first-line-2.js @@ -0,0 +1,34 @@ + --> a comment + +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-html-like-comments +description: > + A SingleLineHTMLCloseComment is allowed in the first line when preceeded by spaces +flags: [raw] +info: | + InputElementHashbangOrRegExp :: + WhiteSpace + LineTerminator + Comment + CommonToken + HashbangComment + RegularExpressionLiteral + HTMLCloseComment + + HTMLCloseComment :: + WhiteSpaceSequence[opt] SingleLineDelimitedCommentSequence[opt] --> SingleLineCommentChars[opt] +negative: + phase: runtime + type: Test262Error +---*/ + +// Because this test concerns the interpretation of non-executable character +// sequences within ECMAScript source code, special care must be taken to +// ensure that executable code is evaluated as expected. +// +// Express the intended behavior by intentionally throwing an error; this +// guarantees that test runners will only consider the test "passing" if +// executable sequences are correctly interpreted as such. +throw new Test262Error("This is not in a comment"); diff --git a/js/src/tests/test262/annexB/language/comments/single-line-html-close-first-line-3.js b/js/src/tests/test262/annexB/language/comments/single-line-html-close-first-line-3.js new file mode 100644 index 0000000000..d638fd5080 --- /dev/null +++ b/js/src/tests/test262/annexB/language/comments/single-line-html-close-first-line-3.js @@ -0,0 +1,34 @@ +/* a comment */ /*another comment*/--> a comment + +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-html-like-comments +description: > + A SingleLineHTMLCloseComment is allowed in the first line when preceeded by spaces and single-line block comments +flags: [raw] +info: | + InputElementHashbangOrRegExp :: + WhiteSpace + LineTerminator + Comment + CommonToken + HashbangComment + RegularExpressionLiteral + HTMLCloseComment + + HTMLCloseComment :: + WhiteSpaceSequence[opt] SingleLineDelimitedCommentSequence[opt] --> SingleLineCommentChars[opt] +negative: + phase: runtime + type: Test262Error +---*/ + +// Because this test concerns the interpretation of non-executable character +// sequences within ECMAScript source code, special care must be taken to +// ensure that executable code is evaluated as expected. +// +// Express the intended behavior by intentionally throwing an error; this +// guarantees that test runners will only consider the test "passing" if +// executable sequences are correctly interpreted as such. +throw new Test262Error("This is not in a comment"); diff --git a/js/src/tests/test262/annexB/language/eval-code/direct/script-decl-lex-collision-in-sloppy-mode.js b/js/src/tests/test262/annexB/language/eval-code/direct/script-decl-lex-collision-in-sloppy-mode.js deleted file mode 100644 index 58d5a125b5..0000000000 --- a/js/src/tests/test262/annexB/language/eval-code/direct/script-decl-lex-collision-in-sloppy-mode.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2023 Alexey Shvayka. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-globaldeclarationinstantiation -description: Let binding collision with existing var declaration that was created for hoisted function. -info: | - [...] - 3. For each element name of lexNames, do - a. If env.HasVarDeclaration(name) is true, throw a SyntaxError exception. -flags: [noStrict] ----*/ - -eval('if (true) { function test262Fn() {} }'); - -assert.throws(SyntaxError, function() { - $262.evalScript('var x; let test262Fn;'); -}); - -assert.throws(ReferenceError, function() { - x; -}, 'no bindings created'); - -reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/eval-code/direct/script-decl-lex-no-collision-in-strict-mode-strict.js b/js/src/tests/test262/annexB/language/eval-code/direct/script-decl-lex-no-collision-in-strict-mode-strict.js deleted file mode 100644 index da859c843d..0000000000 --- a/js/src/tests/test262/annexB/language/eval-code/direct/script-decl-lex-no-collision-in-strict-mode-strict.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; -// Copyright (C) 2023 Alexey Shvayka. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-globaldeclarationinstantiation -description: No let binding collision with existing var declaration due to strict-mode eval(). -info: | - PerformEval ( x, strictCaller, direct ) - - [...] - 16. If direct is true, then - a. Let lexEnv be NewDeclarativeEnvironment(runningContext's LexicalEnvironment). - [...] - 18. If strictEval is true, set varEnv to lexEnv. -flags: [onlyStrict] ----*/ - -eval('if (true) { function test262Fn() {} }'); - -$262.evalScript('let test262Fn = 1;'); - -assert.sameValue(test262Fn, 1); - -reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/eval-code/direct/script-decl-lex-no-collision.js b/js/src/tests/test262/annexB/language/eval-code/direct/script-decl-lex-no-collision.js new file mode 100644 index 0000000000..643b11831d --- /dev/null +++ b/js/src/tests/test262/annexB/language/eval-code/direct/script-decl-lex-no-collision.js @@ -0,0 +1,35 @@ +// Copyright (C) 2023 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-globaldeclarationinstantiation +description: No let binding collision with existing var declaration due to eval(). +info: | + In strict mode: + + PerformEval ( x, strictCaller, direct ) + + [...] + 16. If direct is true, then + a. Let lexEnv be NewDeclarativeEnvironment(runningContext's LexicalEnvironment). + [...] + 18. If strictEval is true, set varEnv to lexEnv. + + In sloppy mode: + + GlobalDeclarationInstantiation ( script, env ) + + [...] + 3. For each element name of lexNames, do + a. If env.HasLexicalDeclaration(name) is true, throw a SyntaxError exception. + b. Let hasRestrictedGlobal be ? env.HasRestrictedGlobalProperty(name). + c. NOTE: Global var and function bindings (except those that are introduced by non-strict direct eval) are non-configurable and are therefore restricted global properties. + d. If hasRestrictedGlobal is true, throw a SyntaxError exception. +---*/ + +eval('if (true) { function test262Fn() {} }'); + +$262.evalScript('let test262Fn = 1;'); + +assert.sameValue(test262Fn, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/Symbol.species/length.js b/js/src/tests/test262/built-ins/Array/Symbol.species/length.js index a0744b86ae..fba06806a3 100644 --- a/js/src/tests/test262/built-ins/Array/Symbol.species/length.js +++ b/js/src/tests/test262/built-ins/Array/Symbol.species/length.js @@ -25,10 +25,11 @@ features: [Symbol.species] var desc = Object.getOwnPropertyDescriptor(Array, Symbol.species); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/Symbol.species/symbol-species-name.js b/js/src/tests/test262/built-ins/Array/Symbol.species/symbol-species-name.js index 8c943ef709..f74dac394e 100644 --- a/js/src/tests/test262/built-ins/Array/Symbol.species/symbol-species-name.js +++ b/js/src/tests/test262/built-ins/Array/Symbol.species/symbol-species-name.js @@ -15,13 +15,11 @@ includes: [propertyHelper.js] var descriptor = Object.getOwnPropertyDescriptor(Array, Symbol.species); -assert.sameValue( - descriptor.get.name, - 'get [Symbol.species]' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get [Symbol.species]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/Array.from-name.js b/js/src/tests/test262/built-ins/Array/from/Array.from-name.js index 267647c639..7aecd2cb32 100644 --- a/js/src/tests/test262/built-ins/Array/from/Array.from-name.js +++ b/js/src/tests/test262/built-ins/Array/from/Array.from-name.js @@ -19,14 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Array.from.name, - 'from', - 'The value of Array.from.name is expected to be "from"' -); - -verifyNotEnumerable(Array.from, 'name'); -verifyNotWritable(Array.from, 'name'); -verifyConfigurable(Array.from, 'name'); +verifyProperty(Array.from, "name", { + value: "from", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/from/Array.from_arity.js b/js/src/tests/test262/built-ins/Array/from/Array.from_arity.js index 68b3287765..9442265a5e 100644 --- a/js/src/tests/test262/built-ins/Array/from/Array.from_arity.js +++ b/js/src/tests/test262/built-ins/Array/from/Array.from_arity.js @@ -14,10 +14,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.from.length, 1, 'The value of Array.from.length is expected to be 1'); - -verifyNotEnumerable(Array.from, 'length'); -verifyNotWritable(Array.from, 'length'); -verifyConfigurable(Array.from, 'length'); +verifyProperty(Array.from, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/shell.js b/js/src/tests/test262/built-ins/Array/fromAsync/shell.js index 3489e7ef68..4daca91e51 100644 --- a/js/src/tests/test262/built-ins/Array/fromAsync/shell.js +++ b/js/src/tests/test262/built-ins/Array/fromAsync/shell.js @@ -2135,6 +2135,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2222,6 +2225,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/built-ins/Array/isArray/name.js b/js/src/tests/test262/built-ins/Array/isArray/name.js index 1b2ebb5e42..22f5c6a23e 100644 --- a/js/src/tests/test262/built-ins/Array/isArray/name.js +++ b/js/src/tests/test262/built-ins/Array/isArray/name.js @@ -20,10 +20,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.isArray.name, "isArray", 'The value of Array.isArray.name is expected to be "isArray"'); - -verifyNotEnumerable(Array.isArray, "name"); -verifyNotWritable(Array.isArray, "name"); -verifyConfigurable(Array.isArray, "name"); +verifyProperty(Array.isArray, "name", { + value: "isArray", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/length.js b/js/src/tests/test262/built-ins/Array/length.js index 16e8c44ec3..f8070579f4 100644 --- a/js/src/tests/test262/built-ins/Array/length.js +++ b/js/src/tests/test262/built-ins/Array/length.js @@ -17,10 +17,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.length, 1, 'The value of Array.length is expected to be 1'); - -verifyNotEnumerable(Array, 'length'); -verifyNotWritable(Array, 'length'); -verifyConfigurable(Array, 'length'); +verifyProperty(Array, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/name.js b/js/src/tests/test262/built-ins/Array/name.js index 621154b510..89a9a6aa89 100644 --- a/js/src/tests/test262/built-ins/Array/name.js +++ b/js/src/tests/test262/built-ins/Array/name.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.name, 'Array', 'The value of Array.name is expected to be "Array"'); - -verifyNotEnumerable(Array, 'name'); -verifyNotWritable(Array, 'name'); -verifyConfigurable(Array, 'name'); +verifyProperty(Array, "name", { + value: "Array", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/length.js b/js/src/tests/test262/built-ins/Array/of/length.js index f77c48b768..59de2ff7ef 100644 --- a/js/src/tests/test262/built-ins/Array/of/length.js +++ b/js/src/tests/test262/built-ins/Array/of/length.js @@ -11,13 +11,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Array.of.length, 0, - 'The value of Array.of.length is expected to be 0' -); - -verifyNotEnumerable(Array.of, 'length'); -verifyNotWritable(Array.of, 'length'); -verifyConfigurable(Array.of, 'length'); +verifyProperty(Array.of, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/of/name.js b/js/src/tests/test262/built-ins/Array/of/name.js index 842dd1ad11..39ce92b8e7 100644 --- a/js/src/tests/test262/built-ins/Array/of/name.js +++ b/js/src/tests/test262/built-ins/Array/of/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Array.of.name, 'of', - 'The value of Array.of.name is expected to be "of"' -); - -verifyNotEnumerable(Array.of, 'name'); -verifyNotWritable(Array.of, 'name'); -verifyConfigurable(Array.of, 'name'); +verifyProperty(Array.of, "name", { + value: "of", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/Symbol.iterator/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/Symbol.iterator/not-a-constructor.js index 5d7c96289e..c04cb85e2e 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/Symbol.iterator/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/Symbol.iterator/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype[Symbol.iterator](); -}, '`new Array.prototype[Symbol.iterator]()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/at/length.js b/js/src/tests/test262/built-ins/Array/prototype/at/length.js index 219f329eb4..68fb344a6d 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/at/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/at/length.js @@ -18,13 +18,11 @@ assert.sameValue( 'The value of `typeof Array.prototype.at` is expected to be "function"' ); -assert.sameValue( - Array.prototype.at.length, 1, - 'The value of Array.prototype.at.length is expected to be 1' -); - -verifyNotEnumerable(Array.prototype.at, 'length'); -verifyNotWritable(Array.prototype.at, 'length'); -verifyConfigurable(Array.prototype.at, 'length'); +verifyProperty(Array.prototype.at, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/length.js b/js/src/tests/test262/built-ins/Array/prototype/concat/length.js index 5bff590dfd..7955443cef 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/concat/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/length.js @@ -25,10 +25,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.concat.length, 1, 'The value of Array.prototype.concat.length is expected to be 1'); - -verifyNotEnumerable(Array.prototype.concat, 'length'); -verifyNotWritable(Array.prototype.concat, 'length'); -verifyConfigurable(Array.prototype.concat, 'length'); +verifyProperty(Array.prototype.concat, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/name.js b/js/src/tests/test262/built-ins/Array/prototype/concat/name.js index f81660ad08..bdb54322a0 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/concat/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/name.js @@ -19,14 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Array.prototype.concat.name, - "concat", - 'The value of Array.prototype.concat.name is expected to be "concat"' -); - -verifyNotEnumerable(Array.prototype.concat, "name"); -verifyNotWritable(Array.prototype.concat, "name"); -verifyConfigurable(Array.prototype.concat, "name"); +verifyProperty(Array.prototype.concat, "name", { + value: "concat", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/length.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/length.js index e846f74754..606a392fd7 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/length.js @@ -10,13 +10,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Array.prototype.copyWithin.length, 2, - 'The value of `Array.prototype.copyWithin.length` is `2`' -); - -verifyNotEnumerable(Array.prototype.copyWithin, 'length'); -verifyNotWritable(Array.prototype.copyWithin, 'length'); -verifyConfigurable(Array.prototype.copyWithin, 'length'); +verifyProperty(Array.prototype.copyWithin, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/name.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/name.js index c8c6c0b5b9..75549164b3 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Array.prototype.copyWithin.name, 'copyWithin', - 'The value of `Array.prototype.copyWithin.name` is `"copyWithin"`' -); - -verifyNotEnumerable(Array.prototype.copyWithin, 'name'); -verifyNotWritable(Array.prototype.copyWithin, 'name'); -verifyConfigurable(Array.prototype.copyWithin, 'name'); +verifyProperty(Array.prototype.copyWithin, "name", { + value: "copyWithin", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/not-a-constructor.js index f16770a6c5..6255574819 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/copyWithin/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/copyWithin/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.copyWithin(); -}, '`new Array.prototype.copyWithin()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/length.js b/js/src/tests/test262/built-ins/Array/prototype/entries/length.js index 28f3093b6b..29b8faf091 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/entries/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Array.prototype.entries.length, 0, - 'The value of `Array.prototype.entries.length` is `0`' -); - -verifyNotEnumerable(Array.prototype.entries, 'length'); -verifyNotWritable(Array.prototype.entries, 'length'); -verifyConfigurable(Array.prototype.entries, 'length'); +verifyProperty(Array.prototype.entries, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/name.js b/js/src/tests/test262/built-ins/Array/prototype/entries/name.js index db9cd7a5d2..7ab25d6a45 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/entries/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Array.prototype.entries.name, 'entries', - 'The value of `Array.prototype.entries.name` is `"entries"`' -); - -verifyNotEnumerable(Array.prototype.entries, 'name'); -verifyNotWritable(Array.prototype.entries, 'name'); -verifyConfigurable(Array.prototype.entries, 'name'); +verifyProperty(Array.prototype.entries, "name", { + value: "entries", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/entries/not-a-constructor.js index 7629f5b507..9149fb8153 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/entries/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.entries(); -}, '`new Array.prototype.entries()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/every/callbackfn-resize-arraybuffer.js index a1a4ee5456..7579225ba9 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/every/callbackfn-resize-arraybuffer.js +++ b/js/src/tests/test262/built-ins/Array/prototype/every/callbackfn-resize-arraybuffer.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/length.js b/js/src/tests/test262/built-ins/Array/prototype/every/length.js index 65015d9799..cf67099506 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/every/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/every/length.js @@ -11,13 +11,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Array.prototype.every.length, 1, - 'The value of `Array.prototype.every.length` is `1`' -); - -verifyNotEnumerable(Array.prototype.every, 'length'); -verifyNotWritable(Array.prototype.every, 'length'); -verifyConfigurable(Array.prototype.every, 'length'); +verifyProperty(Array.prototype.every, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/name.js b/js/src/tests/test262/built-ins/Array/prototype/every/name.js index 5bb10976b6..de095e7480 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/every/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/every/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.every.name, "every"); - -verifyNotEnumerable(Array.prototype.every, "name"); -verifyNotWritable(Array.prototype.every, "name"); -verifyConfigurable(Array.prototype.every, "name"); +verifyProperty(Array.prototype.every, "name", { + value: "every", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/every/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/every/not-a-constructor.js index 54dee55e8b..b817fd312e 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/every/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/every/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.every(() => {}); -}, '`new Array.prototype.every(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/length.js b/js/src/tests/test262/built-ins/Array/prototype/fill/length.js index 1d12345bc0..5a5000c55a 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/fill/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/length.js @@ -8,13 +8,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Array.prototype.fill.length, 1, - 'The value of `Array.prototype.fill.length` is `1`' -); - -verifyNotEnumerable(Array.prototype.fill, 'length'); -verifyNotWritable(Array.prototype.fill, 'length'); -verifyConfigurable(Array.prototype.fill, 'length'); +verifyProperty(Array.prototype.fill, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/name.js b/js/src/tests/test262/built-ins/Array/prototype/fill/name.js index 35d210dec3..e2c7b83e01 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/fill/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Array.prototype.fill.name, 'fill', - 'The value of `Array.prototype.fill.name` is `"fill"`' -); - -verifyNotEnumerable(Array.prototype.fill, 'name'); -verifyNotWritable(Array.prototype.fill, 'name'); -verifyConfigurable(Array.prototype.fill, 'name'); +verifyProperty(Array.prototype.fill, "name", { + value: "fill", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/fill/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/fill/not-a-constructor.js index 77d1be633b..9adb186adb 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/fill/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/fill/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Array.prototype.fill), false, 'isConstructor(Arra assert.throws(TypeError, () => { new Array.prototype.fill(); -}, '`new Array.prototype.fill()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/filter/callbackfn-resize-arraybuffer.js index ef7612695d..3908cfc93f 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/filter/callbackfn-resize-arraybuffer.js +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/callbackfn-resize-arraybuffer.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/length.js b/js/src/tests/test262/built-ins/Array/prototype/filter/length.js index 06c9cf9762..be88cede23 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/filter/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/length.js @@ -23,10 +23,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.filter.length, 1); - -verifyNotEnumerable(Array.prototype.filter, 'length'); -verifyNotWritable(Array.prototype.filter, 'length'); -verifyConfigurable(Array.prototype.filter, 'length'); +verifyProperty(Array.prototype.filter, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/name.js b/js/src/tests/test262/built-ins/Array/prototype/filter/name.js index 4fbfcefd92..5b4f9754bd 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/filter/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.filter.name, "filter"); - -verifyNotEnumerable(Array.prototype.filter, "name"); -verifyNotWritable(Array.prototype.filter, "name"); -verifyConfigurable(Array.prototype.filter, "name"); +verifyProperty(Array.prototype.filter, "name", { + value: "filter", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/filter/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/filter/not-a-constructor.js index f9b011ced5..2853408ae6 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/filter/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/filter/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.filter(() => {}); -}, '`new Array.prototype.filter(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/find/callbackfn-resize-arraybuffer.js index 31a7b55750..3bf3aa2f52 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/find/callbackfn-resize-arraybuffer.js +++ b/js/src/tests/test262/built-ins/Array/prototype/find/callbackfn-resize-arraybuffer.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/length.js b/js/src/tests/test262/built-ins/Array/prototype/find/length.js index 2522319483..a9ca424385 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/find/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/find/length.js @@ -8,13 +8,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Array.prototype.find.length, 1, - 'The value of `Array.prototype.find.length` is `1`' -); - -verifyNotEnumerable(Array.prototype.find, 'length'); -verifyNotWritable(Array.prototype.find, 'length'); -verifyConfigurable(Array.prototype.find, 'length'); +verifyProperty(Array.prototype.find, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/name.js b/js/src/tests/test262/built-ins/Array/prototype/find/name.js index 8a4c21fe67..d9ae189ec5 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/find/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/find/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Array.prototype.find.name, 'find', - 'The value of `Array.prototype.find.name` is `"find"`' -); - -verifyNotEnumerable(Array.prototype.find, 'name'); -verifyNotWritable(Array.prototype.find, 'name'); -verifyConfigurable(Array.prototype.find, 'name'); +verifyProperty(Array.prototype.find, "name", { + value: "find", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/find/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/find/not-a-constructor.js index 8e2d17caff..b8921dd067 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/find/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/find/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Array.prototype.find), false, 'isConstructor(Arra assert.throws(TypeError, () => { new Array.prototype.find(() => {}); -}, '`new Array.prototype.find(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/callbackfn-resize-arraybuffer.js index dbd5c88d63..d7ebd5958b 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/findIndex/callbackfn-resize-arraybuffer.js +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/callbackfn-resize-arraybuffer.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/length.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/length.js index dafeb333b1..44f8e31895 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/findIndex/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/length.js @@ -8,13 +8,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Array.prototype.findIndex.length, 1, - 'The value of `Array.prototype.findIndex.length` is `1`' -); - -verifyNotEnumerable(Array.prototype.findIndex, 'length'); -verifyNotWritable(Array.prototype.findIndex, 'length'); -verifyConfigurable(Array.prototype.findIndex, 'length'); +verifyProperty(Array.prototype.findIndex, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/name.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/name.js index ad6b6d5a28..564448f064 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/findIndex/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Array.prototype.findIndex.name, 'findIndex', - 'The value of `Array.prototype.findIndex.name` is `"findIndex"`' -); - -verifyNotEnumerable(Array.prototype.findIndex, 'name'); -verifyNotWritable(Array.prototype.findIndex, 'name'); -verifyConfigurable(Array.prototype.findIndex, 'name'); +verifyProperty(Array.prototype.findIndex, "name", { + value: "findIndex", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findIndex/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/findIndex/not-a-constructor.js index ce4d52002d..b85edccbe6 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/findIndex/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/findIndex/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.findIndex(() => {}); -}, '`new Array.prototype.findIndex(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/callbackfn-resize-arraybuffer.js index 1f029bde80..6761bd57cd 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/findLast/callbackfn-resize-arraybuffer.js +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/callbackfn-resize-arraybuffer.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLast/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/findLast/not-a-constructor.js index 9b2316f054..7bb9592536 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/findLast/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/findLast/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Array.prototype.findLast), false, 'isConstructor( assert.throws(TypeError, () => { new Array.prototype.findLast(() => {}); -}, '`new Array.prototype.findLast(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/callbackfn-resize-arraybuffer.js index 3d90fa7f17..50f8c9cc33 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/callbackfn-resize-arraybuffer.js +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/callbackfn-resize-arraybuffer.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/not-a-constructor.js index 8c6000eea2..9155f03cab 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.findLastIndex(() => {}); -}, '`new Array.prototype.findLastIndex(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/flat/not-a-constructor.js index 5f9c2c1401..e712f86ec9 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/flat/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Array.prototype.flat), false, 'isConstructor(Arra assert.throws(TypeError, () => { new Array.prototype.flat(); -}, '`new Array.prototype.flat()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/not-a-constructor.js index 8facbadc1c..41480d610d 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/flatMap/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.flatMap(() => {}); -}, '`new Array.prototype.flatMap(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/callbackfn-resize-arraybuffer.js index 402b9a7007..829d744e4d 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/forEach/callbackfn-resize-arraybuffer.js +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/callbackfn-resize-arraybuffer.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/length.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/length.js index 8ca4a6185e..d9b2541122 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/forEach/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/length.js @@ -23,10 +23,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.forEach.length, 1); - -verifyNotEnumerable(Array.prototype.forEach, 'length'); -verifyNotWritable(Array.prototype.forEach, 'length'); -verifyConfigurable(Array.prototype.forEach, 'length'); +verifyProperty(Array.prototype.forEach, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/name.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/name.js index 08beb915e8..8c70987d9f 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/forEach/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.forEach.name, "forEach"); - -verifyNotEnumerable(Array.prototype.forEach, "name"); -verifyNotWritable(Array.prototype.forEach, "name"); -verifyConfigurable(Array.prototype.forEach, "name"); +verifyProperty(Array.prototype.forEach, "name", { + value: "forEach", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/forEach/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/forEach/not-a-constructor.js index 9662abaf98..a69333b135 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/forEach/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/forEach/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.forEach(() => {}); -}, '`new Array.prototype.forEach(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/length.js b/js/src/tests/test262/built-ins/Array/prototype/includes/length.js index e437df4d3c..af15396fab 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/includes/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/length.js @@ -23,10 +23,11 @@ includes: [propertyHelper.js] features: [Array.prototype.includes] ---*/ -assert.sameValue(Array.prototype.includes.length, 1); - -verifyNotEnumerable(Array.prototype.includes, "length"); -verifyNotWritable(Array.prototype.includes, "length"); -verifyConfigurable(Array.prototype.includes, "length"); +verifyProperty(Array.prototype.includes, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/name.js b/js/src/tests/test262/built-ins/Array/prototype/includes/name.js index c97a1fed91..e594108e11 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/includes/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/name.js @@ -20,10 +20,11 @@ includes: [propertyHelper.js] features: [Array.prototype.includes] ---*/ -assert.sameValue(Array.prototype.includes.name, "includes"); - -verifyNotEnumerable(Array.prototype.includes, "name"); -verifyNotWritable(Array.prototype.includes, "name"); -verifyConfigurable(Array.prototype.includes, "name"); +verifyProperty(Array.prototype.includes, "name", { + value: "includes", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/includes/not-a-constructor.js index 0d673a9c31..937168e3e7 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/includes/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/includes/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.includes(1); -}, '`new Array.prototype.includes(1)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/length.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/length.js index 36a44e19dc..b6d399a6be 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/indexOf/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.indexOf.length, 1); - -verifyNotEnumerable(Array.prototype.indexOf, 'length'); -verifyNotWritable(Array.prototype.indexOf, 'length'); -verifyConfigurable(Array.prototype.indexOf, 'length'); +verifyProperty(Array.prototype.indexOf, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/name.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/name.js index 5017f4381c..9d748ece9c 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/indexOf/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.indexOf.name, "indexOf"); - -verifyNotEnumerable(Array.prototype.indexOf, "name"); -verifyNotWritable(Array.prototype.indexOf, "name"); -verifyConfigurable(Array.prototype.indexOf, "name"); +verifyProperty(Array.prototype.indexOf, "name", { + value: "indexOf", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/indexOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/indexOf/not-a-constructor.js index d297029668..f094f6b1c0 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/indexOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/indexOf/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.indexOf(); -}, '`new Array.prototype.indexOf()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/length.js b/js/src/tests/test262/built-ins/Array/prototype/join/length.js index bdef13a59f..f5c31044d1 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/join/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/join/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.join.length, 1); - -verifyNotEnumerable(Array.prototype.join, 'length'); -verifyNotWritable(Array.prototype.join, 'length'); -verifyConfigurable(Array.prototype.join, 'length'); +verifyProperty(Array.prototype.join, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/name.js b/js/src/tests/test262/built-ins/Array/prototype/join/name.js index 3af90e214e..536c306f82 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/join/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/join/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.join.name, "join"); - -verifyNotEnumerable(Array.prototype.join, "name"); -verifyNotWritable(Array.prototype.join, "name"); -verifyConfigurable(Array.prototype.join, "name"); +verifyProperty(Array.prototype.join, "name", { + value: "join", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/join/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/join/not-a-constructor.js index e92cd56335..f0953d9206 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/join/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/join/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Array.prototype.join), false, 'isConstructor(Arra assert.throws(TypeError, () => { new Array.prototype.join(); -}, '`new Array.prototype.join()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/keys/length.js b/js/src/tests/test262/built-ins/Array/prototype/keys/length.js index 6d997e5972..160dea0a2d 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/keys/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/keys/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Array.prototype.keys.length, 0, - 'The value of `Array.prototype.keys.length` is `0`' -); - -verifyNotEnumerable(Array.prototype.keys, 'length'); -verifyNotWritable(Array.prototype.keys, 'length'); -verifyConfigurable(Array.prototype.keys, 'length'); +verifyProperty(Array.prototype.keys, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/keys/name.js b/js/src/tests/test262/built-ins/Array/prototype/keys/name.js index 11ea5c508f..c20e6a2b6f 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/keys/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/keys/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Array.prototype.keys.name, 'keys', - 'The value of `Array.prototype.keys.name` is `"keys"`' -); - -verifyNotEnumerable(Array.prototype.keys, 'name'); -verifyNotWritable(Array.prototype.keys, 'name'); -verifyConfigurable(Array.prototype.keys, 'name'); +verifyProperty(Array.prototype.keys, "name", { + value: "keys", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/keys/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/keys/not-a-constructor.js index 8d0b5db966..4207eebb9b 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/keys/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/keys/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Array.prototype.keys), false, 'isConstructor(Arra assert.throws(TypeError, () => { new Array.prototype.keys(); -}, '`new Array.prototype.keys()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length.js index 56b0fd7f8b..71ba258f1b 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.lastIndexOf.length, 1); - -verifyNotEnumerable(Array.prototype.lastIndexOf, 'length'); -verifyNotWritable(Array.prototype.lastIndexOf, 'length'); -verifyConfigurable(Array.prototype.lastIndexOf, 'length'); +verifyProperty(Array.prototype.lastIndexOf, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/name.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/name.js index 1ab52079e3..d2990a8553 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.lastIndexOf.name, "lastIndexOf"); - -verifyNotEnumerable(Array.prototype.lastIndexOf, "name"); -verifyNotWritable(Array.prototype.lastIndexOf, "name"); -verifyConfigurable(Array.prototype.lastIndexOf, "name"); +verifyProperty(Array.prototype.lastIndexOf, "name", { + value: "lastIndexOf", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/not-a-constructor.js index e3d126b8f9..076d85fcc9 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.lastIndexOf(); -}, '`new Array.prototype.lastIndexOf()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/map/callbackfn-resize-arraybuffer.js index ec8caa847e..5496a2090a 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/map/callbackfn-resize-arraybuffer.js +++ b/js/src/tests/test262/built-ins/Array/prototype/map/callbackfn-resize-arraybuffer.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/length.js b/js/src/tests/test262/built-ins/Array/prototype/map/length.js index f0402be9c5..9eacb86642 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/map/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/map/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.map.length, 1); - -verifyNotEnumerable(Array.prototype.map, 'length'); -verifyNotWritable(Array.prototype.map, 'length'); -verifyConfigurable(Array.prototype.map, 'length'); +verifyProperty(Array.prototype.map, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/name.js b/js/src/tests/test262/built-ins/Array/prototype/map/name.js index 75a94bbb83..c18af83c3f 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/map/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/map/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.map.name, "map"); - -verifyNotEnumerable(Array.prototype.map, "name"); -verifyNotWritable(Array.prototype.map, "name"); -verifyConfigurable(Array.prototype.map, "name"); +verifyProperty(Array.prototype.map, "name", { + value: "map", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/map/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/map/not-a-constructor.js index 98945bd366..8c54276eea 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/map/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/map/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Array.prototype.map), false, 'isConstructor(Array assert.throws(TypeError, () => { new Array.prototype.map(() => {}); -}, '`new Array.prototype.map(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/length.js b/js/src/tests/test262/built-ins/Array/prototype/pop/length.js index 6285c752f0..2f0ec4f16e 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/pop/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.pop.length, 0); - -verifyNotEnumerable(Array.prototype.pop, 'length'); -verifyNotWritable(Array.prototype.pop, 'length'); -verifyConfigurable(Array.prototype.pop, 'length'); +verifyProperty(Array.prototype.pop, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/name.js b/js/src/tests/test262/built-ins/Array/prototype/pop/name.js index 891fb91858..19b678268a 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/pop/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.pop.name, "pop"); - -verifyNotEnumerable(Array.prototype.pop, "name"); -verifyNotWritable(Array.prototype.pop, "name"); -verifyConfigurable(Array.prototype.pop, "name"); +verifyProperty(Array.prototype.pop, "name", { + value: "pop", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/pop/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/pop/not-a-constructor.js index 849c2b3305..ac67502c7e 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/pop/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/pop/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Array.prototype.pop), false, 'isConstructor(Array assert.throws(TypeError, () => { new Array.prototype.pop(); -}, '`new Array.prototype.pop()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/length.js b/js/src/tests/test262/built-ins/Array/prototype/push/length.js index d503ab3cfa..4df58993dd 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/push/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/push/length.js @@ -25,10 +25,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.push.length, 1); - -verifyNotEnumerable(Array.prototype.push, 'length'); -verifyNotWritable(Array.prototype.push, 'length'); -verifyConfigurable(Array.prototype.push, 'length'); +verifyProperty(Array.prototype.push, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/name.js b/js/src/tests/test262/built-ins/Array/prototype/push/name.js index 42e2e96314..1590bdf48b 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/push/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/push/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.push.name, "push"); - -verifyNotEnumerable(Array.prototype.push, "name"); -verifyNotWritable(Array.prototype.push, "name"); -verifyConfigurable(Array.prototype.push, "name"); +verifyProperty(Array.prototype.push, "name", { + value: "push", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/push/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/push/not-a-constructor.js index 291b72867d..f709507f93 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/push/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/push/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Array.prototype.push), false, 'isConstructor(Arra assert.throws(TypeError, () => { new Array.prototype.push(); -}, '`new Array.prototype.push()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/callbackfn-resize-arraybuffer.js index 7196680bec..cead90d05f 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/reduce/callbackfn-resize-arraybuffer.js +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/callbackfn-resize-arraybuffer.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/length.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/length.js index 46705546bd..4ed6ddc04a 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/reduce/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.reduce.length, 1); - -verifyNotEnumerable(Array.prototype.reduce, 'length'); -verifyNotWritable(Array.prototype.reduce, 'length'); -verifyConfigurable(Array.prototype.reduce, 'length'); +verifyProperty(Array.prototype.reduce, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/name.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/name.js index 0b368568bd..83b9a265e8 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/reduce/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.reduce.name, "reduce"); - -verifyNotEnumerable(Array.prototype.reduce, "name"); -verifyNotWritable(Array.prototype.reduce, "name"); -verifyConfigurable(Array.prototype.reduce, "name"); +verifyProperty(Array.prototype.reduce, "name", { + value: "reduce", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduce/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/reduce/not-a-constructor.js index 66a7e1f277..719facd021 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/reduce/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/reduce/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.reduce(() => {}, []); -}, '`new Array.prototype.reduce(() => {}, [])` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/callbackfn-resize-arraybuffer.js index 8704bccee9..bf2ee11cc8 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/callbackfn-resize-arraybuffer.js +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/callbackfn-resize-arraybuffer.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/length.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/length.js index 4f02036c8d..9a2e44850c 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.reduceRight.length, 1); - -verifyNotEnumerable(Array.prototype.reduceRight, 'length'); -verifyNotWritable(Array.prototype.reduceRight, 'length'); -verifyConfigurable(Array.prototype.reduceRight, 'length'); +verifyProperty(Array.prototype.reduceRight, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/name.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/name.js index c3e90f6957..b4a4060073 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.reduceRight.name, "reduceRight"); - -verifyNotEnumerable(Array.prototype.reduceRight, "name"); -verifyNotWritable(Array.prototype.reduceRight, "name"); -verifyConfigurable(Array.prototype.reduceRight, "name"); +verifyProperty(Array.prototype.reduceRight, "name", { + value: "reduceRight", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/not-a-constructor.js index 77e7e825b3..b42a04f7fc 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/reduceRight/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/reduceRight/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.reduceRight(() => {}, []); -}, '`new Array.prototype.reduceRight(() => {}, [])` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/length.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/length.js index fb5562c43d..f55bae44fe 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/reverse/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.reverse.length, 0); - -verifyNotEnumerable(Array.prototype.reverse, 'length'); -verifyNotWritable(Array.prototype.reverse, 'length'); -verifyConfigurable(Array.prototype.reverse, 'length'); +verifyProperty(Array.prototype.reverse, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/name.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/name.js index 450398c5d7..a964c72a4f 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/reverse/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.reverse.name, "reverse"); - -verifyNotEnumerable(Array.prototype.reverse, "name"); -verifyNotWritable(Array.prototype.reverse, "name"); -verifyConfigurable(Array.prototype.reverse, "name"); +verifyProperty(Array.prototype.reverse, "name", { + value: "reverse", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/reverse/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/reverse/not-a-constructor.js index 693a459165..2f25d7a324 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/reverse/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/reverse/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.reverse(); -}, '`new Array.prototype.reverse()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/length.js b/js/src/tests/test262/built-ins/Array/prototype/shift/length.js index 08932c056d..447527ea3b 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/shift/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.shift.length, 0); - -verifyNotEnumerable(Array.prototype.shift, 'length'); -verifyNotWritable(Array.prototype.shift, 'length'); -verifyConfigurable(Array.prototype.shift, 'length'); +verifyProperty(Array.prototype.shift, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/name.js b/js/src/tests/test262/built-ins/Array/prototype/shift/name.js index a64cdab03f..0091e7e2cc 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/shift/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.shift.name, "shift"); - -verifyNotEnumerable(Array.prototype.shift, "name"); -verifyNotWritable(Array.prototype.shift, "name"); -verifyConfigurable(Array.prototype.shift, "name"); +verifyProperty(Array.prototype.shift, "name", { + value: "shift", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/shift/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/shift/not-a-constructor.js index b58cbbb0fa..160d30240b 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/shift/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/shift/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.shift(); -}, '`new Array.prototype.shift()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/length.js b/js/src/tests/test262/built-ins/Array/prototype/slice/length.js index 2d0204600c..21d3dcae6f 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/slice/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.slice.length, 2); - -verifyNotEnumerable(Array.prototype.slice, 'length'); -verifyNotWritable(Array.prototype.slice, 'length'); -verifyConfigurable(Array.prototype.slice, 'length'); +verifyProperty(Array.prototype.slice, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/name.js b/js/src/tests/test262/built-ins/Array/prototype/slice/name.js index b870be1e66..6a37b962e5 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/slice/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.slice.name, "slice"); - -verifyNotEnumerable(Array.prototype.slice, "name"); -verifyNotWritable(Array.prototype.slice, "name"); -verifyConfigurable(Array.prototype.slice, "name"); +verifyProperty(Array.prototype.slice, "name", { + value: "slice", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/slice/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/slice/not-a-constructor.js index 3504fae508..08d6eb8820 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/slice/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/slice/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.slice(); -}, '`new Array.prototype.slice()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/callbackfn-resize-arraybuffer.js b/js/src/tests/test262/built-ins/Array/prototype/some/callbackfn-resize-arraybuffer.js index 0f42d15717..009ee20914 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/some/callbackfn-resize-arraybuffer.js +++ b/js/src/tests/test262/built-ins/Array/prototype/some/callbackfn-resize-arraybuffer.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/length.js b/js/src/tests/test262/built-ins/Array/prototype/some/length.js index 4afccd4124..91e160e62e 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/some/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/some/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.some.length, 1); - -verifyNotEnumerable(Array.prototype.some, 'length'); -verifyNotWritable(Array.prototype.some, 'length'); -verifyConfigurable(Array.prototype.some, 'length'); +verifyProperty(Array.prototype.some, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/name.js b/js/src/tests/test262/built-ins/Array/prototype/some/name.js index 3ccefd3f61..1c6748df51 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/some/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/some/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.some.name, "some"); - -verifyNotEnumerable(Array.prototype.some, "name"); -verifyNotWritable(Array.prototype.some, "name"); -verifyConfigurable(Array.prototype.some, "name"); +verifyProperty(Array.prototype.some, "name", { + value: "some", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/some/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/some/not-a-constructor.js index cff54f8d96..ea2d642790 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/some/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/some/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Array.prototype.some), false, 'isConstructor(Arra assert.throws(TypeError, () => { new Array.prototype.some(() => {}); -}, '`new Array.prototype.some(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/length.js b/js/src/tests/test262/built-ins/Array/prototype/sort/length.js index 67a6be2969..2c386f8955 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/sort/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.sort.length, 1); - -verifyNotEnumerable(Array.prototype.sort, 'length'); -verifyNotWritable(Array.prototype.sort, 'length'); -verifyConfigurable(Array.prototype.sort, 'length'); +verifyProperty(Array.prototype.sort, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/name.js b/js/src/tests/test262/built-ins/Array/prototype/sort/name.js index 5ec58a1bb8..631cdd1816 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/sort/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.sort.name, "sort"); - -verifyNotEnumerable(Array.prototype.sort, "name"); -verifyNotWritable(Array.prototype.sort, "name"); -verifyConfigurable(Array.prototype.sort, "name"); +verifyProperty(Array.prototype.sort, "name", { + value: "sort", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/sort/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/sort/not-a-constructor.js index e9dd5a40d3..b5cf5325a8 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/sort/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/sort/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Array.prototype.sort), false, 'isConstructor(Arra assert.throws(TypeError, () => { new Array.prototype.sort(); -}, '`new Array.prototype.sort()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/length.js b/js/src/tests/test262/built-ins/Array/prototype/splice/length.js index d701b42ae5..051503da45 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/splice/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.splice.length, 2); - -verifyNotEnumerable(Array.prototype.splice, 'length'); -verifyNotWritable(Array.prototype.splice, 'length'); -verifyConfigurable(Array.prototype.splice, 'length'); +verifyProperty(Array.prototype.splice, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/name.js b/js/src/tests/test262/built-ins/Array/prototype/splice/name.js index a0107f69c4..4255958303 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/splice/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.splice.name, "splice"); - -verifyNotEnumerable(Array.prototype.splice, "name"); -verifyNotWritable(Array.prototype.splice, "name"); -verifyConfigurable(Array.prototype.splice, "name"); +verifyProperty(Array.prototype.splice, "name", { + value: "splice", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/splice/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/splice/not-a-constructor.js index 674f869d3a..a19d07703c 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/splice/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/splice/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.splice(); -}, '`new Array.prototype.splice()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/length.js b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/length.js index bc24898e1e..03232222e7 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.toLocaleString.length, 0); - -verifyNotEnumerable(Array.prototype.toLocaleString, 'length'); -verifyNotWritable(Array.prototype.toLocaleString, 'length'); -verifyConfigurable(Array.prototype.toLocaleString, 'length'); +verifyProperty(Array.prototype.toLocaleString, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/name.js b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/name.js index 54f2c57bcb..418664ead2 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.toLocaleString.name, "toLocaleString"); - -verifyNotEnumerable(Array.prototype.toLocaleString, "name"); -verifyNotWritable(Array.prototype.toLocaleString, "name"); -verifyConfigurable(Array.prototype.toLocaleString, "name"); +verifyProperty(Array.prototype.toLocaleString, "name", { + value: "toLocaleString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/not-a-constructor.js index def6d25864..b040fae76f 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/toLocaleString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.toLocaleString(); -}, '`new Array.prototype.toLocaleString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/not-a-constructor.js index 6e848442c9..3b32ac58e3 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/toReversed/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.toReversed(); -}, '`new Array.prototype.toReversed()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toReversed/this-value-nullish.js b/js/src/tests/test262/built-ins/Array/prototype/toReversed/this-value-nullish.js index 682b28addf..1ebdb006c3 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/toReversed/this-value-nullish.js +++ b/js/src/tests/test262/built-ins/Array/prototype/toReversed/this-value-nullish.js @@ -15,10 +15,10 @@ features: [change-array-by-copy] assert.throws(TypeError, () => { Array.prototype.toReversed.call(null); -}, '`Array.prototype.toReversed.call(null)` throws TypeError'); +}); assert.throws(TypeError, () => { Array.prototype.toReversed.call(undefined); -}, '`Array.prototype.toReversed.call(undefined)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/not-a-constructor.js index dda671c3ee..bd2a05683d 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/toSorted/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.toSorted(); -}, '`new Array.prototype.toSorted()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/this-value-nullish.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/this-value-nullish.js index 65690075df..20f9664dfa 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/toSorted/this-value-nullish.js +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/this-value-nullish.js @@ -15,10 +15,10 @@ features: [change-array-by-copy] assert.throws(TypeError, () => { Array.prototype.toSorted.call(null); -}, '`Array.prototype.toSorted.call(null)` throws TypeError'); +}); assert.throws(TypeError, () => { Array.prototype.toSorted.call(undefined); -}, '`Array.prototype.toSorted.call(undefined)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/not-a-constructor.js index 533e8c9eaa..34b5f34f00 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/not-a-constructor.js @@ -29,6 +29,6 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.toSpliced(); -}, '`new Array.prototype.toSpliced()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toString/length.js b/js/src/tests/test262/built-ins/Array/prototype/toString/length.js index d9f0df584e..7b73cc2f87 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/toString/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.toString.length, 0); - -verifyNotEnumerable(Array.prototype.toString, "length"); -verifyNotWritable(Array.prototype.toString, "length"); -verifyConfigurable(Array.prototype.toString, "length"); +verifyProperty(Array.prototype.toString, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toString/name.js b/js/src/tests/test262/built-ins/Array/prototype/toString/name.js index d3fc9528d9..2bd19a5f84 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/toString/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.toString.name, "toString"); - -verifyNotEnumerable(Array.prototype.toString, "name"); -verifyNotWritable(Array.prototype.toString, "name"); -verifyConfigurable(Array.prototype.toString, "name"); +verifyProperty(Array.prototype.toString, "name", { + value: "toString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/toString/not-a-constructor.js index a70534ffd1..630f0301fa 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/toString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/toString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.toString(); -}, '`new Array.prototype.toString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/length.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/length.js index e99bffa6d8..5538fb52aa 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/unshift/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/length.js @@ -25,10 +25,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.unshift.length, 1); - -verifyNotEnumerable(Array.prototype.unshift, 'length'); -verifyNotWritable(Array.prototype.unshift, 'length'); -verifyConfigurable(Array.prototype.unshift, 'length'); +verifyProperty(Array.prototype.unshift, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/name.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/name.js index 4caa8c29b4..320911e6fe 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/unshift/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.unshift.name, "unshift"); - -verifyNotEnumerable(Array.prototype.unshift, "name"); -verifyNotWritable(Array.prototype.unshift, "name"); -verifyConfigurable(Array.prototype.unshift, "name"); +verifyProperty(Array.prototype.unshift, "name", { + value: "unshift", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/unshift/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/unshift/not-a-constructor.js index 415a6e738d..2f308932d8 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/unshift/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/unshift/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.unshift(); -}, '`new Array.prototype.unshift()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/values/length.js b/js/src/tests/test262/built-ins/Array/prototype/values/length.js index c87379d29f..850153c7a7 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/values/length.js +++ b/js/src/tests/test262/built-ins/Array/prototype/values/length.js @@ -18,10 +18,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.values.length, 0); - -verifyNotEnumerable(Array.prototype.values, 'length'); -verifyNotWritable(Array.prototype.values, 'length'); -verifyConfigurable(Array.prototype.values, 'length'); +verifyProperty(Array.prototype.values, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/values/name.js b/js/src/tests/test262/built-ins/Array/prototype/values/name.js index 71eb0fb243..0c311c38e7 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/values/name.js +++ b/js/src/tests/test262/built-ins/Array/prototype/values/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Array.prototype.values.name, 'values'); - -verifyNotEnumerable(Array.prototype.values, 'name'); -verifyNotWritable(Array.prototype.values, 'name'); -verifyConfigurable(Array.prototype.values, 'name'); +verifyProperty(Array.prototype.values, "name", { + value: "values", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/values/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/values/not-a-constructor.js index 2afdde1e37..3ef19e5a4e 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/values/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/values/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.values(); -}, '`new Array.prototype.values()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/with/not-a-constructor.js index 257a21aa51..4d0e060ee4 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/with/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Array/prototype/with/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.with(); -}, '`new Array.prototype.with()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/with/this-value-nullish.js b/js/src/tests/test262/built-ins/Array/prototype/with/this-value-nullish.js index befef0642d..64f029d55e 100644 --- a/js/src/tests/test262/built-ins/Array/prototype/with/this-value-nullish.js +++ b/js/src/tests/test262/built-ins/Array/prototype/with/this-value-nullish.js @@ -15,10 +15,10 @@ features: [change-array-by-copy] assert.throws(TypeError, () => { Array.prototype.with.call(null, 0, 0); -}, '`Array.prototype.with.call(null, 0, 0)` throws TypeError'); +}); assert.throws(TypeError, () => { Array.prototype.with.call(undefined, 0, 0); -}, '`Array.prototype.with.call(undefined, 0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/Symbol.species/length.js b/js/src/tests/test262/built-ins/ArrayBuffer/Symbol.species/length.js index 3d44fa0cae..1ce2f30b45 100644 --- a/js/src/tests/test262/built-ins/ArrayBuffer/Symbol.species/length.js +++ b/js/src/tests/test262/built-ins/ArrayBuffer/Symbol.species/length.js @@ -25,10 +25,11 @@ features: [Symbol.species] var desc = Object.getOwnPropertyDescriptor(ArrayBuffer, Symbol.species); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/Symbol.species/symbol-species-name.js b/js/src/tests/test262/built-ins/ArrayBuffer/Symbol.species/symbol-species-name.js index 2d9d0eb3e8..a5ae191321 100644 --- a/js/src/tests/test262/built-ins/ArrayBuffer/Symbol.species/symbol-species-name.js +++ b/js/src/tests/test262/built-ins/ArrayBuffer/Symbol.species/symbol-species-name.js @@ -15,13 +15,11 @@ includes: [propertyHelper.js] var descriptor = Object.getOwnPropertyDescriptor(ArrayBuffer, Symbol.species); -assert.sameValue( - descriptor.get.name, - 'get [Symbol.species]' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get [Symbol.species]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-buffer.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-buffer.js index 9e8918b388..c3d06668f0 100644 --- a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-buffer.js +++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 The V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-constructor.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-constructor.js index efd5d16984..feee8c989c 100644 --- a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-constructor.js +++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 The V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js index 3d17140d0f..b43ea03666 100644 --- a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js +++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 The V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray.js index 78cbfbbf61..91c4c3330b 100644 --- a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray.js +++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 The V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/invoked-as-a-fn.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/invoked-as-a-fn.js index e58a330cdb..779ab1542a 100644 --- a/js/src/tests/test262/built-ins/ArrayBuffer/isView/invoked-as-a-fn.js +++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/invoked-as-a-fn.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 The V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/length.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/length.js index d74f5ab42d..560f2060f8 100644 --- a/js/src/tests/test262/built-ins/ArrayBuffer/isView/length.js +++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(ArrayBuffer.isView.length, 1); - -verifyNotEnumerable(ArrayBuffer.isView, "length"); -verifyNotWritable(ArrayBuffer.isView, "length"); -verifyConfigurable(ArrayBuffer.isView, "length"); +verifyProperty(ArrayBuffer.isView, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/name.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/name.js index e8ef8b04e5..aeecc5dbad 100644 --- a/js/src/tests/test262/built-ins/ArrayBuffer/isView/name.js +++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(ArrayBuffer.isView.name, "isView"); - -verifyNotEnumerable(ArrayBuffer.isView, "name"); -verifyNotWritable(ArrayBuffer.isView, "name"); -verifyConfigurable(ArrayBuffer.isView, "name"); +verifyProperty(ArrayBuffer.isView, "name", { + value: "isView", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/not-a-constructor.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/not-a-constructor.js index 09f8d71685..5c99e23fc2 100644 --- a/js/src/tests/test262/built-ins/ArrayBuffer/isView/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(ArrayBuffer.isView), false, 'isConstructor(ArrayB assert.throws(TypeError, () => { new ArrayBuffer.isView(); -}, '`new ArrayBuffer.isView()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/options-maxbytelength-allocation-limit.js b/js/src/tests/test262/built-ins/ArrayBuffer/options-maxbytelength-allocation-limit.js new file mode 100644 index 0000000000..e9c5b221d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayBuffer/options-maxbytelength-allocation-limit.js @@ -0,0 +1,43 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer-length +description: > + Throws a RangeError if the requested Data Block is too large. +info: | + ArrayBuffer ( length [ , options ] ) + + ... + 4. Return ? AllocateArrayBuffer(NewTarget, byteLength, requestedMaxByteLength). + + AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] ) + + ... + 5. Let block be ? CreateByteDataBlock(byteLength). + ... + + CreateByteDataBlock ( size ) + + ... + 2. Let db be a new Data Block value consisting of size bytes. If it is + impossible to create such a Data Block, throw a RangeError exception. + ... + +features: [resizable-arraybuffer] +---*/ + +assert.throws(RangeError, function() { + // Allocating 7 PiB should fail with a RangeError. + // Math.pow(1024, 5) = 1125899906842624 + new ArrayBuffer(0, {maxByteLength: 7 * 1125899906842624}); +}, "`maxByteLength` option is 7 PiB"); + +assert.throws(RangeError, function() { + // Allocating almost 8 PiB should fail with a RangeError. + // Math.pow(2, 53) = 9007199254740992 + new ArrayBuffer(0, {maxByteLength: 9007199254740992 - 1}); +}, "`maxByteLength` option is Math.pow(2, 53) - 1"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/options-maxbytelength-compared-before-object-creation.js b/js/src/tests/test262/built-ins/ArrayBuffer/options-maxbytelength-compared-before-object-creation.js new file mode 100644 index 0000000000..d2fd5ff1f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayBuffer/options-maxbytelength-compared-before-object-creation.js @@ -0,0 +1,43 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer-length +description: > + The byteLength argument is validated before OrdinaryCreateFromConstructor. +info: | + ArrayBuffer ( length [ , options ] ) + + ... + 4. Return ? AllocateArrayBuffer(NewTarget, byteLength, requestedMaxByteLength). + + AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] ) + + ... + 3. If allocatingResizableBuffer is true, then + a. If byteLength > maxByteLength, throw a RangeError exception. + ... + 4. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots). + ... + +features: [resizable-arraybuffer, Reflect.construct] +---*/ + +let newTarget = Object.defineProperty(function(){}.bind(null), "prototype", { + get() { + throw new Test262Error(); + } +}); + +assert.throws(RangeError, function() { + let byteLength = 10; + let options = { + maxByteLength: 0, + }; + + // Throws a RangeError, because `byteLength` is larger than `options.maxByteLength`. + Reflect.construct(ArrayBuffer, [byteLength, options], newTarget); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js b/js/src/tests/test262/built-ins/ArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js new file mode 100644 index 0000000000..4e36933b64 --- /dev/null +++ b/js/src/tests/test262/built-ins/ArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js @@ -0,0 +1,44 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-arraybuffer-length +description: > + The new ArrayBuffer instance is created prior to allocating the Data Block. +info: | + ArrayBuffer ( length [ , options ] ) + + ... + 4. Return ? AllocateArrayBuffer(NewTarget, byteLength, requestedMaxByteLength). + + AllocateArrayBuffer ( constructor, byteLength [ , maxByteLength ] ) + + ... + 4. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBuffer.prototype%", slots). + 5. Let block be ? CreateByteDataBlock(byteLength). + ... + +features: [resizable-arraybuffer, Reflect.construct] +---*/ + +function DummyError() {} + +let newTarget = Object.defineProperty(function(){}.bind(null), "prototype", { + get() { + throw new DummyError(); + } +}); + +assert.throws(DummyError, function() { + let byteLength = 0; + let options = { + maxByteLength: 7 * 1125899906842624 + }; + + // Allocating 7 PiB should fail with a RangeError. + // Math.pow(1024, 5) = 1125899906842624 + Reflect.construct(ArrayBuffer, [], newTarget); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/byteLength/length.js b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/byteLength/length.js index 1fb8a5b7b1..a2cc47230a 100644 --- a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/byteLength/length.js +++ b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/byteLength/length.js @@ -24,10 +24,11 @@ includes: [propertyHelper.js] var desc = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength"); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/byteLength/name.js b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/byteLength/name.js index adac94a271..0ac174bcd0 100644 --- a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/byteLength/name.js +++ b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/byteLength/name.js @@ -17,13 +17,11 @@ var descriptor = Object.getOwnPropertyDescriptor( ArrayBuffer.prototype, 'byteLength' ); -assert.sameValue( - descriptor.get.name, 'get byteLength', - 'The value of `descriptor.get.name` is `"get byteLength"`' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get byteLength", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/slice/length.js b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/slice/length.js index e2a15cec4a..2c1c8c198b 100644 --- a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/slice/length.js +++ b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/slice/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(ArrayBuffer.prototype.slice.length, 2); - -verifyNotEnumerable(ArrayBuffer.prototype.slice, "length"); -verifyNotWritable(ArrayBuffer.prototype.slice, "length"); -verifyConfigurable(ArrayBuffer.prototype.slice, "length"); +verifyProperty(ArrayBuffer.prototype.slice, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/slice/name.js b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/slice/name.js index f80ab724da..98df67d368 100644 --- a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/slice/name.js +++ b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/slice/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(ArrayBuffer.prototype.slice.name, "slice"); - -verifyNotEnumerable(ArrayBuffer.prototype.slice, "name"); -verifyNotWritable(ArrayBuffer.prototype.slice, "name"); -verifyConfigurable(ArrayBuffer.prototype.slice, "name"); +verifyProperty(ArrayBuffer.prototype.slice, "name", { + value: "slice", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/slice/not-a-constructor.js b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/slice/not-a-constructor.js index 06ff78c2aa..306c5abdd6 100644 --- a/js/src/tests/test262/built-ins/ArrayBuffer/prototype/slice/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/ArrayBuffer/prototype/slice/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let ab = new ArrayBuffer(); new ab.slice(); -}, '`let ab = new ArrayBuffer(); new ab.slice()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/detach-typedarray-in-progress.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/detach-typedarray-in-progress.js index addce3aa70..e5362c7922 100644 --- a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/detach-typedarray-in-progress.js +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/detach-typedarray-in-progress.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/length.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/length.js index 22f673c500..a992d46b6b 100644 --- a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/length.js +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/length.js @@ -25,10 +25,11 @@ features: [Symbol.iterator] var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); -assert.sameValue(ArrayIteratorProto.next.length, 0); - -verifyNotEnumerable(ArrayIteratorProto.next, "length"); -verifyNotWritable(ArrayIteratorProto.next, "length"); -verifyConfigurable(ArrayIteratorProto.next, "length"); +verifyProperty(ArrayIteratorProto.next, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/name.js b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/name.js index b6e90d9645..781400569e 100644 --- a/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/name.js +++ b/js/src/tests/test262/built-ins/ArrayIteratorPrototype/next/name.js @@ -22,10 +22,11 @@ features: [Symbol.iterator] var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); -assert.sameValue(ArrayIteratorProto.next.name, "next"); - -verifyNotEnumerable(ArrayIteratorProto.next, "name"); -verifyNotWritable(ArrayIteratorProto.next, "name"); -verifyConfigurable(ArrayIteratorProto.next, "name"); +verifyProperty(ArrayIteratorProto.next, "name", { + value: "next", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/AsyncFunction/AsyncFunction-length.js b/js/src/tests/test262/built-ins/AsyncFunction/AsyncFunction-length.js index 03a0119a4e..856ec3b503 100644 --- a/js/src/tests/test262/built-ins/AsyncFunction/AsyncFunction-length.js +++ b/js/src/tests/test262/built-ins/AsyncFunction/AsyncFunction-length.js @@ -10,9 +10,11 @@ includes: [propertyHelper.js] ---*/ var AsyncFunction = async function foo() {}.constructor; -assert.sameValue(AsyncFunction.length, 1); -verifyNotWritable(AsyncFunction, 'length'); -verifyNotEnumerable(AsyncFunction, 'length'); -verifyConfigurable(AsyncFunction, 'length'); +verifyProperty(AsyncFunction, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/AsyncFunction/AsyncFunction-name.js b/js/src/tests/test262/built-ins/AsyncFunction/AsyncFunction-name.js index b745e91a15..b58d0e0a10 100644 --- a/js/src/tests/test262/built-ins/AsyncFunction/AsyncFunction-name.js +++ b/js/src/tests/test262/built-ins/AsyncFunction/AsyncFunction-name.js @@ -10,9 +10,11 @@ includes: [propertyHelper.js] ---*/ var AsyncFunction = async function foo() {}.constructor; -assert.sameValue(AsyncFunction.name, "AsyncFunction"); -verifyNotWritable(AsyncFunction, "name"); -verifyNotEnumerable(AsyncFunction, "name"); -verifyConfigurable(AsyncFunction, "name"); +verifyProperty(AsyncFunction, "name", { + value: "AsyncFunction", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/AsyncFunction/instance-has-name.js b/js/src/tests/test262/built-ins/AsyncFunction/instance-has-name.js index 13a6a8eb53..3492890300 100644 --- a/js/src/tests/test262/built-ins/AsyncFunction/instance-has-name.js +++ b/js/src/tests/test262/built-ins/AsyncFunction/instance-has-name.js @@ -10,9 +10,11 @@ includes: [propertyHelper.js] async function foo() {}; -assert.sameValue(foo.name, "foo"); -verifyNotWritable(foo, "name"); -verifyNotEnumerable(foo, "name"); -verifyConfigurable(foo, "name"); +verifyProperty(foo, "name", { + value: "foo", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/add/bad-range.js b/js/src/tests/test262/built-ins/Atomics/add/bad-range.js index 2654eb2364..218fd647ec 100644 --- a/js/src/tests/test262/built-ins/Atomics/add/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/add/bad-range.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -18,7 +18,7 @@ testWithTypedArrayConstructors(function(TA) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.add(view, IdxGen(view), 10); - }, '`Atomics.add(view, IdxGen(view), 10)` throws RangeError'); + }); }); }, views); diff --git a/js/src/tests/test262/built-ins/Atomics/add/bigint/bad-range.js b/js/src/tests/test262/built-ins/Atomics/add/bigint/bad-range.js index 86f2456e24..f87b765f4d 100644 --- a/js/src/tests/test262/built-ins/Atomics/add/bigint/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/add/bigint/bad-range.js @@ -16,7 +16,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.add(view, IdxGen(view), 10n); - }, '`Atomics.add(view, IdxGen(view), 10n)` throws RangeError'); + }); }); }); diff --git a/js/src/tests/test262/built-ins/Atomics/add/good-views.js b/js/src/tests/test262/built-ins/Atomics/add/good-views.js index fdb204d040..0aa930296c 100644 --- a/js/src/tests/test262/built-ins/Atomics/add/good-views.js +++ b/js/src/tests/test262/built-ins/Atomics/add/good-views.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/add/non-shared-bufferdata.js b/js/src/tests/test262/built-ins/Atomics/add/non-shared-bufferdata.js index 2ca4c447f8..1304d10ae7 100644 --- a/js/src/tests/test262/built-ins/Atomics/add/non-shared-bufferdata.js +++ b/js/src/tests/test262/built-ins/Atomics/add/non-shared-bufferdata.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/add/non-shared-int-views-throws.js b/js/src/tests/test262/built-ins/Atomics/add/non-shared-int-views-throws.js index 6c7c88cec1..0fb2ff3c91 100644 --- a/js/src/tests/test262/built-ins/Atomics/add/non-shared-int-views-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/add/non-shared-int-views-throws.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/add/non-views.js b/js/src/tests/test262/built-ins/Atomics/add/non-views.js index c10fa26753..85e50b31b4 100644 --- a/js/src/tests/test262/built-ins/Atomics/add/non-views.js +++ b/js/src/tests/test262/built-ins/Atomics/add/non-views.js @@ -13,7 +13,7 @@ features: [ArrayBuffer, Atomics, DataView, SharedArrayBuffer, Symbol, TypedArray testWithAtomicsNonViewValues(function(view) { assert.throws(TypeError, function() { Atomics.add(view, 0, 0); - }, '`Atomics.add(view, 0, 0)` throws TypeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/add/not-a-constructor.js b/js/src/tests/test262/built-ins/Atomics/add/not-a-constructor.js index 723164589f..d824718211 100644 --- a/js/src/tests/test262/built-ins/Atomics/add/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Atomics/add/not-a-constructor.js @@ -26,7 +26,7 @@ assert.sameValue(isConstructor(Atomics.add), false, 'isConstructor(Atomics.add) assert.throws(TypeError, () => { new Atomics.add(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))); -}, '`new Atomics.add(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)))` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/add/validate-arraytype-before-index-coercion.js b/js/src/tests/test262/built-ins/Atomics/add/validate-arraytype-before-index-coercion.js index 10ada1eceb..f579bcac5d 100644 --- a/js/src/tests/test262/built-ins/Atomics/add/validate-arraytype-before-index-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/add/validate-arraytype-before-index-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/add/validate-arraytype-before-value-coercion.js b/js/src/tests/test262/built-ins/Atomics/add/validate-arraytype-before-value-coercion.js index f52d769b76..675c1d2059 100644 --- a/js/src/tests/test262/built-ins/Atomics/add/validate-arraytype-before-value-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/add/validate-arraytype-before-value-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/and/bad-range.js b/js/src/tests/test262/built-ins/Atomics/and/bad-range.js index 8548ab5dc3..1f1d83102b 100644 --- a/js/src/tests/test262/built-ins/Atomics/and/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/and/bad-range.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -18,7 +18,7 @@ testWithTypedArrayConstructors(function(TA) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.and(view, IdxGen(view), 10); - }, '`Atomics.and(view, IdxGen(view), 10)` throws RangeError'); + }); }); }, views); diff --git a/js/src/tests/test262/built-ins/Atomics/and/bigint/bad-range.js b/js/src/tests/test262/built-ins/Atomics/and/bigint/bad-range.js index a64ae66282..a031bc31e2 100644 --- a/js/src/tests/test262/built-ins/Atomics/and/bigint/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/and/bigint/bad-range.js @@ -16,7 +16,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.and(view, IdxGen(view), 10n); - }, '`Atomics.and(view, IdxGen(view), 10n)` throws RangeError'); + }); }); }); diff --git a/js/src/tests/test262/built-ins/Atomics/and/good-views.js b/js/src/tests/test262/built-ins/Atomics/and/good-views.js index 532b75674d..0e5a40ec00 100644 --- a/js/src/tests/test262/built-ins/Atomics/and/good-views.js +++ b/js/src/tests/test262/built-ins/Atomics/and/good-views.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/and/non-shared-bufferdata.js b/js/src/tests/test262/built-ins/Atomics/and/non-shared-bufferdata.js index be959d353d..ab6945fcb7 100644 --- a/js/src/tests/test262/built-ins/Atomics/and/non-shared-bufferdata.js +++ b/js/src/tests/test262/built-ins/Atomics/and/non-shared-bufferdata.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/and/non-shared-int-views-throws.js b/js/src/tests/test262/built-ins/Atomics/and/non-shared-int-views-throws.js index 90987ae1ce..67eee61a82 100644 --- a/js/src/tests/test262/built-ins/Atomics/and/non-shared-int-views-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/and/non-shared-int-views-throws.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/and/non-views.js b/js/src/tests/test262/built-ins/Atomics/and/non-views.js index 49732f95c9..37b64d1d7f 100644 --- a/js/src/tests/test262/built-ins/Atomics/and/non-views.js +++ b/js/src/tests/test262/built-ins/Atomics/and/non-views.js @@ -13,7 +13,7 @@ features: [ArrayBuffer, Atomics, DataView, SharedArrayBuffer, Symbol, TypedArray testWithAtomicsNonViewValues(function(view) { assert.throws(TypeError, function() { Atomics.and(view, 0, 0); - }, '`Atomics.and(view, 0, 0)` throws TypeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/and/not-a-constructor.js b/js/src/tests/test262/built-ins/Atomics/and/not-a-constructor.js index 9f6fb08569..c47a6e16b8 100644 --- a/js/src/tests/test262/built-ins/Atomics/and/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Atomics/and/not-a-constructor.js @@ -26,7 +26,7 @@ assert.sameValue(isConstructor(Atomics.and), false, 'isConstructor(Atomics.and) assert.throws(TypeError, () => { new Atomics.and(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))); -}, '`new Atomics.and(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)))` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/and/validate-arraytype-before-index-coercion.js b/js/src/tests/test262/built-ins/Atomics/and/validate-arraytype-before-index-coercion.js index edfe4f88d0..e46ff549b4 100644 --- a/js/src/tests/test262/built-ins/Atomics/and/validate-arraytype-before-index-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/and/validate-arraytype-before-index-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/and/validate-arraytype-before-value-coercion.js b/js/src/tests/test262/built-ins/Atomics/and/validate-arraytype-before-value-coercion.js index 30b017f6b4..4235d4ad32 100644 --- a/js/src/tests/test262/built-ins/Atomics/and/validate-arraytype-before-value-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/and/validate-arraytype-before-value-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/compareExchange/bad-range.js b/js/src/tests/test262/built-ins/Atomics/compareExchange/bad-range.js index 507b33750c..d37df6c890 100644 --- a/js/src/tests/test262/built-ins/Atomics/compareExchange/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/compareExchange/bad-range.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -18,7 +18,7 @@ testWithTypedArrayConstructors(function(TA) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.compareExchange(view, IdxGen(view), 10, 0); - }, '`Atomics.compareExchange(view, IdxGen(view), 10, 0)` throws RangeError'); + }); }); }, views); diff --git a/js/src/tests/test262/built-ins/Atomics/compareExchange/bigint/bad-range.js b/js/src/tests/test262/built-ins/Atomics/compareExchange/bigint/bad-range.js index 1799f1cefc..57fce441d1 100644 --- a/js/src/tests/test262/built-ins/Atomics/compareExchange/bigint/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/compareExchange/bigint/bad-range.js @@ -16,7 +16,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.compareExchange(view, IdxGen(view), 10, 0n); - }, '`Atomics.compareExchange(view, IdxGen(view), 10, 0n)` throws RangeError'); + }); }); }); diff --git a/js/src/tests/test262/built-ins/Atomics/compareExchange/good-views.js b/js/src/tests/test262/built-ins/Atomics/compareExchange/good-views.js index 3f1e5fd82c..a92fbbf9a0 100644 --- a/js/src/tests/test262/built-ins/Atomics/compareExchange/good-views.js +++ b/js/src/tests/test262/built-ins/Atomics/compareExchange/good-views.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/compareExchange/non-shared-bufferdata.js b/js/src/tests/test262/built-ins/Atomics/compareExchange/non-shared-bufferdata.js index a5d3058801..fe669bbcf8 100644 --- a/js/src/tests/test262/built-ins/Atomics/compareExchange/non-shared-bufferdata.js +++ b/js/src/tests/test262/built-ins/Atomics/compareExchange/non-shared-bufferdata.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/compareExchange/non-shared-int-views-throws.js b/js/src/tests/test262/built-ins/Atomics/compareExchange/non-shared-int-views-throws.js index 45df6f8cb5..637dea2721 100644 --- a/js/src/tests/test262/built-ins/Atomics/compareExchange/non-shared-int-views-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/compareExchange/non-shared-int-views-throws.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/compareExchange/non-views.js b/js/src/tests/test262/built-ins/Atomics/compareExchange/non-views.js index f3be53cbe7..9ab32629de 100644 --- a/js/src/tests/test262/built-ins/Atomics/compareExchange/non-views.js +++ b/js/src/tests/test262/built-ins/Atomics/compareExchange/non-views.js @@ -13,7 +13,7 @@ features: [ArrayBuffer, Atomics, DataView, SharedArrayBuffer, Symbol, TypedArray testWithAtomicsNonViewValues(function(view) { assert.throws(TypeError, function() { Atomics.compareExchange(view, 0, 0, 0); - }, '`Atomics.compareExchange(view, 0, 0, 0)` throws TypeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/compareExchange/not-a-constructor.js b/js/src/tests/test262/built-ins/Atomics/compareExchange/not-a-constructor.js index c42a00268b..207a8b2d4d 100644 --- a/js/src/tests/test262/built-ins/Atomics/compareExchange/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Atomics/compareExchange/not-a-constructor.js @@ -30,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Atomics.compareExchange(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))); -}, '`new Atomics.compareExchange(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)))` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/compareExchange/validate-arraytype-before-expectedValue-coercion.js b/js/src/tests/test262/built-ins/Atomics/compareExchange/validate-arraytype-before-expectedValue-coercion.js index 7392e72344..d57c025eaa 100644 --- a/js/src/tests/test262/built-ins/Atomics/compareExchange/validate-arraytype-before-expectedValue-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/compareExchange/validate-arraytype-before-expectedValue-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/compareExchange/validate-arraytype-before-index-coercion.js b/js/src/tests/test262/built-ins/Atomics/compareExchange/validate-arraytype-before-index-coercion.js index 5ddd207d24..004d9f66a3 100644 --- a/js/src/tests/test262/built-ins/Atomics/compareExchange/validate-arraytype-before-index-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/compareExchange/validate-arraytype-before-index-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/compareExchange/validate-arraytype-before-replacementValue-coercion.js b/js/src/tests/test262/built-ins/Atomics/compareExchange/validate-arraytype-before-replacementValue-coercion.js index 065a032809..37676f2c7a 100644 --- a/js/src/tests/test262/built-ins/Atomics/compareExchange/validate-arraytype-before-replacementValue-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/compareExchange/validate-arraytype-before-replacementValue-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/exchange/bad-range.js b/js/src/tests/test262/built-ins/Atomics/exchange/bad-range.js index 23cda3ced4..7267562e60 100644 --- a/js/src/tests/test262/built-ins/Atomics/exchange/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/exchange/bad-range.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -18,7 +18,7 @@ testWithTypedArrayConstructors(function(TA) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.exchange(view, IdxGen(view), 10, 0); - }, '`Atomics.exchange(view, IdxGen(view), 10, 0)` throws RangeError'); + }); }); }, views); diff --git a/js/src/tests/test262/built-ins/Atomics/exchange/bigint/bad-range.js b/js/src/tests/test262/built-ins/Atomics/exchange/bigint/bad-range.js index 205ecdcd59..9a54b77577 100644 --- a/js/src/tests/test262/built-ins/Atomics/exchange/bigint/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/exchange/bigint/bad-range.js @@ -16,7 +16,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.exchange(view, IdxGen(view), 10n, 0n); - }, '`Atomics.exchange(view, IdxGen(view), 10n, 0n)` throws RangeError'); + }); }); }); diff --git a/js/src/tests/test262/built-ins/Atomics/exchange/good-views.js b/js/src/tests/test262/built-ins/Atomics/exchange/good-views.js index 80eab9dfa6..b19a940390 100644 --- a/js/src/tests/test262/built-ins/Atomics/exchange/good-views.js +++ b/js/src/tests/test262/built-ins/Atomics/exchange/good-views.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/exchange/non-shared-bufferdata.js b/js/src/tests/test262/built-ins/Atomics/exchange/non-shared-bufferdata.js index 463ae4ebb6..31cdadc48f 100644 --- a/js/src/tests/test262/built-ins/Atomics/exchange/non-shared-bufferdata.js +++ b/js/src/tests/test262/built-ins/Atomics/exchange/non-shared-bufferdata.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/exchange/non-shared-int-views-throws.js b/js/src/tests/test262/built-ins/Atomics/exchange/non-shared-int-views-throws.js index e3b53900aa..29007955d8 100644 --- a/js/src/tests/test262/built-ins/Atomics/exchange/non-shared-int-views-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/exchange/non-shared-int-views-throws.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/exchange/non-views.js b/js/src/tests/test262/built-ins/Atomics/exchange/non-views.js index 8cc0d76b0a..733df3f58c 100644 --- a/js/src/tests/test262/built-ins/Atomics/exchange/non-views.js +++ b/js/src/tests/test262/built-ins/Atomics/exchange/non-views.js @@ -13,7 +13,7 @@ features: [ArrayBuffer, Atomics, DataView, SharedArrayBuffer, Symbol, TypedArray testWithAtomicsNonViewValues(function(view) { assert.throws(TypeError, function() { Atomics.exchange(view, 0, 0); - }, '`Atomics.exchange(view, 0, 0)` throws TypeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/exchange/nonshared-int-views.js b/js/src/tests/test262/built-ins/Atomics/exchange/nonshared-int-views.js index 5a45151e87..a6400d1f77 100644 --- a/js/src/tests/test262/built-ins/Atomics/exchange/nonshared-int-views.js +++ b/js/src/tests/test262/built-ins/Atomics/exchange/nonshared-int-views.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/exchange/not-a-constructor.js b/js/src/tests/test262/built-ins/Atomics/exchange/not-a-constructor.js index 2115000021..31e0599db0 100644 --- a/js/src/tests/test262/built-ins/Atomics/exchange/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Atomics/exchange/not-a-constructor.js @@ -26,7 +26,7 @@ assert.sameValue(isConstructor(Atomics.exchange), false, 'isConstructor(Atomics. assert.throws(TypeError, () => { new Atomics.exchange(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))); -}, '`new Atomics.exchange(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)))` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/exchange/validate-arraytype-before-index-coercion.js b/js/src/tests/test262/built-ins/Atomics/exchange/validate-arraytype-before-index-coercion.js index 5e8b5c17e3..f5e3a94bf1 100644 --- a/js/src/tests/test262/built-ins/Atomics/exchange/validate-arraytype-before-index-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/exchange/validate-arraytype-before-index-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/exchange/validate-arraytype-before-value-coercion.js b/js/src/tests/test262/built-ins/Atomics/exchange/validate-arraytype-before-value-coercion.js index eb5589c6ea..faf2e2ef13 100644 --- a/js/src/tests/test262/built-ins/Atomics/exchange/validate-arraytype-before-value-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/exchange/validate-arraytype-before-value-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/isLockFree/not-a-constructor.js b/js/src/tests/test262/built-ins/Atomics/isLockFree/not-a-constructor.js index 03202213e7..1ff1840bcb 100644 --- a/js/src/tests/test262/built-ins/Atomics/isLockFree/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Atomics/isLockFree/not-a-constructor.js @@ -26,7 +26,7 @@ assert.sameValue(isConstructor(Atomics.isLockFree), false, 'isConstructor(Atomic assert.throws(TypeError, () => { new Atomics.isLockFree(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))); -}, '`new Atomics.isLockFree(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)))` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/load/bad-range.js b/js/src/tests/test262/built-ins/Atomics/load/bad-range.js index 3dfe8ae858..ea68c9c4e0 100644 --- a/js/src/tests/test262/built-ins/Atomics/load/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/load/bad-range.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -18,7 +18,7 @@ testWithTypedArrayConstructors(function(TA) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.load(view, IdxGen(view)); - }, '`Atomics.load(view, IdxGen(view))` throws RangeError'); + }); }); }, views); diff --git a/js/src/tests/test262/built-ins/Atomics/load/bigint/bad-range.js b/js/src/tests/test262/built-ins/Atomics/load/bigint/bad-range.js index bdb8eed01e..27f6010bef 100644 --- a/js/src/tests/test262/built-ins/Atomics/load/bigint/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/load/bigint/bad-range.js @@ -17,7 +17,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.load(view, IdxGen(view)); - }, '`Atomics.load(view, IdxGen(view))` throws RangeError'); + }); }); }); diff --git a/js/src/tests/test262/built-ins/Atomics/load/good-views.js b/js/src/tests/test262/built-ins/Atomics/load/good-views.js index 6f77377428..b196e35bb9 100644 --- a/js/src/tests/test262/built-ins/Atomics/load/good-views.js +++ b/js/src/tests/test262/built-ins/Atomics/load/good-views.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/load/non-shared-bufferdata.js b/js/src/tests/test262/built-ins/Atomics/load/non-shared-bufferdata.js index 73ae85260c..6d1aedc72b 100644 --- a/js/src/tests/test262/built-ins/Atomics/load/non-shared-bufferdata.js +++ b/js/src/tests/test262/built-ins/Atomics/load/non-shared-bufferdata.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/load/non-shared-int-views-throws.js b/js/src/tests/test262/built-ins/Atomics/load/non-shared-int-views-throws.js index a8bb46083c..4c0075da7d 100644 --- a/js/src/tests/test262/built-ins/Atomics/load/non-shared-int-views-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/load/non-shared-int-views-throws.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/load/non-views.js b/js/src/tests/test262/built-ins/Atomics/load/non-views.js index a88dc89ee8..d0b482d8b0 100644 --- a/js/src/tests/test262/built-ins/Atomics/load/non-views.js +++ b/js/src/tests/test262/built-ins/Atomics/load/non-views.js @@ -13,7 +13,7 @@ features: [ArrayBuffer, Atomics, DataView, SharedArrayBuffer, Symbol, TypedArray testWithAtomicsNonViewValues(function(view) { assert.throws(TypeError, function() { Atomics.load(view, 0); - }, '`Atomics.load(view, 0)` throws TypeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/load/not-a-constructor.js b/js/src/tests/test262/built-ins/Atomics/load/not-a-constructor.js index 270660c5cf..a03779be16 100644 --- a/js/src/tests/test262/built-ins/Atomics/load/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Atomics/load/not-a-constructor.js @@ -26,7 +26,7 @@ assert.sameValue(isConstructor(Atomics.load), false, 'isConstructor(Atomics.load assert.throws(TypeError, () => { new Atomics.load(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))); -}, '`new Atomics.load(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)))` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/load/validate-arraytype-before-index-coercion.js b/js/src/tests/test262/built-ins/Atomics/load/validate-arraytype-before-index-coercion.js index 70ef58f258..4b6e06d9f2 100644 --- a/js/src/tests/test262/built-ins/Atomics/load/validate-arraytype-before-index-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/load/validate-arraytype-before-index-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/notify/bad-range.js b/js/src/tests/test262/built-ins/Atomics/notify/bad-range.js index 78d1f0336a..09600fd0fb 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/bad-range.js @@ -23,7 +23,7 @@ const i32a = new Int32Array( testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.notify(i32a, IdxGen(i32a), 0); - }, '`Atomics.notify(i32a, IdxGen(i32a), 0)` throws RangeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/bigint/bad-range.js b/js/src/tests/test262/built-ins/Atomics/notify/bigint/bad-range.js index 469d169ec9..7c8707612a 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/bigint/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/bigint/bad-range.js @@ -23,7 +23,7 @@ const i64a = new BigInt64Array( testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.notify(i64a, IdxGen(i64a), 0); - }, '`Atomics.notify(i64a, IdxGen(i64a), 0)` throws RangeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-bigint64-typedarray-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-bigint64-typedarray-throws.js index 94fc29e40d..eae67c20ac 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-bigint64-typedarray-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-bigint64-typedarray-throws.js @@ -28,10 +28,10 @@ const poisoned = { assert.throws(TypeError, function() { Atomics.wait(i64a, 0, 0); -}, '`Atomics.wait(i64a, 0, 0)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.wait(i64a, poisoned, poisoned); -}, '`Atomics.wait(i64a, poisoned, poisoned)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-count-evaluation-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-count-evaluation-throws.js index 5c5781f429..9c5911952f 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-count-evaluation-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-count-evaluation-throws.js @@ -31,6 +31,6 @@ const poisoned = { assert.throws(Test262Error, function() { Atomics.notify(i64a, poisoned, 0); -}, '`Atomics.notify(i64a, poisoned, 0)` throws Test262Error'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-index-evaluation-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-index-evaluation-throws.js index c345fa7265..bac6596a0f 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-index-evaluation-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-index-evaluation-throws.js @@ -28,7 +28,7 @@ const poisoned = { assert.throws(Test262Error, function() { Atomics.notify(i64a, 0, poisoned); -}, '`Atomics.notify(i64a, 0, poisoned)` throws Test262Error'); +}); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-non-shared-int-views-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-non-shared-int-views-throws.js index 274bb87374..f32861e48e 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-non-shared-int-views-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/bigint/non-shared-bufferdata-non-shared-int-views-throws.js @@ -19,6 +19,6 @@ const poisoned = { assert.throws(TypeError, function() { Atomics.notify(new BigUint64Array(nonsab), poisoned, poisoned); -}, '`Atomics.notify(new BigUint64Array(nonsab), poisoned, poisoned)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/bigint/null-bufferdata-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/bigint/null-bufferdata-throws.js index 99bfc3cff9..75e2b6b3f9 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/bigint/null-bufferdata-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/bigint/null-bufferdata-throws.js @@ -34,6 +34,6 @@ try { assert.throws(TypeError, function() { Atomics.notify(i64a, poisoned, poisoned); -}, '`Atomics.notify(i64a, poisoned, poisoned)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/count-symbol-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/count-symbol-throws.js index 067e802544..dd59c2fc88 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/count-symbol-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/count-symbol-throws.js @@ -24,6 +24,6 @@ const i32a = new Int32Array( assert.throws(TypeError, function() { Atomics.notify(i32a, 0, Symbol()); -}, '`Atomics.notify(i32a, 0, Symbol())` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/count-tointeger-throws-then-wake-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/count-tointeger-throws-then-wake-throws.js index 69c3c39d09..ca99b74e1f 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/count-tointeger-throws-then-wake-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/count-tointeger-throws-then-wake-throws.js @@ -30,6 +30,6 @@ const poisoned = { assert.throws(Test262Error, function() { Atomics.notify(i32a, 0, poisoned); -}, '`Atomics.notify(i32a, 0, poisoned)` throws Test262Error'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/negative-index-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/negative-index-throws.js index 7b22715ce6..ed9dff1448 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/negative-index-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/negative-index-throws.js @@ -29,15 +29,15 @@ const poisoned = { assert.throws(RangeError, function() { Atomics.notify(i32a, -Infinity, poisoned); -}, '`Atomics.notify(i32a, -Infinity, poisoned)` throws RangeError'); +}); assert.throws(RangeError, function() { Atomics.notify(i32a, -7.999, poisoned); -}, '`Atomics.notify(i32a, -7.999, poisoned)` throws RangeError'); +}); assert.throws(RangeError, function() { Atomics.notify(i32a, -1, poisoned); -}, '`Atomics.notify(i32a, -1, poisoned)` throws RangeError'); +}); assert.throws(RangeError, function() { Atomics.notify(i32a, -300, poisoned); -}, '`Atomics.notify(i32a, -300, poisoned)` throws RangeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/non-int32-typedarray-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/non-int32-typedarray-throws.js index 5ca1ab5080..a3cf9027e3 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/non-int32-typedarray-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/non-int32-typedarray-throws.js @@ -27,14 +27,14 @@ assert.throws(TypeError, function() { new SharedArrayBuffer(Float64Array.BYTES_PER_ELEMENT * 8) ); Atomics.notify(view, poisoned, poisoned); -}, '`const view = new Float64Array( new SharedArrayBuffer(Float64Array.BYTES_PER_ELEMENT * 8) ); Atomics.notify(view, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { const view = new Float32Array( new SharedArrayBuffer(Float32Array.BYTES_PER_ELEMENT * 4) ); Atomics.notify(view, poisoned, poisoned); -}, '`const view = new Float32Array( new SharedArrayBuffer(Float32Array.BYTES_PER_ELEMENT * 4) ); Atomics.notify(view, poisoned, poisoned)` throws TypeError'); +}); if (typeof Float16Array !== 'undefined') { assert.throws(TypeError, function() { @@ -42,7 +42,7 @@ if (typeof Float16Array !== 'undefined') { new SharedArrayBuffer(Float16Array.BYTES_PER_ELEMENT * 2) ); Atomics.notify(view, poisoned, poisoned); - }, '`const view = new Float16Array( new SharedArrayBuffer(Float16Array.BYTES_PER_ELEMENT * 2) ); Atomics.notify(view, poisoned, poisoned)` throws TypeError'); + }); } assert.throws(TypeError, function() { @@ -50,41 +50,41 @@ assert.throws(TypeError, function() { new SharedArrayBuffer(Int16Array.BYTES_PER_ELEMENT * 2) ); Atomics.notify(view, poisoned, poisoned); -}, '`const view = new Int16Array( new SharedArrayBuffer(Int16Array.BYTES_PER_ELEMENT * 2) ); Atomics.notify(view, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { const view = new Int8Array( new SharedArrayBuffer(Int8Array.BYTES_PER_ELEMENT) ); Atomics.notify(view, poisoned, poisoned); -}, '`const view = new Int8Array( new SharedArrayBuffer(Int8Array.BYTES_PER_ELEMENT) ); Atomics.notify(view, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { const view = new Uint32Array( new SharedArrayBuffer(Uint32Array.BYTES_PER_ELEMENT * 4) ); Atomics.notify(new Uint32Array(), poisoned, poisoned); -}, '`const view = new Uint32Array( new SharedArrayBuffer(Uint32Array.BYTES_PER_ELEMENT * 4) ); Atomics.notify(new Uint32Array(), poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { const view = new Uint16Array( new SharedArrayBuffer(Uint16Array.BYTES_PER_ELEMENT * 2) ); Atomics.notify(view, poisoned, poisoned); -}, '`const view = new Uint16Array( new SharedArrayBuffer(Uint16Array.BYTES_PER_ELEMENT * 2) ); Atomics.notify(view, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { const view = new Uint8Array( new SharedArrayBuffer(Uint8Array.BYTES_PER_ELEMENT) ); Atomics.notify(view, poisoned, poisoned); -}, '`const view = new Uint8Array( new SharedArrayBuffer(Uint8Array.BYTES_PER_ELEMENT) ); Atomics.notify(view, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { const view = new Uint8ClampedArray( new SharedArrayBuffer(Uint8ClampedArray.BYTES_PER_ELEMENT) ); Atomics.notify(view, poisoned, poisoned); -}, '`const view = new Uint8ClampedArray( new SharedArrayBuffer(Uint8ClampedArray.BYTES_PER_ELEMENT) ); Atomics.notify(view, poisoned, poisoned)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/non-shared-bufferdata-count-evaluation-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/non-shared-bufferdata-count-evaluation-throws.js index c745669449..a30211d6a2 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/non-shared-bufferdata-count-evaluation-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/non-shared-bufferdata-count-evaluation-throws.js @@ -32,7 +32,7 @@ const poisoned = { assert.throws(Test262Error, function() { Atomics.notify(i32a, 0, poisoned); -}, '`Atomics.notify(i32a, 0, poisoned)` throws Test262Error'); +}); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/non-shared-bufferdata-index-evaluation-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/non-shared-bufferdata-index-evaluation-throws.js index d2cda0718b..799c906bba 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/non-shared-bufferdata-index-evaluation-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/non-shared-bufferdata-index-evaluation-throws.js @@ -28,7 +28,7 @@ const poisoned = { assert.throws(Test262Error, function() { Atomics.notify(i32a, poisoned, 0); -}, '`Atomics.notify(i32a, poisoned, 0)` throws Test262Error'); +}); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/non-shared-bufferdata-non-shared-int-views-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/non-shared-bufferdata-non-shared-int-views-throws.js index 9f9ebd1bb8..6bcc702ef3 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/non-shared-bufferdata-non-shared-int-views-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/non-shared-bufferdata-non-shared-int-views-throws.js @@ -19,26 +19,26 @@ const poisoned = { assert.throws(TypeError, function() { Atomics.notify(new Int16Array(nonsab), poisoned, poisoned); -}, '`Atomics.notify(new Int16Array(nonsab), poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.notify(new Int8Array(nonsab), poisoned, poisoned); -}, '`Atomics.notify(new Int8Array(nonsab), poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.notify(new Uint32Array(nonsab), poisoned, poisoned); -}, '`Atomics.notify(new Uint32Array(nonsab), poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.notify(new Uint16Array(nonsab), poisoned, poisoned); -}, '`Atomics.notify(new Uint16Array(nonsab), poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.notify(new Uint8Array(nonsab), poisoned, poisoned); -}, '`Atomics.notify(new Uint8Array(nonsab), poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.notify(new Uint8ClampedArray(nonsab), poisoned, poisoned); -}, '`Atomics.notify(new Uint8ClampedArray(nonsab), poisoned, poisoned)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/non-shared-int-views.js b/js/src/tests/test262/built-ins/Atomics/notify/non-shared-int-views.js index 4cb606a813..f879615fbd 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/non-shared-int-views.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/non-shared-int-views.js @@ -19,26 +19,26 @@ const poisoned = { assert.throws(TypeError, function() { Atomics.notify(new Int16Array(sab), poisoned, poisoned); -}, '`Atomics.notify(new Int16Array(sab), poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.notify(new Int8Array(sab), poisoned, poisoned); -}, '`Atomics.notify(new Int8Array(sab), poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.notify(new Uint32Array(sab), poisoned, poisoned); -}, '`Atomics.notify(new Uint32Array(sab), poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.notify(new Uint16Array(sab), poisoned, poisoned); -}, '`Atomics.notify(new Uint16Array(sab), poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.notify(new Uint8Array(sab), poisoned, poisoned); -}, '`Atomics.notify(new Uint8Array(sab), poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.notify(new Uint8ClampedArray(sab), poisoned, poisoned); -}, '`Atomics.notify(new Uint8ClampedArray(sab), poisoned, poisoned)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/non-views.js b/js/src/tests/test262/built-ins/Atomics/notify/non-views.js index e068c2d5c7..c01806f9bc 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/non-views.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/non-views.js @@ -13,7 +13,7 @@ features: [ArrayBuffer, Atomics, DataView, SharedArrayBuffer, Symbol, TypedArray testWithAtomicsNonViewValues(function(nonView) { assert.throws(TypeError, function() { Atomics.notify(nonView, 0, 0); - }, '`Atomics.notify(nonView, 0, 0)` throws TypeError'); // Even with count == 0 + }); // Even with count == 0 }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/not-a-constructor.js b/js/src/tests/test262/built-ins/Atomics/notify/not-a-constructor.js index fd1cbdce47..7788ec48ae 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/not-a-constructor.js @@ -26,7 +26,7 @@ assert.sameValue(isConstructor(Atomics.notify), false, 'isConstructor(Atomics.no assert.throws(TypeError, () => { new Atomics.notify(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))); -}, '`new Atomics.notify(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)))` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/not-a-typedarray-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/not-a-typedarray-throws.js index 5f9b7e2b08..befa3511ee 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/not-a-typedarray-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/not-a-typedarray-throws.js @@ -23,10 +23,10 @@ const poisoned = { assert.throws(TypeError, function() { Atomics.wait({}, 0, 0, 0); -}, '`Atomics.wait({}, 0, 0, 0)` throws TypeError'); +}); assert.throws(TypeError, function () { Atomics.wait({}, poisoned, poisoned, poisoned); -}, '`Atomics.wait({}, poisoned, poisoned, poisoned)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/not-an-object-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/not-an-object-throws.js index c8ca4b2a7f..3ed2e9336a 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/not-an-object-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/not-an-object-throws.js @@ -22,30 +22,30 @@ const poisoned = { assert.throws(TypeError, function() { Atomics.notify(null, poisoned, poisoned); -}, '`Atomics.notify(null, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.notify(undefined, poisoned, poisoned); -}, '`Atomics.notify(undefined, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.notify(true, poisoned, poisoned); -}, '`Atomics.notify(true, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.notify(false, poisoned, poisoned); -}, '`Atomics.notify(false, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.notify('***string***', poisoned, poisoned); -}, '`Atomics.notify(\'***string***\', poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.notify(Number.NEGATIVE_INFINITY, poisoned, poisoned); -}, '`Atomics.notify(Number.NEGATIVE_INFINITY, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.notify(Symbol('***symbol***'), poisoned, poisoned); -}, '`Atomics.notify(Symbol(\'***symbol***\'), poisoned, poisoned)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/null-bufferdata-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/null-bufferdata-throws.js index f6594d3331..efe816189c 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/null-bufferdata-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/null-bufferdata-throws.js @@ -41,6 +41,6 @@ try { assert.throws(TypeError, function() { Atomics.notify(i32a, poisoned, poisoned); -}, '`Atomics.notify(i32a, poisoned, poisoned)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/out-of-range-index-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/out-of-range-index-throws.js index cc64555b1e..42d54cbf25 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/out-of-range-index-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/out-of-range-index-throws.js @@ -29,12 +29,12 @@ var poisoned = { assert.throws(RangeError, function() { Atomics.notify(i32a, Infinity, poisoned); -}, '`Atomics.notify(i32a, Infinity, poisoned)` throws RangeError'); +}); assert.throws(RangeError, function() { Atomics.notify(i32a, 4, poisoned); -}, '`Atomics.notify(i32a, 4, poisoned)` throws RangeError'); +}); assert.throws(RangeError, function() { Atomics.notify(i32a, 200, poisoned); -}, '`Atomics.notify(i32a, 200, poisoned)` throws RangeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/symbol-for-index-throws.js b/js/src/tests/test262/built-ins/Atomics/notify/symbol-for-index-throws.js index 1a157f59c6..ddde5e8939 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/symbol-for-index-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/symbol-for-index-throws.js @@ -47,18 +47,18 @@ const poisonedToPrimitive = { assert.throws(Test262Error, function() { Atomics.notify(i32a, poisonedValueOf, poisonedValueOf); -}, '`Atomics.notify(i32a, poisonedValueOf, poisonedValueOf)` throws Test262Error'); +}); assert.throws(Test262Error, function() { Atomics.notify(i32a, poisonedToPrimitive, poisonedToPrimitive); -}, '`Atomics.notify(i32a, poisonedToPrimitive, poisonedToPrimitive)` throws Test262Error'); +}); assert.throws(TypeError, function() { Atomics.notify(i32a, Symbol("foo"), poisonedValueOf); -}, '`Atomics.notify(i32a, Symbol("foo"), poisonedValueOf)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.notify(i32a, Symbol("foo"), poisonedToPrimitive); -}, '`Atomics.notify(i32a, Symbol("foo"), poisonedToPrimitive)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/notify/validate-arraytype-before-count-coercion.js b/js/src/tests/test262/built-ins/Atomics/notify/validate-arraytype-before-count-coercion.js index 6ddf964c81..9750bd3171 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/validate-arraytype-before-count-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/validate-arraytype-before-count-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/notify/validate-arraytype-before-index-coercion.js b/js/src/tests/test262/built-ins/Atomics/notify/validate-arraytype-before-index-coercion.js index 3f4b498b4e..aaf24ba46e 100644 --- a/js/src/tests/test262/built-ins/Atomics/notify/validate-arraytype-before-index-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/notify/validate-arraytype-before-index-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/or/bad-range.js b/js/src/tests/test262/built-ins/Atomics/or/bad-range.js index eaa6285ec4..28bcf0b8a1 100644 --- a/js/src/tests/test262/built-ins/Atomics/or/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/or/bad-range.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -18,7 +18,7 @@ testWithTypedArrayConstructors(function(TA) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.or(view, IdxGen(view), 10); - }, '`Atomics.or(view, IdxGen(view), 10)` throws RangeError'); + }); }); }, views); diff --git a/js/src/tests/test262/built-ins/Atomics/or/bigint/bad-range.js b/js/src/tests/test262/built-ins/Atomics/or/bigint/bad-range.js index 9ae3dd11c0..15c12332ed 100644 --- a/js/src/tests/test262/built-ins/Atomics/or/bigint/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/or/bigint/bad-range.js @@ -16,7 +16,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.or(view, IdxGen(view), 10n); - }, '`Atomics.or(view, IdxGen(view), 10n)` throws RangeError'); + }); }); }); diff --git a/js/src/tests/test262/built-ins/Atomics/or/good-views.js b/js/src/tests/test262/built-ins/Atomics/or/good-views.js index b004226bd8..64423cf284 100644 --- a/js/src/tests/test262/built-ins/Atomics/or/good-views.js +++ b/js/src/tests/test262/built-ins/Atomics/or/good-views.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/or/non-shared-bufferdata.js b/js/src/tests/test262/built-ins/Atomics/or/non-shared-bufferdata.js index 8afe735477..4049f887a1 100644 --- a/js/src/tests/test262/built-ins/Atomics/or/non-shared-bufferdata.js +++ b/js/src/tests/test262/built-ins/Atomics/or/non-shared-bufferdata.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/or/non-shared-int-views-throws.js b/js/src/tests/test262/built-ins/Atomics/or/non-shared-int-views-throws.js index 90987ae1ce..67eee61a82 100644 --- a/js/src/tests/test262/built-ins/Atomics/or/non-shared-int-views-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/or/non-shared-int-views-throws.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/or/non-views.js b/js/src/tests/test262/built-ins/Atomics/or/non-views.js index e5fe5d9079..0dd7672471 100644 --- a/js/src/tests/test262/built-ins/Atomics/or/non-views.js +++ b/js/src/tests/test262/built-ins/Atomics/or/non-views.js @@ -13,7 +13,7 @@ features: [ArrayBuffer, Atomics, DataView, SharedArrayBuffer, Symbol, TypedArray testWithAtomicsNonViewValues(function(view) { assert.throws(TypeError, function() { Atomics.or(view, 0, 0); - }, '`Atomics.or(view, 0, 0)` throws TypeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/or/not-a-constructor.js b/js/src/tests/test262/built-ins/Atomics/or/not-a-constructor.js index 8c40656b9a..c3817fbf56 100644 --- a/js/src/tests/test262/built-ins/Atomics/or/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Atomics/or/not-a-constructor.js @@ -26,7 +26,7 @@ assert.sameValue(isConstructor(Atomics.or), false, 'isConstructor(Atomics.or) mu assert.throws(TypeError, () => { new Atomics.or(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))); -}, '`new Atomics.or(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)))` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/or/validate-arraytype-before-index-coercion.js b/js/src/tests/test262/built-ins/Atomics/or/validate-arraytype-before-index-coercion.js index 1f016df232..445a74eedb 100644 --- a/js/src/tests/test262/built-ins/Atomics/or/validate-arraytype-before-index-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/or/validate-arraytype-before-index-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/or/validate-arraytype-before-value-coercion.js b/js/src/tests/test262/built-ins/Atomics/or/validate-arraytype-before-value-coercion.js index f94a54a843..b1057df597 100644 --- a/js/src/tests/test262/built-ins/Atomics/or/validate-arraytype-before-value-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/or/validate-arraytype-before-value-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/prop-desc.js b/js/src/tests/test262/built-ins/Atomics/prop-desc.js index ffcbac8fa0..dabc6a18d6 100644 --- a/js/src/tests/test262/built-ins/Atomics/prop-desc.js +++ b/js/src/tests/test262/built-ins/Atomics/prop-desc.js @@ -29,11 +29,11 @@ assert.sameValue(typeof Atomics, "object", 'The value of `typeof Atomics` is "ob assert.throws(TypeError, function() { Atomics(); -}, '`Atomics()` throws TypeError'); +}); assert.throws(TypeError, function() { new Atomics(); -}, '`new Atomics()` throws TypeError'); +}); verifyProperty(this, "Atomics", { enumerable: false, diff --git a/js/src/tests/test262/built-ins/Atomics/store/bad-range.js b/js/src/tests/test262/built-ins/Atomics/store/bad-range.js index e383d1d9ff..674fba1df0 100644 --- a/js/src/tests/test262/built-ins/Atomics/store/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/store/bad-range.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -18,7 +18,7 @@ testWithTypedArrayConstructors(function(TA) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.store(view, IdxGen(view), 10); - }, '`Atomics.store(view, IdxGen(view), 10)` throws RangeError'); + }); }); }, views); diff --git a/js/src/tests/test262/built-ins/Atomics/store/bigint/bad-range.js b/js/src/tests/test262/built-ins/Atomics/store/bigint/bad-range.js index e7dd5520ce..e1ecbaeeda 100644 --- a/js/src/tests/test262/built-ins/Atomics/store/bigint/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/store/bigint/bad-range.js @@ -16,7 +16,7 @@ testWithBigIntTypedArrayConstructors(TA => { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.store(view, IdxGen(view), 10n); - }, '`Atomics.store(view, IdxGen(view), 10n)` throws RangeError'); + }); }); }); diff --git a/js/src/tests/test262/built-ins/Atomics/store/good-views.js b/js/src/tests/test262/built-ins/Atomics/store/good-views.js index c24a7cd4c9..932b8bb926 100644 --- a/js/src/tests/test262/built-ins/Atomics/store/good-views.js +++ b/js/src/tests/test262/built-ins/Atomics/store/good-views.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/store/non-shared-bufferdata.js b/js/src/tests/test262/built-ins/Atomics/store/non-shared-bufferdata.js index 78f1dd9ce0..801c1bea38 100644 --- a/js/src/tests/test262/built-ins/Atomics/store/non-shared-bufferdata.js +++ b/js/src/tests/test262/built-ins/Atomics/store/non-shared-bufferdata.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/store/non-shared-int-views-throws.js b/js/src/tests/test262/built-ins/Atomics/store/non-shared-int-views-throws.js index 3924de90d3..675a6d7e00 100644 --- a/js/src/tests/test262/built-ins/Atomics/store/non-shared-int-views-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/store/non-shared-int-views-throws.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/store/non-views.js b/js/src/tests/test262/built-ins/Atomics/store/non-views.js index 46e7b5e812..aa2608b304 100644 --- a/js/src/tests/test262/built-ins/Atomics/store/non-views.js +++ b/js/src/tests/test262/built-ins/Atomics/store/non-views.js @@ -13,7 +13,7 @@ features: [ArrayBuffer, Atomics, DataView, SharedArrayBuffer, Symbol, TypedArray testWithAtomicsNonViewValues(function(view) { assert.throws(TypeError, function() { Atomics.store(view, 0, 0); - }, '`Atomics.store(view, 0, 0)` throws TypeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/store/not-a-constructor.js b/js/src/tests/test262/built-ins/Atomics/store/not-a-constructor.js index c9b126ba56..6fb8b73191 100644 --- a/js/src/tests/test262/built-ins/Atomics/store/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Atomics/store/not-a-constructor.js @@ -26,7 +26,7 @@ assert.sameValue(isConstructor(Atomics.store), false, 'isConstructor(Atomics.sto assert.throws(TypeError, () => { new Atomics.store(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))); -}, '`new Atomics.store(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)))` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/store/validate-arraytype-before-index-coercion.js b/js/src/tests/test262/built-ins/Atomics/store/validate-arraytype-before-index-coercion.js index 08422c1339..4fb7cf03ad 100644 --- a/js/src/tests/test262/built-ins/Atomics/store/validate-arraytype-before-index-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/store/validate-arraytype-before-index-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/store/validate-arraytype-before-value-coercion.js b/js/src/tests/test262/built-ins/Atomics/store/validate-arraytype-before-value-coercion.js index 990d1d163e..3416e22e63 100644 --- a/js/src/tests/test262/built-ins/Atomics/store/validate-arraytype-before-value-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/store/validate-arraytype-before-value-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/sub/bad-range.js b/js/src/tests/test262/built-ins/Atomics/sub/bad-range.js index 7e08c03da5..48a6394293 100644 --- a/js/src/tests/test262/built-ins/Atomics/sub/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/sub/bad-range.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -18,7 +18,7 @@ testWithTypedArrayConstructors(function(TA) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.sub(view, IdxGen(view), 10); - }, '`Atomics.sub(view, IdxGen(view), 10)` throws RangeError'); + }); }); }, views); diff --git a/js/src/tests/test262/built-ins/Atomics/sub/bigint/bad-range.js b/js/src/tests/test262/built-ins/Atomics/sub/bigint/bad-range.js index b0ce7d8cdc..f0a02edc20 100644 --- a/js/src/tests/test262/built-ins/Atomics/sub/bigint/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/sub/bigint/bad-range.js @@ -16,7 +16,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.sub(view, IdxGen(view), 10n); - }, '`Atomics.sub(view, IdxGen(view), 10n)` throws RangeError'); + }); }); }); diff --git a/js/src/tests/test262/built-ins/Atomics/sub/good-views.js b/js/src/tests/test262/built-ins/Atomics/sub/good-views.js index 60ea4ad569..0352b30ac2 100644 --- a/js/src/tests/test262/built-ins/Atomics/sub/good-views.js +++ b/js/src/tests/test262/built-ins/Atomics/sub/good-views.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/sub/non-shared-bufferdata.js b/js/src/tests/test262/built-ins/Atomics/sub/non-shared-bufferdata.js index 3f36ea5eea..2d78a9abcd 100644 --- a/js/src/tests/test262/built-ins/Atomics/sub/non-shared-bufferdata.js +++ b/js/src/tests/test262/built-ins/Atomics/sub/non-shared-bufferdata.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/sub/non-shared-int-views-throws.js b/js/src/tests/test262/built-ins/Atomics/sub/non-shared-int-views-throws.js index c2413ed30b..a72892d925 100644 --- a/js/src/tests/test262/built-ins/Atomics/sub/non-shared-int-views-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/sub/non-shared-int-views-throws.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/sub/non-views.js b/js/src/tests/test262/built-ins/Atomics/sub/non-views.js index 85ee77acff..246470bf62 100644 --- a/js/src/tests/test262/built-ins/Atomics/sub/non-views.js +++ b/js/src/tests/test262/built-ins/Atomics/sub/non-views.js @@ -13,7 +13,7 @@ features: [ArrayBuffer, Atomics, DataView, SharedArrayBuffer, Symbol, TypedArray testWithAtomicsNonViewValues(function(view) { assert.throws(TypeError, function() { Atomics.sub(view, 0, 0); - }, '`Atomics.sub(view, 0, 0)` throws TypeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/sub/not-a-constructor.js b/js/src/tests/test262/built-ins/Atomics/sub/not-a-constructor.js index 74991a59dc..98563ad324 100644 --- a/js/src/tests/test262/built-ins/Atomics/sub/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Atomics/sub/not-a-constructor.js @@ -26,7 +26,7 @@ assert.sameValue(isConstructor(Atomics.sub), false, 'isConstructor(Atomics.sub) assert.throws(TypeError, () => { new Atomics.sub(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))); -}, '`new Atomics.sub(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)))` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/sub/validate-arraytype-before-index-coercion.js b/js/src/tests/test262/built-ins/Atomics/sub/validate-arraytype-before-index-coercion.js index 4bb9587e6d..bd717872c1 100644 --- a/js/src/tests/test262/built-ins/Atomics/sub/validate-arraytype-before-index-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/sub/validate-arraytype-before-index-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/sub/validate-arraytype-before-value-coercion.js b/js/src/tests/test262/built-ins/Atomics/sub/validate-arraytype-before-value-coercion.js index 7af4d36a94..0234ad4ba4 100644 --- a/js/src/tests/test262/built-ins/Atomics/sub/validate-arraytype-before-value-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/sub/validate-arraytype-before-value-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/wait/bad-range.js b/js/src/tests/test262/built-ins/Atomics/wait/bad-range.js index 93175371b9..3602773a4d 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/bad-range.js @@ -23,7 +23,7 @@ const i32a = new Int32Array( testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.wait(i32a, IdxGen(i32a), 0, 0); - }, '`Atomics.wait(i32a, IdxGen(i32a), 0, 0)` throws RangeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/bigint/bad-range.js b/js/src/tests/test262/built-ins/Atomics/wait/bigint/bad-range.js index c36d379406..8035ae5428 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/bigint/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/bigint/bad-range.js @@ -23,7 +23,7 @@ const i64a = new BigInt64Array( testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.wait(i64a, IdxGen(i64a), 0n, 0); - }, '`Atomics.wait(i64a, IdxGen(i64a), 0n, 0)` throws RangeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/bigint/cannot-suspend-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/bigint/cannot-suspend-throws.js index 212dbfddc6..4ca336c9dd 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/bigint/cannot-suspend-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/bigint/cannot-suspend-throws.js @@ -22,6 +22,6 @@ const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELE assert.throws(TypeError, function() { Atomics.wait(i64a, 0, 0n, 0); -}, '`Atomics.wait(i64a, 0, 0n, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/bigint/negative-index-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/bigint/negative-index-throws.js index 4d976026a1..489806e301 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/bigint/negative-index-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/bigint/negative-index-throws.js @@ -28,15 +28,15 @@ const poisoned = { assert.throws(RangeError, function() { Atomics.wait(i64a, -Infinity, poisoned, poisoned); -}, '`Atomics.wait(i64a, -Infinity, poisoned, poisoned)` throws RangeError'); +}); assert.throws(RangeError, function() { Atomics.wait(i64a, -7.999, poisoned, poisoned); -}, '`Atomics.wait(i64a, -7.999, poisoned, poisoned)` throws RangeError'); +}); assert.throws(RangeError, function() { Atomics.wait(i64a, -1, poisoned, poisoned); -}, '`Atomics.wait(i64a, -1, poisoned, poisoned)` throws RangeError'); +}); assert.throws(RangeError, function() { Atomics.wait(i64a, -300, poisoned, poisoned); -}, '`Atomics.wait(i64a, -300, poisoned, poisoned)` throws RangeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/bigint/non-bigint64-typedarray-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/bigint/non-bigint64-typedarray-throws.js index ed42bf7849..4aada1c582 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/bigint/non-bigint64-typedarray-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/bigint/non-bigint64-typedarray-throws.js @@ -35,10 +35,10 @@ const poisoned = { assert.throws(TypeError, function() { Atomics.wait(i64a, 0, 0n, 0); -}, '`Atomics.wait(i64a, 0, 0n, 0)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.wait(i64a, poisoned, poisoned, poisoned); -}, '`Atomics.wait(i64a, poisoned, poisoned, poisoned)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/bigint/non-shared-bufferdata-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/bigint/non-shared-bufferdata-throws.js index ec45720916..04e61cae42 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/bigint/non-shared-bufferdata-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/bigint/non-shared-bufferdata-throws.js @@ -25,10 +25,10 @@ const poisoned = { assert.throws(TypeError, function() { Atomics.wait(i64a, 0, 0n, 0); -}, '`Atomics.wait(i64a, 0, 0n, 0)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.wait(i64a, poisoned, poisoned, poisoned); -}, '`Atomics.wait(i64a, poisoned, poisoned, poisoned)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/bigint/null-bufferdata-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/bigint/null-bufferdata-throws.js index 9499b9f0e6..bfc095cd32 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/bigint/null-bufferdata-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/bigint/null-bufferdata-throws.js @@ -43,6 +43,6 @@ try { assert.throws(TypeError, function() { Atomics.wait(i64a, poisoned, poisoned, poisoned); -}, '`Atomics.wait(i64a, poisoned, poisoned, poisoned)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/bigint/out-of-range-index-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/bigint/out-of-range-index-throws.js index 582a251abb..6475a4f027 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/bigint/out-of-range-index-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/bigint/out-of-range-index-throws.js @@ -29,12 +29,12 @@ const poisoned = { assert.throws(RangeError, function() { Atomics.wait(i64a, Infinity, poisoned, poisoned); -}, '`Atomics.wait(i64a, Infinity, poisoned, poisoned)` throws RangeError'); +}); assert.throws(RangeError, function() { Atomics.wait(i64a, 8, poisoned, poisoned); -}, '`Atomics.wait(i64a, 8, poisoned, poisoned)` throws RangeError'); +}); assert.throws(RangeError, function() { Atomics.wait(i64a, 200, poisoned, poisoned); -}, '`Atomics.wait(i64a, 200, poisoned, poisoned)` throws RangeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/cannot-suspend-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/cannot-suspend-throws.js index a11c635cd1..5889536890 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/cannot-suspend-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/cannot-suspend-throws.js @@ -25,6 +25,6 @@ const i32a = new Int32Array( assert.throws(TypeError, function() { Atomics.wait(i32a, 0, 0, 0); -}, '`Atomics.wait(i32a, 0, 0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/negative-index-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/negative-index-throws.js index 61d0b84067..0993497b0f 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/negative-index-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/negative-index-throws.js @@ -30,15 +30,15 @@ const poisoned = { assert.throws(RangeError, function() { Atomics.wait(i32a, -Infinity, poisoned, poisoned); -}, '`Atomics.wait(i32a, -Infinity, poisoned, poisoned)` throws RangeError'); +}); assert.throws(RangeError, function() { Atomics.wait(i32a, -7.999, poisoned, poisoned); -}, '`Atomics.wait(i32a, -7.999, poisoned, poisoned)` throws RangeError'); +}); assert.throws(RangeError, function() { Atomics.wait(i32a, -1, poisoned, poisoned); -}, '`Atomics.wait(i32a, -1, poisoned, poisoned)` throws RangeError'); +}); assert.throws(RangeError, function() { Atomics.wait(i32a, -300, poisoned, poisoned); -}, '`Atomics.wait(i32a, -300, poisoned, poisoned)` throws RangeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/non-int32-typedarray-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/non-int32-typedarray-throws.js index 64fec573f5..9b5deec8fa 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/non-int32-typedarray-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/non-int32-typedarray-throws.js @@ -27,14 +27,14 @@ assert.throws(TypeError, function() { new SharedArrayBuffer(Float64Array.BYTES_PER_ELEMENT * 8) ); Atomics.wait(view, poisoned, poisoned, poisoned); -}, '`const view = new Float64Array( new SharedArrayBuffer(Float64Array.BYTES_PER_ELEMENT * 8) ); Atomics.wait(view, poisoned, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { const view = new Float32Array( new SharedArrayBuffer(Float32Array.BYTES_PER_ELEMENT * 4) ); Atomics.wait(view, poisoned, poisoned, poisoned); -}, '`const view = new Float32Array( new SharedArrayBuffer(Float32Array.BYTES_PER_ELEMENT * 4) ); Atomics.wait(view, poisoned, poisoned, poisoned)` throws TypeError'); +}); if (typeof Float16Array !== 'undefined') { assert.throws(TypeError, function() { @@ -42,7 +42,7 @@ if (typeof Float16Array !== 'undefined') { new SharedArrayBuffer(Float16Array.BYTES_PER_ELEMENT * 2) ); Atomics.wait(view, poisoned, poisoned, poisoned); - }, '`const view = new Float16Array( new SharedArrayBuffer(Float16Array.BYTES_PER_ELEMENT * 2) ); Atomics.wait(view, poisoned, poisoned, poisoned)` throws TypeError'); + }); } assert.throws(TypeError, function() { @@ -50,41 +50,41 @@ assert.throws(TypeError, function() { new SharedArrayBuffer(Int16Array.BYTES_PER_ELEMENT * 2) ); Atomics.wait(view, poisoned, poisoned, poisoned); -}, '`const view = new Int16Array( new SharedArrayBuffer(Int16Array.BYTES_PER_ELEMENT * 2) ); Atomics.wait(view, poisoned, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { const view = new Int8Array( new SharedArrayBuffer(Int8Array.BYTES_PER_ELEMENT) ); Atomics.wait(view, poisoned, poisoned, poisoned); -}, '`const view = new Int8Array( new SharedArrayBuffer(Int8Array.BYTES_PER_ELEMENT) ); Atomics.wait(view, poisoned, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { const view = new Uint32Array( new SharedArrayBuffer(Uint32Array.BYTES_PER_ELEMENT * 4) ); Atomics.wait(view, poisoned, poisoned, poisoned); -}, '`const view = new Uint32Array( new SharedArrayBuffer(Uint32Array.BYTES_PER_ELEMENT * 4) ); Atomics.wait(view, poisoned, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { const view = new Uint16Array( new SharedArrayBuffer(Uint16Array.BYTES_PER_ELEMENT * 2) ); Atomics.wait(view, poisoned, poisoned, poisoned); -}, '`const view = new Uint16Array( new SharedArrayBuffer(Uint16Array.BYTES_PER_ELEMENT * 2) ); Atomics.wait(view, poisoned, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { const view = new Uint8Array( new SharedArrayBuffer(Uint8Array.BYTES_PER_ELEMENT) ); Atomics.wait(view, poisoned, poisoned, poisoned); -}, '`const view = new Uint8Array( new SharedArrayBuffer(Uint8Array.BYTES_PER_ELEMENT) ); Atomics.wait(view, poisoned, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { const view = new Uint8ClampedArray( new SharedArrayBuffer(Uint8ClampedArray.BYTES_PER_ELEMENT) ); Atomics.wait(view, poisoned, poisoned, poisoned); -}, '`const view = new Uint8ClampedArray( new SharedArrayBuffer(Uint8ClampedArray.BYTES_PER_ELEMENT) ); Atomics.wait(view, poisoned, poisoned, poisoned)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/non-shared-bufferdata-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/non-shared-bufferdata-throws.js index dcee5b7c34..409661602c 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/non-shared-bufferdata-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/non-shared-bufferdata-throws.js @@ -28,10 +28,10 @@ const poisoned = { assert.throws(TypeError, function() { Atomics.wait(i32a, 0, 0, 0); -}, '`Atomics.wait(i32a, 0, 0, 0)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.wait(i32a, poisoned, poisoned, poisoned); -}, '`Atomics.wait(i32a, poisoned, poisoned, poisoned)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/not-a-typedarray-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/not-a-typedarray-throws.js index 484d1affec..ac4f4228ef 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/not-a-typedarray-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/not-a-typedarray-throws.js @@ -23,10 +23,10 @@ var poisoned = { assert.throws(TypeError, function() { Atomics.wait({}, 0, 0, 0); -}, '`Atomics.wait({}, 0, 0, 0)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.wait({}, poisoned, poisoned, poisoned); -}, '`Atomics.wait({}, poisoned, poisoned, poisoned)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/not-an-object-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/not-an-object-throws.js index 64ce6c2277..881d43802c 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/not-an-object-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/not-an-object-throws.js @@ -22,30 +22,30 @@ var poisoned = { assert.throws(TypeError, function() { Atomics.wait(null, poisoned, poisoned, poisoned); -}, '`Atomics.wait(null, poisoned, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.wait(undefined, poisoned, poisoned, poisoned); -}, '`Atomics.wait(undefined, poisoned, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.wait(true, poisoned, poisoned, poisoned); -}, '`Atomics.wait(true, poisoned, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.wait(false, poisoned, poisoned, poisoned); -}, '`Atomics.wait(false, poisoned, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.wait('***string***', poisoned, poisoned, poisoned); -}, '`Atomics.wait(\'***string***\', poisoned, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.wait(Number.NEGATIVE_INFINITY, poisoned, poisoned, poisoned); -}, '`Atomics.wait(Number.NEGATIVE_INFINITY, poisoned, poisoned, poisoned)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.wait(Symbol('***symbol***'), poisoned, poisoned, poisoned); -}, '`Atomics.wait(Symbol(\'***symbol***\'), poisoned, poisoned, poisoned)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/null-bufferdata-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/null-bufferdata-throws.js index 0b8ab82185..90fe511a66 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/null-bufferdata-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/null-bufferdata-throws.js @@ -41,6 +41,6 @@ try { assert.throws(TypeError, function() { Atomics.wait(i32a, poisoned, poisoned, poisoned); -}, '`Atomics.wait(i32a, poisoned, poisoned, poisoned)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/out-of-range-index-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/out-of-range-index-throws.js index d2d3fdea27..fb7a379a19 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/out-of-range-index-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/out-of-range-index-throws.js @@ -29,15 +29,15 @@ const poisoned = { assert.throws(RangeError, function() { Atomics.wait(i32a, Infinity, poisoned, poisoned); -}, '`Atomics.wait(i32a, Infinity, poisoned, poisoned)` throws RangeError'); +}); assert.throws(RangeError, function() { Atomics.wait(i32a, -1, poisoned, poisoned); -}, '`Atomics.wait(i32a, -1, poisoned, poisoned)` throws RangeError'); +}); assert.throws(RangeError, function() { Atomics.wait(i32a, 4, poisoned, poisoned); -}, '`Atomics.wait(i32a, 4, poisoned, poisoned)` throws RangeError'); +}); assert.throws(RangeError, function() { Atomics.wait(i32a, 200, poisoned, poisoned); -}, '`Atomics.wait(i32a, 200, poisoned, poisoned)` throws RangeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/poisoned-object-for-timeout-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/poisoned-object-for-timeout-throws.js index 2d41dcb4d6..7127597c44 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/poisoned-object-for-timeout-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/poisoned-object-for-timeout-throws.js @@ -37,10 +37,10 @@ const poisonedToPrimitive = { assert.throws(Test262Error, function() { Atomics.wait(i32a, 0, 0, poisonedValueOf); -}, '`Atomics.wait(i32a, 0, 0, poisonedValueOf)` throws Test262Error'); +}); assert.throws(Test262Error, function() { Atomics.wait(i32a, 0, 0, poisonedToPrimitive); -}, '`Atomics.wait(i32a, 0, 0, poisonedToPrimitive)` throws Test262Error'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/symbol-for-index-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/symbol-for-index-throws.js index 332588e972..0b86b62d5d 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/symbol-for-index-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/symbol-for-index-throws.js @@ -47,18 +47,18 @@ const poisonedToPrimitive = { assert.throws(Test262Error, function() { Atomics.wait(i32a, poisonedValueOf, poisonedValueOf, poisonedValueOf); -}, '`Atomics.wait(i32a, poisonedValueOf, poisonedValueOf, poisonedValueOf)` throws Test262Error'); +}); assert.throws(Test262Error, function() { Atomics.wait(i32a, poisonedToPrimitive, poisonedToPrimitive, poisonedToPrimitive); -}, '`Atomics.wait(i32a, poisonedToPrimitive, poisonedToPrimitive, poisonedToPrimitive)` throws Test262Error'); +}); assert.throws(TypeError, function() { Atomics.wait(i32a, Symbol('foo'), poisonedValueOf, poisonedValueOf); -}, '`Atomics.wait(i32a, Symbol(\'foo\'), poisonedValueOf, poisonedValueOf)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.wait(i32a, Symbol('foo'), poisonedToPrimitive, poisonedToPrimitive); -}, '`Atomics.wait(i32a, Symbol(\'foo\'), poisonedToPrimitive, poisonedToPrimitive)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/symbol-for-timeout-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/symbol-for-timeout-throws.js index 76d6874f28..2e75ac65f9 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/symbol-for-timeout-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/symbol-for-timeout-throws.js @@ -33,18 +33,18 @@ var poisonedToPrimitive = { assert.throws(Test262Error, function() { Atomics.wait(i32a, 0, 0, poisonedValueOf); -}, '`Atomics.wait(i32a, 0, 0, poisonedValueOf)` throws Test262Error'); +}); assert.throws(Test262Error, function() { Atomics.wait(i32a, 0, 0, poisonedToPrimitive); -}, '`Atomics.wait(i32a, 0, 0, poisonedToPrimitive)` throws Test262Error'); +}); assert.throws(TypeError, function() { Atomics.wait(i32a, 0, 0, Symbol("foo")); -}, '`Atomics.wait(i32a, 0, 0, Symbol("foo"))` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.wait(i32a, 0, 0, Symbol("foo")); -}, '`Atomics.wait(i32a, 0, 0, Symbol("foo"))` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/symbol-for-value-throws.js b/js/src/tests/test262/built-ins/Atomics/wait/symbol-for-value-throws.js index 3a4e3a8cbf..2186a4bace 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/symbol-for-value-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/symbol-for-value-throws.js @@ -38,18 +38,18 @@ const poisonedToPrimitive = { assert.throws(Test262Error, function() { Atomics.wait(i32a, 0, poisonedValueOf, poisonedValueOf); -}, '`Atomics.wait(i32a, 0, poisonedValueOf, poisonedValueOf)` throws Test262Error'); +}); assert.throws(Test262Error, function() { Atomics.wait(i32a, 0, poisonedToPrimitive, poisonedToPrimitive); -}, '`Atomics.wait(i32a, 0, poisonedToPrimitive, poisonedToPrimitive)` throws Test262Error'); +}); assert.throws(TypeError, function() { Atomics.wait(i32a, 0, Symbol("foo"), poisonedValueOf); -}, '`Atomics.wait(i32a, 0, Symbol("foo"), poisonedValueOf)` throws TypeError'); +}); assert.throws(TypeError, function() { Atomics.wait(i32a, 0, Symbol("foo"), poisonedToPrimitive); -}, '`Atomics.wait(i32a, 0, Symbol("foo"), poisonedToPrimitive)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/wait/validate-arraytype-before-index-coercion.js b/js/src/tests/test262/built-ins/Atomics/wait/validate-arraytype-before-index-coercion.js index 26586d313e..4288a65f89 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/validate-arraytype-before-index-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/validate-arraytype-before-index-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/wait/validate-arraytype-before-timeout-coercion.js b/js/src/tests/test262/built-ins/Atomics/wait/validate-arraytype-before-timeout-coercion.js index 58328bc348..c714769674 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/validate-arraytype-before-timeout-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/validate-arraytype-before-timeout-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/wait/validate-arraytype-before-value-coercion.js b/js/src/tests/test262/built-ins/Atomics/wait/validate-arraytype-before-value-coercion.js index b597ebf9f2..0c993843af 100644 --- a/js/src/tests/test262/built-ins/Atomics/wait/validate-arraytype-before-value-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/wait/validate-arraytype-before-value-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/waitAsync/validate-arraytype-before-index-coercion.js b/js/src/tests/test262/built-ins/Atomics/waitAsync/validate-arraytype-before-index-coercion.js index 4bdb4215ab..9886ac6d06 100644 --- a/js/src/tests/test262/built-ins/Atomics/waitAsync/validate-arraytype-before-index-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/waitAsync/validate-arraytype-before-index-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip -- Atomics.waitAsync is not supported +// |reftest| shell-option(--enable-float16array) skip -- Atomics.waitAsync is not supported // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/waitAsync/validate-arraytype-before-value-coercion.js b/js/src/tests/test262/built-ins/Atomics/waitAsync/validate-arraytype-before-value-coercion.js index c329676b4d..5f165c8035 100644 --- a/js/src/tests/test262/built-ins/Atomics/waitAsync/validate-arraytype-before-value-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/waitAsync/validate-arraytype-before-value-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip -- Atomics.waitAsync is not supported +// |reftest| shell-option(--enable-float16array) skip -- Atomics.waitAsync is not supported // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/xor/bad-range.js b/js/src/tests/test262/built-ins/Atomics/xor/bad-range.js index a0f267a353..73237bcc50 100644 --- a/js/src/tests/test262/built-ins/Atomics/xor/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/xor/bad-range.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -18,7 +18,7 @@ testWithTypedArrayConstructors(function(TA) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.xor(view, IdxGen(view), 0); - }, '`Atomics.xor(view, IdxGen(view), 0)` throws RangeError'); + }); }); }, views); diff --git a/js/src/tests/test262/built-ins/Atomics/xor/bigint/bad-range.js b/js/src/tests/test262/built-ins/Atomics/xor/bigint/bad-range.js index 08e2427d5f..16a38a8922 100644 --- a/js/src/tests/test262/built-ins/Atomics/xor/bigint/bad-range.js +++ b/js/src/tests/test262/built-ins/Atomics/xor/bigint/bad-range.js @@ -17,7 +17,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { testWithAtomicsOutOfBoundsIndices(function(IdxGen) { assert.throws(RangeError, function() { Atomics.xor(view, IdxGen(view), 10); - }, '`Atomics.xor(view, IdxGen(view), 10)` throws RangeError'); + }); }); }); diff --git a/js/src/tests/test262/built-ins/Atomics/xor/good-views.js b/js/src/tests/test262/built-ins/Atomics/xor/good-views.js index 6c70e71b28..1548900871 100644 --- a/js/src/tests/test262/built-ins/Atomics/xor/good-views.js +++ b/js/src/tests/test262/built-ins/Atomics/xor/good-views.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/xor/non-shared-bufferdata.js b/js/src/tests/test262/built-ins/Atomics/xor/non-shared-bufferdata.js index b8b4ec7bf2..2c1739108a 100644 --- a/js/src/tests/test262/built-ins/Atomics/xor/non-shared-bufferdata.js +++ b/js/src/tests/test262/built-ins/Atomics/xor/non-shared-bufferdata.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/xor/non-shared-int-views-throws.js b/js/src/tests/test262/built-ins/Atomics/xor/non-shared-int-views-throws.js index d3f1dedbd8..4803a385a8 100644 --- a/js/src/tests/test262/built-ins/Atomics/xor/non-shared-int-views-throws.js +++ b/js/src/tests/test262/built-ins/Atomics/xor/non-shared-int-views-throws.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/xor/non-views.js b/js/src/tests/test262/built-ins/Atomics/xor/non-views.js index 64767f3236..ab1e6d2164 100644 --- a/js/src/tests/test262/built-ins/Atomics/xor/non-views.js +++ b/js/src/tests/test262/built-ins/Atomics/xor/non-views.js @@ -13,7 +13,7 @@ features: [ArrayBuffer, Atomics, DataView, SharedArrayBuffer, Symbol, TypedArray testWithAtomicsNonViewValues(function(view) { assert.throws(TypeError, function() { Atomics.xor(view, 0, 0); - }, '`Atomics.xor(view, 0, 0)` throws TypeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/xor/not-a-constructor.js b/js/src/tests/test262/built-ins/Atomics/xor/not-a-constructor.js index 292954d861..fb7f185257 100644 --- a/js/src/tests/test262/built-ins/Atomics/xor/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Atomics/xor/not-a-constructor.js @@ -26,7 +26,7 @@ assert.sameValue(isConstructor(Atomics.xor), false, 'isConstructor(Atomics.xor) assert.throws(TypeError, () => { new Atomics.xor(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))); -}, '`new Atomics.xor(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)))` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Atomics/xor/validate-arraytype-before-index-coercion.js b/js/src/tests/test262/built-ins/Atomics/xor/validate-arraytype-before-index-coercion.js index dc401d40f6..366a9d5172 100644 --- a/js/src/tests/test262/built-ins/Atomics/xor/validate-arraytype-before-index-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/xor/validate-arraytype-before-index-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/Atomics/xor/validate-arraytype-before-value-coercion.js b/js/src/tests/test262/built-ins/Atomics/xor/validate-arraytype-before-value-coercion.js index b4ee63b0aa..c2d7e9b44a 100644 --- a/js/src/tests/test262/built-ins/Atomics/xor/validate-arraytype-before-value-coercion.js +++ b/js/src/tests/test262/built-ins/Atomics/xor/validate-arraytype-before-value-coercion.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally // Copyright (C) 2019 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/BigInt/asIntN/not-a-constructor.js b/js/src/tests/test262/built-ins/BigInt/asIntN/not-a-constructor.js index 7875347fcf..433e276878 100644 --- a/js/src/tests/test262/built-ins/BigInt/asIntN/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/BigInt/asIntN/not-a-constructor.js @@ -23,6 +23,6 @@ assert.sameValue(isConstructor(BigInt.asIntN), false, 'isConstructor(BigInt.asIn assert.throws(TypeError, () => { new BigInt.asIntN(64, 1n); -}, '`new BigInt.asIntN(64, 1n)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/BigInt/asUintN/not-a-constructor.js b/js/src/tests/test262/built-ins/BigInt/asUintN/not-a-constructor.js index e1208f5886..8e1bf945a0 100644 --- a/js/src/tests/test262/built-ins/BigInt/asUintN/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/BigInt/asUintN/not-a-constructor.js @@ -23,6 +23,6 @@ assert.sameValue(isConstructor(BigInt.asUintN), false, 'isConstructor(BigInt.asU assert.throws(TypeError, () => { new BigInt.asUintN(64, 1n); -}, '`new BigInt.asUintN(64, 1n)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toLocaleString/not-a-constructor.js b/js/src/tests/test262/built-ins/BigInt/prototype/toLocaleString/not-a-constructor.js index e51206920a..0880f443eb 100644 --- a/js/src/tests/test262/built-ins/BigInt/prototype/toLocaleString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/BigInt/prototype/toLocaleString/not-a-constructor.js @@ -28,6 +28,6 @@ assert.sameValue( assert.throws(TypeError, () => { let n = 1n; new n.toLocaleString(); -}, '`let n = 1n; new n.toLocaleString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/BigInt/prototype/toString/not-a-constructor.js index ffa6c1491c..82379998ef 100644 --- a/js/src/tests/test262/built-ins/BigInt/prototype/toString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/BigInt/prototype/toString/not-a-constructor.js @@ -28,6 +28,6 @@ assert.sameValue( assert.throws(TypeError, () => { let n = 1n; new n.toString(); -}, '`let n = 1n; new n.toString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/not-a-constructor.js b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/not-a-constructor.js index 1476cd46dd..2046584fda 100644 --- a/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/not-a-constructor.js @@ -28,6 +28,6 @@ assert.sameValue( assert.throws(TypeError, () => { let n = 1n; new n.valueOf(); -}, '`let n = 1n; new n.valueOf()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/toString/length.js b/js/src/tests/test262/built-ins/Boolean/prototype/toString/length.js index a61183ebe0..bcaddc2e7b 100644 --- a/js/src/tests/test262/built-ins/Boolean/prototype/toString/length.js +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Boolean.prototype.toString.length, 0); - -verifyNotEnumerable(Boolean.prototype.toString, "length"); -verifyNotWritable(Boolean.prototype.toString, "length"); -verifyConfigurable(Boolean.prototype.toString, "length"); +verifyProperty(Boolean.prototype.toString, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/toString/name.js b/js/src/tests/test262/built-ins/Boolean/prototype/toString/name.js index 55b337eaad..1e3edcda85 100644 --- a/js/src/tests/test262/built-ins/Boolean/prototype/toString/name.js +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Boolean.prototype.toString.name, "toString"); - -verifyNotEnumerable(Boolean.prototype.toString, "name"); -verifyNotWritable(Boolean.prototype.toString, "name"); -verifyConfigurable(Boolean.prototype.toString, "name"); +verifyProperty(Boolean.prototype.toString, "name", { + value: "toString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/Boolean/prototype/toString/not-a-constructor.js index 548a4e70c7..db2416404e 100644 --- a/js/src/tests/test262/built-ins/Boolean/prototype/toString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Boolean/prototype/toString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Boolean.prototype.toString(); -}, '`new Boolean.prototype.toString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/length.js b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/length.js index 0d49d0670b..2cf7287737 100644 --- a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/length.js +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Boolean.prototype.valueOf.length, 0); - -verifyNotEnumerable(Boolean.prototype.valueOf, "length"); -verifyNotWritable(Boolean.prototype.valueOf, "length"); -verifyConfigurable(Boolean.prototype.valueOf, "length"); +verifyProperty(Boolean.prototype.valueOf, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/name.js b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/name.js index bb0b1138eb..934986997e 100644 --- a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/name.js +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Boolean.prototype.valueOf.name, "valueOf"); - -verifyNotEnumerable(Boolean.prototype.valueOf, "name"); -verifyNotWritable(Boolean.prototype.valueOf, "name"); -verifyConfigurable(Boolean.prototype.valueOf, "name"); +verifyProperty(Boolean.prototype.valueOf, "name", { + value: "valueOf", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/not-a-constructor.js index f3c549e341..1459698f70 100644 --- a/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Boolean/prototype/valueOf/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Boolean.prototype.valueOf(); -}, '`new Boolean.prototype.valueOf()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/byteOffset-validated-against-initial-buffer-length.js b/js/src/tests/test262/built-ins/DataView/byteOffset-validated-against-initial-buffer-length.js new file mode 100644 index 0000000000..51b030b66b --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/byteOffset-validated-against-initial-buffer-length.js @@ -0,0 +1,46 @@ +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview-buffer-byteoffset-bytelength +description: > + The byteOffset argument is validated against the initial buffer length. +info: | + DataView ( buffer [ , byteOffset [ , byteLength ] ] ) + + ... + 3. Let offset be ? ToIndex(byteOffset). + ... + 5. Let bufferByteLength be ArrayBufferByteLength(buffer, seq-cst). + 6. If offset > bufferByteLength, throw a RangeError exception. + ... + 10. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%DataView.prototype%", + « [[DataView]], [[ViewedArrayBuffer]], [[ByteLength]], [[ByteOffset]] »). + ... + + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) + + ... + 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). + ... + +features: [Reflect.construct] +---*/ + +let newTarget = Object.defineProperty(function(){}.bind(), "prototype", { + get() { + throw new Test262Error("GetPrototypeFromConstructor not executed"); + } +}); + +// Zero length buffer. +let ab = new ArrayBuffer(0); + +// Byte offset is larger than the buffer length, which is zero. +let byteOffset = 10; + +assert.throws(RangeError, () => { + Reflect.construct(DataView, [ab, byteOffset], newTarget); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/name.js b/js/src/tests/test262/built-ins/DataView/name.js index 2b1e1c74bd..da2852d9f8 100644 --- a/js/src/tests/test262/built-ins/DataView/name.js +++ b/js/src/tests/test262/built-ins/DataView/name.js @@ -8,10 +8,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.name, "DataView", "The value of `DataView.name` is `'DataView'`"); - -verifyNotEnumerable(DataView, "name"); -verifyNotWritable(DataView, "name"); -verifyConfigurable(DataView, "name"); +verifyProperty(DataView, "name", { + value: "DataView", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/buffer/length.js b/js/src/tests/test262/built-ins/DataView/prototype/buffer/length.js index 826ab9e259..6d49bd8107 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/buffer/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/buffer/length.js @@ -24,10 +24,11 @@ includes: [propertyHelper.js] var desc = Object.getOwnPropertyDescriptor(DataView.prototype, "buffer"); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/buffer/name.js b/js/src/tests/test262/built-ins/DataView/prototype/buffer/name.js index 6721b00274..62460653b2 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/buffer/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/buffer/name.js @@ -17,13 +17,11 @@ var descriptor = Object.getOwnPropertyDescriptor( DataView.prototype, 'buffer' ); -assert.sameValue( - descriptor.get.name, 'get buffer', - 'The value of `descriptor.get.name` is `"get buffer"`' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get buffer", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteLength/length.js b/js/src/tests/test262/built-ins/DataView/prototype/byteLength/length.js index 85dd54adcf..94a56f8fb4 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/byteLength/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/byteLength/length.js @@ -24,10 +24,11 @@ includes: [propertyHelper.js] var desc = Object.getOwnPropertyDescriptor(DataView.prototype, "byteLength"); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteLength/name.js b/js/src/tests/test262/built-ins/DataView/prototype/byteLength/name.js index b437bd7173..5dee2ae780 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/byteLength/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/byteLength/name.js @@ -17,13 +17,11 @@ var descriptor = Object.getOwnPropertyDescriptor( DataView.prototype, 'byteLength' ); -assert.sameValue( - descriptor.get.name, 'get byteLength', - 'The value of `descriptor.get.name` is `"get byteLength"`' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get byteLength", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/length.js b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/length.js index 6565d89280..b6ed091883 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/length.js @@ -24,10 +24,11 @@ includes: [propertyHelper.js] var desc = Object.getOwnPropertyDescriptor(DataView.prototype, "byteOffset"); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/name.js b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/name.js index e77dc91d09..f4e24e3bc3 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/byteOffset/name.js @@ -17,13 +17,11 @@ var descriptor = Object.getOwnPropertyDescriptor( DataView.prototype, 'byteOffset' ); -assert.sameValue( - descriptor.get.name, 'get byteOffset', - 'The value of `descriptor.get.name` is `"get byteOffset"`' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get byteOffset", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getBigInt64/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/getBigInt64/not-a-constructor.js index 20cb228a77..d6a83eb7fd 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getBigInt64/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getBigInt64/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.getBigInt64(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.getBigInt64(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getBigUint64/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/getBigUint64/not-a-constructor.js index c9a26de1fa..d310d4ea5c 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getBigUint64/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getBigUint64/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.getBigUint64(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.getBigUint64(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/toolkit/components/translations/tests/browser/translations-tester-empty-pdf-file.pdf b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/browser.js index e69de29bb2..e69de29bb2 100644 --- a/toolkit/components/translations/tests/browser/translations-tester-empty-pdf-file.pdf +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/browser.js diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/detached-buffer-after-toindex-byteoffset.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/detached-buffer-after-toindex-byteoffset.js new file mode 100644 index 0000000000..58d6f5547b --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/detached-buffer-after-toindex-byteoffset.js @@ -0,0 +1,26 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: > + Detached buffer is only checked after ToIndex(requestIndex) +features: [Float16Array] +includes: [detachArrayBuffer.js] +---*/ + +var buffer = new ArrayBuffer(6); +var sample = new DataView(buffer, 0); + +$DETACHBUFFER(buffer); + +assert.throws(RangeError, function() { + sample.getFloat16(-1); +}); + +assert.throws(RangeError, function() { + sample.getFloat16(Infinity); +}, "Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/detached-buffer-before-outofrange-byteoffset.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/detached-buffer-before-outofrange-byteoffset.js new file mode 100644 index 0000000000..07c76080e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/detached-buffer-before-outofrange-byteoffset.js @@ -0,0 +1,24 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: > + Detached buffer is checked before out of range byteOffset's value +features: [Float16Array] +includes: [detachArrayBuffer.js] +---*/ + +var sample; +var buffer = new ArrayBuffer(12); + +sample = new DataView(buffer, 0); + +$DETACHBUFFER(buffer); + +assert.throws(TypeError, function() { + sample.getFloat16(13); +}, "13"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/detached-buffer.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/detached-buffer.js new file mode 100644 index 0000000000..f7c59cb29c --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/detached-buffer.js @@ -0,0 +1,21 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: > + Throws a TypeError if buffer is detached +features: [Float16Array] +includes: [detachArrayBuffer.js] +---*/ + +var buffer = new ArrayBuffer(1); +var sample = new DataView(buffer, 0); + +$DETACHBUFFER(buffer); +assert.throws(TypeError, function() { + sample.getFloat16(0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/index-is-out-of-range.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/index-is-out-of-range.js new file mode 100644 index 0000000000..7781bde810 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/index-is-out-of-range.js @@ -0,0 +1,63 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: > + Throws a RangeError if getIndex + elementSize > viewSize +features: [Float16Array] +---*/ + +var sample; +var buffer = new ArrayBuffer(12); + +sample = new DataView(buffer, 0); + +assert.throws(RangeError, function() { + sample.getFloat16(Infinity); +}, "getIndex == Infinity"); + +assert.throws(RangeError, function() { + sample.getFloat16(13); +}, "13 + 2 > 12"); + +assert.throws(RangeError, function() { + sample.getFloat16(12); +}, "12 + 2 > 12"); + +assert.throws(RangeError, function() { + sample.getFloat16(11); +}, "11 + 2 > 12"); + +sample = new DataView(buffer, 10); +assert.throws(RangeError, function() { + sample.getFloat16(1); +}, "1 + 2 > 2 (offset)"); + +sample = new DataView(buffer, 11); +assert.throws(RangeError, function() { + sample.getFloat16(0); +}, "0 + 2 > 1 (offset)"); + +sample = new DataView(buffer, 0, 2); +assert.throws(RangeError, function() { + sample.getFloat16(1); +}, "1 + 2 > 2 (length)"); + +sample = new DataView(buffer, 0, 1); +assert.throws(RangeError, function() { + sample.getFloat16(0); +}, "0 + 2 > 1 (length)"); + +sample = new DataView(buffer, 4, 2); +assert.throws(RangeError, function() { + sample.getFloat16(1); +}, "1 + 2 > 2 (offset+length)"); + +sample = new DataView(buffer, 4, 1); +assert.throws(RangeError, function() { + sample.getFloat16(0); +}, "0 + 2 > 1 (offset+length)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/length.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/length.js new file mode 100644 index 0000000000..bd71c6cbda --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/length.js @@ -0,0 +1,20 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: > + DataView.prototype.getFloat16.length is 1. +features: [Float16Array] +includes: [propertyHelper.js] +---*/ + +verifyProperty(DataView.prototype.getFloat16, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/minus-zero.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/minus-zero.js new file mode 100644 index 0000000000..2279538fd7 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/minus-zero.js @@ -0,0 +1,21 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: > + Return -0 +features: [Float16Array] +---*/ + +var buffer = new ArrayBuffer(8); +var sample = new DataView(buffer, 0); + +sample.setUint8(0, 128); +sample.setUint8(1, 0); + +var result = sample.getFloat16(0); +assert.sameValue(result, -0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/name.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/name.js new file mode 100644 index 0000000000..df100772a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/name.js @@ -0,0 +1,20 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: > + DataView.prototype.getFloat16.name is "getFloat16". +features: [Float16Array] +includes: [propertyHelper.js] +---*/ + +verifyProperty(DataView.prototype.getFloat16, "name", { + value: "getFloat16", + writable: false, + enumerable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/negative-byteoffset-throws.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/negative-byteoffset-throws.js new file mode 100644 index 0000000000..ada6286fd5 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/negative-byteoffset-throws.js @@ -0,0 +1,23 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: > + Throws a RangeError if ToInteger(byteOffset) < 0 +features: [Float16Array] +---*/ + +var buffer = new ArrayBuffer(12); +var sample = new DataView(buffer, 0); + +assert.throws(RangeError, function() { + sample.getFloat16(-1); +}, "-1"); + +assert.throws(RangeError, function() { + sample.getFloat16(-Infinity); +}, "-Infinity"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/not-a-constructor.js new file mode 100644 index 0000000000..af811a5e30 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/not-a-constructor.js @@ -0,0 +1,24 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + DataView.prototype.getFloat16 does not implement [[Construct]], is not new-able +includes: [isConstructor.js] +features: [Float16Array, Reflect.construct, DataView, arrow-function, ArrayBuffer] +---*/ + +assert.sameValue( + isConstructor(DataView.prototype.getFloat16), + false, + 'isConstructor(DataView.prototype.getFloat16) must return false' +); + +assert.throws(TypeError, () => { + let dv = new DataView(new ArrayBuffer(16)); new dv.getFloat16(0, 0); +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/resizable-buffer.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/resizable-buffer.js new file mode 100644 index 0000000000..ef1bbcdb4e --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/resizable-buffer.js @@ -0,0 +1,44 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- Float16Array,resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-dataview.prototype.getfloat16 +description: Throws a TypeError if buffer is out-of-bounds +features: [Float16Array, DataView, ArrayBuffer, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +var buffer = new ArrayBuffer(24, {maxByteLength: 32}); +var sample = new DataView(buffer, 0, 16); + +try { + buffer.resize(32); +} catch (_) {} + +assert.sameValue(sample.getFloat16(0), 0, 'following grow'); + +try { + buffer.resize(16); +} catch (_) {} + +assert.sameValue(sample.getFloat16(0), 0, 'following shrink (within bounds)'); + +var expectedError; +try { + buffer.resize(8); + expectedError = TypeError; +} catch (_) { + expectedError = Test262Error; +} + +assert.throws(expectedError, function() { + sample.getFloat16(0); + throw new Test262Error('the operation completed successfully'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-abrupt-from-tonumber-byteoffset-symbol.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-abrupt-from-tonumber-byteoffset-symbol.js new file mode 100644 index 0000000000..1643b832b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-abrupt-from-tonumber-byteoffset-symbol.js @@ -0,0 +1,21 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: > + Return abrupt from ToNumber(symbol byteOffset) +features: [Float16Array, Symbol] +---*/ + +var buffer = new ArrayBuffer(1); +var sample = new DataView(buffer, 0); + +var s = Symbol("1"); + +assert.throws(TypeError, function() { + sample.getFloat16(s); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-abrupt-from-tonumber-byteoffset.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-abrupt-from-tonumber-byteoffset.js new file mode 100644 index 0000000000..1c5088df49 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-abrupt-from-tonumber-byteoffset.js @@ -0,0 +1,35 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: > + Return abrupt from ToNumber(byteOffset) +features: [Float16Array] +---*/ + +var buffer = new ArrayBuffer(1); +var sample = new DataView(buffer, 0); + +var bo1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var bo2 = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + sample.getFloat16(bo1); +}, "valueOf"); + +assert.throws(Test262Error, function() { + sample.getFloat16(bo2); +}, "toString"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-infinity.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-infinity.js new file mode 100644 index 0000000000..26c0fcecd8 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-infinity.js @@ -0,0 +1,23 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: > + Return Infinity values +features: [Float16Array, DataView.prototype.setUint8] +---*/ + +var buffer = new ArrayBuffer(4); +var sample = new DataView(buffer, 0); + +sample.setUint8(0, 124); // 0b01111100 +sample.setUint8(1, 0); +sample.setUint8(2, 252); // 0b11111100 +sample.setUint8(3, 0); + +assert.sameValue(sample.getFloat16(0), Infinity); +assert.sameValue(sample.getFloat16(2), -Infinity); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-nan.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-nan.js new file mode 100644 index 0000000000..56af38b203 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-nan.js @@ -0,0 +1,23 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: > + Return NaN values +features: [Float16Array, DataView.prototype.setUint8] +---*/ + +var buffer = new ArrayBuffer(8); +var sample = new DataView(buffer, 0); + +sample.setUint8(0, 126); // 0b01111110 +sample.setUint8(1, 0); +sample.setUint8(2, 254); // 0b11111110 +sample.setUint8(3, 0); + +assert.sameValue(sample.getFloat16(0), NaN); +assert.sameValue(sample.getFloat16(2), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-value-clean-arraybuffer.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-value-clean-arraybuffer.js new file mode 100644 index 0000000000..bf8b2b0685 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-value-clean-arraybuffer.js @@ -0,0 +1,26 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: > + Return value from Buffer using a clean ArrayBuffer +features: [Float16Array] +---*/ + +var buffer = new ArrayBuffer(8); +var sample = new DataView(buffer, 0); + +assert.sameValue(sample.getFloat16(0, true), 0, "sample.getFloat16(0, true)"); +assert.sameValue(sample.getFloat16(1, true), 0, "sample.getFloat16(1, true)"); +assert.sameValue(sample.getFloat16(2, true), 0, "sample.getFloat16(2, true)"); +assert.sameValue(sample.getFloat16(3, true), 0, "sample.getFloat16(3, true)"); +assert.sameValue(sample.getFloat16(4, true), 0, "sample.getFloat16(4, true)"); +assert.sameValue(sample.getFloat16(0, false), 0, "sample.getFloat16(0, false)"); +assert.sameValue(sample.getFloat16(1, false), 0, "sample.getFloat16(1, false)"); +assert.sameValue(sample.getFloat16(2, false), 0, "sample.getFloat16(2, false)"); +assert.sameValue(sample.getFloat16(3, false), 0, "sample.getFloat16(3, false)"); +assert.sameValue(sample.getFloat16(4, false), 0, "sample.getFloat16(4, false)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-values-custom-offset.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-values-custom-offset.js new file mode 100644 index 0000000000..c121bd316c --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-values-custom-offset.js @@ -0,0 +1,29 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: > + Return values from Buffer using a custom offset +features: [Float16Array, DataView.prototype.setUint8] +---*/ + +var buffer = new ArrayBuffer(8); +var sample = new DataView(buffer, 0); + +sample.setUint8(4, 75); // 01001011 +sample.setUint8(5, 75); // 01001011 +sample.setUint8(6, 76); // 01001100 +sample.setUint8(7, 77); // 01001101 + +sample = new DataView(buffer, 4); + +assert.sameValue(sample.getFloat16(0, false), 14.5859375, "0, false"); // 01001011 01001011 +assert.sameValue(sample.getFloat16(1, false), 14.59375, "1, false"); // 01001011 01001100 +assert.sameValue(sample.getFloat16(2, false), 17.203125, "2, false"); // 01001100 01001101 +assert.sameValue(sample.getFloat16(0, true), 14.5859375, "0, true"); // 01001011 01001011 +assert.sameValue(sample.getFloat16(1, true), 17.171875, "1, true"); // 01001100 01001011 +assert.sameValue(sample.getFloat16(2, true), 21.1875, "2, true"); // 01001101 01001100 + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-values.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-values.js new file mode 100644 index 0000000000..51b3b874cd --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/return-values.js @@ -0,0 +1,40 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: > + Return values from Buffer +features: [Float16Array, DataView.prototype.setUint8] +---*/ + +var buffer = new ArrayBuffer(4); +var sample = new DataView(buffer, 0); + +sample.setUint8(0, 66); // 01000010 +sample.setUint8(1, 40); // 00101000 +sample.setUint8(2, 64); // 01000000 +sample.setUint8(3, 224); // 11100000 + +assert.sameValue(sample.getFloat16(0, false), 3.078125, "0, false"); // 01000010 00101000 +assert.sameValue(sample.getFloat16(1, false), 0.033203125, "1, false"); // 00101000 01000000 +assert.sameValue(sample.getFloat16(2, false), 2.4375, "2, false"); // 01000000 11100000 + +assert.sameValue(sample.getFloat16(0, true), 0.03326416015625, "0, true"); // 00101000 01000010 +assert.sameValue(sample.getFloat16(1, true), 2.078125, "1, true"); // 01000000 00101000 +assert.sameValue(sample.getFloat16(2, true), -544, "2, true"); // 11100000 01000000 + +sample.setUint8(0, 75); // 01001011 +sample.setUint8(1, 75); // 01001011 +sample.setUint8(2, 76); // 01001100 +sample.setUint8(3, 76); // 01001101 + +assert.sameValue(sample.getFloat16(0, false), 14.5859375, "0, false"); // 01001011 01001011 +assert.sameValue(sample.getFloat16(1, false), 14.59375, "1, false"); // 01001011 01001100 +assert.sameValue(sample.getFloat16(2, false), 17.1875, "2, false"); // 01001100 01001101 +assert.sameValue(sample.getFloat16(0, true), 14.5859375, "0, true"); // 01001011 01001011 +assert.sameValue(sample.getFloat16(1, true), 17.171875, "1, true"); // 01001100 01001011 +assert.sameValue(sample.getFloat16(2, true), 17.1875, "2, true"); // 01001100 01001101 + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/shell.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/shell.js diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/this-has-no-dataview-internal.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/this-has-no-dataview-internal.js new file mode 100644 index 0000000000..3b77b7f5b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/this-has-no-dataview-internal.js @@ -0,0 +1,32 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: > + Throws a TypeError if this does not have a [[DataView]] internal slot +features: [Float16Array, Int8Array] +---*/ + +var getFloat16 = DataView.prototype.getFloat16; + +assert.throws(TypeError, function() { + getFloat16.call({}); +}, "{}"); + +assert.throws(TypeError, function() { + getFloat16.call([]); +}, "[]"); + +var ab = new ArrayBuffer(1); +assert.throws(TypeError, function() { + getFloat16.call(ab); +}, "ArrayBuffer"); + +var ta = new Int8Array(); +assert.throws(TypeError, function() { + getFloat16.call(ta); +}, "TypedArray"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/this-is-not-object.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/this-is-not-object.js new file mode 100644 index 0000000000..917dc61dc8 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/this-is-not-object.js @@ -0,0 +1,42 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: Throws a TypeError if this is not Object +features: [Float16Array, Symbol] +---*/ + +var getFloat16 = DataView.prototype.getFloat16; + +assert.throws(TypeError, function() { + getFloat16.call(undefined); +}, "undefined"); + +assert.throws(TypeError, function() { + getFloat16.call(null); +}, "null"); + +assert.throws(TypeError, function() { + getFloat16.call(1); +}, "1"); + +assert.throws(TypeError, function() { + getFloat16.call("string"); +}, "string"); + +assert.throws(TypeError, function() { + getFloat16.call(true); +}, "true"); + +assert.throws(TypeError, function() { + getFloat16.call(false); +}, "false"); + +var s = Symbol("1"); +assert.throws(TypeError, function() { + getFloat16.call(s); +}, "symbol"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/to-boolean-littleendian.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/to-boolean-littleendian.js new file mode 100644 index 0000000000..793f95477c --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/to-boolean-littleendian.js @@ -0,0 +1,31 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getfloat16 +description: > + Boolean littleEndian argument coerced in ToBoolean +features: [Float16Array, DataView.prototype.setUint8, Symbol] +---*/ + +var buffer = new ArrayBuffer(2); +var sample = new DataView(buffer, 0); + +sample.setUint8(0, 75); +sample.setUint8(1, 76); + +// False +assert.sameValue(sample.getFloat16(0), 14.59375, "no arg"); +assert.sameValue(sample.getFloat16(0, undefined), 14.59375, "undefined"); +assert.sameValue(sample.getFloat16(0, null), 14.59375, "null"); +assert.sameValue(sample.getFloat16(0, 0), 14.59375, "0"); +assert.sameValue(sample.getFloat16(0, ""), 14.59375, "the empty string"); + +// True +assert.sameValue(sample.getFloat16(0, {}), 17.171875, "{}"); +assert.sameValue(sample.getFloat16(0, Symbol("1")), 17.171875, "symbol"); +assert.sameValue(sample.getFloat16(0, 1), 17.171875, "1"); +assert.sameValue(sample.getFloat16(0, "string"), 17.171875, "string"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/toindex-byteoffset.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/toindex-byteoffset.js new file mode 100644 index 0000000000..ae51364d35 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat16/toindex-byteoffset.js @@ -0,0 +1,53 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getFloat16 +description: > + ToIndex conversions on byteOffset +features: [Float16Array, DataView.prototype.setUint8] +---*/ + +var buffer = new ArrayBuffer(6); +var sample = new DataView(buffer, 0); + +sample.setUint8(0, 75); +sample.setUint8(1, 76); +sample.setUint8(2, 77); +sample.setUint8(3, 78); +sample.setUint8(4, 79); +sample.setUint8(5, 80); + +var obj1 = { + valueOf: function() { + return 3; + } +}; + +var obj2 = { + toString: function() { + return 2; + } +}; + +assert.sameValue(sample.getFloat16(-0), 14.59375, "-0"); +assert.sameValue(sample.getFloat16(obj1), 25.234375, "object's valueOf"); +assert.sameValue(sample.getFloat16(obj2), 21.21875, "object's toString"); +assert.sameValue(sample.getFloat16(""), 14.59375, "the Empty string"); +assert.sameValue(sample.getFloat16("0"), 14.59375, "string '0'"); +assert.sameValue(sample.getFloat16("2"), 21.21875, "string '2'"); +assert.sameValue(sample.getFloat16(true), 17.203125, "true"); +assert.sameValue(sample.getFloat16(false), 14.59375, "false"); +assert.sameValue(sample.getFloat16(NaN), 14.59375, "NaN"); +assert.sameValue(sample.getFloat16(null), 14.59375, "null"); +assert.sameValue(sample.getFloat16(0.1), 14.59375, "0.1"); +assert.sameValue(sample.getFloat16(0.9), 14.59375, "0.9"); +assert.sameValue(sample.getFloat16(1.1), 17.203125, "1.1"); +assert.sameValue(sample.getFloat16(1.9), 17.203125, "1.9"); +assert.sameValue(sample.getFloat16(-0.1), 14.59375, "-0.1"); +assert.sameValue(sample.getFloat16(-0.99999), 14.59375, "-0.99999"); +assert.sameValue(sample.getFloat16(undefined), 14.59375, "undefined"); +assert.sameValue(sample.getFloat16(), 14.59375, "no arg"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat32/length.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat32/length.js index 8f1256a67b..c05fb88469 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getFloat32/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat32/length.js @@ -23,10 +23,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.getFloat32.length, 1); - -verifyNotEnumerable(DataView.prototype.getFloat32, "length"); -verifyNotWritable(DataView.prototype.getFloat32, "length"); -verifyConfigurable(DataView.prototype.getFloat32, "length"); +verifyProperty(DataView.prototype.getFloat32, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat32/name.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat32/name.js index 26e5b6d3e0..1feabf5047 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getFloat32/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat32/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.getFloat32.name, "getFloat32"); - -verifyNotEnumerable(DataView.prototype.getFloat32, "name"); -verifyNotWritable(DataView.prototype.getFloat32, "name"); -verifyConfigurable(DataView.prototype.getFloat32, "name"); +verifyProperty(DataView.prototype.getFloat32, "name", { + value: "getFloat32", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat32/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat32/not-a-constructor.js index 628d35ed6d..cb2eef1326 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getFloat32/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat32/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.getFloat32(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.getFloat32(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat64/length.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat64/length.js index 3a2a4d7fcf..d8082606bc 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getFloat64/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat64/length.js @@ -23,10 +23,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.getFloat64.length, 1); - -verifyNotEnumerable(DataView.prototype.getFloat64, "length"); -verifyNotWritable(DataView.prototype.getFloat64, "length"); -verifyConfigurable(DataView.prototype.getFloat64, "length"); +verifyProperty(DataView.prototype.getFloat64, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat64/name.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat64/name.js index 2ae4d6ebae..020a27ccbc 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getFloat64/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat64/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.getFloat64.name, "getFloat64"); - -verifyNotEnumerable(DataView.prototype.getFloat64, "name"); -verifyNotWritable(DataView.prototype.getFloat64, "name"); -verifyConfigurable(DataView.prototype.getFloat64, "name"); +verifyProperty(DataView.prototype.getFloat64, "name", { + value: "getFloat64", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getFloat64/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/getFloat64/not-a-constructor.js index 551e9935fa..1bdeebec4a 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getFloat64/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getFloat64/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.getFloat64(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.getFloat64(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getInt16/length.js b/js/src/tests/test262/built-ins/DataView/prototype/getInt16/length.js index c3b2db9ee3..493574f48d 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getInt16/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getInt16/length.js @@ -23,10 +23,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.getInt16.length, 1); - -verifyNotEnumerable(DataView.prototype.getInt16, "length"); -verifyNotWritable(DataView.prototype.getInt16, "length"); -verifyConfigurable(DataView.prototype.getInt16, "length"); +verifyProperty(DataView.prototype.getInt16, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getInt16/name.js b/js/src/tests/test262/built-ins/DataView/prototype/getInt16/name.js index 933b5b3ddf..c054c266cc 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getInt16/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getInt16/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.getInt16.name, "getInt16"); - -verifyNotEnumerable(DataView.prototype.getInt16, "name"); -verifyNotWritable(DataView.prototype.getInt16, "name"); -verifyConfigurable(DataView.prototype.getInt16, "name"); +verifyProperty(DataView.prototype.getInt16, "name", { + value: "getInt16", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getInt16/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/getInt16/not-a-constructor.js index f4a3a72970..3e720ea085 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getInt16/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getInt16/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.getInt16(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.getInt16(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getInt32/length.js b/js/src/tests/test262/built-ins/DataView/prototype/getInt32/length.js index 746487b54a..7482320415 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getInt32/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getInt32/length.js @@ -23,10 +23,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.getInt32.length, 1); - -verifyNotEnumerable(DataView.prototype.getInt32, "length"); -verifyNotWritable(DataView.prototype.getInt32, "length"); -verifyConfigurable(DataView.prototype.getInt32, "length"); +verifyProperty(DataView.prototype.getInt32, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getInt32/name.js b/js/src/tests/test262/built-ins/DataView/prototype/getInt32/name.js index 7c44bd6960..48b4d515e2 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getInt32/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getInt32/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.getInt32.name, "getInt32"); - -verifyNotEnumerable(DataView.prototype.getInt32, "name"); -verifyNotWritable(DataView.prototype.getInt32, "name"); -verifyConfigurable(DataView.prototype.getInt32, "name"); +verifyProperty(DataView.prototype.getInt32, "name", { + value: "getInt32", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getInt32/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/getInt32/not-a-constructor.js index 2e987dc405..6710a816dd 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getInt32/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getInt32/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.getInt32(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.getInt32(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getInt8/length.js b/js/src/tests/test262/built-ins/DataView/prototype/getInt8/length.js index 7ad4e7999c..b9ec2cc2dd 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getInt8/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getInt8/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.getInt8.length, 1); - -verifyNotEnumerable(DataView.prototype.getInt8, "length"); -verifyNotWritable(DataView.prototype.getInt8, "length"); -verifyConfigurable(DataView.prototype.getInt8, "length"); +verifyProperty(DataView.prototype.getInt8, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getInt8/name.js b/js/src/tests/test262/built-ins/DataView/prototype/getInt8/name.js index 4e56fcf221..e56be1d203 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getInt8/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getInt8/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.getInt8.name, "getInt8"); - -verifyNotEnumerable(DataView.prototype.getInt8, "name"); -verifyNotWritable(DataView.prototype.getInt8, "name"); -verifyConfigurable(DataView.prototype.getInt8, "name"); +verifyProperty(DataView.prototype.getInt8, "name", { + value: "getInt8", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getInt8/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/getInt8/not-a-constructor.js index 8acdd1a409..48e5a88efe 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getInt8/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getInt8/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.getInt8(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.getInt8(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getUint16/length.js b/js/src/tests/test262/built-ins/DataView/prototype/getUint16/length.js index 3403612bf9..19633b33fe 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getUint16/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getUint16/length.js @@ -23,10 +23,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.getUint16.length, 1); - -verifyNotEnumerable(DataView.prototype.getUint16, "length"); -verifyNotWritable(DataView.prototype.getUint16, "length"); -verifyConfigurable(DataView.prototype.getUint16, "length"); +verifyProperty(DataView.prototype.getUint16, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getUint16/name.js b/js/src/tests/test262/built-ins/DataView/prototype/getUint16/name.js index 3c39801e23..54cfb46a1d 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getUint16/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getUint16/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.getUint16.name, "getUint16"); - -verifyNotEnumerable(DataView.prototype.getUint16, "name"); -verifyNotWritable(DataView.prototype.getUint16, "name"); -verifyConfigurable(DataView.prototype.getUint16, "name"); +verifyProperty(DataView.prototype.getUint16, "name", { + value: "getUint16", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getUint16/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/getUint16/not-a-constructor.js index c56587ca00..06c27fb236 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getUint16/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getUint16/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.getUint16(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.getUint16(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getUint32/length.js b/js/src/tests/test262/built-ins/DataView/prototype/getUint32/length.js index 5ca99f56e8..544ffc4536 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getUint32/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getUint32/length.js @@ -23,10 +23,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.getUint32.length, 1); - -verifyNotEnumerable(DataView.prototype.getUint32, "length"); -verifyNotWritable(DataView.prototype.getUint32, "length"); -verifyConfigurable(DataView.prototype.getUint32, "length"); +verifyProperty(DataView.prototype.getUint32, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getUint32/name.js b/js/src/tests/test262/built-ins/DataView/prototype/getUint32/name.js index 9e5f2f2a5c..259d024dc4 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getUint32/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getUint32/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.getUint32.name, "getUint32"); - -verifyNotEnumerable(DataView.prototype.getUint32, "name"); -verifyNotWritable(DataView.prototype.getUint32, "name"); -verifyConfigurable(DataView.prototype.getUint32, "name"); +verifyProperty(DataView.prototype.getUint32, "name", { + value: "getUint32", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getUint32/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/getUint32/not-a-constructor.js index 423a22224f..a3b3c483b6 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getUint32/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getUint32/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.getUint32(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.getUint32(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getUint8/length.js b/js/src/tests/test262/built-ins/DataView/prototype/getUint8/length.js index aaa458a70e..fd67db7453 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getUint8/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getUint8/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.getUint8.length, 1); - -verifyNotEnumerable(DataView.prototype.getUint8, "length"); -verifyNotWritable(DataView.prototype.getUint8, "length"); -verifyConfigurable(DataView.prototype.getUint8, "length"); +verifyProperty(DataView.prototype.getUint8, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getUint8/name.js b/js/src/tests/test262/built-ins/DataView/prototype/getUint8/name.js index 071782c08f..1fd1de4e03 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getUint8/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getUint8/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.getUint8.name, "getUint8"); - -verifyNotEnumerable(DataView.prototype.getUint8, "name"); -verifyNotWritable(DataView.prototype.getUint8, "name"); -verifyConfigurable(DataView.prototype.getUint8, "name"); +verifyProperty(DataView.prototype.getUint8, "name", { + value: "getUint8", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/getUint8/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/getUint8/not-a-constructor.js index 63c22bc84a..ff3afe1647 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/getUint8/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/getUint8/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.getUint8(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.getUint8(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setBigInt64/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/setBigInt64/not-a-constructor.js index 3d57145553..ee47e8ebb7 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setBigInt64/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setBigInt64/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.setBigInt64(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.setBigInt64(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setBigUint64/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/setBigUint64/not-a-constructor.js index 393dab357e..1e07e42d5e 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setBigUint64/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setBigUint64/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.setBigUint64(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.setBigUint64(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/browser.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/browser.js diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/detached-buffer-after-number-value.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/detached-buffer-after-number-value.js new file mode 100644 index 0000000000..7978099dcd --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/detached-buffer-after-number-value.js @@ -0,0 +1,27 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + Detached buffer is checked after ToNumber(value) +features: [Float16Array] +includes: [detachArrayBuffer.js] +---*/ + +var buffer = new ArrayBuffer(8); +var sample = new DataView(buffer, 0); + +var v = { + valueOf: function() { + throw new Test262Error(); + } +}; + +$DETACHBUFFER(buffer); +assert.throws(Test262Error, function() { + sample.setFloat16(0, v); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/detached-buffer-after-toindex-byteoffset.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/detached-buffer-after-toindex-byteoffset.js new file mode 100644 index 0000000000..864850f787 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/detached-buffer-after-toindex-byteoffset.js @@ -0,0 +1,26 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + Detached buffer is only checked after ToIndex(requestIndex) +features: [Float16Array] +includes: [detachArrayBuffer.js] +---*/ + +var buffer = new ArrayBuffer(8); +var sample = new DataView(buffer, 0); + +$DETACHBUFFER(buffer); + +assert.throws(RangeError, function() { + sample.setFloat16(Infinity, 0); +}, "Infinity"); + +assert.throws(RangeError, function() { + sample.setFloat16(-1, 0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/detached-buffer-before-outofrange-byteoffset.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/detached-buffer-before-outofrange-byteoffset.js new file mode 100644 index 0000000000..1d9d289e63 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/detached-buffer-before-outofrange-byteoffset.js @@ -0,0 +1,24 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + Detached buffer is checked before out of range byteOffset's value +features: [Float16Array] +includes: [detachArrayBuffer.js] +---*/ + +var sample; +var buffer = new ArrayBuffer(12); + +sample = new DataView(buffer, 0); + +$DETACHBUFFER(buffer); + +assert.throws(TypeError, function() { + sample.setFloat16(13, 0); +}, "13"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/detached-buffer.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/detached-buffer.js new file mode 100644 index 0000000000..11e71b7cb8 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/detached-buffer.js @@ -0,0 +1,21 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + Throws a TypeError if buffer is detached +features: [Float16Array] +includes: [detachArrayBuffer.js] +---*/ + +var buffer = new ArrayBuffer(1); +var sample = new DataView(buffer, 0); + +$DETACHBUFFER(buffer); +assert.throws(TypeError, function() { + sample.setFloat16(0, 0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/index-check-before-value-conversion.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/index-check-before-value-conversion.js new file mode 100644 index 0000000000..e1b2b18b35 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/index-check-before-value-conversion.js @@ -0,0 +1,36 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + RangeError exception for negative index is thrown before the value conversion. +features: [Float16Array] +---*/ + +var dataView = new DataView(new ArrayBuffer(8), 0); + +var poisoned = { + valueOf: function() { + throw new Test262Error("valueOf called"); + } +}; + +assert.throws(RangeError, function() { + dataView.setFloat16(-1.5, poisoned); +}, "setFloat16(-1.5, poisoned)"); + +assert.throws(RangeError, function() { + dataView.setFloat16(-1, poisoned); +}, "setFloat16(-1, poisoned)"); + +assert.throws(RangeError, function() { + dataView.setFloat16(-Infinity, poisoned); +}, "setFloat16(-Infinity, poisoned)"); + +assert.throws(RangeError, function() { + dataView.setFloat16(Infinity, poisoned); +}, "setFloat16(Infinity, poisoned)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/index-is-out-of-range.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/index-is-out-of-range.js new file mode 100644 index 0000000000..11f0e02a03 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/index-is-out-of-range.js @@ -0,0 +1,71 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + Throws a RangeError if getIndex + elementSize > viewSize +features: [Float16Array] +---*/ + +var sample; +var buffer = new ArrayBuffer(12); + +sample = new DataView(buffer, 0); + +assert.throws(RangeError, function() { + sample.setFloat16(Infinity, 39); +}, "getIndex == Infinity"); + +assert.throws(RangeError, function() { + sample.setFloat16(13, 39); +}, "13 + 2 > 12"); + +assert.throws(RangeError, function() { + sample.setFloat16(12, 39); +}, "12 + 2 > 12"); + +assert.throws(RangeError, function() { + sample.setFloat16(11, 39); +}, "11 + 2 > 12"); + +sample = new DataView(buffer, 10); +assert.throws(RangeError, function() { + sample.setFloat16(1, 39); +}, "1 + 2 > 2 (offset)"); + +sample = new DataView(buffer, 11); +assert.throws(RangeError, function() { + sample.setFloat16(0, 39); +}, "0 + 2 > 1 (offset)"); + +sample = new DataView(buffer, 0, 2); +assert.throws(RangeError, function() { + sample.setFloat16(1, 39); +}, "1 + 2 > 2 (length)"); + +sample = new DataView(buffer, 0, 1); +assert.throws(RangeError, function() { + sample.setFloat16(0, 39); +}, "0 + 2 > 1 (length)"); + +sample = new DataView(buffer, 4, 2); +assert.throws(RangeError, function() { + sample.setFloat16(1, 39); +}, "1 + 2 > 2 (offset+length)"); + +sample = new DataView(buffer, 4, 1); +assert.throws(RangeError, function() { + sample.setFloat16(0, 39); +}, "0 + 2 > 1 (offset+length)"); + +sample = new DataView(buffer, 0); +assert.sameValue(sample.getFloat16(0), 0, "[0] no value was set"); +assert.sameValue(sample.getFloat16(2), 0, "[1] no value was set"); +assert.sameValue(sample.getFloat16(4), 0, "[2] no value was set"); +assert.sameValue(sample.getFloat16(6), 0, "[3] no value was set"); +assert.sameValue(sample.getFloat16(8), 0, "[4] no value was set"); +assert.sameValue(sample.getFloat16(10), 0, "[5] no value was set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/length.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/length.js new file mode 100644 index 0000000000..d6e2809511 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/length.js @@ -0,0 +1,20 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + DataView.prototype.setFloat16.length is 2. +features: [Float16Array] +includes: [propertyHelper.js] +---*/ + +verifyProperty(DataView.prototype.setFloat16, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/name.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/name.js new file mode 100644 index 0000000000..41ef3bb195 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/name.js @@ -0,0 +1,20 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + DataView.prototype.setFloat16.name is "setFloat16". +features: [Float16Array] +includes: [propertyHelper.js] +---*/ + +verifyProperty(DataView.prototype.setFloat16, "name", { + value: "setFloat16", + writable: false, + enumerable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/negative-byteoffset-throws.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/negative-byteoffset-throws.js new file mode 100644 index 0000000000..84722723ad --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/negative-byteoffset-throws.js @@ -0,0 +1,25 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + Throws a RangeError if getIndex < 0 +features: [Float16Array] +---*/ + +var buffer = new ArrayBuffer(12); +var sample = new DataView(buffer, 0); + +assert.throws(RangeError, function() { + sample.setFloat16(-1, 39); +}, "-1"); +assert.sameValue(sample.getFloat32(0), 0, "-1 - no value was set"); + +assert.throws(RangeError, function() { + sample.setFloat16(-Infinity, 39); +}, "-Infinity"); +assert.sameValue(sample.getFloat32(0), 0, "-Infinity - no value was set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/no-value-arg.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/no-value-arg.js new file mode 100644 index 0000000000..75f634b0a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/no-value-arg.js @@ -0,0 +1,20 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + Set value as undefined (cast to NaN) when value argument is not present +features: [Float16Array] +---*/ + +var buffer = new ArrayBuffer(8); +var sample = new DataView(buffer, 0); + +var result = sample.setFloat16(0); + +assert.sameValue(sample.getFloat16(0), NaN); +assert.sameValue(result, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/not-a-constructor.js new file mode 100644 index 0000000000..549f33ba39 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/not-a-constructor.js @@ -0,0 +1,24 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + DataView.prototype.setFloat16 does not implement [[Construct]], is not new-able +includes: [isConstructor.js] +features: [Float16Array, Reflect.construct, DataView, arrow-function, ArrayBuffer] +---*/ + +assert.sameValue( + isConstructor(DataView.prototype.setFloat16), + false, + 'isConstructor(DataView.prototype.setFloat16) must return false' +); + +assert.throws(TypeError, () => { + let dv = new DataView(new ArrayBuffer(16)); new dv.setFloat16(0, 0); +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/range-check-after-value-conversion.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/range-check-after-value-conversion.js new file mode 100644 index 0000000000..04e87fc18c --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/range-check-after-value-conversion.js @@ -0,0 +1,28 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setFloat16 +description: > + Index bounds checks are performed after value conversion. +features: [Float16Array] +---*/ + +var dataView = new DataView(new ArrayBuffer(8), 0); + +var poisoned = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + dataView.setFloat16(100, poisoned); +}, "setFloat16(100, poisoned)"); + +assert.throws(Test262Error, function() { + dataView.setFloat16('100', poisoned); +}, "setFloat16('100', poisoned)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/resizable-buffer.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/resizable-buffer.js new file mode 100644 index 0000000000..17b09d9b13 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/resizable-buffer.js @@ -0,0 +1,44 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- Float16Array,resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-dataview.prototype.setfloat16 +description: Throws a TypeError if buffer is out-of-bounds +features: [Float16Array, DataView, ArrayBuffer, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +var buffer = new ArrayBuffer(24, {maxByteLength: 32}); +var sample = new DataView(buffer, 0, 16); + +try { + buffer.resize(32); +} catch (_) {} + +assert.sameValue(sample.setFloat16(0, 10), undefined, 'following grow'); + +try { + buffer.resize(16); +} catch (_) {} + +assert.sameValue(sample.setFloat16(0, 20), undefined, 'following shrink (within bounds)'); + +var expectedError; +try { + buffer.resize(8); + expectedError = TypeError; +} catch (_) { + expectedError = Test262Error; +} + +assert.throws(expectedError, function() { + sample.setFloat16(0, 30); + throw new Test262Error('the operation completed successfully'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/return-abrupt-from-tonumber-byteoffset-symbol.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/return-abrupt-from-tonumber-byteoffset-symbol.js new file mode 100644 index 0000000000..d56fea3aa5 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/return-abrupt-from-tonumber-byteoffset-symbol.js @@ -0,0 +1,21 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + Return abrupt from ToNumber(symbol byteOffset) +features: [Float16Array, Symbol] +---*/ + +var buffer = new ArrayBuffer(1); +var sample = new DataView(buffer, 0); + +var s = Symbol("1"); + +assert.throws(TypeError, function() { + sample.setFloat16(s); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/return-abrupt-from-tonumber-byteoffset.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/return-abrupt-from-tonumber-byteoffset.js new file mode 100644 index 0000000000..4c70428fc1 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/return-abrupt-from-tonumber-byteoffset.js @@ -0,0 +1,35 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + Return abrupt from ToNumber(byteOffset) +features: [Float16Array] +---*/ + +var buffer = new ArrayBuffer(1); +var sample = new DataView(buffer, 0); + +var bo1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var bo2 = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + sample.setFloat16(bo1, 1); +}, "valueOf"); + +assert.throws(Test262Error, function() { + sample.setFloat16(bo2, 1); +}, "toString"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/return-abrupt-from-tonumber-value-symbol.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/return-abrupt-from-tonumber-value-symbol.js new file mode 100644 index 0000000000..01639d1e10 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/return-abrupt-from-tonumber-value-symbol.js @@ -0,0 +1,21 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + Return abrupt from ToNumber(symbol value) +features: [Float16Array, Symbol] +---*/ + +var buffer = new ArrayBuffer(4); +var sample = new DataView(buffer, 0); + +var s = Symbol("1"); + +assert.throws(TypeError, function() { + sample.setFloat16(0, s); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/return-abrupt-from-tonumber-value.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/return-abrupt-from-tonumber-value.js new file mode 100644 index 0000000000..802757cffc --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/return-abrupt-from-tonumber-value.js @@ -0,0 +1,35 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + Return abrupt from ToNumber(value) +features: [Float16Array] +---*/ + +var buffer = new ArrayBuffer(4); +var sample = new DataView(buffer, 0); + +var bo1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var bo2 = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + sample.setFloat16(0, bo1); +}, "valueOf"); + +assert.throws(Test262Error, function() { + sample.setFloat16(0, bo2); +}, "toString"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/set-values-little-endian-order.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/set-values-little-endian-order.js new file mode 100644 index 0000000000..dcbdd57594 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/set-values-little-endian-order.js @@ -0,0 +1,25 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + Set values with little endian order. +features: [Float16Array] +---*/ + +var buffer = new ArrayBuffer(2); +var sample = new DataView(buffer, 0); + +var result; + +result = sample.setFloat16(0, 42, true); // 01010001 01000000 +assert.sameValue(result, undefined, "returns undefined #1"); +assert.sameValue(sample.getFloat16(0), 2.158203125); // 01000000 01010001 + +result = sample.setFloat16(0, 2.158203125, true); +assert.sameValue(result, undefined, "returns undefined #2"); +assert.sameValue(sample.getFloat16(0), 42); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/set-values-return-undefined.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/set-values-return-undefined.js new file mode 100644 index 0000000000..52212f556a --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/set-values-return-undefined.js @@ -0,0 +1,36 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + Set values and return undefined +features: [Float16Array] +includes: [byteConversionValues.js] +---*/ + +var buffer = new ArrayBuffer(2); +var sample = new DataView(buffer, 0); +var values = byteConversionValues.values; +var expectedValues = byteConversionValues.expected.Float16; + +values.forEach(function(value, i) { + var result; + var expected = expectedValues[i]; + + result = sample.setFloat16(0, value, false); + + assert.sameValue( + sample.getFloat16(0), + expected, + "value: " + value + ); + assert.sameValue( + result, + undefined, + "return is undefined, value: " + value + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/shell.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/shell.js diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/this-has-no-dataview-internal.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/this-has-no-dataview-internal.js new file mode 100644 index 0000000000..e0d2c72daa --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/this-has-no-dataview-internal.js @@ -0,0 +1,32 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + Throws a TypeError if this does not have a [[DataView]] internal slot +features: [Float16Array, Int8Array] +---*/ + +var setFloat16 = DataView.prototype.setFloat16; + +assert.throws(TypeError, function() { + setFloat16.call({}); +}, "{}"); + +assert.throws(TypeError, function() { + setFloat16.call([]); +}, "[]"); + +var ab = new ArrayBuffer(1); +assert.throws(TypeError, function() { + setFloat16.call(ab); +}, "ArrayBuffer"); + +var ta = new Int8Array(); +assert.throws(TypeError, function() { + setFloat16.call(ta); +}, "TypedArray"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/this-is-not-object.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/this-is-not-object.js new file mode 100644 index 0000000000..182647f76f --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/this-is-not-object.js @@ -0,0 +1,42 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: Throws a TypeError if this is not Object +features: [Float16Array, Symbol] +---*/ + +var setFloat16 = DataView.prototype.setFloat16; + +assert.throws(TypeError, function() { + setFloat16.call(undefined); +}, "undefined"); + +assert.throws(TypeError, function() { + setFloat16.call(null); +}, "null"); + +assert.throws(TypeError, function() { + setFloat16.call(1); +}, "1"); + +assert.throws(TypeError, function() { + setFloat16.call("string"); +}, "string"); + +assert.throws(TypeError, function() { + setFloat16.call(true); +}, "true"); + +assert.throws(TypeError, function() { + setFloat16.call(false); +}, "false"); + +var s = Symbol("1"); +assert.throws(TypeError, function() { + setFloat16.call(s); +}, "symbol"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/to-boolean-littleendian.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/to-boolean-littleendian.js new file mode 100644 index 0000000000..1840009be6 --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/to-boolean-littleendian.js @@ -0,0 +1,37 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + Boolean littleEndian argument coerced in ToBoolean +features: [Float16Array, Symbol] +---*/ + +var buffer = new ArrayBuffer(2); +var sample = new DataView(buffer, 0); + +// False +sample.setFloat16(0, 1); +assert.sameValue(sample.getFloat16(0), 1, "no arg"); +sample.setFloat16(0, 2, undefined); +assert.sameValue(sample.getFloat16(0), 2, "undefined"); +sample.setFloat16(0, 3, null); +assert.sameValue(sample.getFloat16(0), 3, "null"); +sample.setFloat16(0, 4, 0); +assert.sameValue(sample.getFloat16(0), 4, "0"); +sample.setFloat16(0, 5, ""); +assert.sameValue(sample.getFloat16(0), 5, "the empty string"); + +// True +sample.setFloat16(0, 6, {}); // 01000110 00000000 +assert.sameValue(sample.getFloat16(0), 0.000004172325134277344, "{}"); // 00000000 01000110 +sample.setFloat16(0, 7, Symbol("1")); // 01000111 00000000 +assert.sameValue(sample.getFloat16(0), 0.000004231929779052734, "symbol"); // 00000000 01000111 +sample.setFloat16(0, 8, 1); // 01001000 00000000 +assert.sameValue(sample.getFloat16(0), 0.000004291534423828125, "1"); // 00000000 01001000 +sample.setFloat16(0, 9, "string"); // 01001000 10000000 +assert.sameValue(sample.getFloat16(0), -0.000004291534423828125, "string"); // 10000000 01001000 + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/toindex-byteoffset.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/toindex-byteoffset.js new file mode 100644 index 0000000000..2e637768de --- /dev/null +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat16/toindex-byteoffset.js @@ -0,0 +1,99 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.setfloat16 +description: > + ToIndex conversions on byteOffset +features: [Float16Array] +---*/ + +var buffer = new ArrayBuffer(6); +var sample = new DataView(buffer, 0); + +var obj1 = { + valueOf: function() { + return 3; + } +}; + +var obj2 = { + toString: function() { + return 4; + } +}; + +sample.setFloat16(0, 0); +sample.setFloat16(-0, 42); +assert.sameValue(sample.getFloat16(0), 42, "-0"); + +sample.setFloat16(3, 0); +sample.setFloat16(obj1, 42); +assert.sameValue(sample.getFloat16(3), 42, "object's valueOf"); + +sample.setFloat16(4, 0); +sample.setFloat16(obj2, 42); +assert.sameValue(sample.getFloat16(4), 42, "object's toString"); + +sample.setFloat16(0, 0); +sample.setFloat16("", 42); +assert.sameValue(sample.getFloat16(0), 42, "the Empty string"); + +sample.setFloat16(0, 0); +sample.setFloat16("0", 42); +assert.sameValue(sample.getFloat16(0), 42, "string '0'"); + +sample.setFloat16(2, 0); +sample.setFloat16("2", 42); +assert.sameValue(sample.getFloat16(2), 42, "string '2'"); + +sample.setFloat16(1, 0); +sample.setFloat16(true, 42); +assert.sameValue(sample.getFloat16(1), 42, "true"); + +sample.setFloat16(0, 0); +sample.setFloat16(false, 42); +assert.sameValue(sample.getFloat16(0), 42, "false"); + +sample.setFloat16(0, 0); +sample.setFloat16(NaN, 42); +assert.sameValue(sample.getFloat16(0), 42, "NaN"); + +sample.setFloat16(0, 0); +sample.setFloat16(null, 42); +assert.sameValue(sample.getFloat16(0), 42, "null"); + +sample.setFloat16(0, 0); +sample.setFloat16(0.1, 42); +assert.sameValue(sample.getFloat16(0), 42, "0.1"); + +sample.setFloat16(0, 0); +sample.setFloat16(0.9, 42); +assert.sameValue(sample.getFloat16(0), 42, "0.9"); + +sample.setFloat16(1, 0); +sample.setFloat16(1.1, 42); +assert.sameValue(sample.getFloat16(1), 42, "1.1"); + +sample.setFloat16(1, 0); +sample.setFloat16(1.9, 42); +assert.sameValue(sample.getFloat16(1), 42, "1.9"); + +sample.setFloat16(0, 0); +sample.setFloat16(-0.1, 42); +assert.sameValue(sample.getFloat16(0), 42, "-0.1"); + +sample.setFloat16(0, 0); +sample.setFloat16(-0.99999, 42); +assert.sameValue(sample.getFloat16(0), 42, "-0.99999"); + +sample.setFloat16(0, 0); +sample.setFloat16(undefined, 42); +assert.sameValue(sample.getFloat16(0), 42, "undefined"); + +sample.setFloat16(0, 7); +sample.setFloat16(); +assert.sameValue(sample.getFloat16(0), NaN, "no arg"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat32/length.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat32/length.js index aeda1f8804..80fdfa5ab8 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setFloat32/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat32/length.js @@ -23,10 +23,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.setFloat32.length, 2); - -verifyNotEnumerable(DataView.prototype.setFloat32, "length"); -verifyNotWritable(DataView.prototype.setFloat32, "length"); -verifyConfigurable(DataView.prototype.setFloat32, "length"); +verifyProperty(DataView.prototype.setFloat32, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat32/name.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat32/name.js index 497527f0ab..56e832d61c 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setFloat32/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat32/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.setFloat32.name, "setFloat32"); - -verifyNotEnumerable(DataView.prototype.setFloat32, "name"); -verifyNotWritable(DataView.prototype.setFloat32, "name"); -verifyConfigurable(DataView.prototype.setFloat32, "name"); +verifyProperty(DataView.prototype.setFloat32, "name", { + value: "setFloat32", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat32/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat32/not-a-constructor.js index 6388f109ab..c0d4b634cf 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setFloat32/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat32/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.setFloat32(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.setFloat32(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat64/length.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat64/length.js index 50eb0bbe97..2fcf6428b3 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setFloat64/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat64/length.js @@ -23,10 +23,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.setFloat64.length, 2); - -verifyNotEnumerable(DataView.prototype.setFloat64, "length"); -verifyNotWritable(DataView.prototype.setFloat64, "length"); -verifyConfigurable(DataView.prototype.setFloat64, "length"); +verifyProperty(DataView.prototype.setFloat64, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat64/name.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat64/name.js index 05ca0ec912..e788228f90 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setFloat64/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat64/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.setFloat64.name, "setFloat64"); - -verifyNotEnumerable(DataView.prototype.setFloat64, "name"); -verifyNotWritable(DataView.prototype.setFloat64, "name"); -verifyConfigurable(DataView.prototype.setFloat64, "name"); +verifyProperty(DataView.prototype.setFloat64, "name", { + value: "setFloat64", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setFloat64/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/setFloat64/not-a-constructor.js index 12ff2af998..305dd13372 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setFloat64/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setFloat64/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.setFloat64(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.setFloat64(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setInt16/length.js b/js/src/tests/test262/built-ins/DataView/prototype/setInt16/length.js index 74e11083b2..1e1640d623 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setInt16/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setInt16/length.js @@ -23,10 +23,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.setInt16.length, 2); - -verifyNotEnumerable(DataView.prototype.setInt16, "length"); -verifyNotWritable(DataView.prototype.setInt16, "length"); -verifyConfigurable(DataView.prototype.setInt16, "length"); +verifyProperty(DataView.prototype.setInt16, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setInt16/name.js b/js/src/tests/test262/built-ins/DataView/prototype/setInt16/name.js index 15220b4d94..3841b8e318 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setInt16/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setInt16/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.setInt16.name, "setInt16"); - -verifyNotEnumerable(DataView.prototype.setInt16, "name"); -verifyNotWritable(DataView.prototype.setInt16, "name"); -verifyConfigurable(DataView.prototype.setInt16, "name"); +verifyProperty(DataView.prototype.setInt16, "name", { + value: "setInt16", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setInt16/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/setInt16/not-a-constructor.js index b04ec4ac06..85616d68cd 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setInt16/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setInt16/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.setInt16(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.setInt16(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setInt32/length.js b/js/src/tests/test262/built-ins/DataView/prototype/setInt32/length.js index 57bcc4db46..9d1fe1515a 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setInt32/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setInt32/length.js @@ -23,10 +23,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.setInt32.length, 2); - -verifyNotEnumerable(DataView.prototype.setInt32, "length"); -verifyNotWritable(DataView.prototype.setInt32, "length"); -verifyConfigurable(DataView.prototype.setInt32, "length"); +verifyProperty(DataView.prototype.setInt32, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setInt32/name.js b/js/src/tests/test262/built-ins/DataView/prototype/setInt32/name.js index 54f2572e30..22c81b434b 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setInt32/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setInt32/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.setInt32.name, "setInt32"); - -verifyNotEnumerable(DataView.prototype.setInt32, "name"); -verifyNotWritable(DataView.prototype.setInt32, "name"); -verifyConfigurable(DataView.prototype.setInt32, "name"); +verifyProperty(DataView.prototype.setInt32, "name", { + value: "setInt32", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setInt32/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/setInt32/not-a-constructor.js index 2f73e1a327..43cc02faf8 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setInt32/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setInt32/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.setInt32(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.setInt32(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setInt8/length.js b/js/src/tests/test262/built-ins/DataView/prototype/setInt8/length.js index 8900d3121e..c1fb981599 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setInt8/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setInt8/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.setInt8.length, 2); - -verifyNotEnumerable(DataView.prototype.setInt8, "length"); -verifyNotWritable(DataView.prototype.setInt8, "length"); -verifyConfigurable(DataView.prototype.setInt8, "length"); +verifyProperty(DataView.prototype.setInt8, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setInt8/name.js b/js/src/tests/test262/built-ins/DataView/prototype/setInt8/name.js index 8464b328a4..4be8f0eb0a 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setInt8/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setInt8/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.setInt8.name, "setInt8"); - -verifyNotEnumerable(DataView.prototype.setInt8, "name"); -verifyNotWritable(DataView.prototype.setInt8, "name"); -verifyConfigurable(DataView.prototype.setInt8, "name"); +verifyProperty(DataView.prototype.setInt8, "name", { + value: "setInt8", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setInt8/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/setInt8/not-a-constructor.js index e497bc1d7b..63c758cfe1 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setInt8/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setInt8/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.setInt8(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.setInt8(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setUint16/length.js b/js/src/tests/test262/built-ins/DataView/prototype/setUint16/length.js index 51e8fa626d..87c8e16952 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setUint16/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setUint16/length.js @@ -23,10 +23,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.setUint16.length, 2); - -verifyNotEnumerable(DataView.prototype.setUint16, "length"); -verifyNotWritable(DataView.prototype.setUint16, "length"); -verifyConfigurable(DataView.prototype.setUint16, "length"); +verifyProperty(DataView.prototype.setUint16, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setUint16/name.js b/js/src/tests/test262/built-ins/DataView/prototype/setUint16/name.js index 25d12bb4b4..58e6dc20d6 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setUint16/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setUint16/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.setUint16.name, "setUint16"); - -verifyNotEnumerable(DataView.prototype.setUint16, "name"); -verifyNotWritable(DataView.prototype.setUint16, "name"); -verifyConfigurable(DataView.prototype.setUint16, "name"); +verifyProperty(DataView.prototype.setUint16, "name", { + value: "setUint16", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setUint16/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/setUint16/not-a-constructor.js index d03027a4e5..e372ae6f8a 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setUint16/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setUint16/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.setUint16(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.setUint16(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setUint32/length.js b/js/src/tests/test262/built-ins/DataView/prototype/setUint32/length.js index 274874d9b6..2a70739e78 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setUint32/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setUint32/length.js @@ -23,10 +23,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.setUint32.length, 2); - -verifyNotEnumerable(DataView.prototype.setUint32, "length"); -verifyNotWritable(DataView.prototype.setUint32, "length"); -verifyConfigurable(DataView.prototype.setUint32, "length"); +verifyProperty(DataView.prototype.setUint32, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setUint32/name.js b/js/src/tests/test262/built-ins/DataView/prototype/setUint32/name.js index 1d72ad1c79..c5b4ad6698 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setUint32/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setUint32/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.setUint32.name, "setUint32"); - -verifyNotEnumerable(DataView.prototype.setUint32, "name"); -verifyNotWritable(DataView.prototype.setUint32, "name"); -verifyConfigurable(DataView.prototype.setUint32, "name"); +verifyProperty(DataView.prototype.setUint32, "name", { + value: "setUint32", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setUint32/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/setUint32/not-a-constructor.js index 91a589a3c4..15e0115a3f 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setUint32/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setUint32/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.setUint32(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.setUint32(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setUint8/length.js b/js/src/tests/test262/built-ins/DataView/prototype/setUint8/length.js index 63f58f4637..d003409e1f 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setUint8/length.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setUint8/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.setUint8.length, 2); - -verifyNotEnumerable(DataView.prototype.setUint8, "length"); -verifyNotWritable(DataView.prototype.setUint8, "length"); -verifyConfigurable(DataView.prototype.setUint8, "length"); +verifyProperty(DataView.prototype.setUint8, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setUint8/name.js b/js/src/tests/test262/built-ins/DataView/prototype/setUint8/name.js index f023fc8bdf..6521b0afd8 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setUint8/name.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setUint8/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(DataView.prototype.setUint8.name, "setUint8"); - -verifyNotEnumerable(DataView.prototype.setUint8, "name"); -verifyNotWritable(DataView.prototype.setUint8, "name"); -verifyConfigurable(DataView.prototype.setUint8, "name"); +verifyProperty(DataView.prototype.setUint8, "name", { + value: "setUint8", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/prototype/setUint8/not-a-constructor.js b/js/src/tests/test262/built-ins/DataView/prototype/setUint8/not-a-constructor.js index 25899332b7..395755f64d 100644 --- a/js/src/tests/test262/built-ins/DataView/prototype/setUint8/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/DataView/prototype/setUint8/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let dv = new DataView(new ArrayBuffer(16)); new dv.setUint8(0, 0); -}, '`let dv = new DataView(new ArrayBuffer(16)); new dv.setUint8(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/DataView/shell.js b/js/src/tests/test262/built-ins/DataView/shell.js index 6bf8be5e31..2b6d995ad7 100644 --- a/js/src/tests/test262/built-ins/DataView/shell.js +++ b/js/src/tests/test262/built-ins/DataView/shell.js @@ -53,7 +53,22 @@ var byteConversionValues = { -4294967296, // - ( 2 ** 32 ) Infinity, -Infinity, - 0 + 0, + 2049, // an integer which rounds down under ties-to-even when cast to float16 + 2051, // an integer which rounds up under ties-to-even when cast to float16 + 0.00006103515625, // smallest normal float16 + 0.00006097555160522461, // largest subnormal float16 + 5.960464477539063e-8, // smallest float16 + 2.9802322387695312e-8, // largest double which rounds to 0 when cast to float16 + 2.980232238769532e-8, // smallest double which does not round to 0 when cast to float16 + 8.940696716308594e-8, // a double which rounds up to a subnormal under ties-to-even when cast to float16 + 1.4901161193847656e-7, // a double which rounds down to a subnormal under ties-to-even when cast to float16 + 1.490116119384766e-7, // the next double above the one on the previous line one + 65504, // max finite float16 + 65520, // smallest double which rounds to infinity when cast to float16 + 65519.99999999999, // largest double which does not round to infinity when cast to float16 + 0.000061005353927612305, // smallest double which rounds to a non-subnormal when cast to float16 + 0.0000610053539276123 // largest double which rounds to a subnormal when cast to float16 ], expected: { @@ -98,7 +113,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 1, // 2049 + 3, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + -32, // 65504 + -16, // 65520 + -17, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint8: [ 127, // 127 @@ -141,7 +171,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 1, // 2049 + 3, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 224, // 65504 + 240, // 65520 + 239, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint8Clamped: [ 127, // 127 @@ -184,7 +229,22 @@ var byteConversionValues = { 0, // -4294967296 255, // Infinity 0, // -Infinity - 0 + 0, // 0 + 255, // 2049 + 255, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 255, // 65504 + 255, // 65520 + 255, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Int16: [ 127, // 127 @@ -227,7 +287,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + -32, // 65504 + -16, // 65520 + -17, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint16: [ 127, // 127 @@ -270,7 +345,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Int32: [ 127, // 127 @@ -313,7 +403,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint32: [ 127, // 127 @@ -356,93 +461,138 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Float16: [ - 127, // 127 - 128, // 128 - 32768, // 32767 - 32768, // 32768 - Infinity, // 2147483647 - Infinity, // 2147483648 - 255, // 255 - 256, // 256 - Infinity, // 65535 - Infinity, // 65536 - Infinity, // 4294967295 - Infinity, // 4294967296 - Infinity, // 9007199254740991 - Infinity, // 9007199254740992 - 1.099609375, // 1.1 - 0.0999755859375, // 0.1 - 0.5, // 0.5 - 0.5, // 0.50000001, - 0.60009765625, // 0.6 - 0.7001953125, // 0.7 - NaN, // undefined - -1, // -1 - -0, // -0 - -0.0999755859375, // -0.1 - -1.099609375, // -1.1 - NaN, // NaN - -127, // -127 - -128, // -128 - -32768, // -32767 - -32768, // -32768 - -Infinity, // -2147483647 - -Infinity, // -2147483648 - -255, // -255 - -256, // -256 - -Infinity, // -65535 - -Infinity, // -65536 - -Infinity, // -4294967295 - -Infinity, // -4294967296 - Infinity, // Infinity - -Infinity, // -Infinity - 0 + 127, // 127 + 128, // 128 + 32768, // 32767 + 32768, // 32768 + Infinity, // 2147483647 + Infinity, // 2147483648 + 255, // 255 + 256, // 256 + Infinity, // 65535 + Infinity, // 65536 + Infinity, // 4294967295 + Infinity, // 4294967296 + Infinity, // 9007199254740991 + Infinity, // 9007199254740992 + 1.099609375, // 1.1 + 0.0999755859375, // 0.1 + 0.5, // 0.5 + 0.5, // 0.50000001, + 0.60009765625, // 0.6 + 0.7001953125, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.0999755859375, // -0.1 + -1.099609375, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32768, // -32767 + -32768, // -32768 + -Infinity, // -2147483647 + -Infinity, // -2147483648 + -255, // -255 + -256, // -256 + -Infinity, // -65535 + -Infinity, // -65536 + -Infinity, // -4294967295 + -Infinity, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0, // 0 + 2048, // 2049 + 2052, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 5.960464477539063e-8, // 2.980232238769532e-8 + 1.1920928955078125e-7, // 8.940696716308594e-8 + 1.1920928955078125e-7, // 1.4901161193847656e-7 + 1.7881393432617188e-7, // 1.490116119384766e-7 + 65504, // 65504 + Infinity, // 65520 + 65504, // 65519.99999999999 + 0.00006103515625, // 0.000061005353927612305 + 0.00006097555160522461 // 0.0000610053539276123 ], Float32: [ - 127, // 127 - 128, // 128 - 32767, // 32767 - 32768, // 32768 - 2147483648, // 2147483647 - 2147483648, // 2147483648 - 255, // 255 - 256, // 256 - 65535, // 65535 - 65536, // 65536 - 4294967296, // 4294967295 - 4294967296, // 4294967296 - 9007199254740992, // 9007199254740991 - 9007199254740992, // 9007199254740992 - 1.100000023841858, // 1.1 - 0.10000000149011612, // 0.1 - 0.5, // 0.5 - 0.5, // 0.50000001, - 0.6000000238418579, // 0.6 - 0.699999988079071, // 0.7 - NaN, // undefined - -1, // -1 - -0, // -0 - -0.10000000149011612, // -0.1 - -1.100000023841858, // -1.1 - NaN, // NaN - -127, // -127 - -128, // -128 - -32767, // -32767 - -32768, // -32768 - -2147483648, // -2147483647 - -2147483648, // -2147483648 - -255, // -255 - -256, // -256 - -65535, // -65535 - -65536, // -65536 - -4294967296, // -4294967295 - -4294967296, // -4294967296 - Infinity, // Infinity - -Infinity, // -Infinity - 0 + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483648, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967296, // 4294967295 + 4294967296, // 4294967296 + 9007199254740992, // 9007199254740991 + 9007199254740992, // 9007199254740992 + 1.100000023841858, // 1.1 + 0.10000000149011612, // 0.1 + 0.5, // 0.5 + 0.5, // 0.50000001, + 0.6000000238418579, // 0.6 + 0.699999988079071, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.10000000149011612, // -0.1 + -1.100000023841858, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483648, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + -4294967296, // -4294967295 + -4294967296, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 2.9802322387695312e-8, // 2.9802322387695312e-8 + 2.9802322387695312e-8, // 2.980232238769532e-8 + 8.940696716308594e-8, // 8.940696716308594e-8 + 1.4901161193847656e-7, // 1.4901161193847656e-7 + 1.4901161193847656e-7, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65520, // 65519.99999999999 + 0.000061005353927612305, // 0.000061005353927612305 + 0.000061005353927612305 // 0.0000610053539276123 ], Float64: [ 127, // 127 @@ -485,7 +635,22 @@ var byteConversionValues = { -4294967296, // -4294967296 Infinity, // Infinity -Infinity, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 2.9802322387695312e-8, // 2.9802322387695312e-8 + 2.980232238769532e-8, // 2.980232238769532e-8 + 8.940696716308594e-8, // 8.940696716308594e-8 + 1.4901161193847656e-7, // 1.4901161193847656e-7 + 1.490116119384766e-7, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519.99999999999, // 65519.99999999999 + 0.000061005353927612305, // 0.000061005353927612305 + 0.0000610053539276123 // 0.0000610053539276123 ] } }; diff --git a/js/src/tests/test262/built-ins/Date/UTC/name.js b/js/src/tests/test262/built-ins/Date/UTC/name.js index 3310708e58..4b94d366f8 100644 --- a/js/src/tests/test262/built-ins/Date/UTC/name.js +++ b/js/src/tests/test262/built-ins/Date/UTC/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.UTC.name, "UTC"); - -verifyNotEnumerable(Date.UTC, "name"); -verifyNotWritable(Date.UTC, "name"); -verifyConfigurable(Date.UTC, "name"); +verifyProperty(Date.UTC, "name", { + value: "UTC", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/UTC/not-a-constructor.js index b655948879..25ef5bf8eb 100644 --- a/js/src/tests/test262/built-ins/Date/UTC/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/UTC/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Date.UTC), false, 'isConstructor(Date.UTC) must r assert.throws(TypeError, () => { new Date.UTC(); -}, '`new Date.UTC()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/name.js b/js/src/tests/test262/built-ins/Date/name.js index 29e869ec72..d58490e5cd 100644 --- a/js/src/tests/test262/built-ins/Date/name.js +++ b/js/src/tests/test262/built-ins/Date/name.js @@ -16,10 +16,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.name, "Date"); - -verifyNotEnumerable(Date, "name"); -verifyNotWritable(Date, "name"); -verifyConfigurable(Date, "name"); +verifyProperty(Date, "name", { + value: "Date", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/now/name.js b/js/src/tests/test262/built-ins/Date/now/name.js index 4189f1f4e7..f150e257f8 100644 --- a/js/src/tests/test262/built-ins/Date/now/name.js +++ b/js/src/tests/test262/built-ins/Date/now/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.now.name, "now"); - -verifyNotEnumerable(Date.now, "name"); -verifyNotWritable(Date.now, "name"); -verifyConfigurable(Date.now, "name"); +verifyProperty(Date.now, "name", { + value: "now", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/now/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/now/not-a-constructor.js index d6a7cf0555..9aac86a56f 100644 --- a/js/src/tests/test262/built-ins/Date/now/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/now/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Date.now), false, 'isConstructor(Date.now) must r assert.throws(TypeError, () => { new Date.now(); -}, '`new Date.now()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/parse/name.js b/js/src/tests/test262/built-ins/Date/parse/name.js index 79595c22f8..0c7fa328a2 100644 --- a/js/src/tests/test262/built-ins/Date/parse/name.js +++ b/js/src/tests/test262/built-ins/Date/parse/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.parse.name, "parse"); - -verifyNotEnumerable(Date.parse, "name"); -verifyNotWritable(Date.parse, "name"); -verifyConfigurable(Date.parse, "name"); +verifyProperty(Date.parse, "name", { + value: "parse", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/parse/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/parse/not-a-constructor.js index 01551a621c..f129a9c814 100644 --- a/js/src/tests/test262/built-ins/Date/parse/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/parse/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Date.parse), false, 'isConstructor(Date.parse) mu assert.throws(TypeError, () => { new Date.parse(); -}, '`new Date.parse()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/length.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/length.js index 1e46f05120..16f78857f2 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/length.js +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/length.js @@ -20,10 +20,11 @@ features: [Symbol.toPrimitive] includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype[Symbol.toPrimitive].length, 1); - -verifyNotEnumerable(Date.prototype[Symbol.toPrimitive], 'length'); -verifyNotWritable(Date.prototype[Symbol.toPrimitive], 'length'); -verifyConfigurable(Date.prototype[Symbol.toPrimitive], 'length'); +verifyProperty(Date.prototype[Symbol.toPrimitive], "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/name.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/name.js index e1e40be0fe..58d9c00d6b 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/name.js @@ -17,12 +17,11 @@ features: [Symbol.toPrimitive] includes: [propertyHelper.js] ---*/ -assert.sameValue( - Date.prototype[Symbol.toPrimitive].name, '[Symbol.toPrimitive]' -); - -verifyNotEnumerable(Date.prototype[Symbol.toPrimitive], 'name'); -verifyNotWritable(Date.prototype[Symbol.toPrimitive], 'name'); -verifyConfigurable(Date.prototype[Symbol.toPrimitive], 'name'); +verifyProperty(Date.prototype[Symbol.toPrimitive], "name", { + value: "[Symbol.toPrimitive]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDate/name.js b/js/src/tests/test262/built-ins/Date/prototype/getDate/name.js index 3c1574d163..31c1a36efe 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getDate/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getDate/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getDate.name, "getDate"); - -verifyNotEnumerable(Date.prototype.getDate, "name"); -verifyNotWritable(Date.prototype.getDate, "name"); -verifyConfigurable(Date.prototype.getDate, "name"); +verifyProperty(Date.prototype.getDate, "name", { + value: "getDate", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDate/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getDate/not-a-constructor.js index 675f61b753..7e3837fede 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getDate/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getDate/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getDate(); -}, '`let date = new Date(Date.now()); new date.getDate()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDay/name.js b/js/src/tests/test262/built-ins/Date/prototype/getDay/name.js index 89c16d7928..3244db692f 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getDay/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getDay/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getDay.name, "getDay"); - -verifyNotEnumerable(Date.prototype.getDay, "name"); -verifyNotWritable(Date.prototype.getDay, "name"); -verifyConfigurable(Date.prototype.getDay, "name"); +verifyProperty(Date.prototype.getDay, "name", { + value: "getDay", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDay/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getDay/not-a-constructor.js index 08a25137e9..e4fc295059 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getDay/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getDay/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getDay(); -}, '`let date = new Date(Date.now()); new date.getDay()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/name.js b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/name.js index d6a5b8e6ce..c02da77602 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getFullYear.name, "getFullYear"); - -verifyNotEnumerable(Date.prototype.getFullYear, "name"); -verifyNotWritable(Date.prototype.getFullYear, "name"); -verifyConfigurable(Date.prototype.getFullYear, "name"); +verifyProperty(Date.prototype.getFullYear, "name", { + value: "getFullYear", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/not-a-constructor.js index 917047cfdb..7a265deb84 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getFullYear(); -}, '`let date = new Date(Date.now()); new date.getFullYear()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getHours/name.js b/js/src/tests/test262/built-ins/Date/prototype/getHours/name.js index b775ade1e9..e93e27affa 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getHours/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getHours/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getHours.name, "getHours"); - -verifyNotEnumerable(Date.prototype.getHours, "name"); -verifyNotWritable(Date.prototype.getHours, "name"); -verifyConfigurable(Date.prototype.getHours, "name"); +verifyProperty(Date.prototype.getHours, "name", { + value: "getHours", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getHours/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getHours/not-a-constructor.js index bdb019bbee..38fa17a44d 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getHours/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getHours/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getHours(); -}, '`let date = new Date(Date.now()); new date.getHours()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/name.js b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/name.js index 0845a2c619..3cea2cb689 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getMilliseconds.name, "getMilliseconds"); - -verifyNotEnumerable(Date.prototype.getMilliseconds, "name"); -verifyNotWritable(Date.prototype.getMilliseconds, "name"); -verifyConfigurable(Date.prototype.getMilliseconds, "name"); +verifyProperty(Date.prototype.getMilliseconds, "name", { + value: "getMilliseconds", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/not-a-constructor.js index 4682cd3c1e..8b0397c310 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getMilliseconds(); -}, '`let date = new Date(Date.now()); new date.getMilliseconds()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/name.js b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/name.js index e1d71363bb..b6b919af98 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getMinutes.name, "getMinutes"); - -verifyNotEnumerable(Date.prototype.getMinutes, "name"); -verifyNotWritable(Date.prototype.getMinutes, "name"); -verifyConfigurable(Date.prototype.getMinutes, "name"); +verifyProperty(Date.prototype.getMinutes, "name", { + value: "getMinutes", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/not-a-constructor.js index 21682d79fc..1459f9b19f 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getMinutes(); -}, '`let date = new Date(Date.now()); new date.getMinutes()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMonth/name.js b/js/src/tests/test262/built-ins/Date/prototype/getMonth/name.js index 7071c3d694..5e349f09e5 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getMonth/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getMonth/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getMonth.name, "getMonth"); - -verifyNotEnumerable(Date.prototype.getMonth, "name"); -verifyNotWritable(Date.prototype.getMonth, "name"); -verifyConfigurable(Date.prototype.getMonth, "name"); +verifyProperty(Date.prototype.getMonth, "name", { + value: "getMonth", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMonth/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getMonth/not-a-constructor.js index 53c9ac0819..1b51675a68 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getMonth/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getMonth/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getMonth(); -}, '`let date = new Date(Date.now()); new date.getMonth()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/name.js b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/name.js index 56d30ef47f..7903622149 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getSeconds.name, "getSeconds"); - -verifyNotEnumerable(Date.prototype.getSeconds, "name"); -verifyNotWritable(Date.prototype.getSeconds, "name"); -verifyConfigurable(Date.prototype.getSeconds, "name"); +verifyProperty(Date.prototype.getSeconds, "name", { + value: "getSeconds", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/not-a-constructor.js index cae3edd42d..c9cd79ad73 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getSeconds(); -}, '`let date = new Date(Date.now()); new date.getSeconds()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTime/name.js b/js/src/tests/test262/built-ins/Date/prototype/getTime/name.js index 3c05eb5508..7c78012059 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getTime/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getTime/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getTime.name, "getTime"); - -verifyNotEnumerable(Date.prototype.getTime, "name"); -verifyNotWritable(Date.prototype.getTime, "name"); -verifyConfigurable(Date.prototype.getTime, "name"); +verifyProperty(Date.prototype.getTime, "name", { + value: "getTime", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTime/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getTime/not-a-constructor.js index 31e56a6eb3..1df1a5d935 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getTime/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getTime/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getTime(); -}, '`let date = new Date(Date.now()); new date.getTime()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/name.js b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/name.js index 0fe3e7046d..ff10e286cb 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getTimezoneOffset.name, "getTimezoneOffset"); - -verifyNotEnumerable(Date.prototype.getTimezoneOffset, "name"); -verifyNotWritable(Date.prototype.getTimezoneOffset, "name"); -verifyConfigurable(Date.prototype.getTimezoneOffset, "name"); +verifyProperty(Date.prototype.getTimezoneOffset, "name", { + value: "getTimezoneOffset", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/not-a-constructor.js index cd1dcd6992..c79024050e 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getTimezoneOffset(); -}, '`let date = new Date(Date.now()); new date.getTimezoneOffset()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/name.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/name.js index 3968908ce4..1f8c30ec17 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getUTCDate.name, "getUTCDate"); - -verifyNotEnumerable(Date.prototype.getUTCDate, "name"); -verifyNotWritable(Date.prototype.getUTCDate, "name"); -verifyConfigurable(Date.prototype.getUTCDate, "name"); +verifyProperty(Date.prototype.getUTCDate, "name", { + value: "getUTCDate", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/not-a-constructor.js index 0590ac9a6e..f49070911d 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getUTCDate(); -}, '`let date = new Date(Date.now()); new date.getUTCDate()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/name.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/name.js index 280b83ed76..fabdfa6c3a 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getUTCDay.name, "getUTCDay"); - -verifyNotEnumerable(Date.prototype.getUTCDay, "name"); -verifyNotWritable(Date.prototype.getUTCDay, "name"); -verifyConfigurable(Date.prototype.getUTCDay, "name"); +verifyProperty(Date.prototype.getUTCDay, "name", { + value: "getUTCDay", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/not-a-constructor.js index 42d0a20852..6ded993a4e 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getUTCDay(); -}, '`let date = new Date(Date.now()); new date.getUTCDay()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/name.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/name.js index a12fcc0b98..a2f5dbd6d1 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getUTCFullYear.name, "getUTCFullYear"); - -verifyNotEnumerable(Date.prototype.getUTCFullYear, "name"); -verifyNotWritable(Date.prototype.getUTCFullYear, "name"); -verifyConfigurable(Date.prototype.getUTCFullYear, "name"); +verifyProperty(Date.prototype.getUTCFullYear, "name", { + value: "getUTCFullYear", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/not-a-constructor.js index 6baf587e38..31deb328a9 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getUTCFullYear(); -}, '`let date = new Date(Date.now()); new date.getUTCFullYear()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/name.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/name.js index d35e74baa5..7ac40b70ff 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getUTCHours.name, "getUTCHours"); - -verifyNotEnumerable(Date.prototype.getUTCHours, "name"); -verifyNotWritable(Date.prototype.getUTCHours, "name"); -verifyConfigurable(Date.prototype.getUTCHours, "name"); +verifyProperty(Date.prototype.getUTCHours, "name", { + value: "getUTCHours", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/not-a-constructor.js index 60ed6e667f..08baa06108 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getUTCHours(); -}, '`let date = new Date(Date.now()); new date.getUTCHours()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/name.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/name.js index 1a723340a3..78a592b823 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getUTCMilliseconds.name, "getUTCMilliseconds"); - -verifyNotEnumerable(Date.prototype.getUTCMilliseconds, "name"); -verifyNotWritable(Date.prototype.getUTCMilliseconds, "name"); -verifyConfigurable(Date.prototype.getUTCMilliseconds, "name"); +verifyProperty(Date.prototype.getUTCMilliseconds, "name", { + value: "getUTCMilliseconds", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/not-a-constructor.js index b9e17b9792..58584449b3 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getUTCMilliseconds(); -}, '`let date = new Date(Date.now()); new date.getUTCMilliseconds()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/name.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/name.js index 5fc1ac7b8d..150f731776 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getUTCMinutes.name, "getUTCMinutes"); - -verifyNotEnumerable(Date.prototype.getUTCMinutes, "name"); -verifyNotWritable(Date.prototype.getUTCMinutes, "name"); -verifyConfigurable(Date.prototype.getUTCMinutes, "name"); +verifyProperty(Date.prototype.getUTCMinutes, "name", { + value: "getUTCMinutes", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/not-a-constructor.js index be50d8d0e6..b8ae1dffa1 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getUTCMinutes(); -}, '`let date = new Date(Date.now()); new date.getUTCMinutes()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/name.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/name.js index 796815dd91..854fc0a14f 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getUTCMonth.name, "getUTCMonth"); - -verifyNotEnumerable(Date.prototype.getUTCMonth, "name"); -verifyNotWritable(Date.prototype.getUTCMonth, "name"); -verifyConfigurable(Date.prototype.getUTCMonth, "name"); +verifyProperty(Date.prototype.getUTCMonth, "name", { + value: "getUTCMonth", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/not-a-constructor.js index 55428f88be..666a073fce 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getUTCMonth(); -}, '`let date = new Date(Date.now()); new date.getUTCMonth()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/name.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/name.js index 11cdea38b7..674434b09a 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.getUTCSeconds.name, "getUTCSeconds"); - -verifyNotEnumerable(Date.prototype.getUTCSeconds, "name"); -verifyNotWritable(Date.prototype.getUTCSeconds, "name"); -verifyConfigurable(Date.prototype.getUTCSeconds, "name"); +verifyProperty(Date.prototype.getUTCSeconds, "name", { + value: "getUTCSeconds", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/not-a-constructor.js index be8ed19fe1..8cc4c66c56 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.getUTCSeconds(); -}, '`let date = new Date(Date.now()); new date.getUTCSeconds()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/name.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/name.js index 15ba085ab7..0b0518bcf5 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setDate/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.setDate.name, "setDate"); - -verifyNotEnumerable(Date.prototype.setDate, "name"); -verifyNotWritable(Date.prototype.setDate, "name"); -verifyConfigurable(Date.prototype.setDate, "name"); +verifyProperty(Date.prototype.setDate, "name", { + value: "setDate", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/not-a-constructor.js index cc4d2bca46..10ce410a35 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setDate/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.setDate(); -}, '`let date = new Date(Date.now()); new date.setDate()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/name.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/name.js index 07255899ed..29e39d5e7c 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.setFullYear.name, "setFullYear"); - -verifyNotEnumerable(Date.prototype.setFullYear, "name"); -verifyNotWritable(Date.prototype.setFullYear, "name"); -verifyConfigurable(Date.prototype.setFullYear, "name"); +verifyProperty(Date.prototype.setFullYear, "name", { + value: "setFullYear", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/not-a-constructor.js index 99b1f387c3..18a21334b4 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.setFullYear(); -}, '`let date = new Date(Date.now()); new date.setFullYear()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/name.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/name.js index 9626594fc3..9f752c681a 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setHours/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.setHours.name, "setHours"); - -verifyNotEnumerable(Date.prototype.setHours, "name"); -verifyNotWritable(Date.prototype.setHours, "name"); -verifyConfigurable(Date.prototype.setHours, "name"); +verifyProperty(Date.prototype.setHours, "name", { + value: "setHours", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/not-a-constructor.js index 767fe264d0..20348701c2 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setHours/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.setHours(); -}, '`let date = new Date(Date.now()); new date.setHours()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/name.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/name.js index 3430c5e216..fb20207a6b 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.setMilliseconds.name, "setMilliseconds"); - -verifyNotEnumerable(Date.prototype.setMilliseconds, "name"); -verifyNotWritable(Date.prototype.setMilliseconds, "name"); -verifyConfigurable(Date.prototype.setMilliseconds, "name"); +verifyProperty(Date.prototype.setMilliseconds, "name", { + value: "setMilliseconds", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/not-a-constructor.js index 3282e1a901..e667918b7c 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.setMilliseconds(); -}, '`let date = new Date(Date.now()); new date.setMilliseconds()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/name.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/name.js index 5b177e2027..3a88966446 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.setMinutes.name, "setMinutes"); - -verifyNotEnumerable(Date.prototype.setMinutes, "name"); -verifyNotWritable(Date.prototype.setMinutes, "name"); -verifyConfigurable(Date.prototype.setMinutes, "name"); +verifyProperty(Date.prototype.setMinutes, "name", { + value: "setMinutes", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/not-a-constructor.js index c65d687fb9..c74f8aa05c 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.setMinutes(); -}, '`let date = new Date(Date.now()); new date.setMinutes()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/name.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/name.js index 9e28f33557..b537c6f3f9 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setMonth/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.setMonth.name, "setMonth"); - -verifyNotEnumerable(Date.prototype.setMonth, "name"); -verifyNotWritable(Date.prototype.setMonth, "name"); -verifyConfigurable(Date.prototype.setMonth, "name"); +verifyProperty(Date.prototype.setMonth, "name", { + value: "setMonth", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/not-a-constructor.js index ce51b8a701..f9d71f03a1 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setMonth/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.setMonth(); -}, '`let date = new Date(Date.now()); new date.setMonth()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/name.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/name.js index 1850428386..08020a855e 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.setSeconds.name, "setSeconds"); - -verifyNotEnumerable(Date.prototype.setSeconds, "name"); -verifyNotWritable(Date.prototype.setSeconds, "name"); -verifyConfigurable(Date.prototype.setSeconds, "name"); +verifyProperty(Date.prototype.setSeconds, "name", { + value: "setSeconds", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/not-a-constructor.js index 47cfa721dd..029042ae4e 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.setSeconds(); -}, '`let date = new Date(Date.now()); new date.setSeconds()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/name.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/name.js index b978b93ad5..dec4cd1c53 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setTime/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.setTime.name, "setTime"); - -verifyNotEnumerable(Date.prototype.setTime, "name"); -verifyNotWritable(Date.prototype.setTime, "name"); -verifyConfigurable(Date.prototype.setTime, "name"); +verifyProperty(Date.prototype.setTime, "name", { + value: "setTime", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/not-a-constructor.js index 5bd2d83907..3679690bf7 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setTime/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.setTime(); -}, '`let date = new Date(Date.now()); new date.setTime()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/name.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/name.js index 4608a57892..18daf453bf 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.setUTCDate.name, "setUTCDate"); - -verifyNotEnumerable(Date.prototype.setUTCDate, "name"); -verifyNotWritable(Date.prototype.setUTCDate, "name"); -verifyConfigurable(Date.prototype.setUTCDate, "name"); +verifyProperty(Date.prototype.setUTCDate, "name", { + value: "setUTCDate", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/not-a-constructor.js index eb0e04f08c..b8046e3eeb 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.setUTCDate(); -}, '`let date = new Date(Date.now()); new date.setUTCDate()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/name.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/name.js index 3f0c1ce4ed..d3b53eb5b0 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.setUTCFullYear.name, "setUTCFullYear"); - -verifyNotEnumerable(Date.prototype.setUTCFullYear, "name"); -verifyNotWritable(Date.prototype.setUTCFullYear, "name"); -verifyConfigurable(Date.prototype.setUTCFullYear, "name"); +verifyProperty(Date.prototype.setUTCFullYear, "name", { + value: "setUTCFullYear", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/not-a-constructor.js index 06d291aa71..715c51f6c3 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.setUTCFullYear(); -}, '`let date = new Date(Date.now()); new date.setUTCFullYear()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/name.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/name.js index 8335871c2c..1bbdd90e18 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.setUTCHours.name, "setUTCHours"); - -verifyNotEnumerable(Date.prototype.setUTCHours, "name"); -verifyNotWritable(Date.prototype.setUTCHours, "name"); -verifyConfigurable(Date.prototype.setUTCHours, "name"); +verifyProperty(Date.prototype.setUTCHours, "name", { + value: "setUTCHours", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/not-a-constructor.js index a572e32b52..379bf379c6 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.setUTCHours(); -}, '`let date = new Date(Date.now()); new date.setUTCHours()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/name.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/name.js index 65d0bd6f99..73ac13ce7d 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.setUTCMilliseconds.name, "setUTCMilliseconds"); - -verifyNotEnumerable(Date.prototype.setUTCMilliseconds, "name"); -verifyNotWritable(Date.prototype.setUTCMilliseconds, "name"); -verifyConfigurable(Date.prototype.setUTCMilliseconds, "name"); +verifyProperty(Date.prototype.setUTCMilliseconds, "name", { + value: "setUTCMilliseconds", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/not-a-constructor.js index a7e4cbcc7b..f2b345157a 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.setUTCMilliseconds(); -}, '`let date = new Date(Date.now()); new date.setUTCMilliseconds()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/name.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/name.js index db16d42c80..b8a686c993 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.setUTCMinutes.name, "setUTCMinutes"); - -verifyNotEnumerable(Date.prototype.setUTCMinutes, "name"); -verifyNotWritable(Date.prototype.setUTCMinutes, "name"); -verifyConfigurable(Date.prototype.setUTCMinutes, "name"); +verifyProperty(Date.prototype.setUTCMinutes, "name", { + value: "setUTCMinutes", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/not-a-constructor.js index 01f6a9293f..fd18c165b4 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.setUTCMinutes(); -}, '`let date = new Date(Date.now()); new date.setUTCMinutes()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/name.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/name.js index 70ca8822ea..31e7374ccb 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.setUTCMonth.name, "setUTCMonth"); - -verifyNotEnumerable(Date.prototype.setUTCMonth, "name"); -verifyNotWritable(Date.prototype.setUTCMonth, "name"); -verifyConfigurable(Date.prototype.setUTCMonth, "name"); +verifyProperty(Date.prototype.setUTCMonth, "name", { + value: "setUTCMonth", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/not-a-constructor.js index 977faba6d2..afc198eecf 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.setUTCMonth(); -}, '`let date = new Date(Date.now()); new date.setUTCMonth()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/name.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/name.js index b73874e84a..6748c4cdd1 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.setUTCSeconds.name, "setUTCSeconds"); - -verifyNotEnumerable(Date.prototype.setUTCSeconds, "name"); -verifyNotWritable(Date.prototype.setUTCSeconds, "name"); -verifyConfigurable(Date.prototype.setUTCSeconds, "name"); +verifyProperty(Date.prototype.setUTCSeconds, "name", { + value: "setUTCSeconds", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/not-a-constructor.js index b6eebae507..df97189a3a 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.setUTCSeconds(); -}, '`let date = new Date(Date.now()); new date.setUTCSeconds()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toDateString/name.js b/js/src/tests/test262/built-ins/Date/prototype/toDateString/name.js index 3cd99649b7..d6c2ac0c85 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/toDateString/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.toDateString.name, "toDateString"); - -verifyNotEnumerable(Date.prototype.toDateString, "name"); -verifyNotWritable(Date.prototype.toDateString, "name"); -verifyConfigurable(Date.prototype.toDateString, "name"); +verifyProperty(Date.prototype.toDateString, "name", { + value: "toDateString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toDateString/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toDateString/not-a-constructor.js index b70807dc68..4e01ccd8d4 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/toDateString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.toDateString(); -}, '`let date = new Date(Date.now()); new date.toDateString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/name.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/name.js index 1abb089310..dfce76f478 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/toISOString/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.toISOString.name, "toISOString"); - -verifyNotEnumerable(Date.prototype.toISOString, "name"); -verifyNotWritable(Date.prototype.toISOString, "name"); -verifyConfigurable(Date.prototype.toISOString, "name"); +verifyProperty(Date.prototype.toISOString, "name", { + value: "toISOString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/not-a-constructor.js index a3dd9891ec..e0e18320f9 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/toISOString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.toISOString(); -}, '`let date = new Date(Date.now()); new date.toISOString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toJSON/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toJSON/not-a-constructor.js index df5faff002..9616f636d7 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/toJSON/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/toJSON/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.toJSON(); -}, '`let date = new Date(Date.now()); new date.toJSON()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/name.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/name.js index 0f3981a565..b346684487 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.toLocaleDateString.name, "toLocaleDateString"); - -verifyNotEnumerable(Date.prototype.toLocaleDateString, "name"); -verifyNotWritable(Date.prototype.toLocaleDateString, "name"); -verifyConfigurable(Date.prototype.toLocaleDateString, "name"); +verifyProperty(Date.prototype.toLocaleDateString, "name", { + value: "toLocaleDateString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/not-a-constructor.js index 45b56d70ed..70f5a23b2f 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.toLocaleDateString(); -}, '`let date = new Date(Date.now()); new date.toLocaleDateString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/name.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/name.js index 1c2d1ad584..0a23badf79 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.toLocaleString.name, "toLocaleString"); - -verifyNotEnumerable(Date.prototype.toLocaleString, "name"); -verifyNotWritable(Date.prototype.toLocaleString, "name"); -verifyConfigurable(Date.prototype.toLocaleString, "name"); +verifyProperty(Date.prototype.toLocaleString, "name", { + value: "toLocaleString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/not-a-constructor.js index 4af86cd1e6..ea251261e9 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.toLocaleString(); -}, '`let date = new Date(Date.now()); new date.toLocaleString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/name.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/name.js index 260baf8b5d..ad4e9237c4 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.toLocaleTimeString.name, "toLocaleTimeString"); - -verifyNotEnumerable(Date.prototype.toLocaleTimeString, "name"); -verifyNotWritable(Date.prototype.toLocaleTimeString, "name"); -verifyConfigurable(Date.prototype.toLocaleTimeString, "name"); +verifyProperty(Date.prototype.toLocaleTimeString, "name", { + value: "toLocaleTimeString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/not-a-constructor.js index 6f648bb789..3ed058cd57 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.toLocaleTimeString(); -}, '`let date = new Date(Date.now()); new date.toLocaleTimeString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toString/name.js b/js/src/tests/test262/built-ins/Date/prototype/toString/name.js index 9bfd383b55..d317a654de 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/toString/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.toString.name, "toString"); - -verifyNotEnumerable(Date.prototype.toString, "name"); -verifyNotWritable(Date.prototype.toString, "name"); -verifyConfigurable(Date.prototype.toString, "name"); +verifyProperty(Date.prototype.toString, "name", { + value: "toString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toString/not-a-constructor.js index 29da7f63b2..a08235eebc 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/toString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.toString(); -}, '`let date = new Date(Date.now()); new date.toString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toTimeString/name.js b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/name.js index 4616efbad2..fe1a3a9efc 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/toTimeString/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.toTimeString.name, "toTimeString"); - -verifyNotEnumerable(Date.prototype.toTimeString, "name"); -verifyNotWritable(Date.prototype.toTimeString, "name"); -verifyConfigurable(Date.prototype.toTimeString, "name"); +verifyProperty(Date.prototype.toTimeString, "name", { + value: "toTimeString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toTimeString/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/not-a-constructor.js index 7191049f7c..d4a5c01932 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/toTimeString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.toTimeString(); -}, '`let date = new Date(Date.now()); new date.toTimeString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/name.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/name.js index 96fb0dce00..33e1c0fffe 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.toUTCString.name, "toUTCString"); - -verifyNotEnumerable(Date.prototype.toUTCString, "name"); -verifyNotWritable(Date.prototype.toUTCString, "name"); -verifyConfigurable(Date.prototype.toUTCString, "name"); +verifyProperty(Date.prototype.toUTCString, "name", { + value: "toUTCString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/not-a-constructor.js index 7c944cd036..6d6088c60c 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.toUTCString(); -}, '`let date = new Date(Date.now()); new date.toUTCString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/name.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/name.js index e1e16eb74b..04efdd6d3f 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/valueOf/name.js +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Date.prototype.valueOf.name, "valueOf"); - -verifyNotEnumerable(Date.prototype.valueOf, "name"); -verifyNotWritable(Date.prototype.valueOf, "name"); -verifyConfigurable(Date.prototype.valueOf, "name"); +verifyProperty(Date.prototype.valueOf, "name", { + value: "valueOf", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/not-a-constructor.js index 5e333ff19e..ee2d0146ce 100644 --- a/js/src/tests/test262/built-ins/Date/prototype/valueOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let date = new Date(Date.now()); new date.valueOf(); -}, '`let date = new Date(Date.now()); new date.valueOf()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/length.js b/js/src/tests/test262/built-ins/Error/prototype/toString/length.js index 0f6d033b73..faad9af1be 100644 --- a/js/src/tests/test262/built-ins/Error/prototype/toString/length.js +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Error.prototype.toString.length, 0); - -verifyNotEnumerable(Error.prototype.toString, "length"); -verifyNotWritable(Error.prototype.toString, "length"); -verifyConfigurable(Error.prototype.toString, "length"); +verifyProperty(Error.prototype.toString, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/name.js b/js/src/tests/test262/built-ins/Error/prototype/toString/name.js index 8896e27dcf..23bdcd8c84 100644 --- a/js/src/tests/test262/built-ins/Error/prototype/toString/name.js +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Error.prototype.toString.name, "toString"); - -verifyNotEnumerable(Error.prototype.toString, "name"); -verifyNotWritable(Error.prototype.toString, "name"); -verifyConfigurable(Error.prototype.toString, "name"); +verifyProperty(Error.prototype.toString, "name", { + value: "toString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Error/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/Error/prototype/toString/not-a-constructor.js index 884c05e62e..c4eb05f6c7 100644 --- a/js/src/tests/test262/built-ins/Error/prototype/toString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Error/prototype/toString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Error.prototype.toString(); -}, '`new Error.prototype.toString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/cleanupSome/not-a-constructor.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/cleanupSome/not-a-constructor.js index 12c979cc12..edceeb8d6b 100644 --- a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/cleanupSome/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/cleanupSome/not-a-constructor.js @@ -30,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let fr = new FinalizationRegistry(() => {}); new fr.cleanupSome(() => {}); -}, '`let fr = new FinalizationRegistry(() => {}); new fr.cleanupSome(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/not-a-constructor.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/not-a-constructor.js index f2471782ab..60e16a1df6 100644 --- a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/register/not-a-constructor.js @@ -30,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let fr = new FinalizationRegistry(() => {}); new fr.register({}); -}, '`let fr = new FinalizationRegistry(() => {}); new fr.register({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/unregister/not-a-constructor.js b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/unregister/not-a-constructor.js index ea51595556..14ab4862c8 100644 --- a/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/unregister/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/FinalizationRegistry/prototype/unregister/not-a-constructor.js @@ -30,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let fr = new FinalizationRegistry(() => {}); let token = {}; fr.register(token); new fr.unregister(token); -}, '`let fr = new FinalizationRegistry(() => {}); let token = {}; fr.register(token); new fr.unregister(token)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/length.js b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/length.js index 7a482b0d73..dff2e7bb58 100644 --- a/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/length.js +++ b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/length.js @@ -19,10 +19,11 @@ features: [Symbol.hasInstance] includes: [propertyHelper.js] ---*/ -assert.sameValue(Function.prototype[Symbol.hasInstance].length, 1); - -verifyNotEnumerable(Function.prototype[Symbol.hasInstance], 'length'); -verifyNotWritable(Function.prototype[Symbol.hasInstance], 'length'); -verifyConfigurable(Function.prototype[Symbol.hasInstance], 'length'); +verifyProperty(Function.prototype[Symbol.hasInstance], "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/name.js b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/name.js index 13f5f41f9f..72ba2d6b34 100644 --- a/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/name.js +++ b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/name.js @@ -10,12 +10,11 @@ features: [Symbol.hasInstance] includes: [propertyHelper.js] ---*/ -assert.sameValue( - Function.prototype[Symbol.hasInstance].name, '[Symbol.hasInstance]' -); - -verifyNotEnumerable(Function.prototype[Symbol.hasInstance], 'name'); -verifyNotWritable(Function.prototype[Symbol.hasInstance], 'name'); -verifyConfigurable(Function.prototype[Symbol.hasInstance], 'name'); +verifyProperty(Function.prototype[Symbol.hasInstance], "name", { + value: "[Symbol.hasInstance]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/apply/name.js b/js/src/tests/test262/built-ins/Function/prototype/apply/name.js index 528cf8f58a..f12cde6de0 100644 --- a/js/src/tests/test262/built-ins/Function/prototype/apply/name.js +++ b/js/src/tests/test262/built-ins/Function/prototype/apply/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Function.prototype.apply.name, "apply"); - -verifyNotEnumerable(Function.prototype.apply, "name"); -verifyNotWritable(Function.prototype.apply, "name"); -verifyConfigurable(Function.prototype.apply, "name"); +verifyProperty(Function.prototype.apply, "name", { + value: "apply", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/apply/not-a-constructor.js b/js/src/tests/test262/built-ins/Function/prototype/apply/not-a-constructor.js index 43275e54f0..8adbf6bce4 100644 --- a/js/src/tests/test262/built-ins/Function/prototype/apply/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Function/prototype/apply/not-a-constructor.js @@ -29,10 +29,10 @@ assert.sameValue( assert.throws(TypeError, () => { new Function.prototype.apply; -}, '`new Function.prototype.apply` throws TypeError'); +}); assert.throws(TypeError, () => { new Function.prototype.apply(); -}, '`new Function.prototype.apply()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/bind/name.js b/js/src/tests/test262/built-ins/Function/prototype/bind/name.js index d9f70e68a4..634d4d95a7 100644 --- a/js/src/tests/test262/built-ins/Function/prototype/bind/name.js +++ b/js/src/tests/test262/built-ins/Function/prototype/bind/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Function.prototype.bind.name, "bind"); - -verifyNotEnumerable(Function.prototype.bind, "name"); -verifyNotWritable(Function.prototype.bind, "name"); -verifyConfigurable(Function.prototype.bind, "name"); +verifyProperty(Function.prototype.bind, "name", { + value: "bind", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/bind/not-a-constructor.js b/js/src/tests/test262/built-ins/Function/prototype/bind/not-a-constructor.js index 22f63d1ade..556e2e474a 100644 --- a/js/src/tests/test262/built-ins/Function/prototype/bind/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Function/prototype/bind/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Function.prototype.bind(); -}, '`new Function.prototype.bind()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/name.js b/js/src/tests/test262/built-ins/Function/prototype/call/name.js index d919573ff9..7f121d7235 100644 --- a/js/src/tests/test262/built-ins/Function/prototype/call/name.js +++ b/js/src/tests/test262/built-ins/Function/prototype/call/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Function.prototype.call.name, "call"); - -verifyNotEnumerable(Function.prototype.call, "name"); -verifyNotWritable(Function.prototype.call, "name"); -verifyConfigurable(Function.prototype.call, "name"); +verifyProperty(Function.prototype.call, "name", { + value: "call", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/call/not-a-constructor.js b/js/src/tests/test262/built-ins/Function/prototype/call/not-a-constructor.js index 1ae179235e..7e90f7fee7 100644 --- a/js/src/tests/test262/built-ins/Function/prototype/call/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Function/prototype/call/not-a-constructor.js @@ -29,11 +29,11 @@ assert.sameValue( assert.throws(TypeError, () => { new Function.prototype.call(); -}, '`new Function.prototype.call()` throws TypeError'); +}); assert.throws(TypeError, () => { new Function.prototype.call; -}, '`new Function.prototype.call` throws TypeError'); +}); var call = Function.prototype.call; assert.throws(TypeError, () => { diff --git a/js/src/tests/test262/built-ins/Function/prototype/name.js b/js/src/tests/test262/built-ins/Function/prototype/name.js index 653145db42..0a0d150fe7 100644 --- a/js/src/tests/test262/built-ins/Function/prototype/name.js +++ b/js/src/tests/test262/built-ins/Function/prototype/name.js @@ -16,9 +16,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Function.prototype.name, ''); -verifyNotEnumerable(Function.prototype, 'name'); -verifyNotWritable(Function.prototype, 'name'); -verifyConfigurable(Function.prototype, 'name'); +verifyProperty(Function.prototype, "name", { + value: "", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/toString/name.js b/js/src/tests/test262/built-ins/Function/prototype/toString/name.js index dc6751fd68..c16ded664e 100644 --- a/js/src/tests/test262/built-ins/Function/prototype/toString/name.js +++ b/js/src/tests/test262/built-ins/Function/prototype/toString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Function.prototype.toString.name, "toString"); - -verifyNotEnumerable(Function.prototype.toString, "name"); -verifyNotWritable(Function.prototype.toString, "name"); -verifyConfigurable(Function.prototype.toString, "name"); +verifyProperty(Function.prototype.toString, "name", { + value: "toString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/Function/prototype/toString/not-a-constructor.js index b13c0c51a2..6384ad81df 100644 --- a/js/src/tests/test262/built-ins/Function/prototype/toString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Function/prototype/toString/not-a-constructor.js @@ -29,11 +29,11 @@ assert.sameValue( assert.throws(TypeError, () => { new Function.prototype.toString(); -}, '`new Function.prototype.toString()` throws TypeError'); +}); var toString = Function.prototype.toString; assert.throws(TypeError, () => { new toString; -}, '`new toString` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/GeneratorFunction/length.js b/js/src/tests/test262/built-ins/GeneratorFunction/length.js index 578af8be55..6da929bd7e 100644 --- a/js/src/tests/test262/built-ins/GeneratorFunction/length.js +++ b/js/src/tests/test262/built-ins/GeneratorFunction/length.js @@ -11,10 +11,11 @@ features: [generators] var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor; -assert.sameValue(GeneratorFunction.length, 1); - -verifyNotEnumerable(GeneratorFunction, 'length'); -verifyNotWritable(GeneratorFunction, 'length'); -verifyConfigurable(GeneratorFunction, 'length'); +verifyProperty(GeneratorFunction, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/GeneratorFunction/name.js b/js/src/tests/test262/built-ins/GeneratorFunction/name.js index 3025416d2c..de3491513c 100644 --- a/js/src/tests/test262/built-ins/GeneratorFunction/name.js +++ b/js/src/tests/test262/built-ins/GeneratorFunction/name.js @@ -21,10 +21,11 @@ features: [generators] var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor; -assert.sameValue(GeneratorFunction.name, 'GeneratorFunction'); - -verifyNotEnumerable(GeneratorFunction, 'name'); -verifyNotWritable(GeneratorFunction, 'name'); -verifyConfigurable(GeneratorFunction, 'name'); +verifyProperty(GeneratorFunction, "name", { + value: "GeneratorFunction", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/GeneratorPrototype/next/length.js b/js/src/tests/test262/built-ins/GeneratorPrototype/next/length.js index d4bbe4aaad..630d5cde07 100644 --- a/js/src/tests/test262/built-ins/GeneratorPrototype/next/length.js +++ b/js/src/tests/test262/built-ins/GeneratorPrototype/next/length.js @@ -26,10 +26,11 @@ features: [generators] function* g() {} var GeneratorPrototype = Object.getPrototypeOf(g).prototype; -assert.sameValue(GeneratorPrototype.next.length, 1); - -verifyNotEnumerable(GeneratorPrototype.next, "length"); -verifyNotWritable(GeneratorPrototype.next, "length"); -verifyConfigurable(GeneratorPrototype.next, "length"); +verifyProperty(GeneratorPrototype.next, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/GeneratorPrototype/next/name.js b/js/src/tests/test262/built-ins/GeneratorPrototype/next/name.js index e52239af1a..f29ac96536 100644 --- a/js/src/tests/test262/built-ins/GeneratorPrototype/next/name.js +++ b/js/src/tests/test262/built-ins/GeneratorPrototype/next/name.js @@ -23,10 +23,11 @@ features: [generators] function* g() {} var GeneratorPrototype = Object.getPrototypeOf(g).prototype; -assert.sameValue(GeneratorPrototype.next.name, "next"); - -verifyNotEnumerable(GeneratorPrototype.next, "name"); -verifyNotWritable(GeneratorPrototype.next, "name"); -verifyConfigurable(GeneratorPrototype.next, "name"); +verifyProperty(GeneratorPrototype.next, "name", { + value: "next", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/GeneratorPrototype/next/not-a-constructor.js b/js/src/tests/test262/built-ins/GeneratorPrototype/next/not-a-constructor.js index 49865588f8..3a8fd1b22f 100644 --- a/js/src/tests/test262/built-ins/GeneratorPrototype/next/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/GeneratorPrototype/next/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { function* g() {} let iterator = g(); new iterator.next(); -}, '`function* g() {} let iterator = g(); new iterator.next()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/GeneratorPrototype/return/length.js b/js/src/tests/test262/built-ins/GeneratorPrototype/return/length.js index a3f8f38369..6fa35a482a 100644 --- a/js/src/tests/test262/built-ins/GeneratorPrototype/return/length.js +++ b/js/src/tests/test262/built-ins/GeneratorPrototype/return/length.js @@ -26,10 +26,11 @@ features: [generators] function* g() {} var GeneratorPrototype = Object.getPrototypeOf(g).prototype; -assert.sameValue(GeneratorPrototype.return.length, 1); - -verifyNotEnumerable(GeneratorPrototype.return, "length"); -verifyNotWritable(GeneratorPrototype.return, "length"); -verifyConfigurable(GeneratorPrototype.return, "length"); +verifyProperty(GeneratorPrototype.return, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/GeneratorPrototype/return/name.js b/js/src/tests/test262/built-ins/GeneratorPrototype/return/name.js index e1b4512522..dfb90b17ba 100644 --- a/js/src/tests/test262/built-ins/GeneratorPrototype/return/name.js +++ b/js/src/tests/test262/built-ins/GeneratorPrototype/return/name.js @@ -23,10 +23,11 @@ features: [generators] function* g() {} var GeneratorPrototype = Object.getPrototypeOf(g).prototype; -assert.sameValue(GeneratorPrototype.return.name, "return"); - -verifyNotEnumerable(GeneratorPrototype.return, "name"); -verifyNotWritable(GeneratorPrototype.return, "name"); -verifyConfigurable(GeneratorPrototype.return, "name"); +verifyProperty(GeneratorPrototype.return, "name", { + value: "return", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/GeneratorPrototype/return/not-a-constructor.js b/js/src/tests/test262/built-ins/GeneratorPrototype/return/not-a-constructor.js index 4c0f2b56b8..424ee0bc22 100644 --- a/js/src/tests/test262/built-ins/GeneratorPrototype/return/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/GeneratorPrototype/return/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { function* g() {} let iterator = g(); new iterator.return(); -}, '`function* g() {} let iterator = g(); new iterator.return()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/GeneratorPrototype/throw/length.js b/js/src/tests/test262/built-ins/GeneratorPrototype/throw/length.js index 75c2f6b2a3..6a933bb835 100644 --- a/js/src/tests/test262/built-ins/GeneratorPrototype/throw/length.js +++ b/js/src/tests/test262/built-ins/GeneratorPrototype/throw/length.js @@ -26,10 +26,11 @@ features: [generators] function* g() {} var GeneratorPrototype = Object.getPrototypeOf(g).prototype; -assert.sameValue(GeneratorPrototype.throw.length, 1); - -verifyNotEnumerable(GeneratorPrototype.throw, "length"); -verifyNotWritable(GeneratorPrototype.throw, "length"); -verifyConfigurable(GeneratorPrototype.throw, "length"); +verifyProperty(GeneratorPrototype.throw, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/GeneratorPrototype/throw/name.js b/js/src/tests/test262/built-ins/GeneratorPrototype/throw/name.js index d167bbc1cc..93bc41696d 100644 --- a/js/src/tests/test262/built-ins/GeneratorPrototype/throw/name.js +++ b/js/src/tests/test262/built-ins/GeneratorPrototype/throw/name.js @@ -23,10 +23,11 @@ features: [generators] function* g() {} var GeneratorPrototype = Object.getPrototypeOf(g).prototype; -assert.sameValue(GeneratorPrototype.throw.name, "throw"); - -verifyNotEnumerable(GeneratorPrototype.throw, "name"); -verifyNotWritable(GeneratorPrototype.throw, "name"); -verifyConfigurable(GeneratorPrototype.throw, "name"); +verifyProperty(GeneratorPrototype.throw, "name", { + value: "throw", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/GeneratorPrototype/throw/not-a-constructor.js b/js/src/tests/test262/built-ins/GeneratorPrototype/throw/not-a-constructor.js index d8d39a4db5..e7702e6f5d 100644 --- a/js/src/tests/test262/built-ins/GeneratorPrototype/throw/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/GeneratorPrototype/throw/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { function* g() {} let expected = new Test262Error(); let iterator = g();try {new iterator.throw(expected);} catch (e) {if (e !== expected) {throw e;}} -}, '`function* g() {} let expected = new Test262Error(); let iterator = g();try {new iterator.throw(expected);} catch (e) {if (e !== expected) {throw e;}}` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/JSON/parse/not-a-constructor.js b/js/src/tests/test262/built-ins/JSON/parse/not-a-constructor.js index d46040d8a3..c91310802a 100644 --- a/js/src/tests/test262/built-ins/JSON/parse/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/JSON/parse/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(JSON.parse), false, 'isConstructor(JSON.parse) mu assert.throws(TypeError, () => { new JSON.parse('{}'); -}, '`new JSON.parse(\'{}\')` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/JSON/stringify/not-a-constructor.js b/js/src/tests/test262/built-ins/JSON/stringify/not-a-constructor.js index 2458cdaf4a..41d024649f 100644 --- a/js/src/tests/test262/built-ins/JSON/stringify/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/JSON/stringify/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(JSON.stringify), false, 'isConstructor(JSON.strin assert.throws(TypeError, () => { new JSON.stringify({}); -}, '`new JSON.stringify({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/Symbol.species/length.js b/js/src/tests/test262/built-ins/Map/Symbol.species/length.js index d606baeca6..e731ed261b 100644 --- a/js/src/tests/test262/built-ins/Map/Symbol.species/length.js +++ b/js/src/tests/test262/built-ins/Map/Symbol.species/length.js @@ -25,10 +25,11 @@ features: [Symbol.species] var desc = Object.getOwnPropertyDescriptor(Map, Symbol.species); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/groupBy/string.js b/js/src/tests/test262/built-ins/Map/groupBy/string.js new file mode 100644 index 0000000000..15a2410c5c --- /dev/null +++ b/js/src/tests/test262/built-ins/Map/groupBy/string.js @@ -0,0 +1,24 @@ +// Copyright (c) 2023 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-map.groupby +description: Map.groupBy works for string items +info: | + Map.groupBy ( items, callbackfn ) + ... +includes: [compareArray.js] +features: [array-grouping, Map] +---*/ + +const string = '🥰💩🙏😈'; + +const map = Map.groupBy(string, function (char) { + return char < '🙏' ? 'before' : 'after'; +}); + +assert.compareArray(Array.from(map.keys()), ['after', 'before']); +assert.compareArray(map.get('before'), ['💩', '😈']); +assert.compareArray(map.get('after'), ['🥰', '🙏']); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/length.js b/js/src/tests/test262/built-ins/Map/length.js index c63939508b..5beb5cfe52 100644 --- a/js/src/tests/test262/built-ins/Map/length.js +++ b/js/src/tests/test262/built-ins/Map/length.js @@ -10,10 +10,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Map.length, 0, 'The value of Map.length is 0'); - -verifyNotEnumerable(Map, 'length'); -verifyNotWritable(Map, 'length'); -verifyConfigurable(Map, 'length'); +verifyProperty(Map, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/name.js b/js/src/tests/test262/built-ins/Map/name.js index 4ff6542786..7960aeb7bf 100644 --- a/js/src/tests/test262/built-ins/Map/name.js +++ b/js/src/tests/test262/built-ins/Map/name.js @@ -11,10 +11,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Map.name, 'Map', 'The value of Map.name is "Map"'); - -verifyNotEnumerable(Map, 'name'); -verifyNotWritable(Map, 'name'); -verifyConfigurable(Map, 'name'); +verifyProperty(Map, "name", { + value: "Map", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/Symbol.iterator/not-a-constructor.js b/js/src/tests/test262/built-ins/Map/prototype/Symbol.iterator/not-a-constructor.js index 9a8bb37858..1dc8d266ce 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/Symbol.iterator/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Map/prototype/Symbol.iterator/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let m = new Map(); new m[Symbol.iterator](); -}, '`let m = new Map(); new m[Symbol.iterator]()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/clear/length.js b/js/src/tests/test262/built-ins/Map/prototype/clear/length.js index 7cc8f3126f..a6511ad387 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/clear/length.js +++ b/js/src/tests/test262/built-ins/Map/prototype/clear/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.clear.length, 0, - 'The value of `Map.prototype.clear.length` is `0`' -); - -verifyNotEnumerable(Map.prototype.clear, 'length'); -verifyNotWritable(Map.prototype.clear, 'length'); -verifyConfigurable(Map.prototype.clear, 'length'); +verifyProperty(Map.prototype.clear, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/clear/name.js b/js/src/tests/test262/built-ins/Map/prototype/clear/name.js index 0bef8b8fe7..eb35f09627 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/clear/name.js +++ b/js/src/tests/test262/built-ins/Map/prototype/clear/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.clear.name, 'clear', - 'The value of `Map.prototype.clear.name` is `"clear"`' -); - -verifyNotEnumerable(Map.prototype.clear, 'name'); -verifyNotWritable(Map.prototype.clear, 'name'); -verifyConfigurable(Map.prototype.clear, 'name'); +verifyProperty(Map.prototype.clear, "name", { + value: "clear", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/clear/not-a-constructor.js b/js/src/tests/test262/built-ins/Map/prototype/clear/not-a-constructor.js index 9567b58b7b..651643d1f4 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/clear/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Map/prototype/clear/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Map.prototype.clear), false, 'isConstructor(Map.p assert.throws(TypeError, () => { let m = new Map(); new m.clear(); -}, '`let m = new Map(); new m.clear()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/delete/length.js b/js/src/tests/test262/built-ins/Map/prototype/delete/length.js index 2be05ee2b1..27c629003a 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/delete/length.js +++ b/js/src/tests/test262/built-ins/Map/prototype/delete/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.delete.length, 1, - 'The value of `Map.prototype.delete.length` is `1`' -); - -verifyNotEnumerable(Map.prototype.delete, 'length'); -verifyNotWritable(Map.prototype.delete, 'length'); -verifyConfigurable(Map.prototype.delete, 'length'); +verifyProperty(Map.prototype.delete, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/delete/name.js b/js/src/tests/test262/built-ins/Map/prototype/delete/name.js index dcacf4f3ee..95ca61a4ef 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/delete/name.js +++ b/js/src/tests/test262/built-ins/Map/prototype/delete/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.delete.name, 'delete', - 'The value of `Map.prototype.delete.name` is `"delete"`' -); - -verifyNotEnumerable(Map.prototype.delete, 'name'); -verifyNotWritable(Map.prototype.delete, 'name'); -verifyConfigurable(Map.prototype.delete, 'name'); +verifyProperty(Map.prototype.delete, "name", { + value: "delete", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/delete/not-a-constructor.js b/js/src/tests/test262/built-ins/Map/prototype/delete/not-a-constructor.js index fb43d0a430..3cc5490f94 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/delete/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Map/prototype/delete/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Map.prototype.delete), false, 'isConstructor(Map. assert.throws(TypeError, () => { let m = new Map(); new m.delete(); -}, '`let m = new Map(); new m.delete()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/entries/length.js b/js/src/tests/test262/built-ins/Map/prototype/entries/length.js index 593e918133..e71b580b0a 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/entries/length.js +++ b/js/src/tests/test262/built-ins/Map/prototype/entries/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.entries.length, 0, - 'The value of `Map.prototype.entries.length` is `0`' -); - -verifyNotEnumerable(Map.prototype.entries, 'length'); -verifyNotWritable(Map.prototype.entries, 'length'); -verifyConfigurable(Map.prototype.entries, 'length'); +verifyProperty(Map.prototype.entries, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/entries/name.js b/js/src/tests/test262/built-ins/Map/prototype/entries/name.js index 533b2fa97e..c9f8960a93 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/entries/name.js +++ b/js/src/tests/test262/built-ins/Map/prototype/entries/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.entries.name, 'entries', - 'The value of `Map.prototype.entries.name` is `"entries"`' -); - -verifyNotEnumerable(Map.prototype.entries, 'name'); -verifyNotWritable(Map.prototype.entries, 'name'); -verifyConfigurable(Map.prototype.entries, 'name'); +verifyProperty(Map.prototype.entries, "name", { + value: "entries", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/entries/not-a-constructor.js b/js/src/tests/test262/built-ins/Map/prototype/entries/not-a-constructor.js index 087ce39b98..e296e9d23a 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/entries/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Map/prototype/entries/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let m = new Map(); new m.entries(); -}, '`let m = new Map(); new m.entries()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/forEach/length.js b/js/src/tests/test262/built-ins/Map/prototype/forEach/length.js index d0e0c95dc8..18d0cef5fe 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/forEach/length.js +++ b/js/src/tests/test262/built-ins/Map/prototype/forEach/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.forEach.length, 1, - 'The value of `Map.prototype.forEach.length` is `1`' -); - -verifyNotEnumerable(Map.prototype.forEach, 'length'); -verifyNotWritable(Map.prototype.forEach, 'length'); -verifyConfigurable(Map.prototype.forEach, 'length'); +verifyProperty(Map.prototype.forEach, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/forEach/name.js b/js/src/tests/test262/built-ins/Map/prototype/forEach/name.js index ea6f8c57fd..26a5e70fb6 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/forEach/name.js +++ b/js/src/tests/test262/built-ins/Map/prototype/forEach/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.forEach.name, 'forEach', - 'The value of `Map.prototype.forEach.name` is `"forEach"`' -); - -verifyNotEnumerable(Map.prototype.forEach, 'name'); -verifyNotWritable(Map.prototype.forEach, 'name'); -verifyConfigurable(Map.prototype.forEach, 'name'); +verifyProperty(Map.prototype.forEach, "name", { + value: "forEach", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/forEach/not-a-constructor.js b/js/src/tests/test262/built-ins/Map/prototype/forEach/not-a-constructor.js index 0a113f9d68..22b601eb64 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/forEach/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Map/prototype/forEach/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let m = new Map(); new m.forEach(); -}, '`let m = new Map(); new m.forEach()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/get/length.js b/js/src/tests/test262/built-ins/Map/prototype/get/length.js index 4d6e66ffcb..e08afe8d05 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/get/length.js +++ b/js/src/tests/test262/built-ins/Map/prototype/get/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.get.length, 1, - 'The value of `Map.prototype.get.length` is `1`' -); - -verifyNotEnumerable(Map.prototype.get, 'length'); -verifyNotWritable(Map.prototype.get, 'length'); -verifyConfigurable(Map.prototype.get, 'length'); +verifyProperty(Map.prototype.get, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/get/name.js b/js/src/tests/test262/built-ins/Map/prototype/get/name.js index ef63a260ee..9e1fd2773e 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/get/name.js +++ b/js/src/tests/test262/built-ins/Map/prototype/get/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.get.name, 'get', - 'The value of `Map.prototype.get.name` is `"get"`' -); - -verifyNotEnumerable(Map.prototype.get, 'name'); -verifyNotWritable(Map.prototype.get, 'name'); -verifyConfigurable(Map.prototype.get, 'name'); +verifyProperty(Map.prototype.get, "name", { + value: "get", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/get/not-a-constructor.js b/js/src/tests/test262/built-ins/Map/prototype/get/not-a-constructor.js index 9bc9b965e2..89a5b51a99 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/get/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Map/prototype/get/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Map.prototype.get), false, 'isConstructor(Map.pro assert.throws(TypeError, () => { let m = new Map(); new m.get(); -}, '`let m = new Map(); new m.get()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/has/length.js b/js/src/tests/test262/built-ins/Map/prototype/has/length.js index d5e9b5b48e..3326625b1f 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/has/length.js +++ b/js/src/tests/test262/built-ins/Map/prototype/has/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.has.length, 1, - 'The value of `Map.prototype.has.length` is `1`' -); - -verifyNotEnumerable(Map.prototype.has, 'length'); -verifyNotWritable(Map.prototype.has, 'length'); -verifyConfigurable(Map.prototype.has, 'length'); +verifyProperty(Map.prototype.has, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/has/name.js b/js/src/tests/test262/built-ins/Map/prototype/has/name.js index 82e1dc3f01..5b406a0d68 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/has/name.js +++ b/js/src/tests/test262/built-ins/Map/prototype/has/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.has.name, 'has', - 'The value of `Map.prototype.has.name` is `"has"`' -); - -verifyNotEnumerable(Map.prototype.has, 'name'); -verifyNotWritable(Map.prototype.has, 'name'); -verifyConfigurable(Map.prototype.has, 'name'); +verifyProperty(Map.prototype.has, "name", { + value: "has", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/has/not-a-constructor.js b/js/src/tests/test262/built-ins/Map/prototype/has/not-a-constructor.js index 6f1d7d9253..1c5b82eb6a 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/has/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Map/prototype/has/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Map.prototype.has), false, 'isConstructor(Map.pro assert.throws(TypeError, () => { let m = new Map(); new m.has(); -}, '`let m = new Map(); new m.has()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/keys/length.js b/js/src/tests/test262/built-ins/Map/prototype/keys/length.js index 6a5c19fd96..48ff475b45 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/keys/length.js +++ b/js/src/tests/test262/built-ins/Map/prototype/keys/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.keys.length, 0, - 'The value of `Map.prototype.keys.length` is `0`' -); - -verifyNotEnumerable(Map.prototype.keys, 'length'); -verifyNotWritable(Map.prototype.keys, 'length'); -verifyConfigurable(Map.prototype.keys, 'length'); +verifyProperty(Map.prototype.keys, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/keys/name.js b/js/src/tests/test262/built-ins/Map/prototype/keys/name.js index ce3aa46661..98926ff056 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/keys/name.js +++ b/js/src/tests/test262/built-ins/Map/prototype/keys/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.keys.name, 'keys', - 'The value of `Map.prototype.keys.name` is `"keys"`' -); - -verifyNotEnumerable(Map.prototype.keys, 'name'); -verifyNotWritable(Map.prototype.keys, 'name'); -verifyConfigurable(Map.prototype.keys, 'name'); +verifyProperty(Map.prototype.keys, "name", { + value: "keys", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/keys/not-a-constructor.js b/js/src/tests/test262/built-ins/Map/prototype/keys/not-a-constructor.js index be9835b84e..f1a6403627 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/keys/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Map/prototype/keys/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Map.prototype.keys), false, 'isConstructor(Map.pr assert.throws(TypeError, () => { let m = new Map(); new m.keys(); -}, '`let m = new Map(); new m.keys()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/set/length.js b/js/src/tests/test262/built-ins/Map/prototype/set/length.js index 939b633c34..5039937eda 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/set/length.js +++ b/js/src/tests/test262/built-ins/Map/prototype/set/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.set.length, 2, - 'The value of `Map.prototype.set.length` is `2`' -); - -verifyNotEnumerable(Map.prototype.set, 'length'); -verifyNotWritable(Map.prototype.set, 'length'); -verifyConfigurable(Map.prototype.set, 'length'); +verifyProperty(Map.prototype.set, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/set/name.js b/js/src/tests/test262/built-ins/Map/prototype/set/name.js index 7c0b83f696..d326a6a3da 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/set/name.js +++ b/js/src/tests/test262/built-ins/Map/prototype/set/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.set.name, 'set', - 'The value of `Map.prototype.set.name` is `"set"`' -); - -verifyNotEnumerable(Map.prototype.set, 'name'); -verifyNotWritable(Map.prototype.set, 'name'); -verifyConfigurable(Map.prototype.set, 'name'); +verifyProperty(Map.prototype.set, "name", { + value: "set", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/set/not-a-constructor.js b/js/src/tests/test262/built-ins/Map/prototype/set/not-a-constructor.js index 2880254c25..0b5dbb5e42 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/set/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Map/prototype/set/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Map.prototype.set), false, 'isConstructor(Map.pro assert.throws(TypeError, () => { let m = new Map(); new m.set(); -}, '`let m = new Map(); new m.set()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/size/length.js b/js/src/tests/test262/built-ins/Map/prototype/size/length.js index b3812e1ec6..2d234c649b 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/size/length.js +++ b/js/src/tests/test262/built-ins/Map/prototype/size/length.js @@ -13,13 +13,11 @@ includes: [propertyHelper.js] var descriptor = Object.getOwnPropertyDescriptor(Map.prototype, 'size'); -assert.sameValue( - descriptor.get.length, 0, - 'The value of `Map.prototype.size.length` is `0`' -); - -verifyNotEnumerable(descriptor.get, 'length'); -verifyNotWritable(descriptor.get, 'length'); -verifyConfigurable(descriptor.get, 'length'); +verifyProperty(descriptor.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/size/name.js b/js/src/tests/test262/built-ins/Map/prototype/size/name.js index 596e1a23c5..a594d7561b 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/size/name.js +++ b/js/src/tests/test262/built-ins/Map/prototype/size/name.js @@ -17,13 +17,11 @@ includes: [propertyHelper.js] var descriptor = Object.getOwnPropertyDescriptor(Map.prototype, 'size'); -assert.sameValue(descriptor.get.name, - 'get size', - 'The value of `descriptor.get.name` is `get size`' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get size", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/values/length.js b/js/src/tests/test262/built-ins/Map/prototype/values/length.js index 304cdd7983..e647192bd8 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/values/length.js +++ b/js/src/tests/test262/built-ins/Map/prototype/values/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.values.length, 0, - 'The value of `Map.prototype.values.length` is `0`' -); - -verifyNotEnumerable(Map.prototype.values, 'length'); -verifyNotWritable(Map.prototype.values, 'length'); -verifyConfigurable(Map.prototype.values, 'length'); +verifyProperty(Map.prototype.values, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/values/name.js b/js/src/tests/test262/built-ins/Map/prototype/values/name.js index 03827d01f3..c07ffcdcdb 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/values/name.js +++ b/js/src/tests/test262/built-ins/Map/prototype/values/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Map.prototype.values.name, 'values', - 'The value of `Map.prototype.values.name` is `"values"`' -); - -verifyNotEnumerable(Map.prototype.values, 'name'); -verifyNotWritable(Map.prototype.values, 'name'); -verifyConfigurable(Map.prototype.values, 'name'); +verifyProperty(Map.prototype.values, "name", { + value: "values", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Map/prototype/values/not-a-constructor.js b/js/src/tests/test262/built-ins/Map/prototype/values/not-a-constructor.js index 0fd6e656d2..9677e75064 100644 --- a/js/src/tests/test262/built-ins/Map/prototype/values/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Map/prototype/values/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Map.prototype.values), false, 'isConstructor(Map. assert.throws(TypeError, () => { let m = new Map(); new m.values(); -}, '`let m = new Map(); new m.values()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/MapIteratorPrototype/next/length.js b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/length.js index 7617371899..bb50cc1d4c 100644 --- a/js/src/tests/test262/built-ins/MapIteratorPrototype/next/length.js +++ b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/length.js @@ -24,10 +24,11 @@ includes: [propertyHelper.js] var MapIteratorProto = Object.getPrototypeOf(new Map().values()); -assert.sameValue(MapIteratorProto.next.length, 0); - -verifyNotEnumerable(MapIteratorProto.next, "length"); -verifyNotWritable(MapIteratorProto.next, "length"); -verifyConfigurable(MapIteratorProto.next, "length"); +verifyProperty(MapIteratorProto.next, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/MapIteratorPrototype/next/name.js b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/name.js index 5666f8ecc8..d8b1c3192d 100644 --- a/js/src/tests/test262/built-ins/MapIteratorPrototype/next/name.js +++ b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/name.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] var MapIteratorProto = Object.getPrototypeOf(new Map().values()); -assert.sameValue(MapIteratorProto.next.name, "next"); - -verifyNotEnumerable(MapIteratorProto.next, "name"); -verifyNotWritable(MapIteratorProto.next, "name"); -verifyConfigurable(MapIteratorProto.next, "name"); +verifyProperty(MapIteratorProto.next, "name", { + value: "next", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/abs/length.js b/js/src/tests/test262/built-ins/Math/abs/length.js index 2d031962ae..978f566e95 100644 --- a/js/src/tests/test262/built-ins/Math/abs/length.js +++ b/js/src/tests/test262/built-ins/Math/abs/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.abs.length, 1); - -verifyNotEnumerable(Math.abs, "length"); -verifyNotWritable(Math.abs, "length"); -verifyConfigurable(Math.abs, "length"); +verifyProperty(Math.abs, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/abs/name.js b/js/src/tests/test262/built-ins/Math/abs/name.js index 640f07b811..e95eb98e95 100644 --- a/js/src/tests/test262/built-ins/Math/abs/name.js +++ b/js/src/tests/test262/built-ins/Math/abs/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.abs.name, "abs"); - -verifyNotEnumerable(Math.abs, "name"); -verifyNotWritable(Math.abs, "name"); -verifyConfigurable(Math.abs, "name"); +verifyProperty(Math.abs, "name", { + value: "abs", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/abs/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/abs/not-a-constructor.js index 3fc474119f..abe5fb0acf 100644 --- a/js/src/tests/test262/built-ins/Math/abs/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/abs/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.abs), false, 'isConstructor(Math.abs) must r assert.throws(TypeError, () => { new Math.abs(); -}, '`new Math.abs()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/acos/length.js b/js/src/tests/test262/built-ins/Math/acos/length.js index 0d1fca6e4a..3785de0c0d 100644 --- a/js/src/tests/test262/built-ins/Math/acos/length.js +++ b/js/src/tests/test262/built-ins/Math/acos/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.acos.length, 1); - -verifyNotEnumerable(Math.acos, "length"); -verifyNotWritable(Math.acos, "length"); -verifyConfigurable(Math.acos, "length"); +verifyProperty(Math.acos, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/acos/name.js b/js/src/tests/test262/built-ins/Math/acos/name.js index d441d92d10..1e8059d1eb 100644 --- a/js/src/tests/test262/built-ins/Math/acos/name.js +++ b/js/src/tests/test262/built-ins/Math/acos/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.acos.name, "acos"); - -verifyNotEnumerable(Math.acos, "name"); -verifyNotWritable(Math.acos, "name"); -verifyConfigurable(Math.acos, "name"); +verifyProperty(Math.acos, "name", { + value: "acos", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/acos/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/acos/not-a-constructor.js index 659f497ee4..8d9ef0724b 100644 --- a/js/src/tests/test262/built-ins/Math/acos/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/acos/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.acos), false, 'isConstructor(Math.acos) must assert.throws(TypeError, () => { new Math.acos(); -}, '`new Math.acos()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/acosh/length.js b/js/src/tests/test262/built-ins/Math/acosh/length.js index 10b7e3c234..f24d80e857 100644 --- a/js/src/tests/test262/built-ins/Math/acosh/length.js +++ b/js/src/tests/test262/built-ins/Math/acosh/length.js @@ -18,10 +18,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.acosh.length, 1); - -verifyNotEnumerable(Math.acosh, "length"); -verifyNotWritable(Math.acosh, "length"); -verifyConfigurable(Math.acosh, "length"); +verifyProperty(Math.acosh, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/acosh/name.js b/js/src/tests/test262/built-ins/Math/acosh/name.js index 5ff5df412f..6fce1df3a7 100644 --- a/js/src/tests/test262/built-ins/Math/acosh/name.js +++ b/js/src/tests/test262/built-ins/Math/acosh/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.acosh.name, "acosh"); - -verifyNotEnumerable(Math.acosh, "name"); -verifyNotWritable(Math.acosh, "name"); -verifyConfigurable(Math.acosh, "name"); +verifyProperty(Math.acosh, "name", { + value: "acosh", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/acosh/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/acosh/not-a-constructor.js index b9866a9eb4..3ea47b872e 100644 --- a/js/src/tests/test262/built-ins/Math/acosh/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/acosh/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.acosh), false, 'isConstructor(Math.acosh) mu assert.throws(TypeError, () => { new Math.acosh(); -}, '`new Math.acosh()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/asin/length.js b/js/src/tests/test262/built-ins/Math/asin/length.js index 40ddb05dea..f9287e3728 100644 --- a/js/src/tests/test262/built-ins/Math/asin/length.js +++ b/js/src/tests/test262/built-ins/Math/asin/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.asin.length, 1); - -verifyNotEnumerable(Math.asin, "length"); -verifyNotWritable(Math.asin, "length"); -verifyConfigurable(Math.asin, "length"); +verifyProperty(Math.asin, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/asin/name.js b/js/src/tests/test262/built-ins/Math/asin/name.js index 2d63be0e06..aa051f2a4b 100644 --- a/js/src/tests/test262/built-ins/Math/asin/name.js +++ b/js/src/tests/test262/built-ins/Math/asin/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.asin.name, "asin"); - -verifyNotEnumerable(Math.asin, "name"); -verifyNotWritable(Math.asin, "name"); -verifyConfigurable(Math.asin, "name"); +verifyProperty(Math.asin, "name", { + value: "asin", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/asin/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/asin/not-a-constructor.js index adcadf0892..c2393843e5 100644 --- a/js/src/tests/test262/built-ins/Math/asin/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/asin/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.asin), false, 'isConstructor(Math.asin) must assert.throws(TypeError, () => { new Math.asin(); -}, '`new Math.asin()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/asinh/length.js b/js/src/tests/test262/built-ins/Math/asinh/length.js index 7dcd44f621..56a557c07f 100644 --- a/js/src/tests/test262/built-ins/Math/asinh/length.js +++ b/js/src/tests/test262/built-ins/Math/asinh/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.asinh.length, 1); - -verifyNotEnumerable(Math.asinh, "length"); -verifyNotWritable(Math.asinh, "length"); -verifyConfigurable(Math.asinh, "length"); +verifyProperty(Math.asinh, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/asinh/name.js b/js/src/tests/test262/built-ins/Math/asinh/name.js index 252117b048..fa9bd41b00 100644 --- a/js/src/tests/test262/built-ins/Math/asinh/name.js +++ b/js/src/tests/test262/built-ins/Math/asinh/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.asinh.name, "asinh"); - -verifyNotEnumerable(Math.asinh, "name"); -verifyNotWritable(Math.asinh, "name"); -verifyConfigurable(Math.asinh, "name"); +verifyProperty(Math.asinh, "name", { + value: "asinh", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/asinh/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/asinh/not-a-constructor.js index bfb53cc7ec..97f90884e6 100644 --- a/js/src/tests/test262/built-ins/Math/asinh/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/asinh/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.asinh), false, 'isConstructor(Math.asinh) mu assert.throws(TypeError, () => { new Math.asinh(); -}, '`new Math.asinh()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/atan/length.js b/js/src/tests/test262/built-ins/Math/atan/length.js index e2a3cfc5ad..e3e97785f3 100644 --- a/js/src/tests/test262/built-ins/Math/atan/length.js +++ b/js/src/tests/test262/built-ins/Math/atan/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.atan.length, 1); - -verifyNotEnumerable(Math.atan, "length"); -verifyNotWritable(Math.atan, "length"); -verifyConfigurable(Math.atan, "length"); +verifyProperty(Math.atan, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/atan/name.js b/js/src/tests/test262/built-ins/Math/atan/name.js index 56009ad6fe..a389cc1be3 100644 --- a/js/src/tests/test262/built-ins/Math/atan/name.js +++ b/js/src/tests/test262/built-ins/Math/atan/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.atan.name, "atan"); - -verifyNotEnumerable(Math.atan, "name"); -verifyNotWritable(Math.atan, "name"); -verifyConfigurable(Math.atan, "name"); +verifyProperty(Math.atan, "name", { + value: "atan", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/atan/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/atan/not-a-constructor.js index 0b00568ba9..13ca4783c9 100644 --- a/js/src/tests/test262/built-ins/Math/atan/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/atan/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.atan), false, 'isConstructor(Math.atan) must assert.throws(TypeError, () => { new Math.atan(); -}, '`new Math.atan()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/atan2/length.js b/js/src/tests/test262/built-ins/Math/atan2/length.js index 8255c76783..308f1434b8 100644 --- a/js/src/tests/test262/built-ins/Math/atan2/length.js +++ b/js/src/tests/test262/built-ins/Math/atan2/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.atan2.length, 2); - -verifyNotEnumerable(Math.atan2, "length"); -verifyNotWritable(Math.atan2, "length"); -verifyConfigurable(Math.atan2, "length"); +verifyProperty(Math.atan2, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/atan2/name.js b/js/src/tests/test262/built-ins/Math/atan2/name.js index fef201b98d..b7ddd1bd23 100644 --- a/js/src/tests/test262/built-ins/Math/atan2/name.js +++ b/js/src/tests/test262/built-ins/Math/atan2/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.atan2.name, "atan2"); - -verifyNotEnumerable(Math.atan2, "name"); -verifyNotWritable(Math.atan2, "name"); -verifyConfigurable(Math.atan2, "name"); +verifyProperty(Math.atan2, "name", { + value: "atan2", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/atan2/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/atan2/not-a-constructor.js index 3b8989dd32..554b7e886f 100644 --- a/js/src/tests/test262/built-ins/Math/atan2/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/atan2/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.atan2), false, 'isConstructor(Math.atan2) mu assert.throws(TypeError, () => { new Math.atan2(); -}, '`new Math.atan2()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/atanh/length.js b/js/src/tests/test262/built-ins/Math/atanh/length.js index 7836a19735..df99c46c57 100644 --- a/js/src/tests/test262/built-ins/Math/atanh/length.js +++ b/js/src/tests/test262/built-ins/Math/atanh/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.atanh.length, 1); - -verifyNotEnumerable(Math.atanh, "length"); -verifyNotWritable(Math.atanh, "length"); -verifyConfigurable(Math.atanh, "length"); +verifyProperty(Math.atanh, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/atanh/name.js b/js/src/tests/test262/built-ins/Math/atanh/name.js index f62a0884df..d215638765 100644 --- a/js/src/tests/test262/built-ins/Math/atanh/name.js +++ b/js/src/tests/test262/built-ins/Math/atanh/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.atanh.name, "atanh"); - -verifyNotEnumerable(Math.atanh, "name"); -verifyNotWritable(Math.atanh, "name"); -verifyConfigurable(Math.atanh, "name"); +verifyProperty(Math.atanh, "name", { + value: "atanh", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/atanh/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/atanh/not-a-constructor.js index 1dd566de55..cd2a34d93d 100644 --- a/js/src/tests/test262/built-ins/Math/atanh/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/atanh/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.atanh), false, 'isConstructor(Math.atanh) mu assert.throws(TypeError, () => { new Math.atanh(); -}, '`new Math.atanh()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/cbrt/length.js b/js/src/tests/test262/built-ins/Math/cbrt/length.js index 254fc702d8..e0bc1c181e 100644 --- a/js/src/tests/test262/built-ins/Math/cbrt/length.js +++ b/js/src/tests/test262/built-ins/Math/cbrt/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.cbrt.length, 1); - -verifyNotEnumerable(Math.cbrt, "length"); -verifyNotWritable(Math.cbrt, "length"); -verifyConfigurable(Math.cbrt, "length"); +verifyProperty(Math.cbrt, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/cbrt/name.js b/js/src/tests/test262/built-ins/Math/cbrt/name.js index d6262036b4..bb0f003077 100644 --- a/js/src/tests/test262/built-ins/Math/cbrt/name.js +++ b/js/src/tests/test262/built-ins/Math/cbrt/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.cbrt.name, "cbrt"); - -verifyNotEnumerable(Math.cbrt, "name"); -verifyNotWritable(Math.cbrt, "name"); -verifyConfigurable(Math.cbrt, "name"); +verifyProperty(Math.cbrt, "name", { + value: "cbrt", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/cbrt/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/cbrt/not-a-constructor.js index 39b62b8f1c..2999fd05e2 100644 --- a/js/src/tests/test262/built-ins/Math/cbrt/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/cbrt/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.cbrt), false, 'isConstructor(Math.cbrt) must assert.throws(TypeError, () => { new Math.cbrt(); -}, '`new Math.cbrt()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/ceil/length.js b/js/src/tests/test262/built-ins/Math/ceil/length.js index c8717de985..a1b84541d0 100644 --- a/js/src/tests/test262/built-ins/Math/ceil/length.js +++ b/js/src/tests/test262/built-ins/Math/ceil/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.ceil.length, 1); - -verifyNotEnumerable(Math.ceil, "length"); -verifyNotWritable(Math.ceil, "length"); -verifyConfigurable(Math.ceil, "length"); +verifyProperty(Math.ceil, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/ceil/name.js b/js/src/tests/test262/built-ins/Math/ceil/name.js index df08f67866..5425e70f51 100644 --- a/js/src/tests/test262/built-ins/Math/ceil/name.js +++ b/js/src/tests/test262/built-ins/Math/ceil/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.ceil.name, "ceil"); - -verifyNotEnumerable(Math.ceil, "name"); -verifyNotWritable(Math.ceil, "name"); -verifyConfigurable(Math.ceil, "name"); +verifyProperty(Math.ceil, "name", { + value: "ceil", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/ceil/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/ceil/not-a-constructor.js index 8e2861138f..34468e9cf3 100644 --- a/js/src/tests/test262/built-ins/Math/ceil/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/ceil/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.ceil), false, 'isConstructor(Math.ceil) must assert.throws(TypeError, () => { new Math.ceil(); -}, '`new Math.ceil()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/clz32/length.js b/js/src/tests/test262/built-ins/Math/clz32/length.js index 038975b13d..b139a9f06d 100644 --- a/js/src/tests/test262/built-ins/Math/clz32/length.js +++ b/js/src/tests/test262/built-ins/Math/clz32/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.clz32.length, 1); - -verifyNotEnumerable(Math.clz32, "length"); -verifyNotWritable(Math.clz32, "length"); -verifyConfigurable(Math.clz32, "length"); +verifyProperty(Math.clz32, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/clz32/name.js b/js/src/tests/test262/built-ins/Math/clz32/name.js index 2862f87439..0ba3af0460 100644 --- a/js/src/tests/test262/built-ins/Math/clz32/name.js +++ b/js/src/tests/test262/built-ins/Math/clz32/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.clz32.name, "clz32"); - -verifyNotEnumerable(Math.clz32, "name"); -verifyNotWritable(Math.clz32, "name"); -verifyConfigurable(Math.clz32, "name"); +verifyProperty(Math.clz32, "name", { + value: "clz32", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/clz32/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/clz32/not-a-constructor.js index 2bff88114f..c1a38ec793 100644 --- a/js/src/tests/test262/built-ins/Math/clz32/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/clz32/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.clz32), false, 'isConstructor(Math.clz32) mu assert.throws(TypeError, () => { new Math.clz32(); -}, '`new Math.clz32()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/cos/length.js b/js/src/tests/test262/built-ins/Math/cos/length.js index b41d87ef73..b7c1feb4ab 100644 --- a/js/src/tests/test262/built-ins/Math/cos/length.js +++ b/js/src/tests/test262/built-ins/Math/cos/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.cos.length, 1); - -verifyNotEnumerable(Math.cos, "length"); -verifyNotWritable(Math.cos, "length"); -verifyConfigurable(Math.cos, "length"); +verifyProperty(Math.cos, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/cos/name.js b/js/src/tests/test262/built-ins/Math/cos/name.js index 88be1490d8..291819a099 100644 --- a/js/src/tests/test262/built-ins/Math/cos/name.js +++ b/js/src/tests/test262/built-ins/Math/cos/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.cos.name, "cos"); - -verifyNotEnumerable(Math.cos, "name"); -verifyNotWritable(Math.cos, "name"); -verifyConfigurable(Math.cos, "name"); +verifyProperty(Math.cos, "name", { + value: "cos", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/cos/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/cos/not-a-constructor.js index e86a689ccb..e680ae9ade 100644 --- a/js/src/tests/test262/built-ins/Math/cos/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/cos/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.cos), false, 'isConstructor(Math.cos) must r assert.throws(TypeError, () => { new Math.cos(); -}, '`new Math.cos()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/cosh/length.js b/js/src/tests/test262/built-ins/Math/cosh/length.js index 6c64935887..42d849b37c 100644 --- a/js/src/tests/test262/built-ins/Math/cosh/length.js +++ b/js/src/tests/test262/built-ins/Math/cosh/length.js @@ -18,10 +18,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.cosh.length, 1); - -verifyNotEnumerable(Math.cosh, "length"); -verifyNotWritable(Math.cosh, "length"); -verifyConfigurable(Math.cosh, "length"); +verifyProperty(Math.cosh, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/cosh/name.js b/js/src/tests/test262/built-ins/Math/cosh/name.js index 161ed02e3a..1358dd428a 100644 --- a/js/src/tests/test262/built-ins/Math/cosh/name.js +++ b/js/src/tests/test262/built-ins/Math/cosh/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.cosh.name, "cosh"); - -verifyNotEnumerable(Math.cosh, "name"); -verifyNotWritable(Math.cosh, "name"); -verifyConfigurable(Math.cosh, "name"); +verifyProperty(Math.cosh, "name", { + value: "cosh", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/cosh/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/cosh/not-a-constructor.js index 8cda77d866..43e7b739c3 100644 --- a/js/src/tests/test262/built-ins/Math/cosh/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/cosh/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.cosh), false, 'isConstructor(Math.cosh) must assert.throws(TypeError, () => { new Math.cosh(); -}, '`new Math.cosh()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/exp/length.js b/js/src/tests/test262/built-ins/Math/exp/length.js index 1f90dbf228..06e2d7e267 100644 --- a/js/src/tests/test262/built-ins/Math/exp/length.js +++ b/js/src/tests/test262/built-ins/Math/exp/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.exp.length, 1); - -verifyNotEnumerable(Math.exp, "length"); -verifyNotWritable(Math.exp, "length"); -verifyConfigurable(Math.exp, "length"); +verifyProperty(Math.exp, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/exp/name.js b/js/src/tests/test262/built-ins/Math/exp/name.js index 9f0ec90ebb..10dface3a7 100644 --- a/js/src/tests/test262/built-ins/Math/exp/name.js +++ b/js/src/tests/test262/built-ins/Math/exp/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.exp.name, "exp"); - -verifyNotEnumerable(Math.exp, "name"); -verifyNotWritable(Math.exp, "name"); -verifyConfigurable(Math.exp, "name"); +verifyProperty(Math.exp, "name", { + value: "exp", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/exp/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/exp/not-a-constructor.js index 9d956e7bcb..ea30924ae8 100644 --- a/js/src/tests/test262/built-ins/Math/exp/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/exp/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.exp), false, 'isConstructor(Math.exp) must r assert.throws(TypeError, () => { new Math.exp(); -}, '`new Math.exp()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/expm1/length.js b/js/src/tests/test262/built-ins/Math/expm1/length.js index ead3c57638..2b58d8cf01 100644 --- a/js/src/tests/test262/built-ins/Math/expm1/length.js +++ b/js/src/tests/test262/built-ins/Math/expm1/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.expm1.length, 1); - -verifyNotEnumerable(Math.expm1, "length"); -verifyNotWritable(Math.expm1, "length"); -verifyConfigurable(Math.expm1, "length"); +verifyProperty(Math.expm1, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/expm1/name.js b/js/src/tests/test262/built-ins/Math/expm1/name.js index 698bdc19c0..5c1e831913 100644 --- a/js/src/tests/test262/built-ins/Math/expm1/name.js +++ b/js/src/tests/test262/built-ins/Math/expm1/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.expm1.name, "expm1"); - -verifyNotEnumerable(Math.expm1, "name"); -verifyNotWritable(Math.expm1, "name"); -verifyConfigurable(Math.expm1, "name"); +verifyProperty(Math.expm1, "name", { + value: "expm1", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/expm1/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/expm1/not-a-constructor.js index d0b9a18935..4ce17e5172 100644 --- a/js/src/tests/test262/built-ins/Math/expm1/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/expm1/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.expm1), false, 'isConstructor(Math.expm1) mu assert.throws(TypeError, () => { new Math.expm1(); -}, '`new Math.expm1()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/f16round/browser.js b/js/src/tests/test262/built-ins/Math/f16round/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/f16round/browser.js diff --git a/js/src/tests/test262/built-ins/Math/f16round/length.js b/js/src/tests/test262/built-ins/Math/f16round/length.js new file mode 100644 index 0000000000..06aa21a352 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/f16round/length.js @@ -0,0 +1,20 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-math.f16round +description: > + Math.f16round.length is 1 +features: [Float16Array] +includes: [propertyHelper.js] +---*/ + +verifyProperty(Math.f16round, 'length', { + value: 1, + enumerable: false, + writable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/f16round/name.js b/js/src/tests/test262/built-ins/Math/f16round/name.js new file mode 100644 index 0000000000..6e6167e469 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/f16round/name.js @@ -0,0 +1,20 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-math.f16round +description: > + Math.f16round.name is "f16round" +features: [Float16Array] +includes: [propertyHelper.js] +---*/ + +verifyProperty(Math.f16round, 'name', { + value: 'f16round', + enumerable: false, + writable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/f16round/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/f16round/not-a-constructor.js new file mode 100644 index 0000000000..1dcb13eb89 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/f16round/not-a-constructor.js @@ -0,0 +1,19 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Math.f16round does not implement [[Construct]], is not new-able +includes: [isConstructor.js] +features: [Float16Array, Reflect.construct] +---*/ + +assert(!isConstructor(Math.f16round), "Math.f16round is not a constructor"); + +assert.throws(TypeError, function () { + new Math.fround(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/f16round/prop-desc.js b/js/src/tests/test262/built-ins/Math/f16round/prop-desc.js new file mode 100644 index 0000000000..970532b3b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/f16round/prop-desc.js @@ -0,0 +1,17 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-math.f16round +description: > + "f16round" property of Math +features: [Float16Array] +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Math, "f16round"); +verifyWritable(Math, "f16round"); +verifyConfigurable(Math, "f16round"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/f16round/shell.js b/js/src/tests/test262/built-ins/Math/f16round/shell.js new file mode 100644 index 0000000000..d71430014e --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/f16round/shell.js @@ -0,0 +1,680 @@ +// GENERATED, DO NOT EDIT +// file: byteConversionValues.js +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Provide a list for original and expected values for different byte + conversions. + This helper is mostly used on tests for TypedArray and DataView, and each + array from the expected values must match the original values array on every + index containing its original value. +defines: [byteConversionValues] +---*/ +var byteConversionValues = { + values: [ + 127, // 2 ** 7 - 1 + 128, // 2 ** 7 + 32767, // 2 ** 15 - 1 + 32768, // 2 ** 15 + 2147483647, // 2 ** 31 - 1 + 2147483648, // 2 ** 31 + 255, // 2 ** 8 - 1 + 256, // 2 ** 8 + 65535, // 2 ** 16 - 1 + 65536, // 2 ** 16 + 4294967295, // 2 ** 32 - 1 + 4294967296, // 2 ** 32 + 9007199254740991, // 2 ** 53 - 1 + 9007199254740992, // 2 ** 53 + 1.1, + 0.1, + 0.5, + 0.50000001, + 0.6, + 0.7, + undefined, + -1, + -0, + -0.1, + -1.1, + NaN, + -127, // - ( 2 ** 7 - 1 ) + -128, // - ( 2 ** 7 ) + -32767, // - ( 2 ** 15 - 1 ) + -32768, // - ( 2 ** 15 ) + -2147483647, // - ( 2 ** 31 - 1 ) + -2147483648, // - ( 2 ** 31 ) + -255, // - ( 2 ** 8 - 1 ) + -256, // - ( 2 ** 8 ) + -65535, // - ( 2 ** 16 - 1 ) + -65536, // - ( 2 ** 16 ) + -4294967295, // - ( 2 ** 32 - 1 ) + -4294967296, // - ( 2 ** 32 ) + Infinity, + -Infinity, + 0, + 2049, // an integer which rounds down under ties-to-even when cast to float16 + 2051, // an integer which rounds up under ties-to-even when cast to float16 + 0.00006103515625, // smallest normal float16 + 0.00006097555160522461, // largest subnormal float16 + 5.960464477539063e-8, // smallest float16 + 2.9802322387695312e-8, // largest double which rounds to 0 when cast to float16 + 2.980232238769532e-8, // smallest double which does not round to 0 when cast to float16 + 8.940696716308594e-8, // a double which rounds up to a subnormal under ties-to-even when cast to float16 + 1.4901161193847656e-7, // a double which rounds down to a subnormal under ties-to-even when cast to float16 + 1.490116119384766e-7, // the next double above the one on the previous line one + 65504, // max finite float16 + 65520, // smallest double which rounds to infinity when cast to float16 + 65519.99999999999, // largest double which does not round to infinity when cast to float16 + 0.000061005353927612305, // smallest double which rounds to a non-subnormal when cast to float16 + 0.0000610053539276123 // largest double which rounds to a subnormal when cast to float16 + ], + + expected: { + Int8: [ + 127, // 127 + -128, // 128 + -1, // 32767 + 0, // 32768 + -1, // 2147483647 + 0, // 2147483648 + -1, // 255 + 0, // 256 + -1, // 65535 + 0, // 65536 + -1, // 4294967295 + 0, // 4294967296 + -1, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + -1, // -1 + 0, // -0 + 0, // -0.1 + -1, // -1.1 + 0, // NaN + -127, // -127 + -128, // -128 + 1, // -32767 + 0, // -32768 + 1, // -2147483647 + 0, // -2147483648 + 1, // -255 + 0, // -256 + 1, // -65535 + 0, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0, // 0 + 1, // 2049 + 3, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + -32, // 65504 + -16, // 65520 + -17, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 + ], + Uint8: [ + 127, // 127 + 128, // 128 + 255, // 32767 + 0, // 32768 + 255, // 2147483647 + 0, // 2147483648 + 255, // 255 + 0, // 256 + 255, // 65535 + 0, // 65536 + 255, // 4294967295 + 0, // 4294967296 + 255, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + 255, // -1 + 0, // -0 + 0, // -0.1 + 255, // -1.1 + 0, // NaN + 129, // -127 + 128, // -128 + 1, // -32767 + 0, // -32768 + 1, // -2147483647 + 0, // -2147483648 + 1, // -255 + 0, // -256 + 1, // -65535 + 0, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0, // 0 + 1, // 2049 + 3, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 224, // 65504 + 240, // 65520 + 239, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 + ], + Uint8Clamped: [ + 127, // 127 + 128, // 128 + 255, // 32767 + 255, // 32768 + 255, // 2147483647 + 255, // 2147483648 + 255, // 255 + 255, // 256 + 255, // 65535 + 255, // 65536 + 255, // 4294967295 + 255, // 4294967296 + 255, // 9007199254740991 + 255, // 9007199254740992 + 1, // 1.1, + 0, // 0.1 + 0, // 0.5 + 1, // 0.50000001, + 1, // 0.6 + 1, // 0.7 + 0, // undefined + 0, // -1 + 0, // -0 + 0, // -0.1 + 0, // -1.1 + 0, // NaN + 0, // -127 + 0, // -128 + 0, // -32767 + 0, // -32768 + 0, // -2147483647 + 0, // -2147483648 + 0, // -255 + 0, // -256 + 0, // -65535 + 0, // -65536 + 0, // -4294967295 + 0, // -4294967296 + 255, // Infinity + 0, // -Infinity + 0, // 0 + 255, // 2049 + 255, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 255, // 65504 + 255, // 65520 + 255, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 + ], + Int16: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + -32768, // 32768 + -1, // 2147483647 + 0, // 2147483648 + 255, // 255 + 256, // 256 + -1, // 65535 + 0, // 65536 + -1, // 4294967295 + 0, // 4294967296 + -1, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + -1, // -1 + 0, // -0 + 0, // -0.1 + -1, // -1.1 + 0, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + 1, // -2147483647 + 0, // -2147483648 + -255, // -255 + -256, // -256 + 1, // -65535 + 0, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + -32, // 65504 + -16, // 65520 + -17, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 + ], + Uint16: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 65535, // 2147483647 + 0, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 0, // 65536 + 65535, // 4294967295 + 0, // 4294967296 + 65535, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + 65535, // -1 + 0, // -0 + 0, // -0.1 + 65535, // -1.1 + 0, // NaN + 65409, // -127 + 65408, // -128 + 32769, // -32767 + 32768, // -32768 + 1, // -2147483647 + 0, // -2147483648 + 65281, // -255 + 65280, // -256 + 1, // -65535 + 0, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 + ], + Int32: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483647, // 2147483647 + -2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + -1, // 4294967295 + 0, // 4294967296 + -1, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + -1, // -1 + 0, // -0 + 0, // -0.1 + -1, // -1.1 + 0, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483647, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 + ], + Uint32: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483647, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967295, // 4294967295 + 0, // 4294967296 + 4294967295, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + 4294967295, // -1 + 0, // -0 + 0, // -0.1 + 4294967295, // -1.1 + 0, // NaN + 4294967169, // -127 + 4294967168, // -128 + 4294934529, // -32767 + 4294934528, // -32768 + 2147483649, // -2147483647 + 2147483648, // -2147483648 + 4294967041, // -255 + 4294967040, // -256 + 4294901761, // -65535 + 4294901760, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 + ], + Float16: [ + 127, // 127 + 128, // 128 + 32768, // 32767 + 32768, // 32768 + Infinity, // 2147483647 + Infinity, // 2147483648 + 255, // 255 + 256, // 256 + Infinity, // 65535 + Infinity, // 65536 + Infinity, // 4294967295 + Infinity, // 4294967296 + Infinity, // 9007199254740991 + Infinity, // 9007199254740992 + 1.099609375, // 1.1 + 0.0999755859375, // 0.1 + 0.5, // 0.5 + 0.5, // 0.50000001, + 0.60009765625, // 0.6 + 0.7001953125, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.0999755859375, // -0.1 + -1.099609375, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32768, // -32767 + -32768, // -32768 + -Infinity, // -2147483647 + -Infinity, // -2147483648 + -255, // -255 + -256, // -256 + -Infinity, // -65535 + -Infinity, // -65536 + -Infinity, // -4294967295 + -Infinity, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0, // 0 + 2048, // 2049 + 2052, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 5.960464477539063e-8, // 2.980232238769532e-8 + 1.1920928955078125e-7, // 8.940696716308594e-8 + 1.1920928955078125e-7, // 1.4901161193847656e-7 + 1.7881393432617188e-7, // 1.490116119384766e-7 + 65504, // 65504 + Infinity, // 65520 + 65504, // 65519.99999999999 + 0.00006103515625, // 0.000061005353927612305 + 0.00006097555160522461 // 0.0000610053539276123 + ], + Float32: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483648, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967296, // 4294967295 + 4294967296, // 4294967296 + 9007199254740992, // 9007199254740991 + 9007199254740992, // 9007199254740992 + 1.100000023841858, // 1.1 + 0.10000000149011612, // 0.1 + 0.5, // 0.5 + 0.5, // 0.50000001, + 0.6000000238418579, // 0.6 + 0.699999988079071, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.10000000149011612, // -0.1 + -1.100000023841858, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483648, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + -4294967296, // -4294967295 + -4294967296, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 2.9802322387695312e-8, // 2.9802322387695312e-8 + 2.9802322387695312e-8, // 2.980232238769532e-8 + 8.940696716308594e-8, // 8.940696716308594e-8 + 1.4901161193847656e-7, // 1.4901161193847656e-7 + 1.4901161193847656e-7, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65520, // 65519.99999999999 + 0.000061005353927612305, // 0.000061005353927612305 + 0.000061005353927612305 // 0.0000610053539276123 + ], + Float64: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483647, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967295, // 4294967295 + 4294967296, // 4294967296 + 9007199254740991, // 9007199254740991 + 9007199254740992, // 9007199254740992 + 1.1, // 1.1 + 0.1, // 0.1 + 0.5, // 0.5 + 0.50000001, // 0.50000001, + 0.6, // 0.6 + 0.7, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.1, // -0.1 + -1.1, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483647, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + -4294967295, // -4294967295 + -4294967296, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 2.9802322387695312e-8, // 2.9802322387695312e-8 + 2.980232238769532e-8, // 2.980232238769532e-8 + 8.940696716308594e-8, // 8.940696716308594e-8 + 1.4901161193847656e-7, // 1.4901161193847656e-7 + 1.490116119384766e-7, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519.99999999999, // 65519.99999999999 + 0.000061005353927612305, // 0.000061005353927612305 + 0.0000610053539276123 // 0.0000610053539276123 + ] + } +}; + +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/built-ins/Math/f16round/value-conversion.js b/js/src/tests/test262/built-ins/Math/f16round/value-conversion.js new file mode 100644 index 0000000000..2e6ebae58b --- /dev/null +++ b/js/src/tests/test262/built-ins/Math/f16round/value-conversion.js @@ -0,0 +1,28 @@ +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('Float16Array')||!xulRuntime.shell) -- Float16Array is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-math.f16round +description: > + Convert to binary16 format and than to binary64 format +features: [Float16Array] +includes: [byteConversionValues.js] +---*/ + +var values = byteConversionValues.values; +var expectedValues = byteConversionValues.expected.Float16; + +values.forEach(function(value, i) { + var expected = expectedValues[i]; + + var result = Math.f16round(value); + + assert.sameValue( + result, + expected, + "value: " + value + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/floor/length.js b/js/src/tests/test262/built-ins/Math/floor/length.js index ee66afc021..7e456dc19c 100644 --- a/js/src/tests/test262/built-ins/Math/floor/length.js +++ b/js/src/tests/test262/built-ins/Math/floor/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.floor.length, 1); - -verifyNotEnumerable(Math.floor, "length"); -verifyNotWritable(Math.floor, "length"); -verifyConfigurable(Math.floor, "length"); +verifyProperty(Math.floor, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/floor/name.js b/js/src/tests/test262/built-ins/Math/floor/name.js index 4b08a81688..00f09e16eb 100644 --- a/js/src/tests/test262/built-ins/Math/floor/name.js +++ b/js/src/tests/test262/built-ins/Math/floor/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.floor.name, "floor"); - -verifyNotEnumerable(Math.floor, "name"); -verifyNotWritable(Math.floor, "name"); -verifyConfigurable(Math.floor, "name"); +verifyProperty(Math.floor, "name", { + value: "floor", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/floor/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/floor/not-a-constructor.js index 140a726d16..e69c5d7c4a 100644 --- a/js/src/tests/test262/built-ins/Math/floor/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/floor/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.floor), false, 'isConstructor(Math.floor) mu assert.throws(TypeError, () => { new Math.floor(); -}, '`new Math.floor()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/fround/length.js b/js/src/tests/test262/built-ins/Math/fround/length.js index 56190466ae..7020d5354e 100644 --- a/js/src/tests/test262/built-ins/Math/fround/length.js +++ b/js/src/tests/test262/built-ins/Math/fround/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.fround.length, 1); - -verifyNotEnumerable(Math.fround, "length"); -verifyNotWritable(Math.fround, "length"); -verifyConfigurable(Math.fround, "length"); +verifyProperty(Math.fround, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/fround/name.js b/js/src/tests/test262/built-ins/Math/fround/name.js index c1f5ac6270..4385f3cb77 100644 --- a/js/src/tests/test262/built-ins/Math/fround/name.js +++ b/js/src/tests/test262/built-ins/Math/fround/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.fround.name, "fround"); - -verifyNotEnumerable(Math.fround, "name"); -verifyNotWritable(Math.fround, "name"); -verifyConfigurable(Math.fround, "name"); +verifyProperty(Math.fround, "name", { + value: "fround", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/fround/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/fround/not-a-constructor.js index d82e346651..029a31f66e 100644 --- a/js/src/tests/test262/built-ins/Math/fround/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/fround/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.fround), false, 'isConstructor(Math.fround) assert.throws(TypeError, () => { new Math.fround(); -}, '`new Math.fround()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/hypot/length.js b/js/src/tests/test262/built-ins/Math/hypot/length.js index 9800debc1a..7a29ac886f 100644 --- a/js/src/tests/test262/built-ins/Math/hypot/length.js +++ b/js/src/tests/test262/built-ins/Math/hypot/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.hypot.length, 2); - -verifyNotEnumerable(Math.hypot, "length"); -verifyNotWritable(Math.hypot, "length"); -verifyConfigurable(Math.hypot, "length"); +verifyProperty(Math.hypot, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/hypot/name.js b/js/src/tests/test262/built-ins/Math/hypot/name.js index 46d395ca06..51224f04e0 100644 --- a/js/src/tests/test262/built-ins/Math/hypot/name.js +++ b/js/src/tests/test262/built-ins/Math/hypot/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.hypot.name, "hypot"); - -verifyNotEnumerable(Math.hypot, "name"); -verifyNotWritable(Math.hypot, "name"); -verifyConfigurable(Math.hypot, "name"); +verifyProperty(Math.hypot, "name", { + value: "hypot", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/hypot/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/hypot/not-a-constructor.js index 21ff4ba634..7e75ae29ea 100644 --- a/js/src/tests/test262/built-ins/Math/hypot/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/hypot/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.hypot), false, 'isConstructor(Math.hypot) mu assert.throws(TypeError, () => { new Math.hypot(); -}, '`new Math.hypot()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/imul/length.js b/js/src/tests/test262/built-ins/Math/imul/length.js index e457fa6151..67dd3a89b8 100644 --- a/js/src/tests/test262/built-ins/Math/imul/length.js +++ b/js/src/tests/test262/built-ins/Math/imul/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.imul.length, 2); - -verifyNotEnumerable(Math.imul, "length"); -verifyNotWritable(Math.imul, "length"); -verifyConfigurable(Math.imul, "length"); +verifyProperty(Math.imul, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/imul/name.js b/js/src/tests/test262/built-ins/Math/imul/name.js index 46ed5dde63..8549eaa2fe 100644 --- a/js/src/tests/test262/built-ins/Math/imul/name.js +++ b/js/src/tests/test262/built-ins/Math/imul/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.imul.name, "imul"); - -verifyNotEnumerable(Math.imul, "name"); -verifyNotWritable(Math.imul, "name"); -verifyConfigurable(Math.imul, "name"); +verifyProperty(Math.imul, "name", { + value: "imul", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/imul/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/imul/not-a-constructor.js index 000f83ab72..ab5492a6f7 100644 --- a/js/src/tests/test262/built-ins/Math/imul/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/imul/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.imul), false, 'isConstructor(Math.imul) must assert.throws(TypeError, () => { new Math.imul(); -}, '`new Math.imul()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/log/length.js b/js/src/tests/test262/built-ins/Math/log/length.js index e23e758bff..b25b3f7771 100644 --- a/js/src/tests/test262/built-ins/Math/log/length.js +++ b/js/src/tests/test262/built-ins/Math/log/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.log.length, 1); - -verifyNotEnumerable(Math.log, "length"); -verifyNotWritable(Math.log, "length"); -verifyConfigurable(Math.log, "length"); +verifyProperty(Math.log, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/log/name.js b/js/src/tests/test262/built-ins/Math/log/name.js index 35009aa9d3..9822c1d027 100644 --- a/js/src/tests/test262/built-ins/Math/log/name.js +++ b/js/src/tests/test262/built-ins/Math/log/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.log.name, "log"); - -verifyNotEnumerable(Math.log, "name"); -verifyNotWritable(Math.log, "name"); -verifyConfigurable(Math.log, "name"); +verifyProperty(Math.log, "name", { + value: "log", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/log/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/log/not-a-constructor.js index 2fe1ae7ee6..a0849c7b30 100644 --- a/js/src/tests/test262/built-ins/Math/log/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/log/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.log), false, 'isConstructor(Math.log) must r assert.throws(TypeError, () => { new Math.log(); -}, '`new Math.log()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/log10/length.js b/js/src/tests/test262/built-ins/Math/log10/length.js index 679d3f0b62..b7a2e430ee 100644 --- a/js/src/tests/test262/built-ins/Math/log10/length.js +++ b/js/src/tests/test262/built-ins/Math/log10/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.log10.length, 1); - -verifyNotEnumerable(Math.log10, "length"); -verifyNotWritable(Math.log10, "length"); -verifyConfigurable(Math.log10, "length"); +verifyProperty(Math.log10, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/log10/name.js b/js/src/tests/test262/built-ins/Math/log10/name.js index a41195533b..b717455f0e 100644 --- a/js/src/tests/test262/built-ins/Math/log10/name.js +++ b/js/src/tests/test262/built-ins/Math/log10/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.log10.name, "log10"); - -verifyNotEnumerable(Math.log10, "name"); -verifyNotWritable(Math.log10, "name"); -verifyConfigurable(Math.log10, "name"); +verifyProperty(Math.log10, "name", { + value: "log10", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/log10/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/log10/not-a-constructor.js index aacc516ebf..9422c777f0 100644 --- a/js/src/tests/test262/built-ins/Math/log10/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/log10/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.log10), false, 'isConstructor(Math.log10) mu assert.throws(TypeError, () => { new Math.log10(); -}, '`new Math.log10()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/log1p/length.js b/js/src/tests/test262/built-ins/Math/log1p/length.js index 40327f636c..51dbc6d86f 100644 --- a/js/src/tests/test262/built-ins/Math/log1p/length.js +++ b/js/src/tests/test262/built-ins/Math/log1p/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.log1p.length, 1); - -verifyNotEnumerable(Math.log1p, "length"); -verifyNotWritable(Math.log1p, "length"); -verifyConfigurable(Math.log1p, "length"); +verifyProperty(Math.log1p, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/log1p/name.js b/js/src/tests/test262/built-ins/Math/log1p/name.js index 9287af89ed..de9e469c0a 100644 --- a/js/src/tests/test262/built-ins/Math/log1p/name.js +++ b/js/src/tests/test262/built-ins/Math/log1p/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.log1p.name, "log1p"); - -verifyNotEnumerable(Math.log1p, "name"); -verifyNotWritable(Math.log1p, "name"); -verifyConfigurable(Math.log1p, "name"); +verifyProperty(Math.log1p, "name", { + value: "log1p", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/log1p/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/log1p/not-a-constructor.js index f89122aac0..fd3e9d10d8 100644 --- a/js/src/tests/test262/built-ins/Math/log1p/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/log1p/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.log1p), false, 'isConstructor(Math.log1p) mu assert.throws(TypeError, () => { new Math.log1p(); -}, '`new Math.log1p()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/log2/length.js b/js/src/tests/test262/built-ins/Math/log2/length.js index 4763011f45..0ba4c00ece 100644 --- a/js/src/tests/test262/built-ins/Math/log2/length.js +++ b/js/src/tests/test262/built-ins/Math/log2/length.js @@ -21,10 +21,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.log2.length, 1); - -verifyNotEnumerable(Math.log2, "length"); -verifyNotWritable(Math.log2, "length"); -verifyConfigurable(Math.log2, "length"); +verifyProperty(Math.log2, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/log2/name.js b/js/src/tests/test262/built-ins/Math/log2/name.js index 33af36ac29..1c2adc899f 100644 --- a/js/src/tests/test262/built-ins/Math/log2/name.js +++ b/js/src/tests/test262/built-ins/Math/log2/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.log2.name, "log2"); - -verifyNotEnumerable(Math.log2, "name"); -verifyNotWritable(Math.log2, "name"); -verifyConfigurable(Math.log2, "name"); +verifyProperty(Math.log2, "name", { + value: "log2", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/log2/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/log2/not-a-constructor.js index 1a40c155c9..6e28337931 100644 --- a/js/src/tests/test262/built-ins/Math/log2/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/log2/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.log2), false, 'isConstructor(Math.log2) must assert.throws(TypeError, () => { new Math.log2(); -}, '`new Math.log2()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/max/length.js b/js/src/tests/test262/built-ins/Math/max/length.js index a985231596..bd0ca09841 100644 --- a/js/src/tests/test262/built-ins/Math/max/length.js +++ b/js/src/tests/test262/built-ins/Math/max/length.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.max.length, 2); - -verifyNotEnumerable(Math.max, "length"); -verifyNotWritable(Math.max, "length"); -verifyConfigurable(Math.max, "length"); +verifyProperty(Math.max, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/max/name.js b/js/src/tests/test262/built-ins/Math/max/name.js index 2078d602bb..c989c92d5c 100644 --- a/js/src/tests/test262/built-ins/Math/max/name.js +++ b/js/src/tests/test262/built-ins/Math/max/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.max.name, "max"); - -verifyNotEnumerable(Math.max, "name"); -verifyNotWritable(Math.max, "name"); -verifyConfigurable(Math.max, "name"); +verifyProperty(Math.max, "name", { + value: "max", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/max/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/max/not-a-constructor.js index 36e92c627c..4215e7f87a 100644 --- a/js/src/tests/test262/built-ins/Math/max/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/max/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.max), false, 'isConstructor(Math.max) must r assert.throws(TypeError, () => { new Math.max(); -}, '`new Math.max()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/min/length.js b/js/src/tests/test262/built-ins/Math/min/length.js index 65706dd110..262d9ee601 100644 --- a/js/src/tests/test262/built-ins/Math/min/length.js +++ b/js/src/tests/test262/built-ins/Math/min/length.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.min.length, 2); - -verifyNotEnumerable(Math.min, "length"); -verifyNotWritable(Math.min, "length"); -verifyConfigurable(Math.min, "length"); +verifyProperty(Math.min, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/min/name.js b/js/src/tests/test262/built-ins/Math/min/name.js index 2fc9c3d206..27cfaa9fc7 100644 --- a/js/src/tests/test262/built-ins/Math/min/name.js +++ b/js/src/tests/test262/built-ins/Math/min/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.min.name, "min"); - -verifyNotEnumerable(Math.min, "name"); -verifyNotWritable(Math.min, "name"); -verifyConfigurable(Math.min, "name"); +verifyProperty(Math.min, "name", { + value: "min", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/min/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/min/not-a-constructor.js index 24fca032af..7c0d13c7d3 100644 --- a/js/src/tests/test262/built-ins/Math/min/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/min/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.min), false, 'isConstructor(Math.min) must r assert.throws(TypeError, () => { new Math.min(); -}, '`new Math.min()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/pow/length.js b/js/src/tests/test262/built-ins/Math/pow/length.js index 0ac918c8fb..a5023e7f7c 100644 --- a/js/src/tests/test262/built-ins/Math/pow/length.js +++ b/js/src/tests/test262/built-ins/Math/pow/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.pow.length, 2); - -verifyNotEnumerable(Math.pow, "length"); -verifyNotWritable(Math.pow, "length"); -verifyConfigurable(Math.pow, "length"); +verifyProperty(Math.pow, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/pow/name.js b/js/src/tests/test262/built-ins/Math/pow/name.js index c0caa2c9ad..894ad33926 100644 --- a/js/src/tests/test262/built-ins/Math/pow/name.js +++ b/js/src/tests/test262/built-ins/Math/pow/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.pow.name, "pow"); - -verifyNotEnumerable(Math.pow, "name"); -verifyNotWritable(Math.pow, "name"); -verifyConfigurable(Math.pow, "name"); +verifyProperty(Math.pow, "name", { + value: "pow", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/pow/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/pow/not-a-constructor.js index 00ba4261fc..48510fd0ca 100644 --- a/js/src/tests/test262/built-ins/Math/pow/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/pow/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.pow), false, 'isConstructor(Math.pow) must r assert.throws(TypeError, () => { new Math.pow(); -}, '`new Math.pow()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/random/length.js b/js/src/tests/test262/built-ins/Math/random/length.js index 21c8e5304f..ef8d3ae4d7 100644 --- a/js/src/tests/test262/built-ins/Math/random/length.js +++ b/js/src/tests/test262/built-ins/Math/random/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.random.length, 0); - -verifyNotEnumerable(Math.random, "length"); -verifyNotWritable(Math.random, "length"); -verifyConfigurable(Math.random, "length"); +verifyProperty(Math.random, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/random/name.js b/js/src/tests/test262/built-ins/Math/random/name.js index a6f983e5bc..ebf19e54fd 100644 --- a/js/src/tests/test262/built-ins/Math/random/name.js +++ b/js/src/tests/test262/built-ins/Math/random/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.random.name, "random"); - -verifyNotEnumerable(Math.random, "name"); -verifyNotWritable(Math.random, "name"); -verifyConfigurable(Math.random, "name"); +verifyProperty(Math.random, "name", { + value: "random", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/random/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/random/not-a-constructor.js index 8160a93744..274e66fe72 100644 --- a/js/src/tests/test262/built-ins/Math/random/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/random/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.random), false, 'isConstructor(Math.random) assert.throws(TypeError, () => { new Math.random(); -}, '`new Math.random()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/round/length.js b/js/src/tests/test262/built-ins/Math/round/length.js index 262c1ddebf..469492aa55 100644 --- a/js/src/tests/test262/built-ins/Math/round/length.js +++ b/js/src/tests/test262/built-ins/Math/round/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.round.length, 1); - -verifyNotEnumerable(Math.round, "length"); -verifyNotWritable(Math.round, "length"); -verifyConfigurable(Math.round, "length"); +verifyProperty(Math.round, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/round/name.js b/js/src/tests/test262/built-ins/Math/round/name.js index d1e21d7be4..5b6877e93e 100644 --- a/js/src/tests/test262/built-ins/Math/round/name.js +++ b/js/src/tests/test262/built-ins/Math/round/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.round.name, "round"); - -verifyNotEnumerable(Math.round, "name"); -verifyNotWritable(Math.round, "name"); -verifyConfigurable(Math.round, "name"); +verifyProperty(Math.round, "name", { + value: "round", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/round/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/round/not-a-constructor.js index 45996875c4..9fbb4b5551 100644 --- a/js/src/tests/test262/built-ins/Math/round/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/round/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.round), false, 'isConstructor(Math.round) mu assert.throws(TypeError, () => { new Math.round(); -}, '`new Math.round()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/sign/length.js b/js/src/tests/test262/built-ins/Math/sign/length.js index 2d172bfaaa..f9beec1cec 100644 --- a/js/src/tests/test262/built-ins/Math/sign/length.js +++ b/js/src/tests/test262/built-ins/Math/sign/length.js @@ -18,10 +18,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.sign.length, 1); - -verifyNotEnumerable(Math.sign, "length"); -verifyNotWritable(Math.sign, "length"); -verifyConfigurable(Math.sign, "length"); +verifyProperty(Math.sign, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/sign/name.js b/js/src/tests/test262/built-ins/Math/sign/name.js index f706d18562..40aa1cc520 100644 --- a/js/src/tests/test262/built-ins/Math/sign/name.js +++ b/js/src/tests/test262/built-ins/Math/sign/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.sign.name, "sign"); - -verifyNotEnumerable(Math.sign, "name"); -verifyNotWritable(Math.sign, "name"); -verifyConfigurable(Math.sign, "name"); +verifyProperty(Math.sign, "name", { + value: "sign", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/sign/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/sign/not-a-constructor.js index 73a8f9f7d9..767ea490d7 100644 --- a/js/src/tests/test262/built-ins/Math/sign/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/sign/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.sign), false, 'isConstructor(Math.sign) must assert.throws(TypeError, () => { new Math.sign(); -}, '`new Math.sign()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/sin/length.js b/js/src/tests/test262/built-ins/Math/sin/length.js index 887df3bb9d..13e8ad33da 100644 --- a/js/src/tests/test262/built-ins/Math/sin/length.js +++ b/js/src/tests/test262/built-ins/Math/sin/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.sin.length, 1); - -verifyNotEnumerable(Math.sin, "length"); -verifyNotWritable(Math.sin, "length"); -verifyConfigurable(Math.sin, "length"); +verifyProperty(Math.sin, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/sin/name.js b/js/src/tests/test262/built-ins/Math/sin/name.js index af0bb7c8a9..d782c0811d 100644 --- a/js/src/tests/test262/built-ins/Math/sin/name.js +++ b/js/src/tests/test262/built-ins/Math/sin/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.sin.name, "sin"); - -verifyNotEnumerable(Math.sin, "name"); -verifyNotWritable(Math.sin, "name"); -verifyConfigurable(Math.sin, "name"); +verifyProperty(Math.sin, "name", { + value: "sin", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/sin/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/sin/not-a-constructor.js index fec296dc85..f894c39841 100644 --- a/js/src/tests/test262/built-ins/Math/sin/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/sin/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.sin), false, 'isConstructor(Math.sin) must r assert.throws(TypeError, () => { new Math.sin(); -}, '`new Math.sin()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/sinh/length.js b/js/src/tests/test262/built-ins/Math/sinh/length.js index 5071e9cc11..4da8f31e8f 100644 --- a/js/src/tests/test262/built-ins/Math/sinh/length.js +++ b/js/src/tests/test262/built-ins/Math/sinh/length.js @@ -18,10 +18,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.sinh.length, 1); - -verifyNotEnumerable(Math.sinh, "length"); -verifyNotWritable(Math.sinh, "length"); -verifyConfigurable(Math.sinh, "length"); +verifyProperty(Math.sinh, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/sinh/name.js b/js/src/tests/test262/built-ins/Math/sinh/name.js index b2bb918e69..2561b33ef6 100644 --- a/js/src/tests/test262/built-ins/Math/sinh/name.js +++ b/js/src/tests/test262/built-ins/Math/sinh/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.sinh.name, "sinh"); - -verifyNotEnumerable(Math.sinh, "name"); -verifyNotWritable(Math.sinh, "name"); -verifyConfigurable(Math.sinh, "name"); +verifyProperty(Math.sinh, "name", { + value: "sinh", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/sinh/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/sinh/not-a-constructor.js index 9a5ff08bf7..cd892411b4 100644 --- a/js/src/tests/test262/built-ins/Math/sinh/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/sinh/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.sinh), false, 'isConstructor(Math.sinh) must assert.throws(TypeError, () => { new Math.sinh(); -}, '`new Math.sinh()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/sqrt/length.js b/js/src/tests/test262/built-ins/Math/sqrt/length.js index 566bbf47b5..ebc36e2be8 100644 --- a/js/src/tests/test262/built-ins/Math/sqrt/length.js +++ b/js/src/tests/test262/built-ins/Math/sqrt/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.sqrt.length, 1); - -verifyNotEnumerable(Math.sqrt, "length"); -verifyNotWritable(Math.sqrt, "length"); -verifyConfigurable(Math.sqrt, "length"); +verifyProperty(Math.sqrt, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/sqrt/name.js b/js/src/tests/test262/built-ins/Math/sqrt/name.js index 0cca2fc7af..5278d51fd5 100644 --- a/js/src/tests/test262/built-ins/Math/sqrt/name.js +++ b/js/src/tests/test262/built-ins/Math/sqrt/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.sqrt.name, "sqrt"); - -verifyNotEnumerable(Math.sqrt, "name"); -verifyNotWritable(Math.sqrt, "name"); -verifyConfigurable(Math.sqrt, "name"); +verifyProperty(Math.sqrt, "name", { + value: "sqrt", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/sqrt/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/sqrt/not-a-constructor.js index e40a2f5d55..599020a14b 100644 --- a/js/src/tests/test262/built-ins/Math/sqrt/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/sqrt/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.sqrt), false, 'isConstructor(Math.sqrt) must assert.throws(TypeError, () => { new Math.sqrt(); -}, '`new Math.sqrt()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/tan/length.js b/js/src/tests/test262/built-ins/Math/tan/length.js index 0915527693..7a21afa332 100644 --- a/js/src/tests/test262/built-ins/Math/tan/length.js +++ b/js/src/tests/test262/built-ins/Math/tan/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.tan.length, 1); - -verifyNotEnumerable(Math.tan, "length"); -verifyNotWritable(Math.tan, "length"); -verifyConfigurable(Math.tan, "length"); +verifyProperty(Math.tan, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/tan/name.js b/js/src/tests/test262/built-ins/Math/tan/name.js index e1f3e188d2..25bed1b1e1 100644 --- a/js/src/tests/test262/built-ins/Math/tan/name.js +++ b/js/src/tests/test262/built-ins/Math/tan/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.tan.name, "tan"); - -verifyNotEnumerable(Math.tan, "name"); -verifyNotWritable(Math.tan, "name"); -verifyConfigurable(Math.tan, "name"); +verifyProperty(Math.tan, "name", { + value: "tan", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/tan/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/tan/not-a-constructor.js index ea79382a35..f57677cac0 100644 --- a/js/src/tests/test262/built-ins/Math/tan/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/tan/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.tan), false, 'isConstructor(Math.tan) must r assert.throws(TypeError, () => { new Math.tan(); -}, '`new Math.tan()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/tanh/length.js b/js/src/tests/test262/built-ins/Math/tanh/length.js index 7af2c89df5..da3e9f2cd4 100644 --- a/js/src/tests/test262/built-ins/Math/tanh/length.js +++ b/js/src/tests/test262/built-ins/Math/tanh/length.js @@ -18,10 +18,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.tanh.length, 1); - -verifyNotEnumerable(Math.tanh, "length"); -verifyNotWritable(Math.tanh, "length"); -verifyConfigurable(Math.tanh, "length"); +verifyProperty(Math.tanh, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/tanh/name.js b/js/src/tests/test262/built-ins/Math/tanh/name.js index af77bcfae0..9108cd0980 100644 --- a/js/src/tests/test262/built-ins/Math/tanh/name.js +++ b/js/src/tests/test262/built-ins/Math/tanh/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.tanh.name, "tanh"); - -verifyNotEnumerable(Math.tanh, "name"); -verifyNotWritable(Math.tanh, "name"); -verifyConfigurable(Math.tanh, "name"); +verifyProperty(Math.tanh, "name", { + value: "tanh", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/tanh/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/tanh/not-a-constructor.js index 7f4914d650..80b8d74407 100644 --- a/js/src/tests/test262/built-ins/Math/tanh/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/tanh/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.tanh), false, 'isConstructor(Math.tanh) must assert.throws(TypeError, () => { new Math.tanh(); -}, '`new Math.tanh()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/trunc/length.js b/js/src/tests/test262/built-ins/Math/trunc/length.js index 593f893d82..0c716e41c9 100644 --- a/js/src/tests/test262/built-ins/Math/trunc/length.js +++ b/js/src/tests/test262/built-ins/Math/trunc/length.js @@ -18,10 +18,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.trunc.length, 1); - -verifyNotEnumerable(Math.trunc, "length"); -verifyNotWritable(Math.trunc, "length"); -verifyConfigurable(Math.trunc, "length"); +verifyProperty(Math.trunc, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/trunc/name.js b/js/src/tests/test262/built-ins/Math/trunc/name.js index 25f8a0cc3c..c351b444f3 100644 --- a/js/src/tests/test262/built-ins/Math/trunc/name.js +++ b/js/src/tests/test262/built-ins/Math/trunc/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Math.trunc.name, "trunc"); - -verifyNotEnumerable(Math.trunc, "name"); -verifyNotWritable(Math.trunc, "name"); -verifyConfigurable(Math.trunc, "name"); +verifyProperty(Math.trunc, "name", { + value: "trunc", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Math/trunc/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/trunc/not-a-constructor.js index 1a55c671b4..3c928d695c 100644 --- a/js/src/tests/test262/built-ins/Math/trunc/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Math/trunc/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Math.trunc), false, 'isConstructor(Math.trunc) mu assert.throws(TypeError, () => { new Math.trunc(); -}, '`new Math.trunc()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/length.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/length.js index 4e6a6863d0..dec081fb67 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/EvalError/length.js +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/length.js @@ -25,10 +25,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(EvalError.length, 1); - -verifyNotEnumerable(EvalError, "length"); -verifyNotWritable(EvalError, "length"); -verifyConfigurable(EvalError, "length"); +verifyProperty(EvalError, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/name.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/name.js index d36e58bf73..66806a0cc2 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/EvalError/name.js +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/name.js @@ -17,10 +17,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(EvalError.name, "EvalError"); - -verifyNotEnumerable(EvalError, "name"); -verifyNotWritable(EvalError, "name"); -verifyConfigurable(EvalError, "name"); +verifyProperty(EvalError, "name", { + value: "EvalError", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/name.js b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/name.js index 7075febda1..2f26093788 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/name.js +++ b/js/src/tests/test262/built-ins/NativeErrors/EvalError/prototype/name.js @@ -17,10 +17,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(EvalError.prototype.name, "EvalError"); - -verifyNotEnumerable(EvalError.prototype, "name"); -verifyWritable(EvalError.prototype, "name"); -verifyConfigurable(EvalError.prototype, "name"); +verifyProperty(EvalError.prototype, "name", { + value: "EvalError", + writable: true, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/length.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/length.js index ce9f6d7f13..93ea9f0f51 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/RangeError/length.js +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/length.js @@ -25,10 +25,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(RangeError.length, 1); - -verifyNotEnumerable(RangeError, "length"); -verifyNotWritable(RangeError, "length"); -verifyConfigurable(RangeError, "length"); +verifyProperty(RangeError, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/name.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/name.js index 621b07684c..5e78532fd4 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/RangeError/name.js +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/name.js @@ -17,10 +17,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(RangeError.name, "RangeError"); - -verifyNotEnumerable(RangeError, "name"); -verifyNotWritable(RangeError, "name"); -verifyConfigurable(RangeError, "name"); +verifyProperty(RangeError, "name", { + value: "RangeError", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/name.js b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/name.js index 24d76f4949..1aa3f5ddc4 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/name.js +++ b/js/src/tests/test262/built-ins/NativeErrors/RangeError/prototype/name.js @@ -17,10 +17,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(RangeError.prototype.name, "RangeError"); - -verifyNotEnumerable(RangeError.prototype, "name"); -verifyWritable(RangeError.prototype, "name"); -verifyConfigurable(RangeError.prototype, "name"); +verifyProperty(RangeError.prototype, "name", { + value: "RangeError", + writable: true, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/length.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/length.js index 5a3f07d497..53554565a8 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/length.js +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/length.js @@ -25,10 +25,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(ReferenceError.length, 1); - -verifyNotEnumerable(ReferenceError, "length"); -verifyNotWritable(ReferenceError, "length"); -verifyConfigurable(ReferenceError, "length"); +verifyProperty(ReferenceError, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/name.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/name.js index 66b0a39351..3ae0c668bb 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/name.js +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/name.js @@ -17,10 +17,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(ReferenceError.name, "ReferenceError"); - -verifyNotEnumerable(ReferenceError, "name"); -verifyNotWritable(ReferenceError, "name"); -verifyConfigurable(ReferenceError, "name"); +verifyProperty(ReferenceError, "name", { + value: "ReferenceError", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/name.js b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/name.js index 563ec73485..5dd7915880 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/name.js +++ b/js/src/tests/test262/built-ins/NativeErrors/ReferenceError/prototype/name.js @@ -17,10 +17,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(ReferenceError.prototype.name, "ReferenceError"); - -verifyNotEnumerable(ReferenceError.prototype, "name"); -verifyWritable(ReferenceError.prototype, "name"); -verifyConfigurable(ReferenceError.prototype, "name"); +verifyProperty(ReferenceError.prototype, "name", { + value: "ReferenceError", + writable: true, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/length.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/length.js index 555a5c1529..af34ff86fd 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/length.js +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/length.js @@ -25,10 +25,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(SyntaxError.length, 1); - -verifyNotEnumerable(SyntaxError, "length"); -verifyNotWritable(SyntaxError, "length"); -verifyConfigurable(SyntaxError, "length"); +verifyProperty(SyntaxError, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/name.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/name.js index f70899d0fc..d252a6408f 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/name.js +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/name.js @@ -17,10 +17,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(SyntaxError.name, "SyntaxError"); - -verifyNotEnumerable(SyntaxError, "name"); -verifyNotWritable(SyntaxError, "name"); -verifyConfigurable(SyntaxError, "name"); +verifyProperty(SyntaxError, "name", { + value: "SyntaxError", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/name.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/name.js index 8f80d797ba..9cd63f7ecd 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/name.js +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/name.js @@ -17,10 +17,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(SyntaxError.prototype.name, "SyntaxError"); - -verifyNotEnumerable(SyntaxError.prototype, "name"); -verifyWritable(SyntaxError.prototype, "name"); -verifyConfigurable(SyntaxError.prototype, "name"); +verifyProperty(SyntaxError.prototype, "name", { + value: "SyntaxError", + writable: true, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/length.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/length.js index c84b02708e..f4ca973dac 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/TypeError/length.js +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/length.js @@ -25,10 +25,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(TypeError.length, 1); - -verifyNotEnumerable(TypeError, "length"); -verifyNotWritable(TypeError, "length"); -verifyConfigurable(TypeError, "length"); +verifyProperty(TypeError, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/name.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/name.js index ede2f73af9..8af9b919b1 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/TypeError/name.js +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/name.js @@ -17,10 +17,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(TypeError.name, "TypeError"); - -verifyNotEnumerable(TypeError, "name"); -verifyNotWritable(TypeError, "name"); -verifyConfigurable(TypeError, "name"); +verifyProperty(TypeError, "name", { + value: "TypeError", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/name.js b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/name.js index c0c0531ff2..04d94af79a 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/name.js +++ b/js/src/tests/test262/built-ins/NativeErrors/TypeError/prototype/name.js @@ -17,10 +17,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(TypeError.prototype.name, "TypeError"); - -verifyNotEnumerable(TypeError.prototype, "name"); -verifyWritable(TypeError.prototype, "name"); -verifyConfigurable(TypeError.prototype, "name"); +verifyProperty(TypeError.prototype, "name", { + value: "TypeError", + writable: true, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/length.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/length.js index 5f645e5ecd..1ec6826200 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/URIError/length.js +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/length.js @@ -25,10 +25,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(URIError.length, 1); - -verifyNotEnumerable(URIError, "length"); -verifyNotWritable(URIError, "length"); -verifyConfigurable(URIError, "length"); +verifyProperty(URIError, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/name.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/name.js index ef912a466b..4c247f0c96 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/URIError/name.js +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/name.js @@ -17,10 +17,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(URIError.name, "URIError"); - -verifyNotEnumerable(URIError, "name"); -verifyNotWritable(URIError, "name"); -verifyConfigurable(URIError, "name"); +verifyProperty(URIError, "name", { + value: "URIError", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/name.js b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/name.js index 3a8b5a369e..f1d24483c4 100644 --- a/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/name.js +++ b/js/src/tests/test262/built-ins/NativeErrors/URIError/prototype/name.js @@ -17,10 +17,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(URIError.prototype.name, "URIError"); - -verifyNotEnumerable(URIError.prototype, "name"); -verifyWritable(URIError.prototype, "name"); -verifyConfigurable(URIError.prototype, "name"); +verifyProperty(URIError.prototype, "name", { + value: "URIError", + writable: true, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isFinite/length.js b/js/src/tests/test262/built-ins/Number/isFinite/length.js index 474fcb877f..f2130d61f8 100644 --- a/js/src/tests/test262/built-ins/Number/isFinite/length.js +++ b/js/src/tests/test262/built-ins/Number/isFinite/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.isFinite.length, 1); - -verifyNotEnumerable(Number.isFinite, "length"); -verifyNotWritable(Number.isFinite, "length"); -verifyConfigurable(Number.isFinite, "length"); +verifyProperty(Number.isFinite, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isFinite/name.js b/js/src/tests/test262/built-ins/Number/isFinite/name.js index 61abe6571a..ce0c2b2e11 100644 --- a/js/src/tests/test262/built-ins/Number/isFinite/name.js +++ b/js/src/tests/test262/built-ins/Number/isFinite/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.isFinite.name, "isFinite"); - -verifyNotEnumerable(Number.isFinite, "name"); -verifyNotWritable(Number.isFinite, "name"); -verifyConfigurable(Number.isFinite, "name"); +verifyProperty(Number.isFinite, "name", { + value: "isFinite", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isFinite/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/isFinite/not-a-constructor.js index 4e42a62e9b..6a97ffb93d 100644 --- a/js/src/tests/test262/built-ins/Number/isFinite/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Number/isFinite/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Number.isFinite), false, 'isConstructor(Number.is assert.throws(TypeError, () => { new Number.isFinite(); -}, '`new Number.isFinite()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isInteger/length.js b/js/src/tests/test262/built-ins/Number/isInteger/length.js index 99bd2d168f..216ee2960a 100644 --- a/js/src/tests/test262/built-ins/Number/isInteger/length.js +++ b/js/src/tests/test262/built-ins/Number/isInteger/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.isInteger.length, 1); - -verifyNotEnumerable(Number.isInteger, "length"); -verifyNotWritable(Number.isInteger, "length"); -verifyConfigurable(Number.isInteger, "length"); +verifyProperty(Number.isInteger, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isInteger/name.js b/js/src/tests/test262/built-ins/Number/isInteger/name.js index 224c94dba9..755e55d2eb 100644 --- a/js/src/tests/test262/built-ins/Number/isInteger/name.js +++ b/js/src/tests/test262/built-ins/Number/isInteger/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.isInteger.name, "isInteger"); - -verifyNotEnumerable(Number.isInteger, "name"); -verifyNotWritable(Number.isInteger, "name"); -verifyConfigurable(Number.isInteger, "name"); +verifyProperty(Number.isInteger, "name", { + value: "isInteger", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isInteger/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/isInteger/not-a-constructor.js index 2dad2e9df7..9c06c58ad3 100644 --- a/js/src/tests/test262/built-ins/Number/isInteger/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Number/isInteger/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Number.isInteger), false, 'isConstructor(Number.i assert.throws(TypeError, () => { new Number.isInteger(); -}, '`new Number.isInteger()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isNaN/length.js b/js/src/tests/test262/built-ins/Number/isNaN/length.js index 302e20edf9..b196887226 100644 --- a/js/src/tests/test262/built-ins/Number/isNaN/length.js +++ b/js/src/tests/test262/built-ins/Number/isNaN/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.isNaN.length, 1); - -verifyNotEnumerable(Number.isNaN, "length"); -verifyNotWritable(Number.isNaN, "length"); -verifyConfigurable(Number.isNaN, "length"); +verifyProperty(Number.isNaN, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isNaN/name.js b/js/src/tests/test262/built-ins/Number/isNaN/name.js index 4d97acdf97..caeb19ed3c 100644 --- a/js/src/tests/test262/built-ins/Number/isNaN/name.js +++ b/js/src/tests/test262/built-ins/Number/isNaN/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.isNaN.name, "isNaN"); - -verifyNotEnumerable(Number.isNaN, "name"); -verifyNotWritable(Number.isNaN, "name"); -verifyConfigurable(Number.isNaN, "name"); +verifyProperty(Number.isNaN, "name", { + value: "isNaN", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isNaN/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/isNaN/not-a-constructor.js index 482812547c..abca3f5a2e 100644 --- a/js/src/tests/test262/built-ins/Number/isNaN/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Number/isNaN/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Number.isNaN), false, 'isConstructor(Number.isNaN assert.throws(TypeError, () => { new Number.isNaN(); -}, '`new Number.isNaN()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/length.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/length.js index bcc7e6a770..10c28bd884 100644 --- a/js/src/tests/test262/built-ins/Number/isSafeInteger/length.js +++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.isSafeInteger.length, 1); - -verifyNotEnumerable(Number.isSafeInteger, "length"); -verifyNotWritable(Number.isSafeInteger, "length"); -verifyConfigurable(Number.isSafeInteger, "length"); +verifyProperty(Number.isSafeInteger, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/name.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/name.js index 3844d43e13..0e892691df 100644 --- a/js/src/tests/test262/built-ins/Number/isSafeInteger/name.js +++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.isSafeInteger.name, "isSafeInteger"); - -verifyNotEnumerable(Number.isSafeInteger, "name"); -verifyNotWritable(Number.isSafeInteger, "name"); -verifyConfigurable(Number.isSafeInteger, "name"); +verifyProperty(Number.isSafeInteger, "name", { + value: "isSafeInteger", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/isSafeInteger/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/isSafeInteger/not-a-constructor.js index dca11c9cd3..d1d73d7d26 100644 --- a/js/src/tests/test262/built-ins/Number/isSafeInteger/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Number/isSafeInteger/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Number.isSafeInteger), false, 'isConstructor(Numb assert.throws(TypeError, () => { new Number.isSafeInteger(); -}, '`new Number.isSafeInteger()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/parseFloat/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/parseFloat/not-a-constructor.js index b660870fa8..e35b21f6f0 100644 --- a/js/src/tests/test262/built-ins/Number/parseFloat/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Number/parseFloat/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Number.parseFloat), false, 'isConstructor(Number. assert.throws(TypeError, () => { new Number.parseFloat(); -}, '`new Number.parseFloat()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/parseInt/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/parseInt/not-a-constructor.js index 871e87adea..105aff520d 100644 --- a/js/src/tests/test262/built-ins/Number/parseInt/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Number/parseInt/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Number.parseInt), false, 'isConstructor(Number.pa assert.throws(TypeError, () => { new Number.parseInt(); -}, '`new Number.parseInt()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/length.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/length.js index 0c146d1500..2215b836a2 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/toExponential/length.js +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.prototype.toExponential.length, 1); - -verifyNotEnumerable(Number.prototype.toExponential, "length"); -verifyNotWritable(Number.prototype.toExponential, "length"); -verifyConfigurable(Number.prototype.toExponential, "length"); +verifyProperty(Number.prototype.toExponential, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/name.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/name.js index a92b59ba75..b7ab8380c0 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/toExponential/name.js +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.prototype.toExponential.name, "toExponential"); - -verifyNotEnumerable(Number.prototype.toExponential, "name"); -verifyNotWritable(Number.prototype.toExponential, "name"); -verifyConfigurable(Number.prototype.toExponential, "name"); +verifyProperty(Number.prototype.toExponential, "name", { + value: "toExponential", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toExponential/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/prototype/toExponential/not-a-constructor.js index bbf60fe972..6df8f0e848 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/toExponential/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Number/prototype/toExponential/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Number.prototype.toExponential(); -}, '`new Number.prototype.toExponential()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/length.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/length.js index 241a60ad57..4451f57b62 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/toFixed/length.js +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.prototype.toFixed.length, 1); - -verifyNotEnumerable(Number.prototype.toFixed, "length"); -verifyNotWritable(Number.prototype.toFixed, "length"); -verifyConfigurable(Number.prototype.toFixed, "length"); +verifyProperty(Number.prototype.toFixed, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/name.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/name.js index 49a7dbd1a5..3037d36cdb 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/toFixed/name.js +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.prototype.toFixed.name, "toFixed"); - -verifyNotEnumerable(Number.prototype.toFixed, "name"); -verifyNotWritable(Number.prototype.toFixed, "name"); -verifyConfigurable(Number.prototype.toFixed, "name"); +verifyProperty(Number.prototype.toFixed, "name", { + value: "toFixed", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toFixed/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/prototype/toFixed/not-a-constructor.js index 639cedbd85..bf196b8639 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/toFixed/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Number/prototype/toFixed/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Number.prototype.toFixed(); -}, '`new Number.prototype.toFixed()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/length.js b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/length.js index 0692c33edd..b2cefae1af 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/length.js +++ b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.prototype.toLocaleString.length, 0); - -verifyNotEnumerable(Number.prototype.toLocaleString, "length"); -verifyNotWritable(Number.prototype.toLocaleString, "length"); -verifyConfigurable(Number.prototype.toLocaleString, "length"); +verifyProperty(Number.prototype.toLocaleString, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/name.js b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/name.js index 35f6b9a62b..9f6cfa7f26 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/name.js +++ b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.prototype.toLocaleString.name, "toLocaleString"); - -verifyNotEnumerable(Number.prototype.toLocaleString, "name"); -verifyNotWritable(Number.prototype.toLocaleString, "name"); -verifyConfigurable(Number.prototype.toLocaleString, "name"); +verifyProperty(Number.prototype.toLocaleString, "name", { + value: "toLocaleString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/not-a-constructor.js index d694532dcf..51ed09a33c 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Number/prototype/toLocaleString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Number.prototype.toLocaleString(); -}, '`new Number.prototype.toLocaleString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/length.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/length.js index a5cecd54d3..d0b018aedb 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/length.js +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.prototype.toPrecision.length, 1); - -verifyNotEnumerable(Number.prototype.toPrecision, "length"); -verifyNotWritable(Number.prototype.toPrecision, "length"); -verifyConfigurable(Number.prototype.toPrecision, "length"); +verifyProperty(Number.prototype.toPrecision, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/name.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/name.js index 946c5ad308..61096abd77 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/name.js +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.prototype.toPrecision.name, "toPrecision"); - -verifyNotEnumerable(Number.prototype.toPrecision, "name"); -verifyNotWritable(Number.prototype.toPrecision, "name"); -verifyConfigurable(Number.prototype.toPrecision, "name"); +verifyProperty(Number.prototype.toPrecision, "name", { + value: "toPrecision", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/not-a-constructor.js index 5424e12b7e..bcb3e378b7 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/toPrecision/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Number/prototype/toPrecision/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Number.prototype.toPrecision(); -}, '`new Number.prototype.toPrecision()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/length.js b/js/src/tests/test262/built-ins/Number/prototype/toString/length.js index 0c57733f13..9d158f0677 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/toString/length.js +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.prototype.toString.length, 1); - -verifyNotEnumerable(Number.prototype.toString, "length"); -verifyNotWritable(Number.prototype.toString, "length"); -verifyConfigurable(Number.prototype.toString, "length"); +verifyProperty(Number.prototype.toString, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/name.js b/js/src/tests/test262/built-ins/Number/prototype/toString/name.js index 5072c7993b..2d6a750ca4 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/toString/name.js +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.prototype.toString.name, "toString"); - -verifyNotEnumerable(Number.prototype.toString, "name"); -verifyNotWritable(Number.prototype.toString, "name"); -verifyConfigurable(Number.prototype.toString, "name"); +verifyProperty(Number.prototype.toString, "name", { + value: "toString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/prototype/toString/not-a-constructor.js index e7f1f2ae77..9e5d5bb81d 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/toString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Number/prototype/toString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Number.prototype.toString(); -}, '`new Number.prototype.toString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/valueOf/length.js b/js/src/tests/test262/built-ins/Number/prototype/valueOf/length.js index 65a31127ff..57f56a4d2e 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/valueOf/length.js +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.prototype.valueOf.length, 0); - -verifyNotEnumerable(Number.prototype.valueOf, "length"); -verifyNotWritable(Number.prototype.valueOf, "length"); -verifyConfigurable(Number.prototype.valueOf, "length"); +verifyProperty(Number.prototype.valueOf, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/valueOf/name.js b/js/src/tests/test262/built-ins/Number/prototype/valueOf/name.js index 8c1830f5fd..83e8a70334 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/valueOf/name.js +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Number.prototype.valueOf.name, "valueOf"); - -verifyNotEnumerable(Number.prototype.valueOf, "name"); -verifyNotWritable(Number.prototype.valueOf, "name"); -verifyConfigurable(Number.prototype.valueOf, "name"); +verifyProperty(Number.prototype.valueOf, "name", { + value: "valueOf", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Number/prototype/valueOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Number/prototype/valueOf/not-a-constructor.js index 5037924ce3..ff11f64c20 100644 --- a/js/src/tests/test262/built-ins/Number/prototype/valueOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Number/prototype/valueOf/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Number.prototype.valueOf(); -}, '`new Number.prototype.valueOf()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/assign/assign-descriptor.js b/js/src/tests/test262/built-ins/Object/assign/assign-descriptor.js index 5ee1c8216e..29f23b7b63 100644 --- a/js/src/tests/test262/built-ins/Object/assign/assign-descriptor.js +++ b/js/src/tests/test262/built-ins/Object/assign/assign-descriptor.js @@ -7,8 +7,10 @@ includes: [propertyHelper.js] es6id: 19.1.2.1 ---*/ -verifyWritable(Object, "assign"); -verifyNotEnumerable(Object, "assign"); -verifyConfigurable(Object, "assign"); +verifyProperty(Object, "assign", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/assign/assign-length.js b/js/src/tests/test262/built-ins/Object/assign/assign-length.js index bcfe2e2eda..600508b7b0 100644 --- a/js/src/tests/test262/built-ins/Object/assign/assign-length.js +++ b/js/src/tests/test262/built-ins/Object/assign/assign-length.js @@ -15,12 +15,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Object.assign.length, 2, "The length property of the assign method should be 2." -); - -verifyNotEnumerable(Object.assign, 'length'); -verifyNotWritable(Object.assign, 'length'); -verifyConfigurable(Object.assign, 'length'); +verifyProperty(Object.assign, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/assign/name.js b/js/src/tests/test262/built-ins/Object/assign/name.js index bab32445c2..c67ef4b8e0 100644 --- a/js/src/tests/test262/built-ins/Object/assign/name.js +++ b/js/src/tests/test262/built-ins/Object/assign/name.js @@ -19,14 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Object.assign.name, - 'assign', - 'The value of `Object.assign.name` is `"assign"`' -); - -verifyNotEnumerable(Object.assign, 'name'); -verifyNotWritable(Object.assign, 'name'); -verifyConfigurable(Object.assign, 'name'); +verifyProperty(Object.assign, "name", { + value: "assign", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/assign/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/assign/not-a-constructor.js index 3c66a4c64a..b94cd4b8e6 100644 --- a/js/src/tests/test262/built-ins/Object/assign/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/assign/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Object.assign), false, 'isConstructor(Object.assi assert.throws(TypeError, () => { new Object.assign({}); -}, '`new Object.assign({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-100.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-100.js index ed3a1d5d13..a0c715b273 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-100.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-100.js @@ -15,7 +15,8 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop"), "expected newObj to have 'prop'"); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-101.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-101.js index f325ce5059..4f2cd35373 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-101.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-101.js @@ -15,7 +15,8 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-103.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-103.js index 4da2d10566..811c119bc2 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-103.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-103.js @@ -26,7 +26,8 @@ var newObj = Object.create({}, { prop: descObj }); -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-104.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-104.js index b76ea8de8b..b5e01360a6 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-104.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-104.js @@ -29,7 +29,8 @@ var newObj = Object.create({}, { prop: descObj }); -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-107.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-107.js index 867a3f4e8c..8cdc1a6017 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-107.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-107.js @@ -28,7 +28,8 @@ var newObj = Object.create({}, { prop: descObj }); -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-108.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-108.js index 14d9da3a70..bab1b7a16b 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-108.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-108.js @@ -31,7 +31,8 @@ var newObj = Object.create({}, { prop: descObj }); -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-109.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-109.js index 8a38c3975e..20bf5a59cb 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-109.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-109.js @@ -19,7 +19,8 @@ var newObj = Object.create({}, { prop: descObj }); -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-110.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-110.js index 9ac2bcea84..60d6fdc53a 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-110.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-110.js @@ -29,7 +29,8 @@ var newObj = Object.create({}, { prop: descObj }); -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-111.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-111.js index e979fe76d7..0b46894531 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-111.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-111.js @@ -24,7 +24,8 @@ var newObj = Object.create({}, { prop: descObj }); -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-125.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-125.js index 17eef5947c..8687b5e1d0 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-125.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-125.js @@ -15,8 +15,8 @@ var newObj = Object.create({}, { } }); - -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-126.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-126.js index 489b57cf3e..42d3dddcee 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-126.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-126.js @@ -15,7 +15,8 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-128.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-128.js index 77cb2171ae..4e1669e5d4 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-128.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-128.js @@ -15,7 +15,8 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-129.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-129.js index 1cf82338ee..e16ee5219a 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-129.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-129.js @@ -15,7 +15,8 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-130.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-130.js index 30855dd7c6..2e8b5ebe33 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-130.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-130.js @@ -15,8 +15,8 @@ var newObj = Object.create({}, { } }); - -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-131.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-131.js index a27ff05e7e..6e86080eb6 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-131.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-131.js @@ -15,7 +15,8 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-132.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-132.js index 0f59a2aa10..00f9ef0d31 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-132.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-132.js @@ -15,7 +15,8 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-135.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-135.js index d6aef6ae19..a74ecda218 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-135.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-135.js @@ -15,7 +15,8 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-179.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-179.js index ceb1884864..e5df5e0c3d 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-179.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-179.js @@ -15,7 +15,9 @@ var newObj = Object.create({}, { } }); -assert.sameValue(newObj.prop, 100); -verifyNotWritable(newObj, "prop"); +verifyProperty(newObj, "prop", { + value: 100, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-188.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-188.js index 91d8c80a52..3d7c3d84f5 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-188.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-188.js @@ -22,7 +22,9 @@ var newObj = Object.create({}, { prop: descObj }); -assert.sameValue(newObj.prop, 100); -verifyNotWritable(newObj, "prop"); +verifyProperty(newObj, "prop", { + value: 100, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-189.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-189.js index 13f8a80bd2..a50b416503 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-189.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-189.js @@ -31,8 +31,9 @@ var newObj = Object.create({}, { prop: descObj }); -assert(newObj.hasOwnProperty("prop")) -assert.sameValue(typeof(newObj.prop), "undefined"); -verifyNotWritable(newObj, "prop"); +verifyProperty(newObj, "prop", { + value: undefined, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-190.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-190.js index 039dd3b032..28f3dfd9ff 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-190.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-190.js @@ -27,7 +27,9 @@ var newObj = Object.create({}, { prop: descObj }); -assert.sameValue(newObj.prop, 100); -verifyNotWritable(newObj, "prop"); +verifyProperty(newObj, "prop", { + value: 100, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-204.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-204.js index 17993ba415..c965df9186 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-204.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-204.js @@ -15,8 +15,9 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop")); -assert.sameValue(typeof newObj.prop, "undefined"); -verifyNotWritable(newObj, "prop"); +verifyProperty(newObj, "prop", { + value: undefined, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-205.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-205.js index 7e414aa5dd..960a0263ef 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-205.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-205.js @@ -15,8 +15,9 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop")); -assert.sameValue(typeof newObj.prop, "undefined"); -verifyNotWritable(newObj, "prop"); +verifyProperty(newObj, "prop", { + value: undefined, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-207.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-207.js index 40513388d8..c1b7043ec6 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-207.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-207.js @@ -15,8 +15,9 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop")); -assert.sameValue(typeof newObj.prop, "undefined"); -verifyNotWritable(newObj, "prop"); +verifyProperty(newObj, "prop", { + value: undefined, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-208.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-208.js index 864af6abf5..0e67c30cb8 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-208.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-208.js @@ -15,8 +15,9 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop")); -assert.sameValue(typeof newObj.prop, "undefined"); -verifyNotWritable(newObj, "prop"); +verifyProperty(newObj, "prop", { + value: undefined, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-209.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-209.js index 057ad51efe..135391d72e 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-209.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-209.js @@ -15,8 +15,9 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop")); -assert.sameValue(typeof newObj.prop, "undefined"); -verifyNotWritable(newObj, "prop"); +verifyProperty(newObj, "prop", { + value: undefined, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-210.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-210.js index d6ff45fb8c..6ec80189af 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-210.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-210.js @@ -15,8 +15,9 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop")) -assert.sameValue(typeof newObj.prop, "undefined"); -verifyNotWritable(newObj, "prop"); +verifyProperty(newObj, "prop", { + value: undefined, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-211.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-211.js index 84a03d23c3..bf6d20941e 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-211.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-211.js @@ -15,8 +15,9 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop")); -assert.sameValue(typeof newObj.prop, "undefined") -verifyNotWritable(newObj, "prop"); +verifyProperty(newObj, "prop", { + value: undefined, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-214.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-214.js index 209db64dda..e80e422d9d 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-214.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-214.js @@ -17,8 +17,9 @@ var newObj = Object.create({}, { prop: descObj }); -assert(newObj.hasOwnProperty("prop")) -assert.sameValue(typeof newObj.prop, "undefined"); -verifyNotWritable(newObj, "prop"); +verifyProperty(newObj, "prop", { + value: undefined, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-307.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-307.js index 02d1a9e465..0f969ae43b 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-307.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-307.js @@ -17,7 +17,8 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop")); -verifyNotWritable(newObj, "prop"); +verifyProperty(newObj, "prop", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-309.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-309.js index 41f48bb638..2977950c78 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-309.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-309.js @@ -18,7 +18,8 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-311.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-311.js index 169e7a69b9..a8c67f0b15 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-311.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-311.js @@ -7,6 +7,7 @@ description: > Object.create - [[Set]] is set as undefined if it is absent in accessor descriptor of one property in 'Properties' (8.12.9 step 4.b) +includes: [propertyHelper.js] ---*/ var newObj = Object.create({}, { @@ -27,21 +28,12 @@ if (newObj.prop === "verifyCreate") { verifyGet = true; } -var verifyEnumerable = false; -for (var p in newObj) { - if (p === "prop") { - verifyEnumerable = true; - } -} - -var verifyConfigurable = false; -var hasProperty = newObj.hasOwnProperty("prop"); -delete newObj.prop; -verifyConfigurable = !newObj.hasOwnProperty("prop") && hasProperty; - assert(verifySet, 'verifySet !== true'); assert(verifyGet, 'verifyGet !== true'); -assert(verifyEnumerable, 'verifyEnumerable !== true'); -assert(verifyConfigurable, 'verifyConfigurable !== true'); + +verifyProperty(newObj, "prop", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-313.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-313.js index b3b0299d4e..988d79ae82 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-313.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-313.js @@ -18,7 +18,8 @@ var newObj = Object.create({}, { } }); -assert(newObj.hasOwnProperty("prop")); -verifyNotConfigurable(newObj, "prop"); +verifyProperty(newObj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-315.js b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-315.js index 2c381680ce..5474af39cb 100644 --- a/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-315.js +++ b/js/src/tests/test262/built-ins/Object/create/15.2.3.5-4-315.js @@ -34,20 +34,20 @@ newObj = Object.create({}, { } }); -verifyEqualTo(newObj, "foo1", 200); - -verifyWritable(newObj, "foo1"); - -verifyEnumerable(newObj, "foo1"); - -verifyConfigurable(newObj, "foo1"); +verifyProperty(newObj, "foo1", { + value: 200, + writable: true, + enumerable: true, + configurable: true, +}); verifyEqualTo(newObj, "foo2", getFunc()); verifyWritable(newObj, "foo2", "setVerifyHelpProp"); -verifyEnumerable(newObj, "foo2"); - -verifyConfigurable(newObj, "foo2"); +verifyProperty(newObj, "foo2", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/name.js b/js/src/tests/test262/built-ins/Object/create/name.js index 63cfe5f126..3555fac0ab 100644 --- a/js/src/tests/test262/built-ins/Object/create/name.js +++ b/js/src/tests/test262/built-ins/Object/create/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.create.name, "create"); - -verifyNotEnumerable(Object.create, "name"); -verifyNotWritable(Object.create, "name"); -verifyConfigurable(Object.create, "name"); +verifyProperty(Object.create, "name", { + value: "create", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/create/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/create/not-a-constructor.js index 00efa6dc33..86e898b19a 100644 --- a/js/src/tests/test262/built-ins/Object/create/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/create/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Object.create), false, 'isConstructor(Object.crea assert.throws(TypeError, () => { new Object.create(null); -}, '`new Object.create(null)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-138.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-138.js index 1ca3793d7b..65fada01d7 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-138.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-138.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-139.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-139.js index f73e256111..a0522ec731 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-139.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-139.js @@ -17,6 +17,8 @@ Object.defineProperties(obj, { } }); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-140.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-140.js index 5e059a4a76..bc0aaee31f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-140.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-140.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-141.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-141.js index da71de2a5e..9be76bcecf 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-141.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-141.js @@ -24,7 +24,8 @@ Object.defineProperties(obj, { property: descObj }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-142.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-142.js index 226a32e614..7f68e3a3d3 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-142.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-142.js @@ -27,7 +27,8 @@ Object.defineProperties(obj, { property: descObj }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-143.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-143.js index 0336ed473b..e22d52d4f8 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-143.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-143.js @@ -35,7 +35,8 @@ Object.defineProperties(obj, { property: descObj }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-144.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-144.js index 1fc7a18431..db1f2541fd 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-144.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-144.js @@ -23,7 +23,8 @@ Object.defineProperties(obj, { property: descObj }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-146.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-146.js index 4cd423d4aa..c1bfdc8238 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-146.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-146.js @@ -31,7 +31,8 @@ Object.defineProperties(obj, { property: descObj }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-147.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-147.js index 8d1b4a1b50..a6a0dc8021 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-147.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-147.js @@ -35,7 +35,8 @@ Object.defineProperties(obj, { property: descObj }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-148.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-148.js index 63cb98e814..393b64d1bf 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-148.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-148.js @@ -21,7 +21,8 @@ Object.defineProperties(obj, { property: descObj }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-149.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-149.js index 1c2556cbc8..069f8267ce 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-149.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-149.js @@ -33,7 +33,8 @@ Object.defineProperties(obj, { property: descObj }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-150.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-150.js index 4c4b1717dc..dd4c0627c2 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-150.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-150.js @@ -27,7 +27,8 @@ Object.defineProperties(obj, { property: descObj }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-151.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-151.js index 65c386d29e..52b27802bb 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-151.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-151.js @@ -22,7 +22,8 @@ Object.defineProperties(obj, { property: func }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-152.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-152.js index 8c48fb76e7..9f41fd0f16 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-152.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-152.js @@ -20,7 +20,8 @@ Object.defineProperties(obj, { property: arr }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-153.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-153.js index bb53c4479c..8350b76d13 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-153.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-153.js @@ -20,7 +20,8 @@ Object.defineProperties(obj, { property: str }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-154.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-154.js index 9169fecaa5..f525efe3bc 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-154.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-154.js @@ -20,7 +20,8 @@ Object.defineProperties(obj, { property: descObj }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-155.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-155.js index 9e00beb444..4c9fc79514 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-155.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-155.js @@ -20,7 +20,8 @@ Object.defineProperties(obj, { property: descObj }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-156.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-156.js index 2ecb58c0ff..32f35ad65a 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-156.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-156.js @@ -19,7 +19,8 @@ Object.defineProperties(obj, { property: Math }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-157.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-157.js index f59bf901cf..2f8b893640 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-157.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-157.js @@ -20,7 +20,8 @@ Object.defineProperties(obj, { property: descObj }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-158.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-158.js index 3dfaede9c5..d496fb8c3f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-158.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-158.js @@ -20,7 +20,8 @@ Object.defineProperties(obj, { property: descObj }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-159.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-159.js index 8aa6779cc4..0caea972f3 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-159.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-159.js @@ -18,7 +18,8 @@ Object.defineProperties(obj, { property: JSON }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-160.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-160.js index 5b32ddb731..4c25c2e3f8 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-160.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-160.js @@ -20,7 +20,8 @@ Object.defineProperties(obj, { property: descObj }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-161.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-161.js index 1b952cf469..b716822825 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-161.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-161.js @@ -19,8 +19,9 @@ var func = function(a, b) { property: arguments }); - assert(obj.hasOwnProperty("property")); - verifyNotWritable(obj, "property"); + verifyProperty(obj, "property", { + writable: false, + }); }; func(); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-163.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-163.js index 16940fe042..0592cacc01 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-163.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-163.js @@ -19,7 +19,8 @@ Object.defineProperties(obj, { property: this }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-164.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-164.js index 46ee75a0b4..e02de2a1c8 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-164.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-164.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-165.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-165.js index 4c84d6a35f..88f2995544 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-165.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-165.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-167.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-167.js index 93001e24f6..edcadba7ad 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-167.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-167.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-168.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-168.js index 59e2d01fe4..e7e798f730 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-168.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-168.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-169.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-169.js index 1482e22d29..b0f1b30c4a 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-169.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-169.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-170.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-170.js index 44fcd2d56f..8027fce780 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-170.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-170.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-171.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-171.js index 5a4d2a2dda..b77bbe2b3d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-171.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-171.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-174.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-174.js index d018248861..dbadab16b2 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-174.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-174.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-60.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-60.js index a213b737e8..3764293f9b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-60.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-60.js @@ -16,7 +16,8 @@ Object.defineProperties(obj, { prop: {} }); -assert(obj.hasOwnProperty("prop")); -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-63.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-63.js index 3564a3c259..fcf969e5eb 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-63.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-63.js @@ -28,7 +28,8 @@ Object.defineProperties(obj, { prop: descObj }); -assert(obj.hasOwnProperty("prop")); -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-64.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-64.js index 895a3897ef..f3dd14d728 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-64.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-64.js @@ -31,7 +31,8 @@ Object.defineProperties(obj, { prop: descObj }); -assert(obj.hasOwnProperty("prop")); -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-67.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-67.js index b9abacb080..513a5bdd5f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-67.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-67.js @@ -30,7 +30,8 @@ Object.defineProperties(obj, { prop: descObj }); -assert(obj.hasOwnProperty("prop")); -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-68.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-68.js index bc74560e09..53d33da07e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-68.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-68.js @@ -33,8 +33,8 @@ Object.defineProperties(obj, { prop: descObj }); -assert(obj.hasOwnProperty("prop")); -verifyNotConfigurable(obj, "prop"); -assert(obj.hasOwnProperty("prop")); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-69.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-69.js index baa2e16a9c..d2f6ee592e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-69.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-69.js @@ -20,7 +20,8 @@ Object.defineProperties(obj, { prop: descObj }); -assert(obj.hasOwnProperty("prop")); -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-70.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-70.js index ef2e2468f2..5a354476bb 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-70.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-70.js @@ -31,7 +31,8 @@ Object.defineProperties(obj, { prop: descObj }); -assert(obj.hasOwnProperty("prop")); -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-71.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-71.js index b0915952d0..a610b091ca 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-71.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-71.js @@ -25,7 +25,8 @@ Object.defineProperties(obj, { prop: descObj }); -assert(obj.hasOwnProperty("prop")); -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-85.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-85.js index 4417c630c6..94c392693d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-85.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-85.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-86.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-86.js index 2745ab8dc5..a856931390 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-86.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-86.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-88.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-88.js index 461bc8e7eb..c7f4adced9 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-88.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-88.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-89.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-89.js index 79c808f491..be36e00228 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-89.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-89.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-90.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-90.js index 198d61ea03..ccb64939b7 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-90.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-90.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-91.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-91.js index 701fe1df53..40b32a4e38 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-91.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-91.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-92.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-92.js index b7997b1714..cda32f5710 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-92.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-92.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-95.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-95.js index db02d8a4c9..277eea621a 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-95.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-5-b-95.js @@ -17,7 +17,8 @@ Object.defineProperties(obj, { } }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-100.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-100.js index 47bc46e287..dfe8e37455 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-100.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-100.js @@ -25,12 +25,12 @@ Object.defineProperties(obj, { configurable: false } }); -verifyEqualTo(obj, "foo", 200); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 200, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-101.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-101.js index 462fb436d4..a0292d8c7f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-101.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-101.js @@ -41,8 +41,9 @@ verifyEqualTo(obj, "foo", get_func2()); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-102.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-102.js index a52e3b7580..6691b4e82e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-102.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-102.js @@ -34,8 +34,9 @@ Object.defineProperties(obj, { }); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-103.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-103.js index 69239b2647..6963afe790 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-103.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-103.js @@ -36,8 +36,9 @@ verifyEqualTo(obj, "foo", get_func()); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-104.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-104.js index 9723898ac6..75e893ec15 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-104.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-104.js @@ -41,8 +41,9 @@ verifyEqualTo(obj, "foo", get_func()); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-105.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-105.js index e8557c7375..5e04bee2d5 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-105.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-105.js @@ -6,6 +6,7 @@ es5id: 15.2.3.7-6-a-105 description: > Object.defineProperties - 'P' is accessor property, P.[[Set]] is present and properties.[[Set]] is undefined (8.12.9 step 12) +includes: [propertyHelper.js] ---*/ var obj = {}; @@ -31,7 +32,6 @@ Object.defineProperties(obj, { } }); -var hasProperty = obj.hasOwnProperty("property"); var verifyGet = false; verifyGet = (obj.property === 10); @@ -39,21 +39,13 @@ var verifySet = false; var desc = Object.getOwnPropertyDescriptor(obj, "property"); verifySet = (typeof desc.set === 'undefined'); -var verifyEnumerable = false; -for (var p in obj) { - if (p === "property") { - verifyEnumerable = true; - } -} - -var verifyConfigurable = false; -delete obj.property; -verifyConfigurable = obj.hasOwnProperty("property"); +verifyProperty(obj, "property", { + enumerable: true, + configurable: true, +}); -assert(hasProperty, 'hasProperty !== true'); assert(verifyGet, 'verifyGet !== true'); assert(verifySet, 'verifySet !== true'); -assert(verifyEnumerable, 'verifyEnumerable !== true'); -assert.sameValue(verifyConfigurable, false, 'verifyConfigurable'); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-106.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-106.js index 67cf09ee28..fff80e4e60 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-106.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-106.js @@ -36,8 +36,9 @@ verifyEqualTo(obj, "foo", get_func()); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-107.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-107.js index 87f7990aaa..95f6f95731 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-107.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-107.js @@ -36,8 +36,9 @@ verifyEqualTo(obj, "foo", get_func()); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyNotEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-108.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-108.js index cf434bfbd8..63f1b17621 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-108.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-108.js @@ -36,8 +36,9 @@ verifyEqualTo(obj, "foo", get_func()); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-109.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-109.js index 021bf58825..ccce309d3b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-109.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-109.js @@ -44,8 +44,9 @@ verifyEqualTo(obj, "foo", get_func2()); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-110.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-110.js index 1dca6bcb2f..71a658e156 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-110.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-110.js @@ -36,19 +36,21 @@ var properties = { }; Object.defineProperties(obj, properties); -verifyEqualTo(obj, "foo1", 200); -verifyWritable(obj, "foo1"); +verifyProperty(obj, "foo1", { + value: 200, + writable: true, + enumerable: true, + configurable: true, +}); -verifyEnumerable(obj, "foo1"); - -verifyConfigurable(obj, "foo1"); verifyEqualTo(obj, "foo2", get_func()); verifyWritable(obj, "foo2", "setVerifyHelpProp"); -verifyEnumerable(obj, "foo2"); - -verifyConfigurable(obj, "foo2"); +verifyProperty(obj, "foo2", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-114-b.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-114-b.js index dd6222e964..fe50a5bf47 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-114-b.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-114-b.js @@ -24,8 +24,9 @@ verifyEqualTo(arr, "length", 0); verifyWritable(arr, "length", "length", 1); -verifyNotEnumerable(arr, "length"); - -verifyNotConfigurable(arr, "length"); +verifyProperty(arr, "length", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-114.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-114.js index 2afb374774..d11ce306db 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-114.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-114.js @@ -26,8 +26,9 @@ verifyEqualTo(arr, "length", 2); verifyWritable(arr, "length", "length", 5); -verifyNotEnumerable(arr, "length"); - -verifyNotConfigurable(arr, "length"); +verifyProperty(arr, "length", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-115.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-115.js index 239ba3bb3e..7bd6e47c8d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-115.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-115.js @@ -24,10 +24,11 @@ Object.defineProperties(arr, { assert.sameValue(arr.length, 0); arr.length = 2; -assert.sameValue(arr.length, 2); -verifyNotEnumerable(arr, "length"); - -verifyNotConfigurable(arr, "length"); +verifyProperty(arr, "length", { + value: 2, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-12.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-12.js index 0c195e5e0d..323e2e3f49 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-12.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-12.js @@ -26,18 +26,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(fun, "prop", 11); - - verifyNotWritable(fun, "prop"); - - verifyNotEnumerable(fun, "prop"); - - verifyNotConfigurable(fun, "prop"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(fun, "prop", { + value: 11, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-120.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-120.js index 4704109b46..0b7585f683 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-120.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-120.js @@ -19,12 +19,11 @@ Object.defineProperties(arr, { } }); -verifyEqualTo(arr, "length", 0); - -verifyNotWritable(arr, "length"); - -verifyNotEnumerable(arr, "length"); - -verifyNotConfigurable(arr, "length"); +verifyProperty(arr, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-13.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-13.js index be22cb8d81..daf0c3e4ec 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-13.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-13.js @@ -25,18 +25,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arr, "prop", 11); - - verifyNotWritable(arr, "prop"); - - verifyNotEnumerable(arr, "prop"); - - verifyNotConfigurable(arr, "prop"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "prop", { + value: 11, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-14.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-14.js index 3ecd73ab51..3de547f1e7 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-14.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-14.js @@ -25,18 +25,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(str, "prop", 11); - - verifyNotWritable(str, "prop"); - - verifyNotEnumerable(str, "prop"); - - verifyNotConfigurable(str, "prop"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(str, "prop", { + value: 11, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-15.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-15.js index a86aaa2ec5..ede416b548 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-15.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-15.js @@ -26,18 +26,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "prop", 11); - - verifyNotWritable(obj, "prop"); - - verifyNotEnumerable(obj, "prop"); - - verifyNotConfigurable(obj, "prop"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "prop", { + value: 11, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-16.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-16.js index e78dcaa3e2..1e72361437 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-16.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-16.js @@ -26,18 +26,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "prop", 11); - - verifyNotWritable(obj, "prop"); - - verifyNotEnumerable(obj, "prop"); - - verifyNotConfigurable(obj, "prop"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "prop", { + value: 11, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-163.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-163.js index cbe3a65ff3..7359782f32 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-163.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-163.js @@ -24,10 +24,12 @@ Object.defineProperties(arr, { }); //try to overwrite length value of arr -verifyNotWritable(arr, "length") +verifyProperty(arr, "length", { + value: 1, + writable: false, +}); assert(!arr.hasOwnProperty("1")); -assert.sameValue(arr.length, 1); assert.sameValue(arr[0], 0); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-164.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-164.js index f699551ca6..f7bd847919 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-164.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-164.js @@ -31,8 +31,11 @@ try { throw new Test262Error("expected to throw TypeError") } catch (e) { assert(e instanceof TypeError); - assert.sameValue(arr.length, 2); - verifyNotWritable(arr, "length"); } +verifyProperty(arr, "length", { + value: 2, + writable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-176.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-176.js index 7117baebef..cbcebe0b84 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-176.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-176.js @@ -31,11 +31,16 @@ try { throw new Test262Error("Expected to throw TypeError"); } catch (e) { assert(e instanceof TypeError); - assert(arr.hasOwnProperty("1")); - verifyNotWritable(arr, "length"); - assert.sameValue(arr[0], 0); - assert.sameValue(arr[1], 1); - assert.sameValue(arr.length, 2) } +assert(arr.hasOwnProperty("1")); + +verifyProperty(arr, "length", { + value: 2, + writable: false, +}); + +assert.sameValue(arr[0], 0); +assert.sameValue(arr[1], 1); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-177.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-177.js index 1ebd1320be..5bcbd47137 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-177.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-177.js @@ -24,8 +24,11 @@ Object.defineProperties(arr, { }); assert(!arr.hasOwnProperty("1")); -assert.sameValue(arr.length, 0); assert(!arr.hasOwnProperty("0")); -verifyNotWritable(arr, "length"); + +verifyProperty(arr, "length", { + value: 0, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-18.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-18.js index fcd1e5d0d7..0c037c61f7 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-18.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-18.js @@ -26,18 +26,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "prop", 11); - - verifyNotWritable(obj, "prop"); - - verifyNotEnumerable(obj, "prop"); - - verifyNotConfigurable(obj, "prop"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "prop", { + value: 11, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-19.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-19.js index 9d5111dd19..f4a223d68e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-19.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-19.js @@ -26,18 +26,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "prop", 11); - - verifyNotWritable(obj, "prop"); - - verifyNotEnumerable(obj, "prop"); - - verifyNotConfigurable(obj, "prop"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "prop", { + value: 11, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-195.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-195.js index 46e202818f..7ba221bf61 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-195.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-195.js @@ -19,12 +19,11 @@ Object.defineProperties(arr, { } }); -verifyEqualTo(arr, "0", undefined); - -verifyNotWritable(arr, "0"); - -verifyEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: undefined, + writable: false, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-197.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-197.js index c95e92a883..b4b4f90351 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-197.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-197.js @@ -24,8 +24,9 @@ Object.defineProperties(arr, { } }); -assert(arr.hasOwnProperty("0")); -verifyNotWritable(arr, "0"); -assert.sameValue(arr[0], 1001); +verifyProperty(arr, "0", { + value: 1001, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-199.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-199.js index 5d24369753..97417e1683 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-199.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-199.js @@ -24,8 +24,8 @@ Object.defineProperties(arr, { } }); -assert(arr.hasOwnProperty("0")); -verifyNotConfigurable(arr, "0"); -assert(arr.hasOwnProperty("0")); +verifyProperty(arr, "0", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-2.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-2.js index 19de43a79c..883e70de76 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-2.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-2.js @@ -26,12 +26,11 @@ Object.defineProperties(obj, { } }); -verifyEqualTo(obj, "prop", 12); - -verifyNotWritable(obj, "prop"); - -verifyNotEnumerable(obj, "prop"); - -verifyConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + value: 12, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-200.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-200.js index b382c908c7..7c43a21b62 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-200.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-200.js @@ -21,12 +21,11 @@ Object.defineProperties(arr, { } }); -verifyEqualTo(arr, "0", 1001); - -verifyNotWritable(arr, "0"); - -verifyNotEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: 1001, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-202.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-202.js index 6997fab614..8a1c4998e5 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-202.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-202.js @@ -8,6 +8,7 @@ description: > named property, 'P' property doesn't exist in 'O', test [[Set]] of 'P' property in 'Attributes' is set as undefined value if [[Set]] is absent in accessor descriptor 'desc' (15.4.5.1 step 4.c) +includes: [propertyHelper.js] ---*/ var arr = []; @@ -23,24 +24,14 @@ Object.defineProperties(arr, { } }); -var verifyEnumerable = false; -for (var i in arr) { - if (i === "0" && arr.hasOwnProperty("0")) { - verifyEnumerable = true; - } -} - var desc = Object.getOwnPropertyDescriptor(arr, "0"); -var propertyDefineCorrect = arr.hasOwnProperty("0"); -var verifyConfigurable = false; -delete arr[0]; -verifyConfigurable = arr.hasOwnProperty("0"); +verifyProperty(arr, "0", { + enumerable: true, + configurable: true, +}); assert.sameValue(typeof desc.set, "undefined", 'typeof desc.set'); -assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); assert.sameValue(desc.get, getFunc, 'desc.get'); -assert.sameValue(verifyConfigurable, false, 'verifyConfigurable'); -assert(verifyEnumerable, 'verifyEnumerable !== true'); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-204.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-204.js index ef679dcc11..1cddaa0ff7 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-204.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-204.js @@ -39,6 +39,8 @@ if (arr.verifySetter !== 101) { throw new Test262Error('Expected arr.verifySetter === 101, actually ' + arr.verifySetter); } -verifyNotConfigurable(arr, 0); +verifyProperty(arr, "0", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-205.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-205.js index 46d98ea0a0..1ebeaac1f8 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-205.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-205.js @@ -42,8 +42,9 @@ verifyEqualTo(arr, "0", getFun()); verifyWritable(arr, "0", "setVerifyHelpProp"); -verifyNotEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-206.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-206.js index a322992ba4..30e0beb774 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-206.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-206.js @@ -18,12 +18,12 @@ arr[0] = 101; // default value of attributes: writable: true, configurable: true Object.defineProperties(arr, { "0": {} }); -verifyEqualTo(arr, "0", 101); -verifyWritable(arr, "0"); - -verifyEnumerable(arr, "0"); - -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: 101, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-207.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-207.js index 46d88c42e1..19ab6047b9 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-207.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-207.js @@ -34,8 +34,9 @@ verifyEqualTo(arr, "0", get_func()); verifyWritable(arr, "0", "setVerifyHelpProp"); -verifyEnumerable(arr, "0"); - -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-208.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-208.js index 7d7f6ae685..33b1beff19 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-208.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-208.js @@ -24,12 +24,12 @@ Object.defineProperties(arr, { } }); -verifyEqualTo(arr, "0", 100); - -verifyWritable(arr, "0"); - -verifyEnumerable(arr, "0"); - -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: 100, + writable: true, + enumerable: true, + configurable: true, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-209.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-209.js index 48d71fdc94..1935f25ea8 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-209.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-209.js @@ -38,8 +38,9 @@ verifyEqualTo(arr, "0", get_func()); verifyWritable(arr, "0", "setVerifyHelpProp"); -verifyEnumerable(arr, "0"); - -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-21.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-21.js index 174de35bac..6f58cf7632 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-21.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-21.js @@ -26,18 +26,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "prop", 11); - - verifyNotWritable(obj, "prop"); - - verifyNotEnumerable(obj, "prop"); - - verifyNotConfigurable(obj, "prop"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "prop", { + value: 11, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-210.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-210.js index 5d74f4dfd0..2809a05d15 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-210.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-210.js @@ -22,12 +22,12 @@ Object.defineProperties(arr, { value: undefined } }); -verifyEqualTo(arr, "0", undefined); -verifyNotWritable(arr, "0"); - -verifyNotEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-211.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-211.js index 163eb6c69f..f1f02085c9 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-211.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-211.js @@ -21,12 +21,12 @@ Object.defineProperties(arr, { value: null } }); -verifyEqualTo(arr, "0", null); -verifyNotWritable(arr, "0"); - -verifyNotEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: null, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-212.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-212.js index d6aa9bdf5b..7d32ce4958 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-212.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-212.js @@ -22,12 +22,11 @@ Object.defineProperties(arr, { } }); -verifyEqualTo(arr, "0", NaN); - -verifyNotWritable(arr, "0"); - -verifyNotEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: NaN, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-213.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-213.js index b9bff48f9d..000b189084 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-213.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-213.js @@ -24,18 +24,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arr, "0", -0); - - verifyNotWritable(arr, "0"); - - verifyNotEnumerable(arr, "0"); - - verifyNotConfigurable(arr, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "0", { + value: -0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-214.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-214.js index 356f64d1bd..934d03d507 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-214.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-214.js @@ -24,18 +24,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arr, "0", +0); - - verifyNotWritable(arr, "0"); - - verifyNotEnumerable(arr, "0"); - - verifyNotConfigurable(arr, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "0", { + value: +0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-215.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-215.js index ea5c1a2d3f..4cc0c47522 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-215.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-215.js @@ -22,12 +22,12 @@ Object.defineProperties(arr, { value: 101 } }); -verifyEqualTo(arr, "0", 101); -verifyNotWritable(arr, "0"); - -verifyNotEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: 101, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-216.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-216.js index b658b05038..bda83e12a4 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-216.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-216.js @@ -22,12 +22,12 @@ Object.defineProperties(arr, { value: "abcd" } }); -verifyEqualTo(arr, "0", "abcd"); -verifyNotWritable(arr, "0"); - -verifyNotEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: "abcd", + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-217.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-217.js index 94e975a2cb..cf81d69f53 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-217.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-217.js @@ -22,12 +22,12 @@ Object.defineProperties(arr, { value: true } }); -verifyEqualTo(arr, "0", true); -verifyNotWritable(arr, "0"); - -verifyNotEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: true, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-218.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-218.js index 9fefdec9a6..c8998fdd88 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-218.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-218.js @@ -27,12 +27,12 @@ var properties = { }; Object.defineProperties(arr, properties); -verifyEqualTo(arr, "0", obj1); -verifyNotWritable(arr, "0"); - -verifyNotEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: obj1, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-219.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-219.js index 50afb5f2b0..7e53f2f81f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-219.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-219.js @@ -21,12 +21,12 @@ Object.defineProperties(arr, { writable: true } }); -verifyEqualTo(arr, "0", undefined); -verifyWritable(arr, "0"); - -verifyNotEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: undefined, + writable: true, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-220.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-220.js index e655774ae2..b6a031738f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-220.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-220.js @@ -22,12 +22,12 @@ Object.defineProperties(arr, { writable: false } }); -verifyEqualTo(arr, "0", undefined); -verifyNotWritable(arr, "0"); - -verifyNotEnumerable(arr, "0"); - -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: undefined, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-221.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-221.js index f3d107084e..a2ee179aba 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-221.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-221.js @@ -28,8 +28,9 @@ Object.defineProperties(arr, { }); verifyEqualTo(arr, "0", get_func()); -verifyNotEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-222.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-222.js index b9f60bdb8f..eaaf719083 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-222.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-222.js @@ -28,8 +28,9 @@ Object.defineProperties(arr, { }); verifyWritable(arr, "0", "setVerifyHelpProp"); -verifyNotEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-223.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-223.js index 25c4ab4089..f66435c528 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-223.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-223.js @@ -21,12 +21,12 @@ Object.defineProperties(arr, { enumerable: true } }); -verifyEqualTo(arr, "0", undefined); -verifyNotWritable(arr, "0"); - -verifyEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: undefined, + writable: false, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-224.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-224.js index 127f8f89dd..e27cf9f8dd 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-224.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-224.js @@ -22,12 +22,12 @@ Object.defineProperties(arr, { enumerable: false } }); -verifyEqualTo(arr, "0", undefined); -verifyNotWritable(arr, "0"); - -verifyNotEnumerable(arr, "0"); - -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: undefined, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-225.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-225.js index 9db9a3514d..ecd4214862 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-225.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-225.js @@ -21,12 +21,12 @@ Object.defineProperties(arr, { configurable: true } }); -verifyEqualTo(arr, "0", undefined); -verifyNotWritable(arr, "0"); - -verifyNotEnumerable(arr, "0"); - -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: undefined, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-226.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-226.js index 0b839c70e3..783378d959 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-226.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-226.js @@ -21,12 +21,12 @@ Object.defineProperties(arr, { configurable: false } }); -verifyEqualTo(arr, "0", undefined); -verifyNotWritable(arr, "0"); - -verifyNotEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-227.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-227.js index 7e0a0eb3b8..2df44c3abe 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-227.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-227.js @@ -27,18 +27,16 @@ try { } }); } catch (e) { - verifyEqualTo(arr, "1", 3); - - verifyNotWritable(arr, "1"); - - verifyNotEnumerable(arr, "1"); - - verifyNotConfigurable(arr, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "1", { + value: 3, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-228.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-228.js index ae93f23bb1..66fcadb131 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-228.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-228.js @@ -31,18 +31,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arr, "1", 3); - - verifyNotWritable(arr, "1"); - - verifyNotEnumerable(arr, "1"); - - verifyNotConfigurable(arr, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "1", { + value: 3, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-229.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-229.js index 52eeb0b5ef..08df4167f5 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-229.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-229.js @@ -35,14 +35,14 @@ try { } catch (e) { verifyWritable(arr, "1", "setVerifyHelpProp"); - verifyNotEnumerable(arr, "1"); - - verifyNotConfigurable(arr, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "1", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-230.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-230.js index 70c1ebbcab..5b385533ed 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-230.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-230.js @@ -27,18 +27,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arr, "1", 3); - - verifyNotWritable(arr, "1"); - - verifyNotEnumerable(arr, "1"); - - verifyNotConfigurable(arr, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "1", { + value: 3, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-231.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-231.js index 77e43c731c..58ab02eb54 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-231.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-231.js @@ -27,8 +27,9 @@ Object.defineProperties(arr, { verifyWritable(arr, "1", "setVerifyHelpProp"); -verifyEnumerable(arr, "1"); - -verifyConfigurable(arr, "1"); +verifyProperty(arr, "1", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-232.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-232.js index a8f2187f8c..f585634fa1 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-232.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-232.js @@ -28,12 +28,11 @@ Object.defineProperties(arr, { } }); -verifyEqualTo(arr, "1", 12); - -verifyNotWritable(arr, "1"); - -verifyNotEnumerable(arr, "1"); - -verifyConfigurable(arr, "1"); +verifyProperty(arr, "1", { + value: 12, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-233.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-233.js index cc3247a9c7..5aa8ecd912 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-233.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-233.js @@ -30,18 +30,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arr, "1", undefined); - - verifyNotWritable(arr, "1"); - - verifyNotEnumerable(arr, "1"); - - verifyNotConfigurable(arr, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "1", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-234.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-234.js index 668e02eb0f..15279c0e89 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-234.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-234.js @@ -32,18 +32,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arr, "1", 3); - - verifyNotWritable(arr, "1"); - - verifyNotEnumerable(arr, "1"); - - verifyNotConfigurable(arr, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "1", { + value: 3, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-235.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-235.js index a4becc4796..63526b84e9 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-235.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-235.js @@ -26,18 +26,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arr, "1", +0); - - verifyNotWritable(arr, "1"); - - verifyNotEnumerable(arr, "1"); - - verifyNotConfigurable(arr, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "1", { + value: +0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-236.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-236.js index 7a76261002..8ccd912ed0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-236.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-236.js @@ -27,18 +27,16 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arr, "1", -0); - - verifyNotWritable(arr, "1"); - - verifyNotEnumerable(arr, "1"); - - verifyNotConfigurable(arr, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "1", { + value: -0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-237.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-237.js index 9914b27c44..5332d11ce9 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-237.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-237.js @@ -28,18 +28,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arr, "1", 12); - - verifyNotWritable(arr, "1"); - - verifyNotEnumerable(arr, "1"); - - verifyNotConfigurable(arr, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "1", { + value: 12, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-238.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-238.js index 5928b5b299..5e6177b726 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-238.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-238.js @@ -27,18 +27,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arr, "1", "abcd"); - - verifyNotWritable(arr, "1"); - - verifyNotEnumerable(arr, "1"); - - verifyNotConfigurable(arr, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "1", { + value: "abcd", + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-239.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-239.js index e27cf66f6e..a696416afe 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-239.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-239.js @@ -28,18 +28,16 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arr, "1", true); - - verifyNotWritable(arr, "1"); - - verifyNotEnumerable(arr, "1"); - - verifyNotConfigurable(arr, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "1", { + value: true, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-24.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-24.js index f57eb5d1db..8b95fea263 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-24.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-24.js @@ -24,13 +24,12 @@ Object.defineProperties(this, { } }); -verifyEqualTo(this, "prop", 12); - -verifyWritable(this, "prop"); - -verifyEnumerable(this, "prop"); - -verifyConfigurable(this, "prop"); +verifyProperty(this, "prop", { + value: 12, + writable: true, + enumerable: true, + configurable: true, +}); delete this.prop; diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-240.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-240.js index 3e22e8bf14..ce8c4c36a6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-240.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-240.js @@ -34,18 +34,16 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arr, "1", obj1); - - verifyNotWritable(arr, "1"); - - verifyNotEnumerable(arr, "1"); - - verifyNotConfigurable(arr, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "1", { + value: obj1, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-241.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-241.js index 6167a6ee64..17bb7efd40 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-241.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-241.js @@ -34,14 +34,14 @@ try { } catch (e) { verifyWritable(arr, "1", "setVerifyHelpProp"); - verifyNotEnumerable(arr, "1"); - - verifyNotConfigurable(arr, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "1", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-242.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-242.js index a794b04f0d..937341c5a5 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-242.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-242.js @@ -33,14 +33,14 @@ try { } catch (e) { verifyWritable(arr, "1", "setVerifyHelpProp"); - verifyNotEnumerable(arr, "1"); - - verifyNotConfigurable(arr, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "1", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-243.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-243.js index 4f8ba301c4..9f1b7a70a2 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-243.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-243.js @@ -25,8 +25,9 @@ Object.defineProperties(arr, { } }); -verifyNotEnumerable(arr, "1"); - -verifyNotConfigurable(arr, "1"); +verifyProperty(arr, "1", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-244.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-244.js index 12d578b86f..4b7394ea5b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-244.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-244.js @@ -36,14 +36,14 @@ try { } catch (e) { verifyEqualTo(arr, "1", get_fun()); - verifyNotEnumerable(arr, "1"); - - verifyNotConfigurable(arr, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "1", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-245.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-245.js index 046fc367f8..bb8670ee80 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-245.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-245.js @@ -32,14 +32,14 @@ try { } catch (e) { verifyEqualTo(arr, "1", get_fun()); - verifyNotEnumerable(arr, "1"); - - verifyNotConfigurable(arr, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "1", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-246.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-246.js index f7bd329a1e..193596163a 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-246.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-246.js @@ -26,8 +26,9 @@ Object.defineProperties(arr, { } }); -verifyNotEnumerable(arr, "1"); - -verifyNotConfigurable(arr, "1"); +verifyProperty(arr, "1", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-247.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-247.js index f597aaf1af..99151a6eb0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-247.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-247.js @@ -19,12 +19,12 @@ Object.defineProperties(arr, { value: 36 } }); -verifyEqualTo(arr, "0", 36); -verifyWritable(arr, "0"); - -verifyEnumerable(arr, "0"); - -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: 36, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-248.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-248.js index 547713544d..a5ec7a2b73 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-248.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-248.js @@ -19,12 +19,12 @@ Object.defineProperties(arr, { value: undefined } }); -verifyEqualTo(arr, "0", undefined); -verifyWritable(arr, "0"); - -verifyEnumerable(arr, "0"); - -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: undefined, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-249.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-249.js index 36907737c5..8a3179cc5b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-249.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-249.js @@ -19,12 +19,12 @@ Object.defineProperties(arr, { value: 12 } }); -verifyEqualTo(arr, "0", 12); -verifyWritable(arr, "0"); - -verifyEnumerable(arr, "0"); - -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: 12, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-250.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-250.js index f247cfd64b..5332c7076e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-250.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-250.js @@ -19,12 +19,12 @@ Object.defineProperties(arr, { writable: false } }); -verifyEqualTo(arr, "0", 100); -verifyNotWritable(arr, "0"); - -verifyEnumerable(arr, "0"); - -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: 100, + writable: false, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-251.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-251.js index d8e2e29bf4..1ffc966b9f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-251.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-251.js @@ -19,12 +19,12 @@ Object.defineProperties(arr, { enumerable: false } }); -verifyEqualTo(arr, "0", 12); -verifyWritable(arr, "0"); - -verifyNotEnumerable(arr, "0"); - -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: 12, + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-252.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-252.js index c74dba3fb4..dea3971ab4 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-252.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-252.js @@ -19,12 +19,12 @@ Object.defineProperties(arr, { configurable: false } }); -verifyEqualTo(arr, "0", 12); -verifyWritable(arr, "0"); - -verifyEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: 12, + writable: true, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-253.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-253.js index bec2effb09..4ec4199c2a 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-253.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-253.js @@ -21,12 +21,12 @@ Object.defineProperties(arr, { configurable: false } }); -verifyEqualTo(arr, "0", 36); -verifyNotWritable(arr, "0"); - -verifyEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + value: 36, + writable: false, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-254.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-254.js index 5ff7603393..52dfbc2240 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-254.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-254.js @@ -32,8 +32,9 @@ Object.defineProperties(arr, { }); verifyEqualTo(arr, "0", get_fun()); -verifyNotEnumerable(arr, "0"); - -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-255.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-255.js index ca5c0bb33f..e10cec2a3f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-255.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-255.js @@ -26,8 +26,10 @@ Object.defineProperties(arr, { get: undefined } }); -verifyNotEnumerable(arr, "0"); -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-256.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-256.js index 5f2eec519b..5578340283 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-256.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-256.js @@ -30,8 +30,9 @@ Object.defineProperties(arr, { }); verifyEqualTo(arr, "0", get_fun()); -verifyNotEnumerable(arr, "0"); - -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-257.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-257.js index 24ebf36025..6400a30657 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-257.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-257.js @@ -30,8 +30,9 @@ Object.defineProperties(arr, { }); verifyWritable(arr, "0", "setVerifyHelpProp"); -verifyNotEnumerable(arr, "0"); - -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-258.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-258.js index 0cb48c5eb7..45d2f9322b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-258.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-258.js @@ -24,8 +24,10 @@ Object.defineProperties(arr, { set: undefined } }); -verifyNotEnumerable(arr, "0"); -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-259.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-259.js index 0e846489aa..9ea293761b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-259.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-259.js @@ -29,8 +29,9 @@ Object.defineProperties(arr, { }); verifyWritable(arr, "0", "setVerifyHelpProp"); -verifyNotEnumerable(arr, "0"); - -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-260.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-260.js index 62e09ab0f2..441fd014bf 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-260.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-260.js @@ -30,8 +30,9 @@ Object.defineProperties(arr, { }); verifyWritable(arr, "0", "setVerifyHelpProp"); -verifyNotEnumerable(arr, "0"); - -verifyConfigurable(arr, "0"); +verifyProperty(arr, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-261.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-261.js index 3a4aeaac10..a89d450ef1 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-261.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-261.js @@ -29,8 +29,9 @@ Object.defineProperties(arr, { }); verifyWritable(arr, "0", "setVerifyHelpProp"); -verifyNotEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-262.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-262.js index ee319f6ff2..6ba5bf8bfc 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-262.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-262.js @@ -41,8 +41,9 @@ verifyEqualTo(arr, "0", get_fun()); verifyWritable(arr, "0", "setVerifyHelpProp"); -verifyNotEnumerable(arr, "0"); - -verifyNotConfigurable(arr, "0"); +verifyProperty(arr, "0", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-266.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-266.js index 689bec9b21..a81edc844e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-266.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-266.js @@ -22,13 +22,13 @@ Object.defineProperties(arr, { configurable: true } }); -verifyEqualTo(arr, "property", 12); -verifyWritable(arr, "property"); - -verifyEnumerable(arr, "property"); - -verifyConfigurable(arr, "property"); +verifyProperty(arr, "property", { + value: 12, + writable: true, + enumerable: true, + configurable: true, +}); if (arr.length !== 0) { throw new Test262Error('Expected arr.length === 0, actually ' + arr.length); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-267.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-267.js index c81aad2b3f..293f8f33a6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-267.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-267.js @@ -33,9 +33,10 @@ verifyEqualTo(arr, "property", get_fun()); verifyWritable(arr, "property", "setVerifyHelpProp"); -verifyEnumerable(arr, "property"); - -verifyConfigurable(arr, "property"); +verifyProperty(arr, "property", { + enumerable: true, + configurable: true, +}); if (arr.length !== 0) { throw new Test262Error('Expected arr.length === 0, actually ' + arr.length); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-268.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-268.js index 3f27c8552a..6ef189d40f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-268.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-268.js @@ -38,8 +38,9 @@ verifyEqualTo(arr, "property", get_fun()); verifyWritable(arr, "property", "verifySetFun"); -verifyNotEnumerable(arr, "property"); - -verifyConfigurable(arr, "property"); +verifyProperty(arr, "property", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-269.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-269.js index 217cd5b052..24d9bf430e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-269.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-269.js @@ -21,13 +21,13 @@ Object.defineProperties(arr, { configurable: false } }); -verifyEqualTo(arr, "property", 12); -verifyNotWritable(arr, "property"); - -verifyNotEnumerable(arr, "property"); - -verifyNotConfigurable(arr, "property"); +verifyProperty(arr, "property", { + value: 12, + writable: false, + enumerable: false, + configurable: false, +}); if (arr.length !== 0) { throw new Test262Error('Expected arr.length === 0, actually ' + arr.length); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-270.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-270.js index 1fb83b1df8..2750ef8cbd 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-270.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-270.js @@ -26,18 +26,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arr, "property", 12); - - verifyNotWritable(arr, "property"); - - verifyNotEnumerable(arr, "property"); - - verifyNotConfigurable(arr, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "property", { + value: 12, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-271.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-271.js index 01af4ede13..9ebe3f3c87 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-271.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-271.js @@ -26,18 +26,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arr, "property", undefined); - - verifyNotWritable(arr, "property"); - - verifyNotEnumerable(arr, "property"); - - verifyNotConfigurable(arr, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "property", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-272.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-272.js index 1235a3604d..8bff8fee16 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-272.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-272.js @@ -27,18 +27,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arr, "property", 12); - - verifyNotWritable(arr, "property"); - - verifyNotEnumerable(arr, "property"); - - verifyNotConfigurable(arr, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "property", { + value: 12, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-273.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-273.js index 9d8807a77f..0108cff387 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-273.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-273.js @@ -26,18 +26,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arr, "property", 12); - - verifyNotWritable(arr, "property"); - - verifyNotEnumerable(arr, "property"); - - verifyNotConfigurable(arr, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "property", { + value: 12, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-274.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-274.js index 87b8c4cb9a..0cab0ced4b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-274.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-274.js @@ -39,14 +39,14 @@ try { verifyWritable(arr, "property", "verifySetFun"); - verifyNotEnumerable(arr, "property"); - - verifyNotConfigurable(arr, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "property", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-275.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-275.js index 73a3eb6ff6..7a13d69ddc 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-275.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-275.js @@ -30,14 +30,14 @@ try { } catch (e) { verifyWritable(arr, "property", "setVerifyHelpProp"); - verifyNotEnumerable(arr, "property"); - - verifyNotConfigurable(arr, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "property", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-276.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-276.js index 4f44eedb27..cc4b257824 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-276.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-276.js @@ -32,14 +32,14 @@ try { } catch (e) { verifyWritable(arr, "property", "setVerifyHelpProp"); - verifyNotEnumerable(arr, "property"); - - verifyNotConfigurable(arr, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "property", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-277.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-277.js index 6015feab01..88cd60fb56 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-277.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-277.js @@ -32,14 +32,14 @@ try { } catch (e) { verifyWritable(arr, "property", "setVerifyHelpProp"); - verifyNotEnumerable(arr, "property"); - - verifyNotConfigurable(arr, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arr, "property", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-278.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-278.js index ee646acae0..380cbf887c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-278.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-278.js @@ -30,12 +30,11 @@ Object.defineProperties(arg, { } }); -verifyEqualTo(arg, "0", 10); - -verifyWritable(arg, "0"); - -verifyEnumerable(arg, "0"); - -verifyConfigurable(arg, "0"); +verifyProperty(arg, "0", { + value: 10, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-279.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-279.js index 69aff91049..a225f9458f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-279.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-279.js @@ -42,8 +42,9 @@ verifyEqualTo(arg, "0", get_func()); verifyWritable(arg, "0", "setVerifyHelpProp"); -verifyEnumerable(arg, "0"); - -verifyConfigurable(arg, "0"); +verifyProperty(arg, "0", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-28.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-28.js index 1b1b00f14b..f46733e9b5 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-28.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-28.js @@ -18,14 +18,9 @@ Object.defineProperties(obj, { } }); -verifyNotWritable(obj, "prop"); - -if (!obj.hasOwnProperty("prop")) { - throw new Test262Error('Expected obj.hasOwnProperty("prop") to be true, actually ' + obj.hasOwnProperty("prop")); -} - -if (obj.prop !== 1001) { - throw new Test262Error('Expected obj.prop === 1001, actually ' + obj.prop); -} +verifyProperty(obj, "prop", { + value: 1001, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-281.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-281.js index 4df7240d9c..87f70353e5 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-281.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-281.js @@ -27,12 +27,11 @@ Object.defineProperties(arg, { } }); -verifyEqualTo(arg, "0", 20); - -verifyNotWritable(arg, "0"); - -verifyNotEnumerable(arg, "0"); - -verifyNotConfigurable(arg, "0"); +verifyProperty(arg, "0", { + value: 20, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-282.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-282.js index 11d6e36781..10322f5329 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-282.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-282.js @@ -34,18 +34,16 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arg, "0", 0); - - verifyNotWritable(arg, "0"); - - verifyEnumerable(arg, "0"); - - verifyNotConfigurable(arg, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "0", { + value: 0, + writable: false, + enumerable: true, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-283.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-283.js index 8ac9b4f704..ccdf040553 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-283.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-283.js @@ -35,18 +35,16 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arg, "0", 0); - - verifyNotWritable(arg, "0"); - - verifyNotEnumerable(arg, "0"); - - verifyNotConfigurable(arg, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "0", { + value: 0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-284.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-284.js index 9fed19833a..6a449ac3d9 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-284.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-284.js @@ -35,18 +35,16 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arg, "0", 0); - - verifyNotWritable(arg, "0"); - - verifyEnumerable(arg, "0"); - - verifyNotConfigurable(arg, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "0", { + value: 0, + writable: false, + enumerable: true, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-285.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-285.js index a22f1a59ba..b375ce09a4 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-285.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-285.js @@ -35,18 +35,16 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arg, "0", 0); - - verifyNotWritable(arg, "0"); - - verifyNotEnumerable(arg, "0"); - - verifyNotConfigurable(arg, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "0", { + value: 0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-288.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-288.js index a5a2feeecd..bb2843f668 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-288.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-288.js @@ -40,14 +40,14 @@ try { } catch (e) { verifyEqualTo(arg, "0", get_func()); - verifyEnumerable(arg, "0"); - - verifyNotConfigurable(arg, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "0", { + enumerable: true, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-289.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-289.js index 58daa19af6..b6ce95181d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-289.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-289.js @@ -40,14 +40,14 @@ try { } catch (e) { verifyEqualTo(arg, "0", get_func()); - verifyEnumerable(arg, "0"); - - verifyNotConfigurable(arg, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "0", { + enumerable: true, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-290.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-290.js index f03e73674a..0b8e42adfe 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-290.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-290.js @@ -30,12 +30,11 @@ Object.defineProperties(arg, { } }); -verifyEqualTo(arg, "0", 10); - -verifyNotWritable(arg, "0"); - -verifyNotEnumerable(arg, "0"); - -verifyNotConfigurable(arg, "0"); +verifyProperty(arg, "0", { + value: 10, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-291.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-291.js index 1319ec70c2..db6f500445 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-291.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-291.js @@ -42,8 +42,9 @@ verifyEqualTo(arg, "0", get_func()); verifyWritable(arg, "0", "setVerifyHelpProp"); -verifyNotEnumerable(arg, "0"); - -verifyNotConfigurable(arg, "0"); +verifyProperty(arg, "0", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-292.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-292.js index a03cfd2060..b46f0bc120 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-292.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-292.js @@ -43,8 +43,9 @@ Object.defineProperties(arg, { verifyEqualTo(arg, "0", get_func2()); -verifyNotEnumerable(arg, "0"); - -verifyNotConfigurable(arg, "0"); +verifyProperty(arg, "0", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-293.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-293.js index 5d9589888b..7267e28935 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-293.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-293.js @@ -28,12 +28,11 @@ Object.defineProperties(arg, { } }); -verifyEqualTo(arg, "0", 20); - -verifyNotWritable(arg, "0"); - -verifyNotEnumerable(arg, "0"); - -verifyNotConfigurable(arg, "0"); +verifyProperty(arg, "0", { + value: 20, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-294.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-294.js index e1af163e2b..efa1e26fb6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-294.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-294.js @@ -34,18 +34,16 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arg, "0", 0); - - verifyNotWritable(arg, "0"); - - verifyNotEnumerable(arg, "0"); - - verifyNotConfigurable(arg, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "0", { + value: 0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-295.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-295.js index 995e695b60..e6fc9e9422 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-295.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-295.js @@ -35,18 +35,16 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arg, "0", 0); - - verifyNotWritable(arg, "0"); - - verifyNotEnumerable(arg, "0"); - - verifyNotConfigurable(arg, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "0", { + value: 0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-296.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-296.js index d63b6abd7c..ee14307684 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-296.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-296.js @@ -35,18 +35,16 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arg, "0", 0); - - verifyNotWritable(arg, "0"); - - verifyEnumerable(arg, "0"); - - verifyNotConfigurable(arg, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "0", { + value: 0, + writable: false, + enumerable: true, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-297.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-297.js index 85a07ad038..d647c69fc9 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-297.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-297.js @@ -35,18 +35,16 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arg, "0", 0); - - verifyNotWritable(arg, "0"); - - verifyNotEnumerable(arg, "0"); - - verifyNotConfigurable(arg, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "0", { + value: 0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-298.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-298.js index 2bb794f123..82f75ed8d5 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-298.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-298.js @@ -42,14 +42,14 @@ try { } catch (e) { verifyEqualTo(arg, "0", get_func1()); - verifyNotEnumerable(arg, "0"); - - verifyNotConfigurable(arg, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "0", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-299.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-299.js index 2e59611209..f3cf964f13 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-299.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-299.js @@ -43,14 +43,14 @@ try { } catch (e) { verifyEqualTo(arg, "0", get_func()); - verifyNotEnumerable(arg, "0"); - - verifyNotConfigurable(arg, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "0", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-30.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-30.js index bba5d89ff4..580dcaf3da 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-30.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-30.js @@ -19,14 +19,9 @@ Object.defineProperties(obj, { } }); -verifyNotConfigurable(obj, "prop"); - -if (!obj.hasOwnProperty("prop")) { - throw new Test262Error('Expected obj.hasOwnProperty("prop") to be true, actually ' + obj.hasOwnProperty("prop")); -} - -if (obj.prop !== 1001) { - throw new Test262Error('Expected obj.prop === 1001, actually ' + obj.prop); -} +verifyProperty(obj, "prop", { + value: 1001, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-300.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-300.js index 7c10d4efa7..4eb41d999f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-300.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-300.js @@ -39,14 +39,14 @@ try { } catch (e) { verifyEqualTo(arg, "0", get_func()); - verifyEnumerable(arg, "0"); - - verifyNotConfigurable(arg, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "0", { + enumerable: true, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-301.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-301.js index 607a3a746d..1dc7c3747d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-301.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-301.js @@ -39,14 +39,14 @@ try { } catch (e) { verifyEqualTo(arg, "0", get_func()); - verifyEnumerable(arg, "0"); - - verifyNotConfigurable(arg, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "0", { + enumerable: true, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-302.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-302.js index 16f710cd40..3e5bee3cc9 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-302.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-302.js @@ -24,12 +24,11 @@ Object.defineProperties(arg, { } }); -verifyEqualTo(arg, "genericProperty", 1001); - -verifyWritable(arg, "genericProperty"); - -verifyEnumerable(arg, "genericProperty"); - -verifyConfigurable(arg, "genericProperty"); +verifyProperty(arg, "genericProperty", { + value: 1001, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-303.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-303.js index f3f32aab1c..91719ca75f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-303.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-303.js @@ -35,8 +35,9 @@ verifyEqualTo(arg, "genericProperty", getFun()); verifyWritable(arg, "genericProperty", "testGetFunction"); -verifyEnumerable(arg, "genericProperty"); - -verifyConfigurable(arg, "genericProperty"); +verifyProperty(arg, "genericProperty", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-304.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-304.js index e5168c7d84..955fc46f5a 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-304.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-304.js @@ -46,8 +46,9 @@ verifyEqualTo(arg, "genericProperty", getFun()); verifyWritable(arg, "genericProperty", "testGetFunction"); -verifyNotEnumerable(arg, "genericProperty"); - -verifyNotConfigurable(arg, "genericProperty"); +verifyProperty(arg, "genericProperty", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-305.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-305.js index 4863298678..2c8528dee0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-305.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-305.js @@ -30,12 +30,11 @@ Object.defineProperties(arg, { } }); -verifyEqualTo(arg, "genericProperty", 1002); - -verifyWritable(arg, "genericProperty"); - -verifyNotEnumerable(arg, "genericProperty"); - -verifyNotConfigurable(arg, "genericProperty"); +verifyProperty(arg, "genericProperty", { + value: 1002, + writable: true, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-306.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-306.js index 5674c28b7d..7fa55bce0e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-306.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-306.js @@ -30,18 +30,16 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arg, "genericProperty", 1001); - - verifyNotWritable(arg, "genericProperty"); - - verifyNotEnumerable(arg, "genericProperty"); - - verifyNotConfigurable(arg, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "genericProperty", { + value: 1001, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-307.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-307.js index f1294cc7e8..7b6840796d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-307.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-307.js @@ -29,18 +29,16 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arg, "genericProperty", undefined); - - verifyNotWritable(arg, "genericProperty"); - - verifyNotEnumerable(arg, "genericProperty"); - - verifyNotConfigurable(arg, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "genericProperty", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-308.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-308.js index f905ee306c..49be313a95 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-308.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-308.js @@ -29,18 +29,16 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arg, "genericProperty", undefined); - - verifyNotWritable(arg, "genericProperty"); - - verifyEnumerable(arg, "genericProperty"); - - verifyNotConfigurable(arg, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "genericProperty", { + value: undefined, + writable: false, + enumerable: true, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-309.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-309.js index fc7e123d7a..20e70b72df 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-309.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-309.js @@ -28,18 +28,16 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arg, "genericProperty", undefined); - - verifyNotWritable(arg, "genericProperty"); - - verifyNotEnumerable(arg, "genericProperty"); - - verifyNotConfigurable(arg, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "genericProperty", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-31.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-31.js index 3e0d7399be..1cc9e68036 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-31.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-31.js @@ -19,12 +19,12 @@ Object.defineProperties(obj, { configurable: false } }); -verifyEqualTo(obj, "prop", 1002); -verifyNotWritable(obj, "prop"); - -verifyNotEnumerable(obj, "prop"); - -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + value: 1002, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-310.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-310.js index a62ee445a7..51326cbe7f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-310.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-310.js @@ -43,14 +43,14 @@ try { verifyWritable(arg, "genericProperty", "verifySetFun"); - verifyNotEnumerable(arg, "genericProperty"); - - verifyNotConfigurable(arg, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "genericProperty", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-311.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-311.js index b5fd0b53f7..e43c360b87 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-311.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-311.js @@ -36,14 +36,14 @@ try { } catch (e) { verifyWritable(arg, "genericProperty", "genericPropertyString"); - verifyNotEnumerable(arg, "genericProperty"); - - verifyNotConfigurable(arg, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "genericProperty", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-312.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-312.js index a890c971e3..1612b14adb 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-312.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-312.js @@ -35,14 +35,14 @@ try { } catch (e) { verifyWritable(arg, "genericProperty", "genericPropertyString"); - verifyEnumerable(arg, "genericProperty"); - - verifyNotConfigurable(arg, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "genericProperty", { + enumerable: true, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-313.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-313.js index 8a0992330e..aa51e97ee2 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-313.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-313.js @@ -34,14 +34,14 @@ try { } catch (e) { verifyWritable(arg, "genericProperty", "genericPropertyString"); - verifyNotEnumerable(arg, "genericProperty"); - - verifyNotConfigurable(arg, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arg, "genericProperty", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-33.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-33.js index c1c992a90d..25c528e02d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-33.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-33.js @@ -24,8 +24,9 @@ Object.defineProperties(obj, { }); verifyWritable(obj, "prop", "setVerifyHelpProp"); -verifyEnumerable(obj, "prop"); - -verifyConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-35.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-35.js index 5ec06c05ef..394f63ff5f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-35.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-35.js @@ -29,8 +29,9 @@ verifyEqualTo(obj, "prop", getFun()); verifyWritable(obj, "prop", "setVerifyHelpProp"); -verifyNotEnumerable(obj, "prop"); - -verifyConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-36.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-36.js index cd1476eaea..7089f666f5 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-36.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-36.js @@ -30,8 +30,9 @@ verifyEqualTo(obj, "prop", 10); verifyWritable(obj, "prop", "setVerifyHelpProp"); -verifyEnumerable(obj, "prop"); - -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-37.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-37.js index afdb5a5709..466884a968 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-37.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-37.js @@ -29,8 +29,9 @@ verifyEqualTo(obj, "prop", getFun()); verifyWritable(obj, "prop", "setVerifyHelpProp"); -verifyNotEnumerable(obj, "prop"); - -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-38-1.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-38-1.js index 97d92d286c..c5c609ad79 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-38-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-38-1.js @@ -29,8 +29,9 @@ Object.defineProperties(obj, { verifyEqualTo(obj, "foo", getFunc()); -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-38.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-38.js index d687d6345e..9bd8a38c7c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-38.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-38.js @@ -17,12 +17,12 @@ obj.foo = 100; // default value of attributes: writable: true, configurable: tru Object.defineProperties(obj, { foo: {} }); -verifyEqualTo(obj, "foo", 100); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 100, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-39.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-39.js index 54c402d74f..ff7d19a48f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-39.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-39.js @@ -22,12 +22,12 @@ Object.defineProperties(obj, { configurable: true } }); -verifyEqualTo(obj, "foo", 101); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 101, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-40.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-40.js index 6c0d2f2c8a..948a61d092 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-40.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-40.js @@ -40,8 +40,9 @@ verifyEqualTo(obj, "foo", get_func()); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-41.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-41.js index f7d9be5dc4..a41d70fd83 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-41.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-41.js @@ -19,12 +19,12 @@ Object.defineProperties(obj, { value: "102" } }); -verifyEqualTo(obj, "foo", "102"); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: "102", + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-42.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-42.js index 26da7ca748..4971c08a34 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-42.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-42.js @@ -22,12 +22,12 @@ Object.defineProperties(obj, { value: undefined } }); -verifyEqualTo(obj, "foo", undefined); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-43.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-43.js index f31e75dbed..53be56ca55 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-43.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-43.js @@ -22,12 +22,12 @@ Object.defineProperties(obj, { value: null } }); -verifyEqualTo(obj, "foo", null); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: null, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-44.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-44.js index ce699a71b2..895b21043b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-44.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-44.js @@ -23,8 +23,10 @@ Object.defineProperties(obj, { } }); -verifyNotEnumerable(obj, "foo"); -verifyNotWritable(obj, "foo"); -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-45.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-45.js index 5738385a85..765e5e3226 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-45.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-45.js @@ -25,18 +25,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", -0); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: -0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-46.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-46.js index 5b7397c87e..3f57029fbc 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-46.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-46.js @@ -25,18 +25,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", +0); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: +0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-47.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-47.js index 3cbc638a8b..871d859a41 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-47.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-47.js @@ -22,12 +22,12 @@ Object.defineProperties(obj, { value: 101 } }); -verifyEqualTo(obj, "foo", 101); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 101, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-48.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-48.js index b3de13ed9d..eb530fdff3 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-48.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-48.js @@ -19,12 +19,12 @@ Object.defineProperties(obj, { value: 102 } }); -verifyEqualTo(obj, "foo", 102); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 102, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-49.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-49.js index 5cb4ac2df9..73beacbde0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-49.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-49.js @@ -23,12 +23,12 @@ Object.defineProperties(obj, { value: "abcd" } }); -verifyEqualTo(obj, "foo", "abcd"); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: "abcd", + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-5.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-5.js index 5893ad38d2..1cf2293e27 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-5.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-5.js @@ -29,16 +29,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "prop", getFunc()); - - verifyNotEnumerable(obj, "prop"); - - verifyNotConfigurable(obj, "prop"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyEqualTo(obj, "prop", getFunc()); + +verifyProperty(obj, "prop", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-50.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-50.js index c4459a802e..2e7473cada 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-50.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-50.js @@ -19,12 +19,12 @@ Object.defineProperties(obj, { value: "fghj" } }); -verifyEqualTo(obj, "foo", "fghj"); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: "fghj", + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-51.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-51.js index eaeb92e3c7..cf927bc359 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-51.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-51.js @@ -22,12 +22,12 @@ Object.defineProperties(obj, { value: true } }); -verifyEqualTo(obj, "foo", true); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: true, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-52.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-52.js index 294565851e..ad4217d829 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-52.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-52.js @@ -19,12 +19,12 @@ Object.defineProperties(obj, { value: false } }); -verifyEqualTo(obj, "foo", false); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: false, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-53.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-53.js index 47a8e4d761..d9a27c8f94 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-53.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-53.js @@ -25,12 +25,12 @@ Object.defineProperties(obj, { value: obj1 } }); -verifyEqualTo(obj, "foo", obj1); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: obj1, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-54.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-54.js index 0c154f563f..b0fc54d4af 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-54.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-54.js @@ -26,12 +26,12 @@ Object.defineProperties(obj, { value: obj2 } }); -verifyEqualTo(obj, "foo", obj2); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: obj2, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-55.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-55.js index 3db7ea5160..da79965576 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-55.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-55.js @@ -22,12 +22,12 @@ Object.defineProperties(obj, { writable: false } }); -verifyEqualTo(obj, "foo", undefined); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-56.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-56.js index c5e8d07b24..8925a1c6a6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-56.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-56.js @@ -24,12 +24,12 @@ Object.defineProperties(obj, { configurable: true } }); -verifyEqualTo(obj, "foo", undefined); -verifyWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: undefined, + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-57.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-57.js index 07a9774921..f257a3fa8a 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-57.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-57.js @@ -26,9 +26,11 @@ Object.defineProperties(obj, { } }); -verifyNotEnumerable(obj, "foo"); assert.sameValue(obj.foo, 10); -verifyNotConfigurable(obj, "foo") +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-58.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-58.js index c774825fb6..2bdb06848a 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-58.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-58.js @@ -6,6 +6,7 @@ es5id: 15.2.3.7-6-a-58 description: > Object.defineProperties - desc.[[Get]] and P.[[Get]] are two objects which refer to the different objects (8.12.9 step 6) +includes: [propertyHelper.js] ---*/ var obj = {}; @@ -29,25 +30,15 @@ Object.defineProperties(obj, { } }); -var verifyEnumerable = false; -for (var p in obj) { - if (p === "foo") { - verifyEnumerable = true; - } -} - -var verifyValue = false; -verifyValue = (obj.foo === 20); +assert.sameValue(obj.foo, 20); var desc = Object.getOwnPropertyDescriptor(obj, "foo"); -var verifyConfigurable = false; -delete obj.foo; -verifyConfigurable = obj.hasOwnProperty("foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: true, +}); -assert.sameValue(verifyConfigurable, false, 'verifyConfigurable'); -assert.sameValue(verifyEnumerable, false, 'verifyEnumerable'); -assert(verifyValue, 'verifyValue !== true'); assert.sameValue(typeof(desc.set), "undefined", 'typeof (desc.set)'); assert.sameValue(desc.get, get_Func2, 'desc.get'); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-59.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-59.js index 55f0b6e98b..c6ef06f2f7 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-59.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-59.js @@ -27,8 +27,9 @@ Object.defineProperties(obj, { }); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-60.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-60.js index 18b3b08eff..654371c09d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-60.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-60.js @@ -30,8 +30,9 @@ Object.defineProperties(obj, { }); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyNotEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-61.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-61.js index d6b97792f2..7bca98d769 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-61.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-61.js @@ -22,12 +22,12 @@ Object.defineProperties(obj, { enumerable: false } }); -verifyEqualTo(obj, "foo", 10); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 10, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-62.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-62.js index 66707f734d..5e8478764f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-62.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-62.js @@ -23,12 +23,12 @@ Object.defineProperties(obj, { enumerable: true } }); -verifyEqualTo(obj, "foo", 10); -verifyNotWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 10, + writable: false, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-63.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-63.js index d6bfa302ff..c88d34a3d9 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-63.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-63.js @@ -23,12 +23,12 @@ Object.defineProperties(obj, { configurable: false } }); -verifyEqualTo(obj, "foo", 10); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 10, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-64.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-64.js index fe97b64dd8..a2666ea4d3 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-64.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-64.js @@ -22,12 +22,12 @@ Object.defineProperties(obj, { configurable: false } }); -verifyEqualTo(obj, "foo", 10); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 10, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-65.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-65.js index c6678316fc..47811b7582 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-65.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-65.js @@ -25,18 +25,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", 10); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: 10, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-66-1.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-66-1.js index dd97034520..ddabfa6957 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-66-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-66-1.js @@ -27,18 +27,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", 10); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: 10, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-66.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-66.js index 6c1a70521e..7bbc90ac6e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-66.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-66.js @@ -27,18 +27,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", 10); - - verifyNotWritable(obj, "foo"); - - verifyEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: 10, + writable: false, + enumerable: true, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-67.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-67.js index 3980343982..3967859349 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-67.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-67.js @@ -31,11 +31,13 @@ try { throw new Test262Error("Expected TypeError"); } catch (e) { assert(e instanceof TypeError); - verifyNotEnumerable(obj, "foo"); assert.sameValue(obj.foo, 10); - verifyNotConfigurable(obj, "foo"); + verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, + }); var desc = Object.getOwnPropertyDescriptor(obj, "foo"); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-68.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-68.js index c2581e46bf..db5ed622cd 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-68.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-68.js @@ -30,18 +30,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", 10); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: 10, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-69.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-69.js index 16f5527999..d94a669dd0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-69.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-69.js @@ -6,6 +6,7 @@ es5id: 15.2.3.7-6-a-69 description: > Object.defineProperties - 'P' is data property and P.configurable is true, desc is accessor property (8.12.9 step 9.b.i) +includes: [propertyHelper.js] ---*/ var obj = {}; @@ -25,25 +26,15 @@ Object.defineProperties(obj, { } }); -var verifyEnumerable = false; -for (var p in obj) { - if (p === "foo") { - verifyEnumerable = true; - } -} - -var verifyValue = false; -verifyValue = (obj.foo === 20); +assert.sameValue(obj.foo, 20); var desc = Object.getOwnPropertyDescriptor(obj, "foo"); -var verifyConfigurable = true; -delete obj.foo; -verifyConfigurable = obj.hasOwnProperty("foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: true, +}); -assert.sameValue(verifyConfigurable, false, 'verifyConfigurable'); -assert.sameValue(verifyEnumerable, false, 'verifyEnumerable'); -assert(verifyValue, 'verifyValue !== true'); assert.sameValue(typeof desc.set, "undefined", 'typeof desc.set'); assert.sameValue(desc.get, get_Func, 'desc.get'); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-70.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-70.js index 2c19545d04..311d85dc1e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-70.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-70.js @@ -27,12 +27,12 @@ Object.defineProperties(obj, { value: 12 } }); -verifyEqualTo(obj, "foo", 12); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 12, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-71.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-71.js index 6be29229ee..85d1d8192e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-71.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-71.js @@ -27,18 +27,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", 10); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: 10, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-72.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-72.js index 3807bf9155..8db43b2aa2 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-72.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-72.js @@ -28,18 +28,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", 10); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: 10, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-73.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-73.js index ec98b17976..4027fc5b41 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-73.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-73.js @@ -24,12 +24,12 @@ Object.defineProperties(obj, { value: undefined } }); -verifyEqualTo(obj, "foo", undefined); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-74.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-74.js index 7efeaf287a..8bbcdbb240 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-74.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-74.js @@ -24,12 +24,12 @@ Object.defineProperties(obj, { value: null } }); -verifyEqualTo(obj, "foo", null); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: null, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-75.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-75.js index a1fe2653ec..b734bd9f6f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-75.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-75.js @@ -26,8 +26,10 @@ Object.defineProperties(obj, { } }); -verifyNotEnumerable(obj, "foo"); -verifyNotWritable(obj, "foo"); -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-76.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-76.js index 1a1c1e02c0..6b6cddb15b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-76.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-76.js @@ -27,18 +27,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", -0); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: -0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-77.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-77.js index 4be63a9fc3..f444cbee00 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-77.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-77.js @@ -27,18 +27,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", +0); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: +0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-78.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-78.js index 2752971e2e..fce755d9ea 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-78.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-78.js @@ -24,12 +24,12 @@ Object.defineProperties(obj, { value: 100 } }); -verifyEqualTo(obj, "foo", 100); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 100, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-79.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-79.js index a6533a918c..b0cddcd66f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-79.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-79.js @@ -27,18 +27,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", 10); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: 10, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-80.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-80.js index a7b91fa17b..bf1780dd56 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-80.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-80.js @@ -24,12 +24,12 @@ Object.defineProperties(obj, { value: "abcd" } }); -verifyEqualTo(obj, "foo", "abcd"); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: "abcd", + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-81.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-81.js index a8b094a8e0..edc253f300 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-81.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-81.js @@ -27,18 +27,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", "abcd"); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: "abcd", + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-82.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-82.js index e5d26c4acd..3d8b01d752 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-82.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-82.js @@ -25,12 +25,12 @@ Object.defineProperties(obj, { value: false } }); -verifyEqualTo(obj, "foo", false); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: false, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-83.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-83.js index 7e69ae863b..28625eebf8 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-83.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-83.js @@ -27,18 +27,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", false); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: false, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-84-1.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-84-1.js index 19c54b3883..b4f1985956 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-84-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-84-1.js @@ -32,12 +32,12 @@ Object.defineProperties(obj, { value: obj2 } }); -verifyEqualTo(obj, "foo", obj1); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: obj1, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-84.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-84.js index 0edfc761a9..873bfc248a 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-84.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-84.js @@ -29,12 +29,12 @@ Object.defineProperties(obj, { value: obj1 } }); -verifyEqualTo(obj, "foo", obj1); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: obj1, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-85.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-85.js index f9b41a56a4..10e7399cf1 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-85.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-85.js @@ -35,18 +35,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", obj1); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: obj1, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-86-1.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-86-1.js index 500986c18d..7b10abcdc2 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-86-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-86-1.js @@ -34,16 +34,16 @@ try { } }); } catch (e) { - verifyWritable(obj, "foo", "setVerifyHelpProp"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyWritable(obj, "foo", "setVerifyHelpProp"); + +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-86.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-86.js index a6f109dabd..b1ebcbc4dd 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-86.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-86.js @@ -29,8 +29,10 @@ Object.defineProperties(obj, { }); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyNotEnumerable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); -verifyNotConfigurable(obj, "foo"); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-87.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-87.js index f1cee12ac7..b4e642bcdc 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-87.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-87.js @@ -32,16 +32,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyWritable(obj, "foo", "setVerifyHelpProp"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyWritable(obj, "foo", "setVerifyHelpProp"); + +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-88.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-88.js index 12de5bbe14..5534a858b6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-88.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-88.js @@ -34,20 +34,20 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - var desc = Object.getOwnPropertyDescriptor(obj, "foo"); - - if (typeof(desc.set) !== "undefined") { - throw new Test262Error('Expected typeof (desc.set) === "undefined", actually ' + typeof(desc.set)); - } - - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } +} + +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "foo"); +if (typeof(desc.set) !== "undefined") { + throw new Test262Error('Expected typeof (desc.set) === "undefined", actually ' + typeof(desc.set)); } reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-89.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-89.js index ae7c1d6aa4..f8cf6dc904 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-89.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-89.js @@ -30,9 +30,10 @@ Object.defineProperties(obj, { } }); -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); var desc = Object.getOwnPropertyDescriptor(obj, "foo"); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-90.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-90.js index 4a7b37c5b0..a6c7d008c1 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-90.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-90.js @@ -37,8 +37,9 @@ verifyEqualTo(obj, "foo", get_func()); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-91.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-91.js index 77f1b0a61c..94a43927be 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-91.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-91.js @@ -44,14 +44,14 @@ try { verifyWritable(obj, "foo", "setVerifyHelpProp"); - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-92.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-92.js index 8a79bf19b1..f17c0e9826 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-92.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-92.js @@ -38,14 +38,14 @@ try { } catch (e) { verifyWritable(obj, "foo", "setVerifyHelpProp"); - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93-1.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93-1.js index 14f8f294c5..702cfc7abd 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93-1.js @@ -38,25 +38,23 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "property", 1002); - - verifyNotWritable(obj, "property"); - - verifyNotEnumerable(obj, "property"); - - verifyConfigurable(obj, "property"); - verifyEqualTo(obj, "property1", 1003); - - verifyNotWritable(obj, "property1"); - - verifyNotEnumerable(obj, "property1"); - - verifyNotConfigurable(obj, "property1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "property", { + value: 1002, + writable: false, + enumerable: false, + configurable: true, +}); + +verifyProperty(obj, "property1", { + value: 1003, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93-2.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93-2.js index 3426413f72..c3651d96a6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93-2.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93-2.js @@ -38,25 +38,23 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "0", 1002); - - verifyNotWritable(obj, "0"); - - verifyNotEnumerable(obj, "0"); - - verifyConfigurable(obj, "0"); - verifyEqualTo(obj, "1", 1003); - - verifyNotWritable(obj, "1"); - - verifyNotEnumerable(obj, "1"); - - verifyNotConfigurable(obj, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "0", { + value: 1002, + writable: false, + enumerable: false, + configurable: true, +}); + +verifyProperty(obj, "1", { + value: 1003, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93-3.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93-3.js index 927d25a004..9ae84e271d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93-3.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93-3.js @@ -37,26 +37,23 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "property", 1001); - - verifyNotWritable(obj, "property"); - - verifyNotEnumerable(obj, "property"); - - verifyNotConfigurable(obj, "property"); - - verifyEqualTo(obj, "property1", 1003); - - verifyNotWritable(obj, "property1"); - - verifyNotEnumerable(obj, "property1"); - - verifyConfigurable(obj, "property1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "property", { + value: 1001, + writable: false, + enumerable: false, + configurable: false, +}); + +verifyProperty(obj, "property1", { + value: 1003, + writable: false, + enumerable: false, + configurable: true, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93-4.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93-4.js index 7d6548ea1d..53ff196de0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93-4.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93-4.js @@ -37,25 +37,23 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "0", 1001); - - verifyNotWritable(obj, "0"); - - verifyNotEnumerable(obj, "0"); - - verifyNotConfigurable(obj, "0"); - verifyEqualTo(obj, "1", 1003); - - verifyNotWritable(obj, "1"); - - verifyNotEnumerable(obj, "1"); - - verifyConfigurable(obj, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "0", { + value: 1001, + writable: false, + enumerable: false, + configurable: false, +}); + +verifyProperty(obj, "1", { + value: 1003, + writable: false, + enumerable: false, + configurable: true, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93.js index cbfc06a190..3c53e641cc 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-93.js @@ -31,8 +31,9 @@ Object.defineProperties(obj, { }); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-94.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-94.js index 8f97c40e12..7eeef1842b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-94.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-94.js @@ -19,12 +19,12 @@ Object.defineProperties(obj, { value: 200 } }); -verifyEqualTo(obj, "foo", 200); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 200, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-95.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-95.js index b89ec12636..fed250c3a3 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-95.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-95.js @@ -24,12 +24,12 @@ Object.defineProperties(obj, { value: undefined } }); -verifyEqualTo(obj, "foo", undefined); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: undefined, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-96.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-96.js index cecec30eb2..06d55a0c5f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-96.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-96.js @@ -24,12 +24,12 @@ Object.defineProperties(obj, { value: 200 } }); -verifyEqualTo(obj, "foo", 200); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 200, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-97.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-97.js index 830402f265..23461d6227 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-97.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-97.js @@ -24,12 +24,12 @@ Object.defineProperties(obj, { writable: true } }); -verifyEqualTo(obj, "foo", 100); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 100, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-98.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-98.js index c45c0b3582..938e2a7b17 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-98.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-98.js @@ -24,12 +24,12 @@ Object.defineProperties(obj, { enumerable: true } }); -verifyEqualTo(obj, "foo", 200); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 200, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-99.js b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-99.js index 8dee2771e6..a91c0ab91f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-99.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/15.2.3.7-6-a-99.js @@ -24,12 +24,12 @@ Object.defineProperties(obj, { configurable: false } }); -verifyEqualTo(obj, "foo", 200); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 200, + writable: true, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/name.js b/js/src/tests/test262/built-ins/Object/defineProperties/name.js index 64e4c0c4c2..2a9d5c9fbe 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/name.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.defineProperties.name, "defineProperties"); - -verifyNotEnumerable(Object.defineProperties, "name"); -verifyNotWritable(Object.defineProperties, "name"); -verifyConfigurable(Object.defineProperties, "name"); +verifyProperty(Object.defineProperties, "name", { + value: "defineProperties", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperties/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/defineProperties/not-a-constructor.js index 7987b575ff..151dd2d509 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperties/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/defineProperties/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Object.defineProperties({}, {}); -}, '`new Object.defineProperties({}, {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-100.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-100.js index de37bdae68..0f9b56f06d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-100.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-100.js @@ -15,7 +15,8 @@ Object.defineProperty(obj, "property", { configurable: null }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-102.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-102.js index a0abf592c3..9352cdf328 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-102.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-102.js @@ -15,7 +15,8 @@ Object.defineProperty(obj, "property", { configurable: false }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-103.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-103.js index c9b59463af..e25a7ab12b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-103.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-103.js @@ -15,7 +15,8 @@ Object.defineProperty(obj, "property", { configurable: 0 }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-104.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-104.js index 9ae7f58e48..ac87f08e86 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-104.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-104.js @@ -15,7 +15,8 @@ Object.defineProperty(obj, "property", { configurable: +0 }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-105.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-105.js index 3055a6ff9f..ccff0ebded 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-105.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-105.js @@ -15,7 +15,8 @@ Object.defineProperty(obj, "property", { configurable: -0 }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-106.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-106.js index c6a037f9a6..5c024dd411 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-106.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-106.js @@ -15,7 +15,8 @@ Object.defineProperty(obj, "property", { configurable: NaN }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-109.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-109.js index 575c4c9459..f433030ddf 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-109.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-109.js @@ -15,7 +15,8 @@ Object.defineProperty(obj, "property", { configurable: "" }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-152.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-152.js index 87913b2d2d..61d481e7e8 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-152.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-152.js @@ -17,8 +17,9 @@ var attr = { Object.defineProperty(obj, "property", attr); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-153.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-153.js index 20c3e5c191..9f2c747347 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-153.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-153.js @@ -17,7 +17,8 @@ var attr = { Object.defineProperty(obj, "property", attr); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-162.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-162.js index 088bb9d5d2..79882c4f16 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-162.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-162.js @@ -18,7 +18,8 @@ Object.defineProperty(attr, "writable", { Object.defineProperty(obj, "property", attr); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-163.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-163.js index bfd2ff3dfb..80b482d4f3 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-163.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-163.js @@ -29,7 +29,8 @@ Object.defineProperty(child, "writable", { Object.defineProperty(obj, "property", child); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-164.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-164.js index 61fe9a5583..2f270d9b9d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-164.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-164.js @@ -24,7 +24,8 @@ var child = new ConstructFun(); Object.defineProperty(obj, "property", child); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-171-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-171-1.js index d8ee8da884..feffeefe59 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-171-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-171-1.js @@ -17,8 +17,10 @@ try { var dateObj = new Date(); Object.defineProperty(obj, "property", dateObj); - verifyWritable(obj, "property"); + verifyProperty(obj, "property", { + writable: true, + }); } finally { delete Date.prototype.writable; } diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-178.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-178.js index 42ab36b422..9069d503ad 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-178.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-178.js @@ -15,7 +15,8 @@ Object.defineProperty(obj, "property", { writable: undefined }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-179.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-179.js index be0fca785e..c4082a47cc 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-179.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-179.js @@ -15,7 +15,8 @@ Object.defineProperty(obj, "property", { writable: null }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-181.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-181.js index 04a60062e3..1f47b6b09e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-181.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-181.js @@ -15,7 +15,8 @@ Object.defineProperty(obj, "property", { writable: false }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-182.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-182.js index e1506931c8..b38cc2d799 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-182.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-182.js @@ -15,7 +15,8 @@ Object.defineProperty(obj, "property", { writable: 0 }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-183.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-183.js index 08b46c555a..762d8861bd 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-183.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-183.js @@ -15,7 +15,8 @@ Object.defineProperty(obj, "property", { writable: +0 }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-184.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-184.js index d456fbeb38..dca54d121b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-184.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-184.js @@ -15,7 +15,8 @@ Object.defineProperty(obj, "property", { writable: -0 }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-185.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-185.js index 81061f91f0..d51323620d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-185.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-185.js @@ -15,10 +15,9 @@ Object.defineProperty(obj, "property", { writable: NaN }); -assert(obj.hasOwnProperty("property")); - -verifyNotWritable(obj, "property"); - -assert.sameValue(typeof(obj.property), "undefined"); +verifyProperty(obj, "property", { + value: undefined, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-188.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-188.js index 29e6a06d42..554b370535 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-188.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-188.js @@ -15,7 +15,8 @@ Object.defineProperty(obj, "property", { writable: "" }); -assert(obj.hasOwnProperty("property")); -verifyNotWritable(obj, "property"); +verifyProperty(obj, "property", { + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-73.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-73.js index 965fa44537..816b74380c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-73.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-73.js @@ -15,7 +15,8 @@ Object.defineProperty(obj, "property", { configurable: false }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-74.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-74.js index 443d61a4a7..5a2d1d8b46 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-74.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-74.js @@ -15,7 +15,8 @@ Object.defineProperty(obj, "property", { value: 100 }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-76.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-76.js index 076c86ede5..70bbe20368 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-76.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-76.js @@ -22,12 +22,9 @@ var child = new ConstructFun(); Object.defineProperty(obj, "property", child); -assert(obj.hasOwnProperty("property")); - -verifyNotConfigurable(obj, "property"); - -assert(obj.hasOwnProperty("property")); - -assert.sameValue(typeof(obj.property), "undefined"); +verifyProperty(obj, "property", { + value: undefined, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-83.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-83.js index 1ab0672165..e08a8f1e06 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-83.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-83.js @@ -18,7 +18,8 @@ Object.defineProperty(attr, "configurable", { Object.defineProperty(obj, "property", attr); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-84.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-84.js index 2361aa0708..a5be67bd6f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-84.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-84.js @@ -29,7 +29,8 @@ Object.defineProperty(child, "configurable", { Object.defineProperty(obj, "property", child); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-85.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-85.js index 0b0868625f..cab6d919d0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-85.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-85.js @@ -24,11 +24,10 @@ var child = new ConstructFun(); Object.defineProperty(obj, "property", child); -assert(obj.hasOwnProperty("property")); - -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); -assert(obj.hasOwnProperty("property")); assert.sameValue(typeof(obj.property), "undefined"); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-99.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-99.js index aabe445bef..2e46f03642 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-99.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-99.js @@ -15,7 +15,8 @@ Object.defineProperty(obj, "property", { configurable: undefined }); -assert(obj.hasOwnProperty("property")); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-100.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-100.js index 34c2f090cd..4e92039f13 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-100.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-100.js @@ -16,12 +16,12 @@ obj.foo = 100; // default value of attributes: writable: true, configurable: tru Object.defineProperty(obj, "foo", { value: 200 }); -verifyEqualTo(obj, "foo", 200); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 200, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-101.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-101.js index 1da7826cf5..3dc30d6ed0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-101.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-101.js @@ -16,12 +16,12 @@ obj.foo = 100; // default value of attributes: writable: true, configurable: tru Object.defineProperty(obj, "foo", { value: undefined }); -verifyEqualTo(obj, "foo", undefined); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: undefined, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-102.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-102.js index 33d84c9f53..06fc9a4887 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-102.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-102.js @@ -16,12 +16,12 @@ obj.foo = undefined; // default value of attributes: writable: true, configurabl Object.defineProperty(obj, "foo", { value: 100 }); -verifyEqualTo(obj, "foo", 100); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 100, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-103.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-103.js index b98b2837f7..b179185952 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-103.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-103.js @@ -20,12 +20,12 @@ Object.defineProperty(obj, "foo", { Object.defineProperty(obj, "foo", { writable: true }); -verifyEqualTo(obj, "foo", undefined); -verifyWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: undefined, + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-104.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-104.js index 28de47218b..5ec8732e23 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-104.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-104.js @@ -20,12 +20,12 @@ Object.defineProperty(obj, "foo", { Object.defineProperty(obj, "foo", { enumerable: true }); -verifyEqualTo(obj, "foo", undefined); -verifyNotWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: undefined, + writable: false, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-105.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-105.js index d1c51afdd3..9da65ba390 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-105.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-105.js @@ -23,12 +23,11 @@ Object.defineProperty(obj, "foo", { configurable: false }); -verifyEqualTo(obj, "foo", 200); - -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 200, + writable: true, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-106.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-106.js index 9d726fe9c3..d4897eb29c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-106.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-106.js @@ -24,12 +24,12 @@ Object.defineProperty(obj, "foo", { writable: false, enumerable: false }); -verifyEqualTo(obj, "foo", 200); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 200, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-107.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-107.js index 949c297366..9c66006422 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-107.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-107.js @@ -38,8 +38,9 @@ verifyEqualTo(obj, "foo", getFunc2()); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyNotEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-108.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-108.js index c9f5864973..58e2152dc6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-108.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-108.js @@ -34,8 +34,9 @@ Object.defineProperty(obj, "foo", { }); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-109.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-109.js index 8093ffd718..fa2d599742 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-109.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-109.js @@ -34,8 +34,9 @@ verifyEqualTo(obj, "foo", getFunc()); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-110.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-110.js index c94fbc8af0..bfbf658e9f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-110.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-110.js @@ -32,8 +32,9 @@ Object.defineProperty(obj, "foo", { }); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-112.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-112.js index 4a80f6b084..662a1cbdca 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-112.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-112.js @@ -35,8 +35,9 @@ verifyEqualTo(obj, "foo", getFunc()); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-113.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-113.js index 48e4fa7f6d..bce7c0d28e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-113.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-113.js @@ -30,8 +30,9 @@ Object.defineProperty(obj, "foo", { verifyEqualTo(obj, "foo", getFunc()); -verifyNotEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-114.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-114.js index a0a8bc367d..a8c2631ca3 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-114.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-114.js @@ -35,8 +35,9 @@ verifyEqualTo(obj, "foo", getFunc()); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-115.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-115.js index 5481206420..6137b1d684 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-115.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-115.js @@ -42,8 +42,9 @@ verifyEqualTo(obj, "foo", getFunc2()); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyNotEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-118.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-118.js index 47a6508761..4407e43422 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-118.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-118.js @@ -16,8 +16,11 @@ Object.defineProperty(arrObj, "length", {}); assert.sameValue(arrObj.length, 0); arrObj.length = 2; -assert.sameValue(arrObj.length, 2); -verifyNotEnumerable(arrObj, "length"); -verifyNotConfigurable(arrObj, "length"); + +verifyProperty(arrObj, "length", { + value: 2, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-119.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-119.js index 0c07b625e0..5f50d645dc 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-119.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-119.js @@ -21,8 +21,11 @@ Object.defineProperty(arrObj, "length", { assert.sameValue(arrObj.length, 0); arrObj.length = 2; -assert.sameValue(arrObj.length, 2); -verifyNotEnumerable(arrObj, "length"); -verifyNotConfigurable(arrObj, "length"); + +verifyProperty(arrObj, "length", { + value: 2, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-124.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-124.js index 1dce4ea87c..ba58d7b69b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-124.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-124.js @@ -16,12 +16,12 @@ var arrObj = []; Object.defineProperty(arrObj, "length", { writable: false }); -verifyEqualTo(arrObj, "length", 0); -verifyNotWritable(arrObj, "length"); - -verifyNotEnumerable(arrObj, "length"); - -verifyNotConfigurable(arrObj, "length"); +verifyProperty(arrObj, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-167.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-167.js index 8c51484bd1..a611ceaf40 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-167.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-167.js @@ -22,7 +22,10 @@ Object.defineProperty(arrObj, "length", { }); assert(!arrObj.hasOwnProperty("1")) -assert.sameValue(arrObj.length, 1); -verifyNotWritable(arrObj, "length"); + +verifyProperty(arrObj, "length", { + value: 1, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-181.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-181.js index 26f0e3e3cd..9b8881341b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-181.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-181.js @@ -21,9 +21,11 @@ Object.defineProperty(arrObj, "length", { writable: false }); -verifyNotWritable(arrObj, "length"); - assert(!arrObj.hasOwnProperty("1")); -assert.sameValue(arrObj.length, 0); + +verifyProperty(arrObj, "length", { + value: 0, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-190.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-190.js index e9f7f17e6a..06d0f71da5 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-190.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-190.js @@ -24,17 +24,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "0", "ownDataProperty"); - - verifyNotWritable(arrObj, "0"); - - verifyNotEnumerable(arrObj, "0"); - - verifyNotConfigurable(arrObj, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } } +verifyProperty(arrObj, "0", { + value: "ownDataProperty", + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-194.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-194.js index c69f78bdbc..f1172f8810 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-194.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-194.js @@ -29,14 +29,14 @@ try { } catch (e) { verifyEqualTo(arrObj, "0", getFunc()); - verifyNotEnumerable(arrObj, "0"); - - verifyNotConfigurable(arrObj, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e.name); } - } +verifyProperty(arrObj, "0", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-195.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-195.js index 56e50846b6..ff0dd05fa3 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-195.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-195.js @@ -41,9 +41,10 @@ try { verifyWritable(arrObj, "0", "helpVerifySet"); - verifyNotEnumerable(arrObj, "0"); - - verifyNotConfigurable(arrObj, "0"); + verifyProperty(arrObj, "0", { + enumerable: false, + configurable: false, + }); } finally { delete Array.prototype[0]; } diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-199.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-199.js index 98cefd1ded..80cbce9a39 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-199.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-199.js @@ -17,12 +17,11 @@ Object.defineProperty(arrObj, "0", { enumerable: true }); -verifyEqualTo(arrObj, "0", undefined); - -verifyNotWritable(arrObj, "0"); - -verifyEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: undefined, + writable: false, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-200.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-200.js index 2c0632c716..b727dfd394 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-200.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-200.js @@ -20,12 +20,11 @@ Object.defineProperty(arrObj, "0", { configurable: false }); -verifyEqualTo(arrObj, "0", undefined); - -verifyWritable(arrObj, "0"); - -verifyEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: undefined, + writable: true, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-201.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-201.js index ab771a71c0..67e5615699 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-201.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-201.js @@ -19,12 +19,12 @@ Object.defineProperty(arrObj, "0", { enumerable: true, configurable: false }); -verifyEqualTo(arrObj, "0", 1001); -verifyNotWritable(arrObj, "0"); - -verifyEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: 1001, + writable: false, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-202.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-202.js index f6fe819199..bb074efafc 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-202.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-202.js @@ -19,12 +19,12 @@ Object.defineProperty(arrObj, "0", { writable: true, configurable: true }); -verifyEqualTo(arrObj, "0", 1001); -verifyWritable(arrObj, "0"); - -verifyNotEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: 1001, + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-203.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-203.js index 9e6cad35fb..49840159a2 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-203.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-203.js @@ -19,12 +19,12 @@ Object.defineProperty(arrObj, "0", { writable: true, enumerable: true }); -verifyEqualTo(arrObj, "0", 1001); -verifyWritable(arrObj, "0"); - -verifyEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: 1001, + writable: true, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-204.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-204.js index b513a1dbb9..49c684f429 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-204.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-204.js @@ -19,12 +19,11 @@ Object.defineProperty(arrObj, "0", { configurable: false }); -verifyEqualTo(arrObj, "0", 1001); - -verifyNotWritable(arrObj, "0"); - -verifyNotEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: 1001, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-205.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-205.js index 72e179ef74..13a6128fa3 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-205.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-205.js @@ -24,8 +24,9 @@ Object.defineProperty(arrObj, "0", { verifyWritable(arrObj, "0", "setVerifyHelpProp"); -verifyEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-207.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-207.js index 966b1744bd..72501910fb 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-207.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-207.js @@ -28,8 +28,9 @@ verifyEqualTo(arrObj, "0", getFunc()); verifyWritable(arrObj, "0", "setVerifyHelpProp"); -verifyNotEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-208.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-208.js index ba15c84b8e..be88bcd111 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-208.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-208.js @@ -27,8 +27,9 @@ verifyEqualTo(arrObj, "0", getFunc()); verifyWritable(arrObj, "0", "setVerifyHelpProp"); -verifyEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-209.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-209.js index cdefdc539e..6a6284615f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-209.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-209.js @@ -38,8 +38,9 @@ verifyEqualTo(arrObj, "0", getFunc()); verifyWritable(arrObj, "0", "setVerifyHelpProp"); -verifyNotEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-210.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-210.js index 3d5614db18..d94a0e32c2 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-210.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-210.js @@ -15,12 +15,12 @@ var arrObj = []; arrObj[0] = 101; // default value of attributes: writable: true, configurable: true, enumerable: true Object.defineProperty(arrObj, "0", {}); -verifyEqualTo(arrObj, "0", 101); -verifyWritable(arrObj, "0"); - -verifyEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: 101, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-211.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-211.js index 74773a8b8c..963370db23 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-211.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-211.js @@ -32,8 +32,9 @@ verifyEqualTo(arrObj, "0", getFunc()); verifyWritable(arrObj, "0", "setVerifyHelpProp"); -verifyEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-212.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-212.js index 60a73af96b..ac275e4b75 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-212.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-212.js @@ -22,12 +22,11 @@ Object.defineProperty(arrObj, "0", { configurable: true }); -verifyEqualTo(arrObj, "0", 100); - -verifyWritable(arrObj, "0"); - -verifyEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: 100, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-213.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-213.js index aba7e1fb85..9af3a4f98e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-213.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-213.js @@ -39,8 +39,9 @@ verifyEqualTo(arrObj, "0", getFunc()); verifyWritable(arrObj, "0", "setVerifyHelpProp"); -verifyEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-214.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-214.js index a68119a095..95c97dc221 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-214.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-214.js @@ -26,18 +26,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "0", 101); - - verifyNotWritable(arrObj, "0"); - - verifyNotEnumerable(arrObj, "0"); - - verifyNotConfigurable(arrObj, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "0", { + value: 101, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-215.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-215.js index f6fccd3a61..84af6b3d29 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-215.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-215.js @@ -19,12 +19,12 @@ Object.defineProperty(arrObj, "0", { Object.defineProperty(arrObj, "0", { value: undefined }); -verifyEqualTo(arrObj, "0", undefined); -verifyNotWritable(arrObj, "0"); - -verifyNotEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-216.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-216.js index ac7099d2bd..fd58d43e5c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-216.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-216.js @@ -19,12 +19,12 @@ Object.defineProperty(arrObj, "0", { Object.defineProperty(arrObj, "0", { value: null }); -verifyEqualTo(arrObj, "0", null); -verifyNotWritable(arrObj, "0"); - -verifyNotEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: null, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-217.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-217.js index 3b9df95a20..b539dc5c9d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-217.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-217.js @@ -20,11 +20,11 @@ Object.defineProperty(arrObj, "0", { value: NaN }); -assert(arrObj.hasOwnProperty("0")); -assert(arrObj[0] !== arrObj[0]); - -verifyNotWritable(arrObj, "0"); -verifyNotEnumerable(arrObj, "0"); -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: NaN, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-218.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-218.js index f9e2e8c567..4f1697f07b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-218.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-218.js @@ -23,18 +23,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "0", -0); - - verifyNotWritable(arrObj, "0"); - - verifyNotEnumerable(arrObj, "0"); - - verifyNotConfigurable(arrObj, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "0", { + value: -0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-219.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-219.js index 627a70f3ac..ef0742dce5 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-219.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-219.js @@ -23,18 +23,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "0", +0); - - verifyNotWritable(arrObj, "0"); - - verifyNotEnumerable(arrObj, "0"); - - verifyNotConfigurable(arrObj, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "0", { + value: +0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-220.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-220.js index 1e3d4a2d4c..a890330b36 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-220.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-220.js @@ -20,12 +20,12 @@ Object.defineProperty(arrObj, "0", { Object.defineProperty(arrObj, "0", { value: 101 }); -verifyEqualTo(arrObj, "0", 101); -verifyNotWritable(arrObj, "0"); - -verifyNotEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: 101, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-221.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-221.js index 00732ff7be..441feff1b9 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-221.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-221.js @@ -25,18 +25,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "0", 101); - - verifyNotWritable(arrObj, "0"); - - verifyNotEnumerable(arrObj, "0"); - - verifyNotConfigurable(arrObj, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "0", { + value: 101, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-222.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-222.js index 88d73c0af9..93d15fbf4f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-222.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-222.js @@ -20,12 +20,12 @@ Object.defineProperty(arrObj, "0", { Object.defineProperty(arrObj, "0", { value: "abcd" }); -verifyEqualTo(arrObj, "0", "abcd"); -verifyNotWritable(arrObj, "0"); - -verifyNotEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: "abcd", + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-223.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-223.js index 7177f6a39a..b39670d94c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-223.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-223.js @@ -25,18 +25,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "0", "abcd"); - - verifyNotWritable(arrObj, "0"); - - verifyNotEnumerable(arrObj, "0"); - - verifyNotConfigurable(arrObj, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "0", { + value: "abcd", + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-224.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-224.js index 91cac8ffdc..01c57e38f7 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-224.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-224.js @@ -20,12 +20,12 @@ Object.defineProperty(arrObj, "0", { Object.defineProperty(arrObj, "0", { value: true }); -verifyEqualTo(arrObj, "0", true); -verifyNotWritable(arrObj, "0"); - -verifyNotEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: true, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-225.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-225.js index 28d8f74f8e..29b344eb75 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-225.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-225.js @@ -25,18 +25,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "0", true); - - verifyNotWritable(arrObj, "0"); - - verifyNotEnumerable(arrObj, "0"); - - verifyNotConfigurable(arrObj, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "0", { + value: true, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-226.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-226.js index d766b26449..1b02ed6bbb 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-226.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-226.js @@ -24,12 +24,13 @@ Object.defineProperty(arrObj, "0", { Object.defineProperty(arrObj, "0", { value: obj1 }); -verifyEqualTo(arrObj, "0", obj1); -verifyNotWritable(arrObj, "0"); - -verifyNotEnumerable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: obj1, + writable: false, + enumerable: false, + configurable: false, +}); -verifyNotConfigurable(arrObj, "0"); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-227.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-227.js index 1834373563..a01f415dac 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-227.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-227.js @@ -32,18 +32,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "0", obj1); - - verifyNotWritable(arrObj, "0"); - - verifyNotEnumerable(arrObj, "0"); - - verifyNotConfigurable(arrObj, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "0", { + value: obj1, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-228.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-228.js index 9316e59db2..c6a7bea532 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-228.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-228.js @@ -20,12 +20,12 @@ Object.defineProperty(arrObj, "0", { Object.defineProperty(arrObj, "0", { writable: false }); -verifyEqualTo(arrObj, "0", undefined); -verifyNotWritable(arrObj, "0"); - -verifyNotEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-229.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-229.js index e1dead5a60..7dc8b36836 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-229.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-229.js @@ -21,12 +21,12 @@ Object.defineProperty(arrObj, "0", { Object.defineProperty(arrObj, "0", { writable: true }); -verifyEqualTo(arrObj, "0", undefined); -verifyWritable(arrObj, "0"); - -verifyNotEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: undefined, + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-230.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-230.js index 61d0187d81..44305782dc 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-230.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-230.js @@ -34,8 +34,9 @@ verifyEqualTo(arrObj, "0", getFunc()); verifyWritable(arrObj, "0", "helpVerifySet"); -verifyNotEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-231.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-231.js index 40199bd209..9180a48ff8 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-231.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-231.js @@ -40,8 +40,9 @@ verifyEqualTo(arrObj, "0", getFunc2()); verifyWritable(arrObj, "0", "helpVerifySet"); -verifyNotEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-232.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-232.js index d22adbe6f1..b61f732589 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-232.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-232.js @@ -26,8 +26,9 @@ Object.defineProperty(arrObj, "0", { }); verifyWritable(arrObj, "0", "setVerifyHelpProp"); -verifyNotEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-233.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-233.js index bd2f68977e..137485c1eb 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-233.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-233.js @@ -29,8 +29,9 @@ Object.defineProperty(arrObj, "0", { }); verifyWritable(arrObj, "0", "setVerifyHelpProp"); -verifyNotEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-234.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-234.js index b67690ecd5..056b76e72c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-234.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-234.js @@ -20,12 +20,12 @@ Object.defineProperty(arrObj, "0", { Object.defineProperty(arrObj, "0", { enumerable: false }); -verifyEqualTo(arrObj, "0", undefined); -verifyNotWritable(arrObj, "0"); - -verifyNotEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-235.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-235.js index d10baaf8d4..6d46f6e47f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-235.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-235.js @@ -21,12 +21,12 @@ Object.defineProperty(arrObj, "0", { Object.defineProperty(arrObj, "0", { enumerable: true }); -verifyEqualTo(arrObj, "0", undefined); -verifyNotWritable(arrObj, "0"); - -verifyEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: undefined, + writable: false, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-236.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-236.js index b7df65b72a..d403262794 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-236.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-236.js @@ -20,12 +20,12 @@ Object.defineProperty(arrObj, "0", { Object.defineProperty(arrObj, "0", { configurable: false }); -verifyEqualTo(arrObj, "0", undefined); -verifyNotWritable(arrObj, "0"); - -verifyNotEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-237.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-237.js index 59d2e8c84e..291c075755 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-237.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-237.js @@ -20,12 +20,12 @@ Object.defineProperty(arrObj, "0", { Object.defineProperty(arrObj, "0", { configurable: false }); -verifyEqualTo(arrObj, "0", undefined); -verifyNotWritable(arrObj, "0"); - -verifyNotEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-238.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-238.js index 9708bd0766..2afbac121c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-238.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-238.js @@ -27,20 +27,17 @@ try { configurable: true }); throw new Test262Error("Expected an exception."); - } catch (e) { - verifyEqualTo(arrObj, "1", 3); - - verifyWritable(arrObj, "1"); - - verifyNotEnumerable(arrObj, "1"); - - verifyNotConfigurable(arrObj, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "1", { + value: 3, + writable: true, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-239.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-239.js index 16a8aa0b1a..3036c00095 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-239.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-239.js @@ -29,20 +29,17 @@ try { enumerable: true }); throw new Test262Error("Expected an exception."); - } catch (e) { - verifyEqualTo(arrObj, "1", 3); - - verifyWritable(arrObj, "1"); - - verifyNotEnumerable(arrObj, "1"); - - verifyNotConfigurable(arrObj, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "1", { + value: 3, + writable: true, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-240.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-240.js index e74b2479d3..7c3712b1e3 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-240.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-240.js @@ -32,14 +32,14 @@ try { } catch (e) { verifyWritable(arrObj, "1", "setVerifyHelpProp"); - verifyNotEnumerable(arrObj, "1"); - - verifyNotConfigurable(arrObj, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "1", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-241.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-241.js index 8923abc966..6447fcad04 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-241.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-241.js @@ -24,20 +24,17 @@ try { set: function() {} }); throw new Test262Error("Expected an exception."); - } catch (e) { - verifyEqualTo(arrObj, "1", 3); - - verifyNotWritable(arrObj, "1"); - - verifyNotEnumerable(arrObj, "1"); - - verifyNotConfigurable(arrObj, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "1", { + value: 3, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-242-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-242-1.js index 7c21f48ca5..b943a2a765 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-242-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-242-1.js @@ -20,12 +20,11 @@ Object.defineProperty(arrObj, "0", { enumerable: false }); -verifyEqualTo(arrObj, "0", 1001); - -verifyNotWritable(arrObj, "0"); - -verifyNotEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: 1001, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-242.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-242.js index 5f1d4a8dce..29b55c9ba9 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-242.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-242.js @@ -24,8 +24,9 @@ Object.defineProperty(arrObj, "0", { verifyWritable(arrObj, "0", "setVerifyHelpProp"); -verifyEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243-1.js index a87d6172ea..672f5cc677 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243-1.js @@ -27,8 +27,9 @@ arrObj[1] = 4; verifyEqualTo(arrObj, "1", getFunc()); -verifyNotEnumerable(arrObj, "1"); - -verifyConfigurable(arrObj, "1"); +verifyProperty(arrObj, "1", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243-2-strict.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243-2-strict.js index ef5649662c..6ac6382e7d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243-2-strict.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243-2-strict.js @@ -29,8 +29,9 @@ assert.throws(TypeError, function() { }); verifyEqualTo(arrObj, "1", getFunc()); -verifyNotEnumerable(arrObj, "1"); - -verifyConfigurable(arrObj, "1"); +verifyProperty(arrObj, "1", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243.js index 08a11f8705..c6be9ba3ec 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243.js @@ -27,12 +27,11 @@ Object.defineProperty(arrObj, "1", { value: 12 }); -verifyEqualTo(arrObj, "1", 12); - -verifyNotWritable(arrObj, "1"); - -verifyNotEnumerable(arrObj, "1"); - -verifyConfigurable(arrObj, "1"); +verifyProperty(arrObj, "1", { + value: 12, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-244.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-244.js index e5e1d30c7b..112dc0cbfd 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-244.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-244.js @@ -22,25 +22,21 @@ Object.defineProperty(arrObj, "1", { }); try { - Object.defineProperty(arrObj, "1", { writable: true }); throw new Test262Error("Expected an exception."); - } catch (e) { - verifyEqualTo(arrObj, "1", undefined); - - verifyNotWritable(arrObj, "1"); - - verifyNotEnumerable(arrObj, "1"); - - verifyNotConfigurable(arrObj, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "1", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-245.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-245.js index eae22cfee2..91c5b07da6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-245.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-245.js @@ -29,18 +29,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "1", 3); - - verifyNotWritable(arrObj, "1"); - - verifyNotEnumerable(arrObj, "1"); - - verifyNotConfigurable(arrObj, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "1", { + value: 3, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-246.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-246.js index dddbc50767..863f1a7c71 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-246.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-246.js @@ -18,7 +18,6 @@ var arrObj = []; Object.defineProperty(arrObj, "1", { value: -0 - }); try { @@ -27,18 +26,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "1", -0); - - verifyNotWritable(arrObj, "1"); - - verifyNotEnumerable(arrObj, "1"); - - verifyNotConfigurable(arrObj, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "1", { + value: -0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-247.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-247.js index 1a3085a231..fb296bd6b0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-247.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-247.js @@ -27,18 +27,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "1", +0); - - verifyNotWritable(arrObj, "1"); - - verifyNotEnumerable(arrObj, "1"); - - verifyNotConfigurable(arrObj, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "1", { + value: +0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-248.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-248.js index b946c44ae1..8bcd5768f8 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-248.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-248.js @@ -26,18 +26,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "1", 12); - - verifyNotWritable(arrObj, "1"); - - verifyNotEnumerable(arrObj, "1"); - - verifyNotConfigurable(arrObj, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "1", { + value: 12, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-249.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-249.js index 9a7132c20f..7753d29ba7 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-249.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-249.js @@ -26,18 +26,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "1", "abc"); - - verifyNotWritable(arrObj, "1"); - - verifyNotEnumerable(arrObj, "1"); - - verifyNotConfigurable(arrObj, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "1", { + value: "abc", + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-250.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-250.js index e4710d7ef8..5475d629db 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-250.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-250.js @@ -26,18 +26,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "1", false); - - verifyNotWritable(arrObj, "1"); - - verifyNotEnumerable(arrObj, "1"); - - verifyNotConfigurable(arrObj, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "1", { + value: false, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-251.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-251.js index 594cb3a3ee..90796842bc 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-251.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-251.js @@ -29,18 +29,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "1", obj); - - verifyNotWritable(arrObj, "1"); - - verifyNotEnumerable(arrObj, "1"); - - verifyNotConfigurable(arrObj, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "1", { + value: obj, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-252.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-252.js index ab56258dc1..a3ac4bf1ef 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-252.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-252.js @@ -32,14 +32,14 @@ try { } catch (e) { verifyWritable(arrObj, "1", "setVerifyHelpProp"); - verifyNotEnumerable(arrObj, "1"); - - verifyNotConfigurable(arrObj, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "1", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-253.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-253.js index a6fbb2221c..90c76748ad 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-253.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-253.js @@ -32,14 +32,14 @@ try { } catch (e) { verifyEqualTo(arrObj, "1", getFunc()); - verifyNotEnumerable(arrObj, "1"); - - verifyNotConfigurable(arrObj, "1"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "1", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-254.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-254.js index 857f5bd3e1..3960688abb 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-254.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-254.js @@ -29,7 +29,9 @@ var desc = Object.getOwnPropertyDescriptor(arrObj, "1"); assert(desc.hasOwnProperty("get") && typeof desc.get === "undefined"); assert(desc.hasOwnProperty("set") && typeof desc.set === "undefined"); -verifyNotEnumerable(arrObj, "1"); -verifyNotConfigurable(arrObj, "1"); +verifyProperty(arrObj, "1", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-255.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-255.js index 03e3d8a268..d4ec618a12 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-255.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-255.js @@ -40,9 +40,11 @@ try { assert(arrObj[1] === getFunc()); assert(desc.hasOwnProperty("set") && typeof desc.set === "undefined"); - - verifyNotEnumerable(arrObj, "1"); - verifyNotConfigurable(arrObj, "1"); } +verifyProperty(arrObj, "1", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-256.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-256.js index a015f2a9a0..20fb18a60a 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-256.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-256.js @@ -38,8 +38,10 @@ try { assert(desc.hasOwnProperty("set") && typeof desc.set === "undefined"); verifyNotWritable(arrObj, "1"); - - verifyNotConfigurable(arrObj, "1"); } +verifyProperty(arrObj, "1", { + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-257.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-257.js index e6e8c2d369..96f9aae122 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-257.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-257.js @@ -31,8 +31,9 @@ Object.defineProperty(arrObj, "1", { verifyWritable(arrObj, "1", "setVerifyHelpProp"); -verifyNotEnumerable(arrObj, "1"); - -verifyNotConfigurable(arrObj, "1"); +verifyProperty(arrObj, "1", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-258.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-258.js index 9821d646bb..c1fe51cf10 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-258.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-258.js @@ -17,12 +17,12 @@ var arrObj = [100]; Object.defineProperty(arrObj, "0", { value: 200 }); -verifyEqualTo(arrObj, "0", 200); -verifyWritable(arrObj, "0"); - -verifyEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: 200, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-259.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-259.js index b0fbd5e780..e7fbdc8f17 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-259.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-259.js @@ -17,12 +17,12 @@ var arrObj = [100]; Object.defineProperty(arrObj, "0", { value: undefined }); -verifyEqualTo(arrObj, "0", undefined); -verifyWritable(arrObj, "0"); - -verifyEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: undefined, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-260.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-260.js index 5e2b69c160..3a195ba846 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-260.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-260.js @@ -16,12 +16,12 @@ var arrObj = [undefined]; Object.defineProperty(arrObj, "0", { value: 100 }); -verifyEqualTo(arrObj, "0", 100); -verifyWritable(arrObj, "0"); - -verifyEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: 100, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-261.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-261.js index e945f54eeb..7ecc70fc44 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-261.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-261.js @@ -16,12 +16,12 @@ var arrObj = [100]; Object.defineProperty(arrObj, "0", { writable: false }); -verifyEqualTo(arrObj, "0", 100); -verifyNotWritable(arrObj, "0"); - -verifyEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: 100, + writable: false, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-262.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-262.js index aed61cb5ae..b9a6475463 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-262.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-262.js @@ -17,12 +17,12 @@ var arrObj = [100]; Object.defineProperty(arrObj, "0", { enumerable: false }); -verifyEqualTo(arrObj, "0", 100); -verifyWritable(arrObj, "0"); - -verifyNotEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: 100, + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-263.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-263.js index b0b4ea2cc0..c0caa9fd90 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-263.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-263.js @@ -17,12 +17,12 @@ var arrObj = [100]; Object.defineProperty(arrObj, "0", { configurable: false }); -verifyEqualTo(arrObj, "0", 100); -verifyWritable(arrObj, "0"); - -verifyEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: 100, + writable: true, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-264.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-264.js index a7d2eac7f2..97db5f6f91 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-264.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-264.js @@ -18,12 +18,12 @@ Object.defineProperty(arrObj, "0", { enumerable: false, configurable: false }); -verifyEqualTo(arrObj, "0", 100); -verifyNotWritable(arrObj, "0"); - -verifyNotEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + value: 100, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-265.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-265.js index f68fdd93f4..ae3d86596c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-265.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-265.js @@ -28,8 +28,9 @@ Object.defineProperty(arrObj, "0", { }); verifyEqualTo(arrObj, "0", getFunc()); -verifyNotEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-266.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-266.js index 98d664d424..7fd1bfcf7f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-266.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-266.js @@ -26,8 +26,10 @@ Object.defineProperty(arrObj, "0", { Object.defineProperty(arrObj, "0", { get: undefined }); -verifyNotEnumerable(arrObj, "0"); -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-267.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-267.js index b1d1f3c19e..532c94c676 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-267.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-267.js @@ -27,8 +27,9 @@ Object.defineProperty(arrObj, "0", { }); verifyEqualTo(arrObj, "0", getFunc()); -verifyNotEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-268.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-268.js index 8f65ec43a1..3f60a9de36 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-268.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-268.js @@ -27,8 +27,9 @@ Object.defineProperty(arrObj, "0", { }); verifyWritable(arrObj, "0", "setVerifyHelpProp"); -verifyNotEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-269.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-269.js index 84be2830ff..9f0535aa58 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-269.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-269.js @@ -22,8 +22,10 @@ Object.defineProperty(arrObj, "0", { Object.defineProperty(arrObj, "0", { set: undefined }); -verifyNotEnumerable(arrObj, "0"); -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-270.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-270.js index 696ebb956a..5d22407b0b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-270.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-270.js @@ -28,8 +28,9 @@ Object.defineProperty(arrObj, "0", { }); verifyWritable(arrObj, "0", "setVerifyHelpProp"); -verifyNotEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-271.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-271.js index e82084fe9e..f79b212fcf 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-271.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-271.js @@ -29,8 +29,9 @@ Object.defineProperty(arrObj, "0", { }); verifyWritable(arrObj, "0", "setVerifyHelpProp"); -verifyNotEnumerable(arrObj, "0"); - -verifyConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-272.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-272.js index 663614560e..478981ccd2 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-272.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-272.js @@ -28,8 +28,9 @@ Object.defineProperty(arrObj, "0", { }); verifyWritable(arrObj, "0", "setVerifyHelpProp"); -verifyNotEnumerable(arrObj, "0"); - -verifyNotConfigurable(arrObj, "0"); +verifyProperty(arrObj, "0", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-273.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-273.js index 14d45dbbb5..0855f67372 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-273.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-273.js @@ -39,8 +39,9 @@ verifyEqualTo(arrObj, "1", getFunc()); verifyWritable(arrObj, "1", "setVerifyHelpProp"); -verifyNotEnumerable(arrObj, "1"); - -verifyNotConfigurable(arrObj, "1"); +verifyProperty(arrObj, "1", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-277.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-277.js index 825c594a6b..919c7ebc51 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-277.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-277.js @@ -21,12 +21,11 @@ Object.defineProperty(arrObj, "property", { configurable: true }); -verifyEqualTo(arrObj, "property", 12); - -verifyWritable(arrObj, "property"); - -verifyEnumerable(arrObj, "property"); - -verifyConfigurable(arrObj, "property"); +verifyProperty(arrObj, "property", { + value: 12, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-278.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-278.js index 4ad70e2558..bf537c408d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-278.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-278.js @@ -32,8 +32,9 @@ verifyEqualTo(arrObj, "property", getFunc()); verifyWritable(arrObj, "property", "setVerifyHelpProp"); -verifyEnumerable(arrObj, "property"); - -verifyConfigurable(arrObj, "property"); +verifyProperty(arrObj, "property", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-279.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-279.js index 9f78e7cc67..6536ef9bdc 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-279.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-279.js @@ -38,8 +38,9 @@ verifyEqualTo(arrObj, "property", getFunc()); verifyWritable(arrObj, "property", "setVerifyHelpProp"); -verifyNotEnumerable(arrObj, "property"); - -verifyNotConfigurable(arrObj, "property"); +verifyProperty(arrObj, "property", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-280.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-280.js index 7315c8c784..63f0d7d140 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-280.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-280.js @@ -21,12 +21,11 @@ Object.defineProperty(arrObj, "property", { configurable: false }); -verifyEqualTo(arrObj, "property", 12); - -verifyNotWritable(arrObj, "property"); - -verifyNotEnumerable(arrObj, "property"); - -verifyNotConfigurable(arrObj, "property"); +verifyProperty(arrObj, "property", { + value: 12, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-281.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-281.js index 67ec5776bc..36b8dc51e3 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-281.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-281.js @@ -23,18 +23,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "property", 12); - - verifyNotWritable(arrObj, "property"); - - verifyNotEnumerable(arrObj, "property"); - - verifyNotConfigurable(arrObj, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "property", { + value: 12, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-282.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-282.js index 0b05899bc6..01f4174e22 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-282.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-282.js @@ -23,18 +23,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "property", undefined); - - verifyNotWritable(arrObj, "property"); - - verifyNotEnumerable(arrObj, "property"); - - verifyNotConfigurable(arrObj, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "property", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-283.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-283.js index 7ca939b4f5..c106eef000 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-283.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-283.js @@ -23,18 +23,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "property", 12); - - verifyNotWritable(arrObj, "property"); - - verifyNotEnumerable(arrObj, "property"); - - verifyNotConfigurable(arrObj, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "property", { + value: 12, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-284.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-284.js index 48bd118b9c..ef9e68ce98 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-284.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-284.js @@ -23,18 +23,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arrObj, "property", 12); - - verifyNotWritable(arrObj, "property"); - - verifyNotEnumerable(arrObj, "property"); - - verifyNotConfigurable(arrObj, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "property", { + value: 12, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-285.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-285.js index 055d7d32d7..5604a04a61 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-285.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-285.js @@ -37,14 +37,14 @@ try { verifyWritable(arrObj, "property", "setVerifyHelpProp"); - verifyNotEnumerable(arrObj, "property"); - - verifyNotConfigurable(arrObj, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "property", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-286.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-286.js index ebf54b5e61..7c2317d15f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-286.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-286.js @@ -28,14 +28,14 @@ try { } catch (e) { verifyWritable(arrObj, "property", "setVerifyHelpProp"); - verifyNotEnumerable(arrObj, "property"); - - verifyNotConfigurable(arrObj, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "property", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-287.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-287.js index 3aa609e301..28ce64b648 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-287.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-287.js @@ -29,14 +29,14 @@ try { } catch (e) { verifyWritable(arrObj, "property", "setVerifyHelpProp"); - verifyNotEnumerable(arrObj, "property"); - - verifyNotConfigurable(arrObj, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "property", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-288.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-288.js index 99317bcbab..a022fc284d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-288.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-288.js @@ -29,14 +29,14 @@ try { } catch (e) { verifyWritable(arrObj, "property", "setVerifyHelpProp"); - verifyNotEnumerable(arrObj, "property"); - - verifyNotConfigurable(arrObj, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(arrObj, "property", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-289-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-289-1.js index 9c16dbb07a..83ecff8e49 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-289-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-289-1.js @@ -28,13 +28,12 @@ includes: [propertyHelper.js] throw new Test262Error("Expected a === 0, actually " + a); } - verifyEqualTo(arguments, "0", 10); - - verifyWritable(arguments, "0"); - - verifyEnumerable(arguments, "0"); - - verifyConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + value: 10, + writable: true, + enumerable: true, + configurable: true, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-289.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-289.js index 4b90e38ef6..c5f4bc699a 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-289.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-289.js @@ -19,13 +19,13 @@ includes: [propertyHelper.js] enumerable: true, configurable: true }); - verifyEqualTo(arguments, "0", 10); - verifyWritable(arguments, "0"); - - verifyEnumerable(arguments, "0"); - - verifyConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + value: 10, + writable: true, + enumerable: true, + configurable: true, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-290-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-290-1.js index 71fa4baeff..b31957da09 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-290-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-290-1.js @@ -37,9 +37,10 @@ includes: [propertyHelper.js] verifyWritable(arguments, "0", "setVerifyHelpProp"); - verifyEnumerable(arguments, "0"); - - verifyConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + enumerable: true, + configurable: true, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-290.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-290.js index 6b4d350268..204d9550c6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-290.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-290.js @@ -31,9 +31,10 @@ includes: [propertyHelper.js] verifyWritable(arguments, "0", "setVerifyHelpProp"); - verifyEnumerable(arguments, "0"); - - verifyConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + enumerable: true, + configurable: true, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-291-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-291-1.js index 04faea4a9e..98cac6c8b0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-291-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-291-1.js @@ -36,9 +36,10 @@ includes: [propertyHelper.js] verifyEqualTo(arguments, "0", getFunc2()); - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-291.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-291.js index 0d936a72a3..d7b113d7d4 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-291.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-291.js @@ -31,9 +31,10 @@ includes: [propertyHelper.js] }); verifyEqualTo(arguments, "0", getFunc2()); - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292-1.js index 124143b87c..8eb28bae83 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292-1.js @@ -25,13 +25,12 @@ flags: [noStrict] throw new Test262Error('Expected a === 20, actually ' + a); } - verifyEqualTo(arguments, "0", 20); - - verifyNotWritable(arguments, "0"); - - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + value: 20, + writable: false, + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292-2-strict.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292-2-strict.js index 5327e61f5d..da294bea67 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292-2-strict.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292-2-strict.js @@ -26,13 +26,12 @@ flags: [onlyStrict] throw new Test262Error('Expected a === 0, actually ' + a); } - verifyEqualTo(arguments, "0", 20); - - verifyNotWritable(arguments, "0"); - - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + value: 20, + writable: false, + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292.js index 7091d42cf8..b96b3476f4 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292.js @@ -18,13 +18,13 @@ includes: [propertyHelper.js] enumerable: false, configurable: false }); - verifyEqualTo(arguments, "0", 20); - verifyNotWritable(arguments, "0"); - - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + value: 20, + writable: false, + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-1.js index 642e95f413..f4d493bade 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-1.js @@ -20,13 +20,13 @@ includes: [propertyHelper.js] Object.defineProperty(arguments, "0", { value: 20 }); - verifyEqualTo(arguments, "0", 20); - verifyNotWritable(arguments, "0"); - - verifyEnumerable(arguments, "0"); - - verifyConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + value: 20, + writable: false, + enumerable: true, + configurable: true, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-2.js index 063ab121d1..9ed17e4bb3 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-2.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-2.js @@ -28,24 +28,21 @@ flags: [noStrict] throw new Test262Error("Expected an exception."); } catch (e) { - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - verifyEqualTo(arguments, "0", 10); - - verifyNotWritable(arguments, "0"); - - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (a !== 10) { throw new Test262Error('Expected "a === 10", actually ' + a); } - } + + verifyProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-3.js index a27f584a65..bb3170d229 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-3.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-3.js @@ -26,13 +26,12 @@ flags: [noStrict] throw new Test262Error('Expected "a === 10", actually ' + a); } - verifyEqualTo(arguments, "0", 20); - - verifyNotWritable(arguments, "0"); - - verifyEnumerable(arguments, "0"); - - verifyConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + value: 20, + writable: false, + enumerable: true, + configurable: true, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-4-strict.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-4-strict.js index 03ace78694..6e6c2d9eda 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-4-strict.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-4-strict.js @@ -27,13 +27,12 @@ flags: [onlyStrict] throw new Test262Error('Expected "a === 0", actually ' + a); } - verifyEqualTo(arguments, "0", 20); - - verifyNotWritable(arguments, "0"); - - verifyEnumerable(arguments, "0"); - - verifyConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + value: 20, + writable: false, + enumerable: true, + configurable: true, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293.js index 4ca208ba8e..002556ebbe 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293.js @@ -25,19 +25,17 @@ includes: [propertyHelper.js] }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arguments, "0", 10); - - verifyNotWritable(arguments, "0"); - - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-294-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-294-1.js index e358ab75e8..38413c6b14 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-294-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-294-1.js @@ -32,20 +32,17 @@ flags: [noStrict] throw new Test262Error("Expected TypeError, got " + e); } - verifyEqualTo(arguments, "0", 10); - - verifyNotWritable(arguments, "0"); - - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (a !== 10) { throw new Test262Error('Expected "a === 10", actually ' + a); } - } + verifyProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-294.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-294.js index 08c69e755e..5138dc4c3f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-294.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-294.js @@ -24,19 +24,17 @@ includes: [propertyHelper.js] }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arguments, "0", 10); - - verifyNotWritable(arguments, "0"); - - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-295-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-295-1.js index 394066dfc2..3045dee339 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-295-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-295-1.js @@ -32,18 +32,17 @@ flags: [noStrict] throw new Test262Error("Expected TypeError, got " + e); } - verifyEqualTo(arguments, "0", 10); - - verifyNotWritable(arguments, "0"); - - verifyEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (a !== 10) { throw new Test262Error('Expected "a === 10", actually ' + a); } } + + verifyProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: true, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-295.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-295.js index cd7eb340b7..34df8eb700 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-295.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-295.js @@ -24,19 +24,17 @@ includes: [propertyHelper.js] }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arguments, "0", 10); - - verifyNotWritable(arguments, "0"); - - verifyEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: true, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-296-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-296-1.js index 77e9fe1642..90a53ae720 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-296-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-296-1.js @@ -31,18 +31,17 @@ flags: [noStrict] throw new Test262Error("Expected TypeError, got " + e); } - verifyEqualTo(arguments, "0", 10); - - verifyNotWritable(arguments, "0"); - - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (a !== 10) { throw new Test262Error('Expected "a === 10", actually ' + a); } } + + verifyProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-296.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-296.js index 8625821007..af40ff4d9c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-296.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-296.js @@ -24,19 +24,17 @@ includes: [propertyHelper.js] }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arguments, "0", 10); - - verifyNotWritable(arguments, "0"); - - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-297-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-297-1.js index 8627560fa9..ec2b3857da 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-297-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-297-1.js @@ -38,15 +38,15 @@ includes: [propertyHelper.js] verifyEqualTo(arguments, "0", getFunc1()); - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-297.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-297.js index e738fc84a3..fee2b5a6d6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-297.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-297.js @@ -32,15 +32,15 @@ includes: [propertyHelper.js] } catch (e) { verifyEqualTo(arguments, "0", getFunc1()); - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-298-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-298-1.js index 9cb976b0fd..3bf5f45f96 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-298-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-298-1.js @@ -39,15 +39,15 @@ includes: [propertyHelper.js] verifyEqualTo(arguments, "0", getFunc()); - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-298.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-298.js index 651330f8f5..e0f0627691 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-298.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-298.js @@ -33,15 +33,15 @@ includes: [propertyHelper.js] } catch (e) { verifyEqualTo(arguments, "0", getFunc()); - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-299-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-299-1.js index 2ef3e98416..f56db5b666 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-299-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-299-1.js @@ -33,15 +33,15 @@ includes: [propertyHelper.js] } verifyEqualTo(arguments, "0", getFunc()); - verifyEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + enumerable: true, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-299.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-299.js index 8294112d3a..533e491194 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-299.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-299.js @@ -28,15 +28,15 @@ includes: [propertyHelper.js] } catch (e) { verifyEqualTo(arguments, "0", getFunc()); - verifyEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + enumerable: true, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-300-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-300-1.js index 802dd24613..b3d77c7423 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-300-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-300-1.js @@ -33,15 +33,15 @@ includes: [propertyHelper.js] } verifyEqualTo(arguments, "0", getFunc()); - verifyEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + enumerable: true, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-300.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-300.js index 2341d87dca..6e14aa45a6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-300.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-300.js @@ -28,15 +28,15 @@ includes: [propertyHelper.js] } catch (e) { verifyEqualTo(arguments, "0", getFunc()); - verifyEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + enumerable: true, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-301-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-301-1.js index 50854b502f..ba3ff3691c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-301-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-301-1.js @@ -23,13 +23,13 @@ includes: [propertyHelper.js] if (a !== 0) { throw new Test262Error("Expected a === 0, actually " + a); } - verifyEqualTo(arguments, "0", 10); - verifyNotWritable(arguments, "0"); - - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-301.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-301.js index 6387b45b3c..0f32d2e7bc 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-301.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-301.js @@ -20,13 +20,13 @@ includes: [propertyHelper.js] enumerable: false, configurable: false }); - verifyEqualTo(arguments, "0", 10); - verifyNotWritable(arguments, "0"); - - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-302-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-302-1.js index d9e24450e1..2ccfa7b7b0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-302-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-302-1.js @@ -36,9 +36,10 @@ includes: [propertyHelper.js] verifyWritable(arguments, "0", "setVerifyHelpProp"); - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-302.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-302.js index 40fe4d4fcd..a3818170b8 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-302.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-302.js @@ -32,9 +32,10 @@ includes: [propertyHelper.js] verifyWritable(arguments, "0", "setVerifyHelpProp"); - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + enumerable: false, + configurable: false, + }); }(0, 1, 2)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-303.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-303.js index e1d15a9dcd..b627552c2b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-303.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-303.js @@ -32,9 +32,10 @@ includes: [propertyHelper.js] }); verifyEqualTo(arguments, "0", getFunc2()); - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + enumerable: false, + configurable: false, + }); }()); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-304.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-304.js index 058949b82b..a327b5b422 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-304.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-304.js @@ -19,13 +19,13 @@ includes: [propertyHelper.js] enumerable: false, configurable: false }); - verifyEqualTo(arguments, "0", 20); - verifyNotWritable(arguments, "0"); - - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); + verifyProperty(arguments, "0", { + value: 20, + writable: false, + enumerable: false, + configurable: false, + }); }()); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-305.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-305.js index 88e3ea9526..fedd5c087c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-305.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-305.js @@ -25,19 +25,17 @@ includes: [propertyHelper.js] }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arguments, "0", 0); - - verifyNotWritable(arguments, "0"); - - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + value: 0, + writable: false, + enumerable: false, + configurable: false, + }); }()); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-306.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-306.js index a33eff559b..54208f8013 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-306.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-306.js @@ -25,19 +25,17 @@ includes: [propertyHelper.js] }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arguments, "0", 0); - - verifyNotWritable(arguments, "0"); - - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + value: 0, + writable: false, + enumerable: false, + configurable: false, + }); }()); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-307.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-307.js index c9fdf870ff..df233b482d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-307.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-307.js @@ -25,19 +25,17 @@ includes: [propertyHelper.js] }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arguments, "0", 0); - - verifyNotWritable(arguments, "0"); - - verifyEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + value: 0, + writable: false, + enumerable: true, + configurable: false, + }); }()); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-308.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-308.js index aceabc53a0..e9cff62621 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-308.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-308.js @@ -25,19 +25,17 @@ includes: [propertyHelper.js] }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arguments, "0", 0); - - verifyNotWritable(arguments, "0"); - - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + value: 0, + writable: false, + enumerable: false, + configurable: false, + }); }()); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-309.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-309.js index f1803f13cd..36adce5824 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-309.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-309.js @@ -33,15 +33,15 @@ includes: [propertyHelper.js] } catch (e) { verifyEqualTo(arguments, "0", getFunc1()); - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + enumerable: false, + configurable: false, + }); }()); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-310.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-310.js index 094229861a..462d472756 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-310.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-310.js @@ -34,15 +34,15 @@ includes: [propertyHelper.js] } catch (e) { verifyEqualTo(arguments, "0", getFunc()); - verifyNotEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + enumerable: false, + configurable: false, + }); }()); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-311.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-311.js index ede81f7918..9a4c8172be 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-311.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-311.js @@ -29,15 +29,15 @@ includes: [propertyHelper.js] } catch (e) { verifyEqualTo(arguments, "0", getFunc()); - verifyEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + enumerable: true, + configurable: false, + }); }()); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-312.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-312.js index eaf2c27fab..b906d92976 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-312.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-312.js @@ -27,15 +27,15 @@ includes: [propertyHelper.js] } catch (e) { verifyEqualTo(arguments, "0", getFunc()); - verifyEnumerable(arguments, "0"); - - verifyNotConfigurable(arguments, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "0", { + enumerable: true, + configurable: false, + }); }()); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-313-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-313-1.js index 24f6b77d8b..f51e471fec 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-313-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-313-1.js @@ -18,13 +18,13 @@ includes: [propertyHelper.js] enumerable: true, configurable: true }); - verifyEqualTo(arguments, "genericProperty", 1001); - verifyWritable(arguments, "genericProperty"); - - verifyEnumerable(arguments, "genericProperty"); - - verifyConfigurable(arguments, "genericProperty"); + verifyProperty(arguments, "genericProperty", { + value: 1001, + writable: true, + enumerable: true, + configurable: true, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-313.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-313.js index 5f5650d942..815ad29d11 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-313.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-313.js @@ -18,13 +18,13 @@ includes: [propertyHelper.js] enumerable: true, configurable: true }); - verifyEqualTo(arguments, "genericProperty", 1001); - verifyWritable(arguments, "genericProperty"); - - verifyEnumerable(arguments, "genericProperty"); - - verifyConfigurable(arguments, "genericProperty"); + verifyProperty(arguments, "genericProperty", { + value: 1001, + writable: true, + enumerable: true, + configurable: true, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-314-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-314-1.js index aaa4d6a0fc..60c2f1066f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-314-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-314-1.js @@ -29,9 +29,10 @@ includes: [propertyHelper.js] verifyWritable(arguments, "genericProperty", "testgetFunction"); - verifyEnumerable(arguments, "genericProperty"); - - verifyConfigurable(arguments, "genericProperty"); + verifyProperty(arguments, "genericProperty", { + enumerable: true, + configurable: true, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-314.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-314.js index 707689d404..de44b05071 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-314.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-314.js @@ -29,9 +29,10 @@ includes: [propertyHelper.js] verifyWritable(arguments, "genericProperty", "testgetFunction"); - verifyEnumerable(arguments, "genericProperty"); - - verifyConfigurable(arguments, "genericProperty"); + verifyProperty(arguments, "genericProperty", { + enumerable: true, + configurable: true, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-315-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-315-1.js index 078b2b0c03..83290dddd1 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-315-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-315-1.js @@ -44,9 +44,10 @@ includes: [propertyHelper.js] verifyWritable(arguments, "genericProperty", "testgetFunction"); - verifyNotEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); + verifyProperty(arguments, "genericProperty", { + enumerable: false, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-315.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-315.js index f9e6b876a8..7d6c5b80c8 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-315.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-315.js @@ -40,9 +40,10 @@ includes: [propertyHelper.js] verifyWritable(arguments, "genericProperty", "testgetFunction"); - verifyNotEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); + verifyProperty(arguments, "genericProperty", { + enumerable: false, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-316-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-316-1.js index 4c18c0b45c..9d4203c2b7 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-316-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-316-1.js @@ -23,13 +23,13 @@ includes: [propertyHelper.js] enumerable: false, configurable: false }); - verifyEqualTo(arguments, "genericProperty", 1002); - verifyWritable(arguments, "genericProperty"); - - verifyNotEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); + verifyProperty(arguments, "genericProperty", { + value: 1002, + writable: true, + enumerable: false, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-316.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-316.js index 6683891473..7ed325b7ab 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-316.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-316.js @@ -23,13 +23,13 @@ includes: [propertyHelper.js] enumerable: false, configurable: false }); - verifyEqualTo(arguments, "genericProperty", 1002); - verifyWritable(arguments, "genericProperty"); - - verifyNotEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); + verifyProperty(arguments, "genericProperty", { + value: 1002, + writable: true, + enumerable: false, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-317-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-317-1.js index be820cbce1..5eec5035ee 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-317-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-317-1.js @@ -28,19 +28,17 @@ includes: [propertyHelper.js] throw new Test262Error('Expected "b === 2;", actually ' + b); } - verifyEqualTo(arguments, "genericProperty", 1001); - - verifyNotWritable(arguments, "genericProperty"); - - verifyNotEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "genericProperty", { + value: 1001, + writable: false, + enumerable: false, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-317.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-317.js index 77ca0ba862..0d7c8266b0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-317.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-317.js @@ -23,19 +23,17 @@ includes: [propertyHelper.js] }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arguments, "genericProperty", 1001); - - verifyNotWritable(arguments, "genericProperty"); - - verifyNotEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "genericProperty", { + value: 1001, + writable: false, + enumerable: false, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-318-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-318-1.js index c275772feb..acd8d37483 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-318-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-318-1.js @@ -23,19 +23,17 @@ includes: [propertyHelper.js] }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arguments, "genericProperty", undefined); - - verifyNotWritable(arguments, "genericProperty"); - - verifyNotEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "genericProperty", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-318.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-318.js index 95284091f6..ce31e7dc9f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-318.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-318.js @@ -22,21 +22,17 @@ includes: [propertyHelper.js] }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arguments, "genericProperty", undefined); - - verifyNotWritable(arguments, "genericProperty"); - - verifyNotEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); - - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + verifyProperty(arguments, "genericProperty", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-319-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-319-1.js index 6f184f8196..449fdf3fbd 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-319-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-319-1.js @@ -23,20 +23,17 @@ includes: [propertyHelper.js] }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arguments, "genericProperty", undefined); - - verifyNotWritable(arguments, "genericProperty"); - - verifyEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); - - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "genericProperty", { + value: undefined, + writable: false, + enumerable: true, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-319.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-319.js index d4c4c20dc9..a9059f043f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-319.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-319.js @@ -22,19 +22,17 @@ includes: [propertyHelper.js] }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arguments, "genericProperty", undefined); - - verifyNotWritable(arguments, "genericProperty"); - - verifyEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "genericProperty", { + value: undefined, + writable: false, + enumerable: true, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-320-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-320-1.js index 794b689a98..343a81b5eb 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-320-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-320-1.js @@ -22,19 +22,17 @@ includes: [propertyHelper.js] }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arguments, "genericProperty", undefined); - - verifyNotWritable(arguments, "genericProperty"); - - verifyNotEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "genericProperty", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-320.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-320.js index 2d16488d20..018b12ae85 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-320.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-320.js @@ -21,21 +21,17 @@ includes: [propertyHelper.js] }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(arguments, "genericProperty", undefined); - - verifyNotWritable(arguments, "genericProperty"); - - verifyNotEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); - - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + verifyProperty(arguments, "genericProperty", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-321-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-321-1.js index f0b19aff91..328f00ac56 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-321-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-321-1.js @@ -41,15 +41,15 @@ includes: [propertyHelper.js] verifyWritable(arguments, "genericProperty", "helpVerifyGet"); - verifyNotEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "genericProperty", { + enumerable: false, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-321.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-321.js index ce1ebc65ec..cc21c38b96 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-321.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-321.js @@ -36,15 +36,15 @@ includes: [propertyHelper.js] verifyWritable(arguments, "genericProperty", "helpVerifyGet"); - verifyNotEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "genericProperty", { + enumerable: false, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-322-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-322-1.js index 4261b4980b..e50a02d336 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-322-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-322-1.js @@ -30,15 +30,15 @@ includes: [propertyHelper.js] } catch (e) { verifyWritable(arguments, "genericProperty", "genericPropertyString"); - verifyNotEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "genericProperty", { + enumerable: false, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-322.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-322.js index 9414c90d54..3d52c42a3d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-322.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-322.js @@ -29,15 +29,15 @@ includes: [propertyHelper.js] } catch (e) { verifyWritable(arguments, "genericProperty", "genericPropertyString"); - verifyNotEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "genericProperty", { + enumerable: false, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-323-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-323-1.js index 769c0a8634..252fad78ae 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-323-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-323-1.js @@ -32,16 +32,15 @@ includes: [propertyHelper.js] } verifyWritable(arguments, "genericProperty", "genericPropertyString"); - verifyEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + verifyProperty(arguments, "genericProperty", { + enumerable: true, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-323.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-323.js index a6e17705ef..ee0cbf67ac 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-323.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-323.js @@ -28,15 +28,15 @@ includes: [propertyHelper.js] } catch (e) { verifyWritable(arguments, "genericProperty", "genericPropertyString"); - verifyEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "genericProperty", { + enumerable: true, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-324-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-324-1.js index 949102ee2f..0bffa63c65 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-324-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-324-1.js @@ -28,15 +28,15 @@ includes: [propertyHelper.js] } catch (e) { verifyWritable(arguments, "genericProperty", "genericPropertyString"); - verifyNotEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } + + verifyProperty(arguments, "genericProperty", { + enumerable: false, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-324.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-324.js index bd7e47b2d2..c7f0a023f6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-324.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-324.js @@ -27,16 +27,15 @@ includes: [propertyHelper.js] } catch (e) { verifyWritable(arguments, "genericProperty", "genericPropertyString"); - verifyNotEnumerable(arguments, "genericProperty"); - - verifyNotConfigurable(arguments, "genericProperty"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } - false; + + verifyProperty(arguments, "genericProperty", { + enumerable: false, + configurable: false, + }); }(1, 2, 3)); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-1.js index b38f669f07..b1eb009f19 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-1.js @@ -24,12 +24,11 @@ Object.defineProperty(obj, "property", { value: 1002 }); -verifyEqualTo(obj, "property", 1002); - -verifyWritable(obj, "property"); - -verifyNotEnumerable(obj, "property"); - -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + value: 1002, + writable: true, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-2.js index 2c7ac9fd07..e2df9640ff 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-2.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-2.js @@ -24,12 +24,11 @@ Object.defineProperty(obj, "0", { value: 1002 }); -verifyEqualTo(obj, "0", 1002); - -verifyWritable(obj, "0"); - -verifyNotEnumerable(obj, "0"); - -verifyNotConfigurable(obj, "0"); +verifyProperty(obj, "0", { + value: 1002, + writable: true, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-3.js index 214436cb50..cd9db364ea 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-3.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-3.js @@ -26,12 +26,11 @@ Object.defineProperty(obj, "property", { value: 1002 }); -verifyEqualTo(obj, "property", 1002); - -verifyWritable(obj, "property"); - -verifyNotEnumerable(obj, "property"); - -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + value: 1002, + writable: true, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-6.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-6.js index 21265866ff..77186e1b85 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-6.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-6.js @@ -24,12 +24,11 @@ Object.defineProperty(obj, "0", { value: 1002 }); -verifyEqualTo(obj, "0", 1002); - -verifyWritable(obj, "0"); - -verifyNotEnumerable(obj, "0"); - -verifyNotConfigurable(obj, "0"); +verifyProperty(obj, "0", { + value: 1002, + writable: true, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-7.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-7.js index dea755a355..8881de5da7 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-7.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-7.js @@ -24,12 +24,11 @@ Object.defineProperty(obj, "prop", { value: 1002 }); -verifyEqualTo(obj, "prop", 1002); - -verifyWritable(obj, "prop"); - -verifyNotEnumerable(obj, "prop"); - -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + value: 1002, + writable: true, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-8.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-8.js index 785d0adc99..1e440f485b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-8.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-8.js @@ -26,12 +26,11 @@ Object.defineProperty(obj, "0", { value: 1002 }); -verifyEqualTo(obj, "0", 1002); - -verifyWritable(obj, "0"); - -verifyNotEnumerable(obj, "0"); - -verifyNotConfigurable(obj, "0"); +verifyProperty(obj, "0", { + value: 1002, + writable: true, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-335.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-335.js index 177a249f90..8afe8c12f0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-335.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-335.js @@ -18,8 +18,9 @@ Object.defineProperty(obj, "prop", { configurable: false }); -assert(obj.hasOwnProperty("prop")); -verifyNotConfigurable(obj, "prop"); -assert.sameValue(obj.prop, 2010); +verifyProperty(obj, "prop", { + value: 2010, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-349.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-349.js index 143606c7a9..af098aa486 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-349.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-349.js @@ -18,8 +18,9 @@ Object.defineProperty(obj, "prop", { configurable: false }); -assert(obj.hasOwnProperty("prop")); -verifyNotConfigurable(obj, "prop"); -assert.sameValue(obj.prop, 2010); +verifyProperty(obj, "prop", { + value: 2010, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-1.js index 3e580abc51..f17f51615c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-1.js @@ -24,12 +24,11 @@ Object.defineProperty(obj, "property", { value: 1002 }); -verifyEqualTo(obj, "property", 1002); - -verifyNotWritable(obj, "property"); - -verifyNotEnumerable(obj, "property"); - -verifyConfigurable(obj, "property"); +verifyProperty(obj, "property", { + value: 1002, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-10.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-10.js index 4fa47d892d..78e8a4e234 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-10.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-10.js @@ -24,12 +24,11 @@ Object.defineProperty(obj, "0", { value: 1002 }); -verifyEqualTo(obj, "0", 1002); - -verifyNotWritable(obj, "0"); - -verifyNotEnumerable(obj, "0"); - -verifyConfigurable(obj, "0"); +verifyProperty(obj, "0", { + value: 1002, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-11.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-11.js index 0f23373bff..3cde36b73f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-11.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-11.js @@ -24,12 +24,11 @@ Object.defineProperty(obj, "prop", { value: 1002 }); -verifyEqualTo(obj, "prop", 1002); - -verifyNotWritable(obj, "prop"); - -verifyNotEnumerable(obj, "prop"); - -verifyConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + value: 1002, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-12.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-12.js index c301667d62..762a767ecc 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-12.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-12.js @@ -26,12 +26,11 @@ Object.defineProperty(obj, "0", { value: 1002 }); -verifyEqualTo(obj, "0", 1002); - -verifyNotWritable(obj, "0"); - -verifyNotEnumerable(obj, "0"); - -verifyConfigurable(obj, "0"); +verifyProperty(obj, "0", { + value: 1002, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-15.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-15.js index 42cf188ef5..df68d33fc5 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-15.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-15.js @@ -19,7 +19,9 @@ Object.defineProperty(obj, "prop", { configurable: true }); -assert.sameValue(obj.prop, 2010); -verifyNotWritable(obj, "prop"); +verifyProperty(obj, "prop", { + value: 2010, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-16.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-16.js index b5947a8818..94466d9dcf 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-16.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-16.js @@ -22,7 +22,9 @@ Object.defineProperty(obj, "0", { configurable: true }); -assert.sameValue(obj[0], 2010); -verifyNotWritable(obj, "0"); +verifyProperty(obj, "0", { + value: 2010, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-2.js index 60ef5a8187..25c8fd2b22 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-2.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-2.js @@ -24,12 +24,11 @@ Object.defineProperty(obj, "0", { value: 1002 }); -verifyEqualTo(obj, "0", 1002); - -verifyNotWritable(obj, "0"); - -verifyNotEnumerable(obj, "0"); - -verifyConfigurable(obj, "0"); +verifyProperty(obj, "0", { + value: 1002, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-3.js index fecfdd55a4..7567ddf16d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-3.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-3.js @@ -25,12 +25,11 @@ Object.defineProperty(obj, "property", { value: 1002 }); -verifyEqualTo(obj, "property", 1002); - -verifyNotWritable(obj, "property"); - -verifyNotEnumerable(obj, "property"); - -verifyConfigurable(obj, "property"); +verifyProperty(obj, "property", { + value: 1002, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-6.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-6.js index 140bc5b7f7..58669c9a14 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-6.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-6.js @@ -19,7 +19,9 @@ Object.defineProperty(obj, "0", { configurable: true }); -assert.sameValue(obj[0], 2010); -verifyNotWritable(obj, "0"); +verifyProperty(obj, "0", { + value: 2010, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-7.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-7.js index 31fffa2ee2..c7f38278ed 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-7.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-7.js @@ -21,7 +21,9 @@ Object.defineProperty(obj, "prop", { configurable: true }); -assert.sameValue(obj.prop, 2010); -verifyNotWritable(obj, "prop"); +verifyProperty(obj, "prop", { + value: 2010, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354.js index dbf15887fb..d43159c7c6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354.js @@ -18,7 +18,9 @@ Object.defineProperty(obj, "prop", { configurable: true }); -assert.sameValue(obj.prop, 2010); -verifyNotWritable(obj, "prop"); +verifyProperty(obj, "prop", { + value: 2010, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-361.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-361.js index ddaf657cd8..5369b5da0b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-361.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-361.js @@ -18,7 +18,9 @@ Object.defineProperty(obj, "prop", { configurable: false }); -assert.sameValue(obj.prop, 2010); -verifyNotWritable(obj, "prop"); +verifyProperty(obj, "prop", { + value: 2010, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-363.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-363.js index 5eb3404f36..cd9b1d6519 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-363.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-363.js @@ -18,7 +18,8 @@ Object.defineProperty(obj, "prop", { configurable: false }); -assert(obj.hasOwnProperty("prop")); -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-368.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-368.js index 1faaa98d37..1a9cb6b12b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-368.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-368.js @@ -18,7 +18,9 @@ Object.defineProperty(obj, "prop", { configurable: true }); -assert.sameValue(obj.prop, 2010); -verifyNotWritable(obj, "prop"); +verifyProperty(obj, "prop", { + value: 2010, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-375.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-375.js index b41c9513e2..9c9cbd5511 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-375.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-375.js @@ -18,7 +18,9 @@ Object.defineProperty(obj, "prop", { configurable: false }); -assert.sameValue(obj.prop, 2010); -verifyNotWritable(obj, "prop"); +verifyProperty(obj, "prop", { + value: 2010, + writable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-377.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-377.js index efd2e54659..c9102fcc6f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-377.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-377.js @@ -18,7 +18,8 @@ Object.defineProperty(obj, "prop", { configurable: false }); -assert(obj.hasOwnProperty("prop")); -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-38.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-38.js index f40b4f152a..b3ac2b6d88 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-38.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-38.js @@ -16,13 +16,12 @@ try { configurable: true }); - verifyEqualTo(Math, "foo", 12); - - verifyNotWritable(Math, "foo"); - - verifyNotEnumerable(Math, "foo"); - - verifyConfigurable(Math, "foo"); + verifyProperty(Math, "foo", { + value: 12, + writable: false, + enumerable: false, + configurable: true, + }); } finally { delete Math.foo; } diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-41.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-41.js index e69119a145..df5be6a6c9 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-41.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-41.js @@ -16,13 +16,12 @@ Object.defineProperty(JSON, "foo", { configurable: true }); -verifyEqualTo(JSON, "foo", 12); - -verifyNotWritable(JSON, "foo"); - -verifyNotEnumerable(JSON, "foo"); - -verifyConfigurable(JSON, "foo"); +verifyProperty(JSON, "foo", { + value: 12, + writable: false, + enumerable: false, + configurable: true, +}); delete JSON.foo; diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-429.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-429.js index 1484ccd385..074908184e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-429.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-429.js @@ -24,11 +24,11 @@ var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); Object.defineProperty(obj, "prop", { configurable: false }); -var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); -verifyNotConfigurable(obj, "prop"); assert.sameValue(desc1.configurable, true); -assert.sameValue(desc2.configurable, false); -assert(obj.hasOwnProperty("prop")); + +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-434.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-434.js index 0c278f09b7..7d3bd1adc5 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-434.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-434.js @@ -19,12 +19,8 @@ Object.defineProperty(obj, "prop", { configurable: false }); -assert(obj.hasOwnProperty("prop")); - -var desc = Object.getOwnPropertyDescriptor(obj, "prop"); - -assert.sameValue(desc.configurable, false); - -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-438.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-438.js index ccf6b3d0aa..25bb6064b0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-438.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-438.js @@ -30,14 +30,11 @@ try { } catch (e) { assert(e instanceof TypeError); - var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); - assert.sameValue(desc1.configurable, false); - assert.sameValue(desc2.configurable, false); - - verifyNotConfigurable(obj, "prop"); - - assert(obj.hasOwnProperty("prop")); } +verifyProperty(obj, "prop", { + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-447.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-447.js index e7580caeb2..e983a44b71 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-447.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-447.js @@ -25,12 +25,10 @@ Object.defineProperty(obj, "prop", { configurable: false }); -var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); - assert.sameValue(desc1.configurable, true); -assert.sameValue(desc2.configurable, false); -verifyNotConfigurable(obj, "prop"); -assert(obj.hasOwnProperty("prop")); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-45.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-45.js index 65701f6c78..63126072c2 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-45.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-45.js @@ -15,12 +15,11 @@ Object.defineProperty(this, "foo", { configurable: true }); -verifyEqualTo(this, "foo", 12); - -verifyNotWritable(this, "foo"); - -verifyNotEnumerable(this, "foo"); - -verifyConfigurable(this, "foo"); +verifyProperty(this, "foo", { + value: 12, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-452.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-452.js index d099d78495..19a74b78ac 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-452.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-452.js @@ -19,12 +19,8 @@ Object.defineProperty(obj, "prop", { configurable: false }); -assert(obj.hasOwnProperty("prop")); - -var desc = Object.getOwnPropertyDescriptor(obj, "prop"); - -assert.sameValue(desc.configurable, false); - -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-456.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-456.js index da9397f14d..3f008f372c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-456.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-456.js @@ -30,14 +30,11 @@ try { } catch (e) { assert(e instanceof TypeError); - var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); - assert.sameValue(desc1.configurable, false); - assert.sameValue(desc2.configurable, false); - - verifyNotConfigurable(obj, "prop"); - - assert(obj.hasOwnProperty("prop")); } +verifyProperty(obj, "prop", { + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-465.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-465.js index 6ff40b2cc5..f4071187d6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-465.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-465.js @@ -30,12 +30,10 @@ Object.defineProperty(obj, "prop", { configurable: false }); -var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); - assert.sameValue(desc1.configurable, true); -assert.sameValue(desc2.configurable, false); -verifyNotConfigurable(obj, "prop"); -assert(obj.hasOwnProperty("prop")); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-47.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-47.js index 4b8fd1bf7f..6734e898d6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-47.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-47.js @@ -18,12 +18,11 @@ Object.defineProperty(obj, "property", { configurable: false }); -verifyEqualTo(obj, "property", undefined); - -verifyWritable(obj, "property"); - -verifyEnumerable(obj, "property"); - -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + value: undefined, + writable: true, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-470.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-470.js index 39b025006b..9a8cdc0e77 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-470.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-470.js @@ -26,13 +26,10 @@ Object.defineProperty(obj, "prop", { assert(obj.hasOwnProperty("prop")); -var desc = Object.getOwnPropertyDescriptor(obj, "prop"); - verifyNotWritable(obj, "prop"); -verifyNotConfigurable(obj, "prop"); - -assert.sameValue(desc.configurable, false); -assert(obj.hasOwnProperty("prop")); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-474.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-474.js index ce3fa250dd..6c9bdd63e7 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-474.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-474.js @@ -35,14 +35,11 @@ try { } catch (e) { assert(e instanceof TypeError); - var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); - assert.sameValue(desc1.configurable, false); - assert.sameValue(desc2.configurable, false); - - verifyNotConfigurable(obj, "prop"); - - assert(obj.hasOwnProperty("prop")); } +verifyProperty(obj, "prop", { + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-48.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-48.js index 1dcf25ea46..68228104fc 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-48.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-48.js @@ -18,12 +18,11 @@ Object.defineProperty(obj, "property", { configurable: false }); -verifyEqualTo(obj, "property", 1001); - -verifyNotWritable(obj, "property"); - -verifyEnumerable(obj, "property"); - -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + value: 1001, + writable: false, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-483.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-483.js index 118a8aac10..44225c7497 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-483.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-483.js @@ -30,13 +30,10 @@ Object.defineProperty(obj, "prop", { configurable: false }); -var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); - assert.sameValue(desc1.configurable, true); -assert.sameValue(desc2.configurable, false); - -verifyNotConfigurable(obj, "prop"); -assert(obj.hasOwnProperty("prop")); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-488.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-488.js index 0785a3996e..c6155cd8de 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-488.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-488.js @@ -24,13 +24,8 @@ Object.defineProperty(obj, "prop", { configurable: false }); -assert(obj.hasOwnProperty("prop")); - -var desc = Object.getOwnPropertyDescriptor(obj, "prop"); - -verifyNotConfigurable(obj, "prop"); -assert.sameValue(desc.configurable, false); - -assert(obj.hasOwnProperty("prop")); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-49.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-49.js index 9e45eed271..5861ea3315 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-49.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-49.js @@ -17,12 +17,12 @@ Object.defineProperty(obj, "property", { writable: true, configurable: true }); -verifyEqualTo(obj, "property", 1001); -verifyWritable(obj, "property"); - -verifyNotEnumerable(obj, "property"); - -verifyConfigurable(obj, "property"); +verifyProperty(obj, "property", { + value: 1001, + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-492.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-492.js index cc418c9e12..08df806be9 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-492.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-492.js @@ -35,14 +35,11 @@ try { } catch (e) { assert(e instanceof TypeError); - var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); - - verifyNotConfigurable(obj, "prop"); - assert.sameValue(desc1.configurable, false); - assert.sameValue(desc2.configurable, false); - - assert(obj.hasOwnProperty("prop")); } +verifyProperty(obj, "prop", { + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-50.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-50.js index f49f61a6c3..3a3a1ae707 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-50.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-50.js @@ -17,12 +17,12 @@ Object.defineProperty(obj, "property", { writable: true, enumerable: true }); -verifyEqualTo(obj, "property", 1001); -verifyWritable(obj, "property"); - -verifyEnumerable(obj, "property"); - -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + value: 1001, + writable: true, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-501.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-501.js index 7de38b5055..436f8d63e3 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-501.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-501.js @@ -29,14 +29,12 @@ Object.defineProperty(obj, "prop", { configurable: false }); -var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); - assert.sameValue(desc1.configurable, true); -assert.sameValue(desc2.configurable, false); verifyNotWritable(obj, "prop"); -verifyNotConfigurable(obj, "prop"); -assert(obj.hasOwnProperty("prop")); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-506.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-506.js index 8ad6ca3b7c..a65dd9b778 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-506.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-506.js @@ -23,14 +23,8 @@ Object.defineProperty(obj, "prop", { configurable: false }); -assert(obj.hasOwnProperty("prop")); - -var desc = Object.getOwnPropertyDescriptor(obj, "prop"); - -assert.sameValue(desc.configurable, false); - -verifyNotConfigurable(obj, "prop"); - -assert(obj.hasOwnProperty("prop")); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-51.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-51.js index 989d71d164..7c987bdbb3 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-51.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-51.js @@ -20,12 +20,11 @@ Object.defineProperty(obj, "property", { configurable: false }); -verifyEqualTo(obj, "property", 1001); - -verifyNotWritable(obj, "property"); - -verifyNotEnumerable(obj, "property"); - -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + value: 1001, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-510.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-510.js index 325f76e16c..418d8113e1 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-510.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-510.js @@ -34,14 +34,11 @@ try { } catch (e) { assert(e instanceof TypeError); - var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); - assert.sameValue(desc1.configurable, false); - assert.sameValue(desc2.configurable, false); - - verifyNotConfigurable(obj, "prop"); - - assert(obj.hasOwnProperty("prop")); } +verifyProperty(obj, "prop", { + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-519.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-519.js index 60baf731ee..b5305b02e3 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-519.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-519.js @@ -29,13 +29,10 @@ Object.defineProperty(obj, "prop", { configurable: false }); -var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); - assert.sameValue(desc1.configurable, true); -assert.sameValue(desc2.configurable, false); - -verifyNotConfigurable(obj, "prop"); -assert(obj.hasOwnProperty("prop")); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-52.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-52.js index 0d2ca8420a..4c2713c081 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-52.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-52.js @@ -14,12 +14,11 @@ var obj = {}; Object.defineProperty(obj, "property", {}); -verifyEqualTo(obj, "property", undefined); - -verifyNotWritable(obj, "property"); - -verifyNotEnumerable(obj, "property"); - -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-524.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-524.js index aa6fe43c25..7f2161477f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-524.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-524.js @@ -23,13 +23,8 @@ Object.defineProperty(obj, "prop", { configurable: false }); -assert(obj.hasOwnProperty("prop")); -var desc = Object.getOwnPropertyDescriptor(obj, "prop"); - -assert.sameValue(desc.configurable, false); - -verifyNotConfigurable(obj, "prop"); - -assert(obj.hasOwnProperty("prop")); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-528.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-528.js index b666822536..5dab355151 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-528.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-528.js @@ -34,14 +34,11 @@ try { } catch (e) { assert(e instanceof TypeError); - var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); - assert.sameValue(desc1.configurable, false); - assert.sameValue(desc2.configurable, false); - - verifyNotConfigurable(obj, "prop"); - - assert(obj.hasOwnProperty("prop")); } +verifyProperty(obj, "prop", { + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-53.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-53.js index b8dd34d5ab..2da947a546 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-53.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-53.js @@ -23,8 +23,9 @@ Object.defineProperty(obj, "property", { verifyWritable(obj, "property", "setVerifyHelpProp"); -verifyEnumerable(obj, "property"); - -verifyConfigurable(obj, "property"); +verifyProperty(obj, "property", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-1.js index 167099fb52..8326068541 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-1.js @@ -40,8 +40,9 @@ verifyEqualTo(obj, "property", getFunc()); verifyWritable(obj, "property", "verifySetFunction1"); -verifyNotEnumerable(obj, "property"); - -verifyConfigurable(obj, "property"); +verifyProperty(obj, "property", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-10.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-10.js index 50dbf751f4..a419791c35 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-10.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-10.js @@ -42,8 +42,9 @@ verifyEqualTo(obj, "0", getFunc()); verifyWritable(obj, "0", "verifySetFunction1"); -verifyNotEnumerable(obj, "0"); - -verifyConfigurable(obj, "0"); +verifyProperty(obj, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-11.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-11.js index d23dfcde09..304b9db3bb 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-11.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-11.js @@ -41,8 +41,9 @@ verifyEqualTo(obj, "prop", getFunc()); verifyWritable(obj, "prop", "verifySetFunction1"); -verifyNotEnumerable(obj, "prop"); - -verifyConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-12.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-12.js index 05a7954bab..7cac1e393e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-12.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-12.js @@ -43,8 +43,9 @@ verifyEqualTo(obj, "0", getFunc()); verifyWritable(obj, "0", "verifySetFunction1"); -verifyNotEnumerable(obj, "0"); - -verifyConfigurable(obj, "0"); +verifyProperty(obj, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-2.js index 6c459d0db2..2151ea314c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-2.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-2.js @@ -42,8 +42,9 @@ verifyEqualTo(obj, "0", getFunc()); verifyWritable(obj, "0", "verifySetFunction1"); -verifyNotEnumerable(obj, "0"); - -verifyConfigurable(obj, "0"); +verifyProperty(obj, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-3.js index 0dc6f76257..9720210f17 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-3.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-3.js @@ -43,8 +43,9 @@ verifyEqualTo(obj, "property", getFunc()); verifyWritable(obj, "property", "verifySetFunction1"); -verifyNotEnumerable(obj, "property"); - -verifyConfigurable(obj, "property"); +verifyProperty(obj, "property", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-537.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-537.js index e05ce8fecf..a361819a17 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-537.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-537.js @@ -34,11 +34,11 @@ var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); Object.defineProperty(obj, "prop", { configurable: false }); -var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); -verifyNotConfigurable(obj, "prop"); assert.sameValue(desc1.configurable, true); -assert.sameValue(desc2.configurable, false); -assert(obj.hasOwnProperty("prop")); + +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-1.js index 06dd0aa4b9..340bbd5aa2 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-1.js @@ -54,8 +54,9 @@ verifyEqualTo(obj, "0", 1001); verifyNotWritable(obj, "0"); -verifyEnumerable(obj, "0"); - -verifyConfigurable(obj, "0"); +verifyProperty(obj, "0", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-2.js index c1a03d0ff9..89fcca4632 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-2.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-2.js @@ -56,8 +56,9 @@ verifyEqualTo(obj, "prop", 1001); verifyNotWritable(obj, "prop"); -verifyEnumerable(obj, "prop"); - -verifyConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-5.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-5.js index effdbc3676..146f5c421b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-5.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-5.js @@ -55,8 +55,9 @@ verifyEqualTo(obj, "prop", 1001); verifyNotWritable(obj, "prop"); -verifyEnumerable(obj, "prop"); - -verifyConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-6.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-6.js index 4bfe9d32ee..aa286ce903 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-6.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-6.js @@ -56,8 +56,9 @@ verifyEqualTo(obj, "0", 1001); verifyNotWritable(obj, "0"); -verifyEnumerable(obj, "0"); - -verifyConfigurable(obj, "0"); +verifyProperty(obj, "0", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538.js index 8943f5cff9..89f7fbe3e5 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538.js @@ -51,8 +51,9 @@ verifyEqualTo(obj, "prop", 1001); verifyNotWritable(obj, "prop"); -verifyEnumerable(obj, "prop"); - -verifyConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-54.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-54.js index 34de6eff1d..e36e1e18ac 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-54.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-54.js @@ -26,7 +26,9 @@ assert.sameValue(obj.property, "property"); var desc = Object.getOwnPropertyDescriptor(obj, "property"); assert.sameValue(typeof desc.set, "undefined"); -verifyNotEnumerable(obj, "property"); -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-1.js index ac2f8d5fb0..b7ccfef31f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-1.js @@ -38,12 +38,13 @@ try { verifyEqualTo(obj, "property", getFunc()); verifyWritable(obj, "property", "verifySetFunction"); - - verifyNotEnumerable(obj, "property"); - - verifyNotConfigurable(obj, "property"); } +verifyProperty(obj, "property", { + enumerable: false, + configurable: false, +}); + try { Object.defineProperty(obj, "property", { set: function(value) { @@ -59,14 +60,14 @@ try { verifyWritable(obj, "property", "verifySetFunction"); - verifyNotEnumerable(obj, "property"); - - verifyNotConfigurable(obj, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "property", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-2.js index df61180433..4e2ac6db59 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-2.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-2.js @@ -38,12 +38,13 @@ try { verifyEqualTo(obj, "0", getFunc()); verifyWritable(obj, "0", "verifySetFunction"); - - verifyNotEnumerable(obj, "0"); - - verifyNotConfigurable(obj, "0"); } +verifyProperty(obj, "0", { + enumerable: false, + configurable: false, +}); + try { Object.defineProperty(obj, "0", { set: function(value) { @@ -59,14 +60,14 @@ try { verifyWritable(obj, "0", "verifySetFunction"); - verifyNotEnumerable(obj, "0"); - - verifyNotConfigurable(obj, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "0", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-3.js index f7018700c9..1aeb2c071d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-3.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-3.js @@ -39,12 +39,13 @@ try { verifyEqualTo(obj, "property", getFunc()); verifyWritable(obj, "property", "verifySetFunction"); - - verifyNotEnumerable(obj, "property"); - - verifyNotConfigurable(obj, "property"); } +verifyProperty(obj, "property", { + enumerable: false, + configurable: false, +}); + try { Object.defineProperty(obj, "property", { set: function(value) { @@ -61,14 +62,14 @@ try { verifyWritable(obj, "property", "verifySetFunction"); - verifyNotEnumerable(obj, "property"); - - verifyNotConfigurable(obj, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "property", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-6.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-6.js index 64cc3ff55f..8431a64191 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-6.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-6.js @@ -39,12 +39,13 @@ try { verifyEqualTo(obj, "0", getFunc()); verifyWritable(obj, "0", "verifySetFunction"); - - verifyNotEnumerable(obj, "0"); - - verifyNotConfigurable(obj, "0"); } +verifyProperty(obj, "0", { + enumerable: false, + configurable: false, +}); + try { Object.defineProperty(obj, "0", { set: function(value) { @@ -60,15 +61,14 @@ try { verifyWritable(obj, "0", "verifySetFunction"); - verifyNotEnumerable(obj, "0"); - - verifyNotConfigurable(obj, "0"); - - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "0", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-7.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-7.js index bc90c7b983..1bc3fcfa22 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-7.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-7.js @@ -38,12 +38,13 @@ try { verifyEqualTo(obj, "prop", getFunc()); verifyWritable(obj, "prop", "verifySetFunction"); - - verifyNotEnumerable(obj, "prop"); - - verifyNotConfigurable(obj, "prop"); } +verifyProperty(obj, "prop", { + enumerable: false, + configurable: false, +}); + try { Object.defineProperty(obj, "prop", { set: function(value) { @@ -60,15 +61,14 @@ try { verifyWritable(obj, "prop", "verifySetFunction"); - verifyNotEnumerable(obj, "prop"); - - verifyNotConfigurable(obj, "prop"); - - if (!(e1 instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e1); } - } +verifyProperty(obj, "prop", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-8.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-8.js index 26be4c5177..cca11f6b53 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-8.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-8.js @@ -40,12 +40,13 @@ try { verifyEqualTo(obj, "0", getFunc()); verifyWritable(obj, "0", "verifySetFunction"); - - verifyNotEnumerable(obj, "0"); - - verifyNotConfigurable(obj, "0"); } +verifyProperty(obj, "0", { + enumerable: false, + configurable: false, +}); + try { Object.defineProperty(obj, "0", { set: function(value) { @@ -61,14 +62,14 @@ try { verifyWritable(obj, "0", "verifySetFunction"); - verifyNotEnumerable(obj, "0"); - - verifyNotConfigurable(obj, "0"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "0", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-542.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-542.js index 0768fd3034..d1effa9fe0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-542.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-542.js @@ -28,7 +28,8 @@ Object.defineProperty(obj, "prop", { configurable: false }); -assert(obj.hasOwnProperty("prop")); -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-546.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-546.js index bd266dbcb3..2cefdfbb7f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-546.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-546.js @@ -29,6 +29,7 @@ Object.defineProperty(obj, "prop", { configurable: false }); var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.sameValue(desc1.configurable, false); try { Object.defineProperty(obj, "prop", { @@ -38,12 +39,10 @@ try { throw new Test262Error("Expected TypeError"); } catch (e) { assert(e instanceof TypeError); - assert.sameValue(desc1.configurable, false); - - var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); - assert.sameValue(desc2.configurable, false); - - verifyNotConfigurable(obj, "prop"); } +verifyProperty(obj, "prop", { + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-1.js index ae003f7fdd..24c73a6f46 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-1.js @@ -51,15 +51,14 @@ try { verifyWritable(obj, "0", "verifySetFunc"); - verifyEnumerable(obj, "0"); - - verifyNotConfigurable(obj, "0"); - - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "0", { + enumerable: true, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-2.js index 6b40da84ff..1fc93445ef 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-2.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-2.js @@ -53,15 +53,14 @@ try { verifyWritable(obj, "prop", "verifySetFunc"); - verifyEnumerable(obj, "prop"); - - verifyNotConfigurable(obj, "prop"); - - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "prop", { + enumerable: true, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-3.js index db6e0fdd62..3e3815b131 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-3.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-3.js @@ -51,14 +51,15 @@ try { verifyWritable(obj, "prop", "verifySetFunc"); - verifyEnumerable(obj, "prop"); - - verifyNotConfigurable(obj, "prop"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } } +verifyProperty(obj, "prop", { + enumerable: true, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-4.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-4.js index ffc954933e..f5261f8ce5 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-4.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-4.js @@ -51,15 +51,14 @@ try { verifyWritable(obj, "0", "verifySetFunc"); - verifyEnumerable(obj, "0"); - - verifyNotConfigurable(obj, "0"); - - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "0", { + enumerable: true, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-55.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-55.js index ca020589dd..7fced08f66 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-55.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-55.js @@ -28,8 +28,9 @@ verifyEqualTo(obj, "property", getFunc()); verifyWritable(obj, "property", "setVerifyHelpProp"); -verifyNotEnumerable(obj, "property"); - -verifyConfigurable(obj, "property"); +verifyProperty(obj, "property", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-555.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-555.js index 96f0f78ea5..64d8596265 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-555.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-555.js @@ -36,6 +36,8 @@ Object.defineProperty(obj, "prop", { configurable: false }); -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-56.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-56.js index c5ea0ffad5..004dc7e27a 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-56.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-56.js @@ -27,8 +27,9 @@ verifyEqualTo(obj, "property", getFunc()); verifyWritable(obj, "property", "setVerifyHelpProp"); -verifyEnumerable(obj, "property"); - -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-560.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-560.js index 127e3d4d42..ce9172ee37 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-560.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-560.js @@ -28,7 +28,8 @@ Object.defineProperty(obj, "prop", { configurable: false }); -assert(obj.hasOwnProperty("prop")); -verifyNotConfigurable(obj, "prop"); +verifyProperty(obj, "prop", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-564.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-564.js index b4d0e29416..24c6c00d0b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-564.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-564.js @@ -28,7 +28,6 @@ Object.defineProperty(obj, "prop", { enumerable: false, configurable: false }); -var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); try { Object.defineProperty(obj, "prop", { @@ -38,8 +37,10 @@ try { throw new Test262Error("Expected TypeError"); } catch (e) { assert(e instanceof TypeError); - assert.sameValue(desc1.configurable, false); - verifyNotConfigurable(obj, "prop"); } +verifyProperty(obj, "prop", { + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-57.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-57.js index 5ad316ca51..3d010a65ec 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-57.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-57.js @@ -37,8 +37,9 @@ verifyEqualTo(obj, "property", getFunc()); verifyWritable(obj, "property", "setVerifyHelpProp"); -verifyNotEnumerable(obj, "property"); - -verifyNotConfigurable(obj, "property"); +verifyProperty(obj, "property", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-58.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-58.js index d561f384f6..0e63b0085c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-58.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-58.js @@ -15,12 +15,12 @@ var obj = {}; obj.foo = 101; // default value of attributes: writable: true, configurable: true, enumerable: true Object.defineProperty(obj, "foo", {}); -verifyEqualTo(obj, "foo", 101); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 101, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-59.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-59.js index 903ac63326..6621860c56 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-59.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-59.js @@ -30,8 +30,9 @@ verifyEqualTo(obj, "foo", getFunc()); verifyWritable(obj, "foo", "helpVerifySet"); -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-60.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-60.js index bb14e77bed..58699274f6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-60.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-60.js @@ -17,12 +17,12 @@ obj.foo = 101; // default value of attributes: writable: true, configurable: tru Object.defineProperty(obj, "foo", { value: "abc" }); -verifyEqualTo(obj, "foo", "abc"); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: "abc", + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-61.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-61.js index a59d8e6098..6e9ca52710 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-61.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-61.js @@ -19,12 +19,12 @@ Object.defineProperty(obj, "foo", { Object.defineProperty(obj, "foo", { value: undefined }); -verifyEqualTo(obj, "foo", undefined); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-611.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-611.js index 19c0ef715c..29f1c7b0e6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-611.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-611.js @@ -6,33 +6,13 @@ es5id: 15.2.3.6-4-611 description: > ES5 Attributes - all attributes in Function.prototype.bind are correct +includes: [propertyHelper.js] ---*/ -var desc = Object.getOwnPropertyDescriptor(Function.prototype, "bind"); - -var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); - -var temp = Function.prototype.bind; - -Function.prototype.bind = "2010"; - -var isWritable = (Function.prototype.bind === "2010"); - -var isEnumerable = false; - -for (var prop in Function.prototype) { - if (prop === "bind") { - isEnumerable = true; - } -} - -delete Function.prototype.bind; - -var isConfigurable = !Function.prototype.hasOwnProperty("bind"); - -assert(propertyAreCorrect, 'propertyAreCorrect !== true'); -assert(isWritable, 'isWritable !== true'); -assert.sameValue(isEnumerable, false, 'isEnumerable'); -assert(isConfigurable, 'isConfigurable !== true'); +verifyProperty(Function.prototype, "bind", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-612.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-612.js index e33d81a9c2..5669e33ad1 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-612.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-612.js @@ -6,33 +6,13 @@ es5id: 15.2.3.6-4-612 description: > ES5 Attributes - all attributes in Array.prototype.indexOf are correct +includes: [propertyHelper.js] ---*/ -var desc = Object.getOwnPropertyDescriptor(Array.prototype, "indexOf"); - -var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); - -var temp = Array.prototype.indexOf; - -Array.prototype.indexOf = "2010"; - -var isWritable = (Array.prototype.indexOf === "2010"); - -var isEnumerable = false; - -for (var prop in Array.prototype) { - if (prop === "indexOf") { - isEnumerable = true; - } -} - -delete Array.prototype.indexOf; - -var isConfigurable = !Array.prototype.hasOwnProperty("indexOf"); - -assert(propertyAreCorrect, 'propertyAreCorrect !== true'); -assert(isWritable, 'isWritable !== true'); -assert.sameValue(isEnumerable, false, 'isEnumerable'); -assert(isConfigurable, 'isConfigurable !== true'); +verifyProperty(Array.prototype, "indexOf", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-613.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-613.js index 162333109f..3be61c6ded 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-613.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-613.js @@ -4,33 +4,13 @@ /*--- es5id: 15.2.3.6-4-613 description: ES5 Attributes - all attributes in Object.lastIndexOf are correct +includes: [propertyHelper.js] ---*/ -var desc = Object.getOwnPropertyDescriptor(Array.prototype, "lastIndexOf"); - -var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); - -var temp = Array.prototype.lastIndexOf; - -Array.prototype.lastIndexOf = "2010"; - -var isWritable = (Array.prototype.lastIndexOf === "2010"); - -var isEnumerable = false; - -for (var prop in Array.prototype) { - if (prop === "lastIndexOf") { - isEnumerable = true; - } -} - -delete Array.prototype.lastIndexOf; - -var isConfigurable = !Array.prototype.hasOwnProperty("lastIndexOf"); - -assert(propertyAreCorrect, 'propertyAreCorrect !== true'); -assert(isWritable, 'isWritable !== true'); -assert.sameValue(isEnumerable, false, 'isEnumerable'); -assert(isConfigurable, 'isConfigurable !== true'); +verifyProperty(Array.prototype, "lastIndexOf", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-614.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-614.js index 368a3b8977..b4017c499c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-614.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-614.js @@ -6,33 +6,13 @@ es5id: 15.2.3.6-4-614 description: > ES5 Attributes - all attributes in Array.prototype.every are correct +includes: [propertyHelper.js] ---*/ -var desc = Object.getOwnPropertyDescriptor(Array.prototype, "every"); - -var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); - -var temp = Array.prototype.every; - -Array.prototype.every = "2010"; - -var isWritable = (Array.prototype.every === "2010"); - -var isEnumerable = false; - -for (var prop in Array.prototype) { - if (prop === "every") { - isEnumerable = true; - } -} - -delete Array.prototype.every; - -var isConfigurable = !Array.prototype.hasOwnProperty("every"); - -assert(propertyAreCorrect, 'propertyAreCorrect !== true'); -assert(isWritable, 'isWritable !== true'); -assert.sameValue(isEnumerable, false, 'isEnumerable'); -assert(isConfigurable, 'isConfigurable !== true'); +verifyProperty(Array.prototype, "every", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-615.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-615.js index c4deed0cd6..de306634f0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-615.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-615.js @@ -4,33 +4,13 @@ /*--- es5id: 15.2.3.6-4-615 description: ES5 Attributes - all attributes in Array.prototype.some are correct +includes: [propertyHelper.js] ---*/ -var desc = Object.getOwnPropertyDescriptor(Array.prototype, "some"); - -var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); - -var temp = Array.prototype.some; - -Array.prototype.some = "2010"; - -var isWritable = (Array.prototype.some === "2010"); - -var isEnumerable = false; - -for (var prop in Array.prototype) { - if (prop === "some") { - isEnumerable = true; - } -} - -delete Array.prototype.some; - -var isConfigurable = !Array.prototype.hasOwnProperty("some"); - -assert(propertyAreCorrect, 'propertyAreCorrect !== true'); -assert(isWritable, 'isWritable !== true'); -assert.sameValue(isEnumerable, false, 'isEnumerable'); -assert(isConfigurable, 'isConfigurable !== true'); +verifyProperty(Array.prototype, "some", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-616.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-616.js index d5547bda86..a55fea0497 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-616.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-616.js @@ -6,33 +6,13 @@ es5id: 15.2.3.6-4-616 description: > ES5 Attributes - all attributes in Array.prototype.forEach are correct +includes: [propertyHelper.js] ---*/ -var desc = Object.getOwnPropertyDescriptor(Array.prototype, "forEach"); - -var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); - -var temp = Array.prototype.forEach; - -Array.prototype.forEach = "2010"; - -var isWritable = (Array.prototype.forEach === "2010"); - -var isEnumerable = false; - -for (var prop in Array.prototype) { - if (prop === "forEach") { - isEnumerable = true; - } -} - -delete Array.prototype.forEach; - -var isConfigurable = !Array.prototype.hasOwnProperty("forEach"); - -assert(propertyAreCorrect, 'propertyAreCorrect !== true'); -assert(isWritable, 'isWritable !== true'); -assert.sameValue(isEnumerable, false, 'isEnumerable'); -assert(isConfigurable, 'isConfigurable !== true'); +verifyProperty(Array.prototype, "forEach", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-617.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-617.js index 0d18438ceb..a2ba3ab540 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-617.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-617.js @@ -4,33 +4,13 @@ /*--- es5id: 15.2.3.6-4-617 description: ES5 Attributes - all attributes in Array.prototype.map are correct +includes: [propertyHelper.js] ---*/ -var desc = Object.getOwnPropertyDescriptor(Array.prototype, "map"); - -var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); - -var temp = Array.prototype.map; - -Array.prototype.map = "2010"; - -var isWritable = (Array.prototype.map === "2010"); - -var isEnumerable = false; - -for (var prop in Array.prototype) { - if (prop === "map") { - isEnumerable = true; - } -} - -delete Array.prototype.map; - -var isConfigurable = !Array.prototype.hasOwnProperty("map"); - -assert(propertyAreCorrect, 'propertyAreCorrect !== true'); -assert(isWritable, 'isWritable !== true'); -assert.sameValue(isEnumerable, false, 'isEnumerable'); -assert(isConfigurable, 'isConfigurable !== true'); +verifyProperty(Array.prototype, "map", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-618.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-618.js index 3e21462908..8b7d744743 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-618.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-618.js @@ -6,33 +6,13 @@ es5id: 15.2.3.6-4-618 description: > ES5 Attributes - all attributes in Array.prototype.filter are correct +includes: [propertyHelper.js] ---*/ -var desc = Object.getOwnPropertyDescriptor(Array.prototype, "filter"); - -var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); - -var temp = Array.prototype.filter; - -Array.prototype.filter = "2010"; - -var isWritable = (Array.prototype.filter === "2010"); - -var isEnumerable = false; - -for (var prop in Array.prototype) { - if (prop === "filter") { - isEnumerable = true; - } -} - -delete Array.prototype.filter; - -var isConfigurable = !Array.prototype.hasOwnProperty("filter"); - -assert(propertyAreCorrect, 'propertyAreCorrect !== true'); -assert(isWritable, 'isWritable !== true'); -assert.sameValue(isEnumerable, false, 'isEnumerable'); -assert(isConfigurable, 'isConfigurable !== true'); +verifyProperty(Array.prototype, "filter", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-619.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-619.js index 746209ea13..2bc25fcfe4 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-619.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-619.js @@ -6,33 +6,13 @@ es5id: 15.2.3.6-4-619 description: > ES5 Attributes - all attributes in Array.prototype.reduce are correct +includes: [propertyHelper.js] ---*/ -var desc = Object.getOwnPropertyDescriptor(Array.prototype, "reduce"); - -var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); - -var temp = Array.prototype.reduce; - -Array.prototype.reduce = "2010"; - -var isWritable = (Array.prototype.reduce === "2010"); - -var isEnumerable = false; - -for (var prop in Array.prototype) { - if (prop === "reduce") { - isEnumerable = true; - } -} - -delete Array.prototype.reduce; - -var isConfigurable = !Array.prototype.hasOwnProperty("reduce"); - -assert(propertyAreCorrect, 'propertyAreCorrect !== true'); -assert(isWritable, 'isWritable !== true'); -assert.sameValue(isEnumerable, false, 'isEnumerable'); -assert(isConfigurable, 'isConfigurable !== true'); +verifyProperty(Array.prototype, "reduce", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-62.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-62.js index f16d18a98b..4faabfad64 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-62.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-62.js @@ -19,12 +19,12 @@ Object.defineProperty(obj, "foo", { Object.defineProperty(obj, "foo", { value: null }); -verifyEqualTo(obj, "foo", null); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: null, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-620.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-620.js index 6ce2dbb7ce..d20710fc44 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-620.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-620.js @@ -6,33 +6,13 @@ es5id: 15.2.3.6-4-620 description: > ES5 Attributes - all attributes in Array.prototype.reduceRight are correct +includes: [propertyHelper.js] ---*/ -var desc = Object.getOwnPropertyDescriptor(Array.prototype, "reduceRight"); - -var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); - -var temp = Array.prototype.reduceRight; - -Array.prototype.reduceRight = "2010"; - -var isWritable = (Array.prototype.reduceRight === "2010"); - -var isEnumerable = false; - -for (var prop in Array.prototype) { - if (prop === "reduceRight") { - isEnumerable = true; - } -} - -delete Array.prototype.reduceRight; - -var isConfigurable = !Array.prototype.hasOwnProperty("reduceRight"); - -assert(propertyAreCorrect, 'propertyAreCorrect !== true'); -assert(isWritable, 'isWritable !== true'); -assert.sameValue(isEnumerable, false, 'isEnumerable'); -assert(isConfigurable, 'isConfigurable !== true'); +verifyProperty(Array.prototype, "reduceRight", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-621.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-621.js index 5e00e1db4f..9bd87e96e3 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-621.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-621.js @@ -6,33 +6,13 @@ es5id: 15.2.3.6-4-621 description: > ES5 Attributes - all attributes in String.prototype.trim are correct +includes: [propertyHelper.js] ---*/ -var desc = Object.getOwnPropertyDescriptor(String.prototype, "trim"); - -var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); - -var temp = String.prototype.trim; - -String.prototype.trim = "2010"; - -var isWritable = (String.prototype.trim === "2010"); - -var isEnumerable = false; - -for (var prop in String.prototype) { - if (prop === "trim") { - isEnumerable = true; - } -} - -delete String.prototype.trim; - -var isConfigurable = !String.prototype.hasOwnProperty("trim"); - -assert(propertyAreCorrect, 'propertyAreCorrect !== true'); -assert(isWritable, 'isWritable !== true'); -assert.sameValue(isEnumerable, false, 'isEnumerable'); -assert(isConfigurable, 'isConfigurable !== true'); +verifyProperty(String.prototype, "trim", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-622.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-622.js index db59aba810..fe21ad4d58 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-622.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-622.js @@ -4,33 +4,14 @@ /*--- es5id: 15.2.3.6-4-622 description: ES5 Attributes - all attributes in Date.now are correct +includes: [propertyHelper.js] ---*/ -var desc = Object.getOwnPropertyDescriptor(Date, "now"); +verifyProperty(Date, "now", { + writable: true, + enumerable: false, + configurable: true, +}); -var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); - -var temp = Date.now; - -Date.now = "2010"; - -var isWritable = (Date.now === "2010"); - -var isEnumerable = false; - -for (var prop in Date) { - if (prop === "now") { - isEnumerable = true; - } -} - -delete Date.now; - -var isConfigurable = !Date.hasOwnProperty("now"); - -assert(propertyAreCorrect, 'propertyAreCorrect !== true'); -assert(isWritable, 'isWritable !== true'); -assert.sameValue(isEnumerable, false, 'isEnumerable'); -assert(isConfigurable, 'isConfigurable !== true'); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-623.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-623.js index a5c94f29b7..b314bc2c50 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-623.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-623.js @@ -6,33 +6,13 @@ es5id: 15.2.3.6-4-623 description: > ES5 Attributes - all attributes in Date.prototype.toISOString are correct +includes: [propertyHelper.js] ---*/ -var desc = Object.getOwnPropertyDescriptor(Date.prototype, "toISOString"); - -var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); - -var temp = Date.prototype.toISOString; - -Date.prototype.toISOString = "2010"; - -var isWritable = (Date.prototype.toISOString === "2010"); - -var isEnumerable = false; - -for (var prop in Date.prototype) { - if (prop === "toISOString") { - isEnumerable = true; - } -} - -delete Date.prototype.toISOString; - -var isConfigurable = !Date.prototype.hasOwnProperty("toISOString"); - -assert(propertyAreCorrect, 'propertyAreCorrect !== true'); -assert(isWritable, 'isWritable !== true'); -assert.sameValue(isEnumerable, false, 'isEnumerable'); -assert(isConfigurable, 'isConfigurable !== true'); +verifyProperty(Date.prototype, "toISOString", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-624.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-624.js index 4774991788..e2362387ca 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-624.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-624.js @@ -6,33 +6,13 @@ es5id: 15.2.3.6-4-624 description: > ES5 Attributes - all attributes in Date.prototype.toJSON are correct +includes: [propertyHelper.js] ---*/ -var desc = Object.getOwnPropertyDescriptor(Date.prototype, "toJSON"); - -var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); - -var temp = Date.prototype.toJSON; - -Date.prototype.toJSON = "2010"; - -var isWritable = (Date.prototype.toJSON === "2010"); - -var isEnumerable = false; - -for (var prop in Date.prototype) { - if (prop === "toJSON") { - isEnumerable = true; - } -} - -delete Date.prototype.toJSON; - -var isConfigurable = !Date.prototype.hasOwnProperty("toJSON"); - -assert(propertyAreCorrect, 'propertyAreCorrect !== true'); -assert(isWritable, 'isWritable !== true'); -assert.sameValue(isEnumerable, false, 'isEnumerable'); -assert(isConfigurable, 'isConfigurable !== true'); +verifyProperty(Date.prototype, "toJSON", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-63.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-63.js index feaf556cef..e92be049d0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-63.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-63.js @@ -19,12 +19,11 @@ Object.defineProperty(obj, "foo", { value: NaN }); -assert.sameValue(obj.foo, NaN); - -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: NaN, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-64.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-64.js index d627e8a13f..53599d36c6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-64.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-64.js @@ -23,18 +23,16 @@ try { throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", -0); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: -0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-65.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-65.js index ed2ac2cc12..f0abc12984 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-65.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-65.js @@ -22,18 +22,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", +0); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: +0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-66.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-66.js index 87fe39bdbd..3339c81706 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-66.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-66.js @@ -17,12 +17,12 @@ obj.foo = 101; // default value of attributes: writable: true, configurable: tru Object.defineProperty(obj, "foo", { value: 102 }); -verifyEqualTo(obj, "foo", 102); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 102, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-67.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-67.js index 6778b65e76..ab0c3fce02 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-67.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-67.js @@ -20,12 +20,12 @@ Object.defineProperty(obj, "foo", { Object.defineProperty(obj, "foo", { value: "abcd" }); -verifyEqualTo(obj, "foo", "abcd"); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: "abcd", + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-68.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-68.js index f3f74ca0b1..e914ee7275 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-68.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-68.js @@ -17,12 +17,12 @@ obj.foo = "abcd"; // default value of attributes: writable: true, configurable: Object.defineProperty(obj, "foo", { value: "fghj" }); -verifyEqualTo(obj, "foo", "fghj"); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: "fghj", + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-69.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-69.js index 39244aa40a..682db19208 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-69.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-69.js @@ -19,12 +19,12 @@ Object.defineProperty(obj, "foo", { Object.defineProperty(obj, "foo", { value: true }); -verifyEqualTo(obj, "foo", true); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: true, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-70.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-70.js index 24d4977637..c431b43b55 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-70.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-70.js @@ -17,12 +17,12 @@ obj.foo = true; // default value of attributes: writable: true, configurable: tr Object.defineProperty(obj, "foo", { value: false }); -verifyEqualTo(obj, "foo", false); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: false, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-71.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-71.js index c12aa123b1..146f1b2a92 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-71.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-71.js @@ -23,12 +23,12 @@ Object.defineProperty(obj, "foo", { Object.defineProperty(obj, "foo", { value: obj1 }); -verifyEqualTo(obj, "foo", obj1); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: obj1, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-72.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-72.js index 36c4fe3a34..2e10a620e6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-72.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-72.js @@ -24,12 +24,12 @@ var obj2 = { Object.defineProperty(obj, "foo", { value: obj2 }); -verifyEqualTo(obj, "foo", obj2); -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: obj2, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-73.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-73.js index e003f7060f..19ee10354a 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-73.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-73.js @@ -19,12 +19,12 @@ Object.defineProperty(obj, "foo", { Object.defineProperty(obj, "foo", { writable: false }); -verifyEqualTo(obj, "foo", undefined); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-74.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-74.js index 735ff9e36d..a711a14148 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-74.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-74.js @@ -20,12 +20,12 @@ Object.defineProperty(obj, "foo", { Object.defineProperty(obj, "foo", { writable: true }); -verifyEqualTo(obj, "foo", undefined); -verifyWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: undefined, + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-75.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-75.js index ffb8fa59fc..b51fe84c77 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-75.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-75.js @@ -32,8 +32,9 @@ verifyEqualTo(obj, "foo", getFunc()); verifyWritable(obj, "foo", "helpVerifySet"); -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-76.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-76.js index 91a011f019..b6b16ff6ac 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-76.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-76.js @@ -37,8 +37,9 @@ verifyEqualTo(obj, "foo", getFunc2()); verifyWritable(obj, "foo", "helpVerifySet"); -verifyNotEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-77.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-77.js index 11813c0338..6e9275c910 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-77.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-77.js @@ -25,8 +25,9 @@ Object.defineProperty(obj, "foo", { }); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-78.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-78.js index 9ffdeb435b..7be495b41e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-78.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-78.js @@ -28,8 +28,9 @@ Object.defineProperty(obj, "foo", { }); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyNotEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-79.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-79.js index 0295f90eef..f82e5431b1 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-79.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-79.js @@ -19,12 +19,12 @@ Object.defineProperty(obj, "foo", { Object.defineProperty(obj, "foo", { enumerable: false }); -verifyEqualTo(obj, "foo", undefined); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-80.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-80.js index 06c6f05859..f2595e67e6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-80.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-80.js @@ -20,12 +20,12 @@ Object.defineProperty(obj, "foo", { Object.defineProperty(obj, "foo", { enumerable: true }); -verifyEqualTo(obj, "foo", undefined); -verifyNotWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: undefined, + writable: false, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-81.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-81.js index bb04cb882d..88b4844633 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-81.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-81.js @@ -19,12 +19,12 @@ Object.defineProperty(obj, "foo", { Object.defineProperty(obj, "foo", { configurable: false }); -verifyEqualTo(obj, "foo", undefined); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-1.js index b2a9b4b8ae..c5dfda4bc9 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-1.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-1.js @@ -27,12 +27,11 @@ Object.defineProperty(obj, "foo", { enumerable: false }); -verifyEqualTo(obj, "foo", 1001); - -verifyWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 1001, + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-10.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-10.js index 4c2395e14d..ac6298f340 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-10.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-10.js @@ -38,8 +38,9 @@ verifyEqualTo(obj, "foo", get_func()); verifyWritable(obj, "foo", "verifySetFunction"); -verifyEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-11.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-11.js index 0fefd5de68..416f684952 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-11.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-11.js @@ -38,8 +38,9 @@ verifyEqualTo(obj, "foo", get_func()); verifyWritable(obj, "foo", "verifySetFunction"); -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-12.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-12.js index ba8dd041b1..14e09775c2 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-12.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-12.js @@ -37,8 +37,9 @@ verifyEqualTo(obj, "foo", get_func()); verifyWritable(obj, "foo", "verifySetFunction"); -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-13.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-13.js index 4e954f0939..0e3cd8165c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-13.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-13.js @@ -27,12 +27,11 @@ Object.defineProperty(obj, "0", { enumerable: false }); -verifyEqualTo(obj, "0", 1001); - -verifyWritable(obj, "0"); - -verifyNotEnumerable(obj, "0"); - -verifyConfigurable(obj, "0"); +verifyProperty(obj, "0", { + value: 1001, + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-14.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-14.js index b91f538d57..3f21dbcd94 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-14.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-14.js @@ -28,12 +28,11 @@ Object.defineProperty(obj, "0", { configurable: true }); -verifyEqualTo(obj, "0", 1001); - -verifyWritable(obj, "0"); - -verifyNotEnumerable(obj, "0"); - -verifyConfigurable(obj, "0"); +verifyProperty(obj, "0", { + value: 1001, + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-15.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-15.js index 5a88b4781c..49d20e8780 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-15.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-15.js @@ -26,12 +26,11 @@ Object.defineProperty(obj, "0", { configurable: false }); -verifyEqualTo(obj, "0", 1001); - -verifyWritable(obj, "0"); - -verifyEnumerable(obj, "0"); - -verifyNotConfigurable(obj, "0"); +verifyProperty(obj, "0", { + value: 1001, + writable: true, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-16.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-16.js index fe07c56e74..b22ff1fb7c 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-16.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-16.js @@ -28,12 +28,11 @@ Object.defineProperty(obj, "0", { configurable: false }); -verifyEqualTo(obj, "0", 1001); - -verifyWritable(obj, "0"); - -verifyEnumerable(obj, "0"); - -verifyNotConfigurable(obj, "0"); +verifyProperty(obj, "0", { + value: 1001, + writable: true, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-17.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-17.js index de43ae8048..acac52e8c1 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-17.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-17.js @@ -28,12 +28,11 @@ Object.defineProperty(obj, "0", { configurable: false }); -verifyEqualTo(obj, "0", 1001); - -verifyWritable(obj, "0"); - -verifyNotEnumerable(obj, "0"); - -verifyNotConfigurable(obj, "0"); +verifyProperty(obj, "0", { + value: 1001, + writable: true, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-18.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-18.js index 30b44c922c..063c7d48a1 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-18.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-18.js @@ -27,12 +27,11 @@ Object.defineProperty(obj, "0", { enumerable: true }); -verifyEqualTo(obj, "0", 1001); - -verifyWritable(obj, "0"); - -verifyEnumerable(obj, "0"); - -verifyConfigurable(obj, "0"); +verifyProperty(obj, "0", { + value: 1001, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-19.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-19.js index b8776f7da0..894860a0a6 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-19.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-19.js @@ -37,8 +37,9 @@ verifyEqualTo(obj, "0", get_func()); verifyWritable(obj, "0", "verifySetFunction"); -verifyNotEnumerable(obj, "0"); - -verifyConfigurable(obj, "0"); +verifyProperty(obj, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-2.js index e5093aeec7..0c3c12cb09 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-2.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-2.js @@ -28,12 +28,11 @@ Object.defineProperty(obj, "foo", { configurable: true }); -verifyEqualTo(obj, "foo", 1001); - -verifyWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 1001, + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-20.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-20.js index 4b4ee70a99..d05a255134 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-20.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-20.js @@ -38,8 +38,9 @@ verifyEqualTo(obj, "0", get_func()); verifyWritable(obj, "0", "verifySetFunction"); -verifyNotEnumerable(obj, "0"); - -verifyConfigurable(obj, "0"); +verifyProperty(obj, "0", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-21.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-21.js index f4d984ef54..c3f45f0fb5 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-21.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-21.js @@ -37,8 +37,9 @@ verifyEqualTo(obj, "0", get_func()); verifyWritable(obj, "0", "verifySetFunction"); -verifyEnumerable(obj, "0"); - -verifyNotConfigurable(obj, "0"); +verifyProperty(obj, "0", { + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-22.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-22.js index 4df84cf130..88c4a33a60 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-22.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-22.js @@ -38,8 +38,9 @@ verifyEqualTo(obj, "0", get_func()); verifyWritable(obj, "0", "verifySetFunction"); -verifyEnumerable(obj, "0"); - -verifyNotConfigurable(obj, "0"); +verifyProperty(obj, "0", { + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-23.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-23.js index a313d8ed02..8c9693671f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-23.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-23.js @@ -38,8 +38,9 @@ verifyEqualTo(obj, "0", get_func()); verifyWritable(obj, "0", "verifySetFunction"); -verifyNotEnumerable(obj, "0"); - -verifyNotConfigurable(obj, "0"); +verifyProperty(obj, "0", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-24.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-24.js index fd2e6d537b..199a0c8f9e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-24.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-24.js @@ -37,8 +37,9 @@ verifyEqualTo(obj, "0", get_func()); verifyWritable(obj, "0", "verifySetFunction"); -verifyEnumerable(obj, "0"); - -verifyConfigurable(obj, "0"); +verifyProperty(obj, "0", { + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-3.js index f031e54a38..083cd2a349 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-3.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-3.js @@ -26,12 +26,11 @@ Object.defineProperty(obj, "foo", { configurable: false }); -verifyEqualTo(obj, "foo", 1001); - -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 1001, + writable: true, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-4.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-4.js index 9e6bd3600a..341f8055ba 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-4.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-4.js @@ -28,12 +28,11 @@ Object.defineProperty(obj, "foo", { configurable: false }); -verifyEqualTo(obj, "foo", 1001); - -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 1001, + writable: true, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-5.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-5.js index d0dae554c5..431ae80ae1 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-5.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-5.js @@ -28,12 +28,11 @@ Object.defineProperty(obj, "foo", { configurable: false }); -verifyEqualTo(obj, "foo", 1001); - -verifyWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 1001, + writable: true, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-6.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-6.js index 265df4a1bb..c5821b1bba 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-6.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-6.js @@ -27,12 +27,11 @@ Object.defineProperty(obj, "foo", { enumerable: true }); -verifyEqualTo(obj, "foo", 1001); - -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 1001, + writable: true, + enumerable: true, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-7.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-7.js index 72e6355d42..d41b441ab0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-7.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-7.js @@ -37,8 +37,9 @@ verifyEqualTo(obj, "foo", get_func()); verifyWritable(obj, "foo", "verifySetFunction"); -verifyNotEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-8.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-8.js index 1238652846..3404e81fe0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-8.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-8.js @@ -38,8 +38,9 @@ verifyEqualTo(obj, "foo", get_func()); verifyWritable(obj, "foo", "verifySetFunction"); -verifyNotEnumerable(obj, "foo"); - -verifyConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-9.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-9.js index 7f7b8b7a1d..e8a7bdfb6e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-9.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-9.js @@ -37,8 +37,9 @@ verifyEqualTo(obj, "foo", get_func()); verifyWritable(obj, "foo", "verifySetFunction"); -verifyEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82.js index f80c1afff1..961ee791bb 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82.js @@ -19,12 +19,12 @@ Object.defineProperty(obj, "foo", { Object.defineProperty(obj, "foo", { configurable: false }); -verifyEqualTo(obj, "foo", undefined); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-83.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-83.js index c9fb22b3d7..34d5c23c1f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-83.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-83.js @@ -24,12 +24,12 @@ Object.defineProperty(obj, "foo", { writable: false, configurable: false }); -verifyEqualTo(obj, "foo", undefined); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: undefined, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-84.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-84.js index fdb49395ee..cd1857b57f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-84.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-84.js @@ -24,12 +24,12 @@ Object.defineProperty(obj, "foo", { writable: false, configurable: false }); -verifyEqualTo(obj, "foo", null); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: null, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-85.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-85.js index 882a018143..077358427d 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-85.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-85.js @@ -24,12 +24,11 @@ Object.defineProperty(obj, "foo", { configurable: false }); -assert.sameValue(obj.foo, NaN); - -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: NaN, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-86.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-86.js index 1bf35f3460..e06026db5f 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-86.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-86.js @@ -25,18 +25,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", -0); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: -0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-87.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-87.js index cbf3421f4e..bb440cdfab 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-87.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-87.js @@ -25,18 +25,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", +0); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: +0, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-88.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-88.js index 27b56ee337..acf4b9ef0b 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-88.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-88.js @@ -23,12 +23,12 @@ Object.defineProperty(obj, "foo", { Object.defineProperty(obj, "foo", { value: 100 }); -verifyEqualTo(obj, "foo", 100); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 100, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-89.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-89.js index a8b3ba707f..c2486ea1c9 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-89.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-89.js @@ -25,18 +25,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", 10); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: 10, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-90.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-90.js index 07438a7406..e5909987a0 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-90.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-90.js @@ -23,12 +23,12 @@ Object.defineProperty(obj, "foo", { Object.defineProperty(obj, "foo", { value: "abcd" }); -verifyEqualTo(obj, "foo", "abcd"); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: "abcd", + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-91.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-91.js index 665ae48b79..b8b341634e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-91.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-91.js @@ -25,18 +25,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", "abcd"); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: "abcd", + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-92.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-92.js index 780ad68e54..5eea0ded00 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-92.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-92.js @@ -23,12 +23,12 @@ Object.defineProperty(obj, "foo", { Object.defineProperty(obj, "foo", { value: false }); -verifyEqualTo(obj, "foo", false); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: false, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-93.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-93.js index 27113a056f..ae20af55cb 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-93.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-93.js @@ -25,18 +25,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", false); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: false, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-94.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-94.js index 6a3a90950d..62816a425e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-94.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-94.js @@ -27,12 +27,12 @@ Object.defineProperty(obj, "foo", { Object.defineProperty(obj, "foo", { value: obj1 }); -verifyEqualTo(obj, "foo", obj1); -verifyNotWritable(obj, "foo"); - -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: obj1, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-95.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-95.js index 9590be199b..d88f1f6a86 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-95.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-95.js @@ -34,18 +34,16 @@ try { }); throw new Test262Error("Expected an exception."); } catch (e) { - verifyEqualTo(obj, "foo", obj1); - - verifyNotWritable(obj, "foo"); - - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + value: obj1, + writable: false, + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-96.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-96.js index 6cc17c467e..f0629223d7 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-96.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-96.js @@ -27,8 +27,9 @@ Object.defineProperty(obj, "foo", { }); verifyWritable(obj, "foo", "setVerifyHelpProp"); -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-97.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-97.js index 6e3d07a24b..8a5ada0331 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-97.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-97.js @@ -33,14 +33,14 @@ try { } catch (e) { verifyEqualTo(obj, "property", getFunc()); - verifyNotEnumerable(obj, "property"); - - verifyNotConfigurable(obj, "property"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "property", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-98.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-98.js index 0b54b241d5..99cd678b2a 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-98.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-98.js @@ -35,8 +35,9 @@ verifyEqualTo(obj, "foo", getFunc()); verifyWritable(obj, "foo", "verifyGetHelpMethod"); -verifyNotEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-99.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-99.js index bc8efa7208..2d0cd0e7da 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-99.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-99.js @@ -35,14 +35,14 @@ try { } catch (e) { verifyWritable(obj, "foo", "setVerifyHelpProp"); - verifyNotEnumerable(obj, "foo"); - - verifyNotConfigurable(obj, "foo"); - if (!(e instanceof TypeError)) { throw new Test262Error("Expected TypeError, got " + e); } - } +verifyProperty(obj, "foo", { + enumerable: false, + configurable: false, +}); + reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/name.js b/js/src/tests/test262/built-ins/Object/defineProperty/name.js index 93e3066236..277210934e 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/name.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.defineProperty.name, "defineProperty"); - -verifyNotEnumerable(Object.defineProperty, "name"); -verifyNotWritable(Object.defineProperty, "name"); -verifyConfigurable(Object.defineProperty, "name"); +verifyProperty(Object.defineProperty, "name", { + value: "defineProperty", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/defineProperty/not-a-constructor.js index 8c49a7085c..4b5af11af9 100644 --- a/js/src/tests/test262/built-ins/Object/defineProperty/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/defineProperty/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Object.defineProperty({}, '', {}); -}, '`new Object.defineProperty({}, \'\', {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/entries/function-length.js b/js/src/tests/test262/built-ins/Object/entries/function-length.js index 6510ac12b6..297c3acb8b 100644 --- a/js/src/tests/test262/built-ins/Object/entries/function-length.js +++ b/js/src/tests/test262/built-ins/Object/entries/function-length.js @@ -8,10 +8,11 @@ author: Jordan Harband includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.entries.length, 1, 'Expected Object.entries.length to be 1'); - -verifyNotEnumerable(Object.entries, 'length'); -verifyNotWritable(Object.entries, 'length'); -verifyConfigurable(Object.entries, 'length'); +verifyProperty(Object.entries, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/entries/function-name.js b/js/src/tests/test262/built-ins/Object/entries/function-name.js index ddc50048d8..981386649c 100644 --- a/js/src/tests/test262/built-ins/Object/entries/function-name.js +++ b/js/src/tests/test262/built-ins/Object/entries/function-name.js @@ -8,14 +8,11 @@ author: Jordan Harband includes: [propertyHelper.js] ---*/ -assert.sameValue( - Object.entries.name, - 'entries', - 'Expected Object.entries.name to be "entries"' -); - -verifyNotEnumerable(Object.entries, 'name'); -verifyNotWritable(Object.entries, 'name'); -verifyConfigurable(Object.entries, 'name'); +verifyProperty(Object.entries, "name", { + value: "entries", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/entries/function-property-descriptor.js b/js/src/tests/test262/built-ins/Object/entries/function-property-descriptor.js index a1ed98ba44..35bb70debf 100644 --- a/js/src/tests/test262/built-ins/Object/entries/function-property-descriptor.js +++ b/js/src/tests/test262/built-ins/Object/entries/function-property-descriptor.js @@ -8,8 +8,10 @@ author: Jordan Harband includes: [propertyHelper.js] ---*/ -verifyNotEnumerable(Object, 'entries'); -verifyWritable(Object, 'entries'); -verifyConfigurable(Object, 'entries'); +verifyProperty(Object, "entries", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/entries/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/entries/not-a-constructor.js index cab5f1d2e6..5c53c08703 100644 --- a/js/src/tests/test262/built-ins/Object/entries/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/entries/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Object.entries), false, 'isConstructor(Object.ent assert.throws(TypeError, () => { new Object.entries({}); -}, '`new Object.entries({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-4.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-4.js index d1c0131160..812183048a 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-4.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-4.js @@ -17,8 +17,9 @@ Object.defineProperty(obj, "foo", { Object.freeze(obj); -assert(obj.hasOwnProperty("foo")); -verifyNotWritable(obj, "foo"); -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + writable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-1.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-1.js index a03d148d17..49575f4042 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-1.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-1.js @@ -13,9 +13,10 @@ obj.foo = 10; // default [[Configurable]] attribute value of foo: true Object.freeze(obj); -verifyNotWritable(obj, "foo"); -verifyNotConfigurable(obj, "foo"); - -assert.sameValue(obj.foo, 10); +verifyProperty(obj, "foo", { + value: 10, + writable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-10.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-10.js index ac66e48f32..4f8efb99c8 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-10.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-10.js @@ -15,9 +15,10 @@ arrObj.foo = 10; // default [[Configurable]] attribute value of foo: true Object.freeze(arrObj); -verifyNotWritable(arrObj, "foo"); -verifyNotConfigurable(arrObj, "foo"); - -assert.sameValue(arrObj.foo, 10); +verifyProperty(arrObj, "foo", { + value: 10, + writable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-11.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-11.js index b9db664525..4e4fe8ac10 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-11.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-11.js @@ -17,10 +17,10 @@ var argObj = (function() { Object.freeze(argObj); -var desc = Object.getOwnPropertyDescriptor(argObj, "0"); - -verifyNotWritable(argObj, "0"); -verifyNotConfigurable(argObj, "0"); -assert.sameValue(argObj[0], 1); +verifyProperty(argObj, "0", { + value: 1, + writable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-12.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-12.js index 1eb5dbbc11..4072d7b0f1 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-12.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-12.js @@ -15,9 +15,10 @@ var strObj = new String("abc"); Object.freeze(strObj); -verifyNotWritable(strObj, "0"); -verifyNotConfigurable(strObj, "0"); - -assert.sameValue(strObj[0], "a"); +verifyProperty(strObj, "0", { + value: "a", + writable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-13.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-13.js index c4d1fa96be..41ce47b491 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-13.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-13.js @@ -17,9 +17,10 @@ var obj = { Object.freeze(obj); -verifyNotWritable(obj, "0"); -verifyNotConfigurable(obj, "0"); - -assert.sameValue(obj[0], 0); +verifyProperty(obj, "0", { + value: 0, + writable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-14.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-14.js index eecc860739..f14cf55984 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-14.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-14.js @@ -14,8 +14,10 @@ var arrObj = [0, 1, 2]; Object.freeze(arrObj); -verifyNotWritable(arrObj, "0"); -verifyNotConfigurable(arrObj, "0"); -assert.sameValue(arrObj[0], 0); +verifyProperty(arrObj, "0", { + value: 0, + writable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-2.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-2.js index 3bf26de301..94daf9f243 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-2.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-2.js @@ -23,9 +23,10 @@ child.foo = 10; // default [[Configurable]] attribute value of foo: true Object.freeze(child); -verifyNotWritable(child, "foo"); -verifyNotConfigurable(child, "foo"); - -assert.sameValue(child.foo, 10); +verifyProperty(child, "foo", { + value: 10, + writable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-3.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-3.js index 9e70497f78..00faf0bfc8 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-3.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-3.js @@ -29,8 +29,10 @@ Object.defineProperty(child, "foo", { Object.freeze(child); -verifyNotWritable(child, "foo"); -verifyNotConfigurable(child, "foo"); -assert.sameValue(child.foo, 10); +verifyProperty(child, "foo", { + value: 10, + writable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-4.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-4.js index acdfed7f01..be1ed8c528 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-4.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-4.js @@ -18,7 +18,10 @@ Object.defineProperty(obj, "foo", { Object.freeze(obj); -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + configurable: false, +}); + assert.sameValue(obj.foo, 10); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-5.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-5.js index 00ff5bfc63..f08d411009 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-5.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-5.js @@ -28,7 +28,10 @@ Object.defineProperty(child, "foo", { Object.freeze(child); -verifyNotConfigurable(child, "foo"); +verifyProperty(child, "foo", { + configurable: false, +}); + assert.sameValue(child.foo, 10); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-6.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-6.js index 163d0a951e..a1e8b22dac 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-6.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-6.js @@ -32,7 +32,10 @@ Object.defineProperty(child, "foo", { Object.freeze(child); -verifyNotConfigurable(child, "foo"); +verifyProperty(child, "foo", { + configurable: false, +}); + assert.sameValue(child.foo, 10); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-7.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-7.js index c8de353b20..5243d62cec 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-7.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-7.js @@ -17,8 +17,10 @@ argObj.foo = 10; // default [[Configurable]] attribute value of foo: true Object.freeze(argObj); -verifyNotWritable(argObj, "foo"); -verifyNotConfigurable(argObj, "foo"); -assert.sameValue(argObj.foo, 10); +verifyProperty(argObj, "foo", { + value: 10, + writable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-8.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-8.js index f930bdee5f..d7eabe58ec 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-8.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-8.js @@ -15,8 +15,10 @@ strObj.foo = 10; // default [[Configurable]] attribute value of foo: true Object.freeze(strObj); -verifyNotWritable(strObj, "foo"); -verifyNotConfigurable(strObj, "foo"); -assert.sameValue(strObj.foo, 10); +verifyProperty(strObj, "foo", { + value: 10, + writable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-9.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-9.js index 2d2c722646..f79a8ba921 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-9.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-a-9.js @@ -15,9 +15,10 @@ funObj.foo = 10; // default [[Configurable]] attribute value of foo: true Object.freeze(funObj); -verifyNotWritable(funObj, "foo"); -verifyNotConfigurable(funObj, "foo"); - -assert.sameValue(funObj.foo, 10); +verifyProperty(funObj, "foo", { + value: 10, + writable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-b-i-1.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-b-i-1.js index 4c6c953c7b..26e0c0cb37 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-b-i-1.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-b-i-1.js @@ -19,22 +19,12 @@ Object.defineProperty(obj, "foo", { }); Object.freeze(obj); -var desc = Object.getOwnPropertyDescriptor(obj, "foo"); -verifyEqualTo(obj, "foo", 10); - -verifyNotWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); - -if (desc.writable !== false) { - throw new Test262Error('Expected desc.writable === false, actually ' + desc.writable); -} - -if (desc.configurable !== false) { - throw new Test262Error('Expected desc.configurable === false, actually ' + desc.configurable); -} +verifyProperty(obj, "foo", { + value: 10, + writable: false, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-b-i-2.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-b-i-2.js index 2d8a00a53b..bb6fd6bcf2 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-b-i-2.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-b-i-2.js @@ -28,39 +28,18 @@ Object.defineProperty(obj, "foo2", { Object.freeze(obj); -var desc1 = Object.getOwnPropertyDescriptor(obj, "foo1"); -var desc2 = Object.getOwnPropertyDescriptor(obj, "foo2"); - -verifyEqualTo(obj, "foo1", 10); - -verifyNotWritable(obj, "foo1"); - -verifyEnumerable(obj, "foo1"); - -verifyNotConfigurable(obj, "foo1"); - -verifyEqualTo(obj, "foo2", 20); - -verifyNotWritable(obj, "foo2"); - -verifyNotEnumerable(obj, "foo2"); - -verifyNotConfigurable(obj, "foo2"); - -if (desc1.configurable !== false) { - throw new Test262Error('Expected desc1.configurable === false, actually ' + desc1.configurable); -} - -if (desc1.writable !== false) { - throw new Test262Error('Expected desc1.writable === false, actually ' + desc1.writable); -} - -if (desc2.configurable !== false) { - throw new Test262Error('Expected desc2.configurable === false, actually ' + desc2.configurable); -} +verifyProperty(obj, "foo1", { + value: 10, + writable: false, + enumerable: true, + configurable: false, +}); -if (desc2.writable !== false) { - throw new Test262Error('Expected desc2.writable === false, actually ' + desc2.writable); -} +verifyProperty(obj, "foo2", { + value: 20, + writable: false, + enumerable: false, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-1.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-1.js index 219519195c..4969d18425 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-1.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-1.js @@ -21,21 +21,11 @@ Object.defineProperty(obj, "foo", { Object.freeze(obj); -var desc = Object.getOwnPropertyDescriptor(obj, "foo"); - -if (desc.configurable !== false) { - throw new Test262Error("Expected desc.configurable to be false, actually " + desc.configurable); -} -if (desc.writable !== false) { - throw new Test262Error("Expected desc.writable to be false, actually " + desc.writable); -} - -verifyEqualTo(obj, "foo", 10); - -verifyNotWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 10, + writable: false, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-2.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-2.js index af0797a00d..c59e8e068a 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-2.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-2.js @@ -31,17 +31,18 @@ Object.defineProperty(obj, "foo", { Object.freeze(obj); -assert(obj.hasOwnProperty("foo")); -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + configurable: false, +}); assert.sameValue(obj.foo, 10); obj.foo = 12; assert(set_funcCalled); -verifyEnumerable(obj, "foo"); - -var desc = Object.getOwnPropertyDescriptor(obj, "foo"); -assert.sameValue(desc.configurable, false); +verifyProperty(obj, "foo", { + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-3.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-3.js index 24be086754..9ac2917a53 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-3.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-3.js @@ -37,7 +37,10 @@ Object.defineProperty(obj, "foo2", { Object.freeze(obj); -verifyNotConfigurable(obj, "foo2"); +verifyProperty(obj, "foo2", { + configurable: false, +}); + verifyEqualTo(obj, "foo2", 10); obj.foo2 = 12; @@ -45,26 +48,21 @@ if (!resultSetFun) { throw new Test262Error('Expected obj["foo2"] set() to be called, but was not.'); } -if (!isEnumerable(obj, "foo2")) { - throw new Test262Error('Expected obj["foo2"] to be enumerable.'); -} - -var desc1 = Object.getOwnPropertyDescriptor(obj, "foo1"); -if (desc1.configurable || desc1.writable) { - throw new Test262Error('Expected obj["foo1"] to be non-writable, non-configurable; actually ' + JSON.stringify(desc1)); -} +verifyProperty(obj, "foo2", { + enumerable: true, + configurable: false, +}); var desc2 = Object.getOwnPropertyDescriptor(obj, "foo2"); -if (desc2.configurable || desc2.writable) { +if (desc2.writable) { throw new Test262Error('Expected obj["foo2"] to be non-writable, non-configurable; actually ' + JSON.stringify(desc2)); } -verifyEqualTo(obj, "foo1", 10); - -verifyNotWritable(obj, "foo1"); - -verifyEnumerable(obj, "foo1"); - -verifyNotConfigurable(obj, "foo1"); +verifyProperty(obj, "foo1", { + value: 10, + writable: false, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-4.js b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-4.js index 49390cbf84..f211cbeb73 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-4.js +++ b/js/src/tests/test262/built-ins/Object/freeze/15.2.3.9-2-c-4.js @@ -38,31 +38,30 @@ Object.freeze(obj); verifyEqualTo(obj, "foo2", 10); -verifyNotConfigurable(obj, "foo2"); +verifyProperty(obj, "foo2", { + configurable: false, +}); obj.foo2 = 12; if (!resultSetFun) { throw new Test262Error('Expected obj["foo2"] set() to be called, but was not.'); } -verifyEnumerable(obj, "foo2"); - -var desc1 = Object.getOwnPropertyDescriptor(obj, "foo1"); -if (desc1.configurable || desc1.writable) { - throw new Test262Error('Expected obj["foo1"] to be non-writable, non-configurable; actually ' + JSON.stringify(desc1)); -} +verifyProperty(obj, "foo2", { + enumerable: true, + configurable: false, +}); var desc2 = Object.getOwnPropertyDescriptor(obj, "foo2"); -if (desc2.configurable || desc2.writable) { +if (desc2.writable) { throw new Test262Error('Expected obj["foo2"] to be non-writable, non-configurable; actually ' + JSON.stringify(desc2)); } -verifyEqualTo(obj, "foo1", 10); - -verifyNotWritable(obj, "foo1"); - -verifyEnumerable(obj, "foo1"); - -verifyNotConfigurable(obj, "foo1"); +verifyProperty(obj, "foo1", { + value: 10, + writable: false, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/name.js b/js/src/tests/test262/built-ins/Object/freeze/name.js index 1881d15751..c9f8c5115b 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/name.js +++ b/js/src/tests/test262/built-ins/Object/freeze/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.freeze.name, "freeze"); - -verifyNotEnumerable(Object.freeze, "name"); -verifyNotWritable(Object.freeze, "name"); -verifyConfigurable(Object.freeze, "name"); +verifyProperty(Object.freeze, "name", { + value: "freeze", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/freeze/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/freeze/not-a-constructor.js index 6d928f4f11..d4f1eadcfb 100644 --- a/js/src/tests/test262/built-ins/Object/freeze/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/freeze/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Object.freeze), false, 'isConstructor(Object.free assert.throws(TypeError, () => { new Object.freeze({}); -}, '`new Object.freeze({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/fromEntries/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/fromEntries/not-a-constructor.js index d63a99663e..7c83209db1 100644 --- a/js/src/tests/test262/built-ins/Object/fromEntries/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/fromEntries/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Object.fromEntries), false, 'isConstructor(Object assert.throws(TypeError, () => { new Object.fromEntries([]); -}, '`new Object.fromEntries([])` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptor/name.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptor/name.js index 8752810f81..377656f7dd 100644 --- a/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptor/name.js +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptor/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.getOwnPropertyDescriptor.name, "getOwnPropertyDescriptor"); - -verifyNotEnumerable(Object.getOwnPropertyDescriptor, "name"); -verifyNotWritable(Object.getOwnPropertyDescriptor, "name"); -verifyConfigurable(Object.getOwnPropertyDescriptor, "name"); +verifyProperty(Object.getOwnPropertyDescriptor, "name", { + value: "getOwnPropertyDescriptor", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptor/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptor/not-a-constructor.js index af851726d6..e48a450826 100644 --- a/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptor/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptor/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Object.getOwnPropertyDescriptor({}, ''); -}, '`new Object.getOwnPropertyDescriptor({}, \'\')` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-length.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-length.js index 8c1746ba9c..223cd5b1b4 100644 --- a/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-length.js +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-length.js @@ -8,10 +8,11 @@ author: Jordan Harband includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.getOwnPropertyDescriptors.length, 1, 'Expected Object.getOwnPropertyDescriptors.length to be 1'); - -verifyNotEnumerable(Object.getOwnPropertyDescriptors, 'length'); -verifyNotWritable(Object.getOwnPropertyDescriptors, 'length'); -verifyConfigurable(Object.getOwnPropertyDescriptors, 'length'); +verifyProperty(Object.getOwnPropertyDescriptors, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-name.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-name.js index 7037128d72..a718eb883c 100644 --- a/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-name.js +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-name.js @@ -8,14 +8,11 @@ author: Jordan Harband includes: [propertyHelper.js] ---*/ -assert.sameValue( - Object.getOwnPropertyDescriptors.name, - 'getOwnPropertyDescriptors', - 'Expected Object.getOwnPropertyDescriptors.name to be "getOwnPropertyDescriptors"' -); - -verifyNotEnumerable(Object.getOwnPropertyDescriptors, 'name'); -verifyNotWritable(Object.getOwnPropertyDescriptors, 'name'); -verifyConfigurable(Object.getOwnPropertyDescriptors, 'name'); +verifyProperty(Object.getOwnPropertyDescriptors, "name", { + value: "getOwnPropertyDescriptors", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-property-descriptor.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-property-descriptor.js index 2182f1234b..1d305b6d83 100644 --- a/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-property-descriptor.js +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/function-property-descriptor.js @@ -8,8 +8,10 @@ author: Jordan Harband includes: [propertyHelper.js] ---*/ -verifyNotEnumerable(Object, 'getOwnPropertyDescriptors'); -verifyWritable(Object, 'getOwnPropertyDescriptors'); -verifyConfigurable(Object, 'getOwnPropertyDescriptors'); +verifyProperty(Object, "getOwnPropertyDescriptors", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/not-a-constructor.js index 3d03780e66..1ee9f034de 100644 --- a/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Object.getOwnPropertyDescriptors({}); -}, '`new Object.getOwnPropertyDescriptors({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/name.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/name.js index 9ed3603700..1952cd6272 100644 --- a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/name.js +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.getOwnPropertyNames.name, "getOwnPropertyNames"); - -verifyNotEnumerable(Object.getOwnPropertyNames, "name"); -verifyNotWritable(Object.getOwnPropertyNames, "name"); -verifyConfigurable(Object.getOwnPropertyNames, "name"); +verifyProperty(Object.getOwnPropertyNames, "name", { + value: "getOwnPropertyNames", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/not-a-constructor.js index 70a205d5a4..7a7cc7ffb3 100644 --- a/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertyNames/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Object.getOwnPropertyNames({}); -}, '`new Object.getOwnPropertyNames({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/length.js b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/length.js index 6807e1d8dc..feb50325ca 100644 --- a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/length.js +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/length.js @@ -22,10 +22,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.getOwnPropertySymbols.length, 1); - -verifyNotEnumerable(Object.getOwnPropertySymbols, "length"); -verifyNotWritable(Object.getOwnPropertySymbols, "length"); -verifyConfigurable(Object.getOwnPropertySymbols, "length"); +verifyProperty(Object.getOwnPropertySymbols, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/name.js b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/name.js index 0199dbba7d..811508fbe5 100644 --- a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/name.js +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.getOwnPropertySymbols.name, "getOwnPropertySymbols"); - -verifyNotEnumerable(Object.getOwnPropertySymbols, "name"); -verifyNotWritable(Object.getOwnPropertySymbols, "name"); -verifyConfigurable(Object.getOwnPropertySymbols, "name"); +verifyProperty(Object.getOwnPropertySymbols, "name", { + value: "getOwnPropertySymbols", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/not-a-constructor.js index c9a4d86680..1c9a660888 100644 --- a/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Object.getOwnPropertySymbols({}); -}, '`new Object.getOwnPropertySymbols({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getPrototypeOf/name.js b/js/src/tests/test262/built-ins/Object/getPrototypeOf/name.js index ad6ed3dfd7..5760387715 100644 --- a/js/src/tests/test262/built-ins/Object/getPrototypeOf/name.js +++ b/js/src/tests/test262/built-ins/Object/getPrototypeOf/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.getPrototypeOf.name, "getPrototypeOf"); - -verifyNotEnumerable(Object.getPrototypeOf, "name"); -verifyNotWritable(Object.getPrototypeOf, "name"); -verifyConfigurable(Object.getPrototypeOf, "name"); +verifyProperty(Object.getPrototypeOf, "name", { + value: "getPrototypeOf", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/getPrototypeOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/getPrototypeOf/not-a-constructor.js index a40dd4beca..9bf94e49a5 100644 --- a/js/src/tests/test262/built-ins/Object/getPrototypeOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/getPrototypeOf/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Object.getPrototypeOf({}); -}, '`new Object.getPrototypeOf({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/groupBy/string.js b/js/src/tests/test262/built-ins/Object/groupBy/string.js new file mode 100644 index 0000000000..6e34359f6d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/groupBy/string.js @@ -0,0 +1,24 @@ +// Copyright (c) 2023 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.groupby +description: Object.groupBy works for string items +info: | + Object.groupBy ( items, callbackfn ) + ... +includes: [compareArray.js] +features: [array-grouping] +---*/ + +const string = '🥰💩🙏😈'; + +const obj = Object.groupBy(string, function (char) { + return char < '🙏' ? 'before' : 'after'; +}); + +assert.compareArray(Object.keys(obj), ['after', 'before']); +assert.compareArray(obj.before, ['💩', '😈']); +assert.compareArray(obj.after, ['🥰', '🙏']); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/hasOwn/descriptor.js b/js/src/tests/test262/built-ins/Object/hasOwn/descriptor.js index 105e9eaa10..88feeea09a 100644 --- a/js/src/tests/test262/built-ins/Object/hasOwn/descriptor.js +++ b/js/src/tests/test262/built-ins/Object/hasOwn/descriptor.js @@ -9,8 +9,10 @@ author: Jamie Kyle features: [Object.hasOwn] ---*/ -verifyWritable(Object, "hasOwn"); -verifyNotEnumerable(Object, "hasOwn"); -verifyConfigurable(Object, "hasOwn"); +verifyProperty(Object, "hasOwn", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/hasOwn/name.js b/js/src/tests/test262/built-ins/Object/hasOwn/name.js index c8532bc559..c421cc6b2b 100644 --- a/js/src/tests/test262/built-ins/Object/hasOwn/name.js +++ b/js/src/tests/test262/built-ins/Object/hasOwn/name.js @@ -21,10 +21,11 @@ author: Jamie Kyle features: [Object.hasOwn] ---*/ -assert.sameValue(Object.hasOwn.name, "hasOwn"); - -verifyNotEnumerable(Object.hasOwn, "name"); -verifyNotWritable(Object.hasOwn, "name"); -verifyConfigurable(Object.hasOwn, "name"); +verifyProperty(Object.hasOwn, "name", { + value: "hasOwn", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/hasOwn/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/hasOwn/not-a-constructor.js index a3badb6c87..a5baf6b30d 100644 --- a/js/src/tests/test262/built-ins/Object/hasOwn/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/hasOwn/not-a-constructor.js @@ -30,6 +30,6 @@ assert.sameValue( assert.throws(TypeError, () => { new Object.hasOwn(''); -}, '`new Object.hasOwn(\'\')` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/is/length.js b/js/src/tests/test262/built-ins/Object/is/length.js index 98483984b9..9218a31356 100644 --- a/js/src/tests/test262/built-ins/Object/is/length.js +++ b/js/src/tests/test262/built-ins/Object/is/length.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.is.length, 2, "The value of `Object.is.length` is `2`"); - -verifyNotEnumerable(Object.is, "length"); -verifyNotWritable(Object.is, "length"); -verifyConfigurable(Object.is, "length"); +verifyProperty(Object.is, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/is/name.js b/js/src/tests/test262/built-ins/Object/is/name.js index f495ccbc12..d614d88d0a 100644 --- a/js/src/tests/test262/built-ins/Object/is/name.js +++ b/js/src/tests/test262/built-ins/Object/is/name.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.is.name, 'is', "The value of `Object.is.name` is `'is'`"); - -verifyNotEnumerable(Object.is, "name"); -verifyNotWritable(Object.is, "name"); -verifyConfigurable(Object.is, "name"); +verifyProperty(Object.is, "name", { + value: "is", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/is/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/is/not-a-constructor.js index 96c90fcc5d..b56849e5f1 100644 --- a/js/src/tests/test262/built-ins/Object/is/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/is/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Object.is), false, 'isConstructor(Object.is) must assert.throws(TypeError, () => { new Object.is(0, 0); -}, '`new Object.is(0, 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/is/object-is.js b/js/src/tests/test262/built-ins/Object/is/object-is.js index 22dcd083aa..0865fb21ad 100644 --- a/js/src/tests/test262/built-ins/Object/is/object-is.js +++ b/js/src/tests/test262/built-ins/Object/is/object-is.js @@ -10,12 +10,12 @@ description: > includes: [propertyHelper.js] ---*/ - assert.sameValue(typeof Object.is, "function"); -assert.sameValue(Object.is.name, "is"); -verifyWritable(Object, "is"); -verifyNotEnumerable(Object, "is"); -verifyConfigurable(Object, "is"); +verifyProperty(Object, "is", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/isExtensible/name.js b/js/src/tests/test262/built-ins/Object/isExtensible/name.js index ae6a6e6549..eff74b07fa 100644 --- a/js/src/tests/test262/built-ins/Object/isExtensible/name.js +++ b/js/src/tests/test262/built-ins/Object/isExtensible/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.isExtensible.name, "isExtensible"); - -verifyNotEnumerable(Object.isExtensible, "name"); -verifyNotWritable(Object.isExtensible, "name"); -verifyConfigurable(Object.isExtensible, "name"); +verifyProperty(Object.isExtensible, "name", { + value: "isExtensible", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/isExtensible/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/isExtensible/not-a-constructor.js index 56ab6d19e3..b314e5250c 100644 --- a/js/src/tests/test262/built-ins/Object/isExtensible/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/isExtensible/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Object.isExtensible), false, 'isConstructor(Objec assert.throws(TypeError, () => { new Object.isExtensible({}); -}, '`new Object.isExtensible({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/isFrozen/name.js b/js/src/tests/test262/built-ins/Object/isFrozen/name.js index 4b83c75722..d769d8939d 100644 --- a/js/src/tests/test262/built-ins/Object/isFrozen/name.js +++ b/js/src/tests/test262/built-ins/Object/isFrozen/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.isFrozen.name, "isFrozen"); - -verifyNotEnumerable(Object.isFrozen, "name"); -verifyNotWritable(Object.isFrozen, "name"); -verifyConfigurable(Object.isFrozen, "name"); +verifyProperty(Object.isFrozen, "name", { + value: "isFrozen", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/isFrozen/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/isFrozen/not-a-constructor.js index 5f8014985b..cc42d1d9e8 100644 --- a/js/src/tests/test262/built-ins/Object/isFrozen/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/isFrozen/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Object.isFrozen), false, 'isConstructor(Object.is assert.throws(TypeError, () => { new Object.isFrozen({}); -}, '`new Object.isFrozen({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/isSealed/name.js b/js/src/tests/test262/built-ins/Object/isSealed/name.js index c11f5b4842..54620f96f1 100644 --- a/js/src/tests/test262/built-ins/Object/isSealed/name.js +++ b/js/src/tests/test262/built-ins/Object/isSealed/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.isSealed.name, "isSealed"); - -verifyNotEnumerable(Object.isSealed, "name"); -verifyNotWritable(Object.isSealed, "name"); -verifyConfigurable(Object.isSealed, "name"); +verifyProperty(Object.isSealed, "name", { + value: "isSealed", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/isSealed/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/isSealed/not-a-constructor.js index a02bf5f415..ed39336fd1 100644 --- a/js/src/tests/test262/built-ins/Object/isSealed/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/isSealed/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Object.isSealed), false, 'isConstructor(Object.is assert.throws(TypeError, () => { new Object.isSealed({}); -}, '`new Object.isSealed({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/keys/name.js b/js/src/tests/test262/built-ins/Object/keys/name.js index 4839cf4031..413d847fc8 100644 --- a/js/src/tests/test262/built-ins/Object/keys/name.js +++ b/js/src/tests/test262/built-ins/Object/keys/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.keys.name, "keys"); - -verifyNotEnumerable(Object.keys, "name"); -verifyNotWritable(Object.keys, "name"); -verifyConfigurable(Object.keys, "name"); +verifyProperty(Object.keys, "name", { + value: "keys", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/keys/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/keys/not-a-constructor.js index dc5c3083f2..4dbfa236f6 100644 --- a/js/src/tests/test262/built-ins/Object/keys/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/keys/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Object.keys), false, 'isConstructor(Object.keys) assert.throws(TypeError, () => { new Object.keys({}); -}, '`new Object.keys({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/name.js b/js/src/tests/test262/built-ins/Object/preventExtensions/name.js index 09e9f7130d..b42ad2df39 100644 --- a/js/src/tests/test262/built-ins/Object/preventExtensions/name.js +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.preventExtensions.name, "preventExtensions"); - -verifyNotEnumerable(Object.preventExtensions, "name"); -verifyNotWritable(Object.preventExtensions, "name"); -verifyConfigurable(Object.preventExtensions, "name"); +verifyProperty(Object.preventExtensions, "name", { + value: "preventExtensions", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/preventExtensions/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/preventExtensions/not-a-constructor.js index dac8c6ee18..1b8b5fb864 100644 --- a/js/src/tests/test262/built-ins/Object/preventExtensions/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/preventExtensions/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Object.preventExtensions({}); -}, '`new Object.preventExtensions({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prop-desc.js b/js/src/tests/test262/built-ins/Object/prop-desc.js index 64e7a8969a..512b652cbb 100644 --- a/js/src/tests/test262/built-ins/Object/prop-desc.js +++ b/js/src/tests/test262/built-ins/Object/prop-desc.js @@ -11,8 +11,10 @@ info: | includes: [propertyHelper.js] ---*/ -verifyNotEnumerable(this, "Object"); -verifyWritable(this, "Object"); -verifyConfigurable(this, "Object"); +verifyProperty(this, "Object", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/hasOwnProperty/name.js b/js/src/tests/test262/built-ins/Object/prototype/hasOwnProperty/name.js index ae01259e26..35d0280902 100644 --- a/js/src/tests/test262/built-ins/Object/prototype/hasOwnProperty/name.js +++ b/js/src/tests/test262/built-ins/Object/prototype/hasOwnProperty/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.prototype.hasOwnProperty.name, "hasOwnProperty"); - -verifyNotEnumerable(Object.prototype.hasOwnProperty, "name"); -verifyNotWritable(Object.prototype.hasOwnProperty, "name"); -verifyConfigurable(Object.prototype.hasOwnProperty, "name"); +verifyProperty(Object.prototype.hasOwnProperty, "name", { + value: "hasOwnProperty", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/hasOwnProperty/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/prototype/hasOwnProperty/not-a-constructor.js index 07d38e779c..33f4aca473 100644 --- a/js/src/tests/test262/built-ins/Object/prototype/hasOwnProperty/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/prototype/hasOwnProperty/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Object.prototype.hasOwnProperty(''); -}, '`new Object.prototype.hasOwnProperty(\'\')` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/isPrototypeOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/prototype/isPrototypeOf/not-a-constructor.js index 9de714cba9..e8324db0be 100644 --- a/js/src/tests/test262/built-ins/Object/prototype/isPrototypeOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/prototype/isPrototypeOf/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Object.prototype.isPrototypeOf({}); -}, '`new Object.prototype.isPrototypeOf({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/propertyIsEnumerable/name.js b/js/src/tests/test262/built-ins/Object/prototype/propertyIsEnumerable/name.js index 9054d1f7a5..b6638e42e3 100644 --- a/js/src/tests/test262/built-ins/Object/prototype/propertyIsEnumerable/name.js +++ b/js/src/tests/test262/built-ins/Object/prototype/propertyIsEnumerable/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.prototype.propertyIsEnumerable.name, "propertyIsEnumerable"); - -verifyNotEnumerable(Object.prototype.propertyIsEnumerable, "name"); -verifyNotWritable(Object.prototype.propertyIsEnumerable, "name"); -verifyConfigurable(Object.prototype.propertyIsEnumerable, "name"); +verifyProperty(Object.prototype.propertyIsEnumerable, "name", { + value: "propertyIsEnumerable", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/propertyIsEnumerable/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/prototype/propertyIsEnumerable/not-a-constructor.js index e8bdaf469e..71cb963283 100644 --- a/js/src/tests/test262/built-ins/Object/prototype/propertyIsEnumerable/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/prototype/propertyIsEnumerable/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Object.prototype.propertyIsEnumerable(''); -}, '`new Object.prototype.propertyIsEnumerable(\'\')` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/name.js b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/name.js index 5f258165ba..835f5a488b 100644 --- a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/name.js +++ b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.prototype.toLocaleString.name, "toLocaleString"); - -verifyNotEnumerable(Object.prototype.toLocaleString, "name"); -verifyNotWritable(Object.prototype.toLocaleString, "name"); -verifyConfigurable(Object.prototype.toLocaleString, "name"); +verifyProperty(Object.prototype.toLocaleString, "name", { + value: "toLocaleString", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/not-a-constructor.js index 49fc0525db..ed9b6d87dc 100644 --- a/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/prototype/toLocaleString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Object.prototype.toLocaleString(''); -}, '`new Object.prototype.toLocaleString(\'\')` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/prototype/toString/not-a-constructor.js index 54f974d24f..ca2f1b3d64 100644 --- a/js/src/tests/test262/built-ins/Object/prototype/toString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/prototype/toString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Object.prototype.toString(); -}, '`new Object.prototype.toString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/toString/prop-desc.js b/js/src/tests/test262/built-ins/Object/prototype/toString/prop-desc.js index 7d3ac0d66b..6ce7d132aa 100644 --- a/js/src/tests/test262/built-ins/Object/prototype/toString/prop-desc.js +++ b/js/src/tests/test262/built-ins/Object/prototype/toString/prop-desc.js @@ -16,8 +16,10 @@ info: | includes: [propertyHelper.js] ---*/ -verifyWritable(Object.prototype, "toString"); -verifyNotEnumerable(Object.prototype, "toString"); -verifyConfigurable(Object.prototype, "toString"); +verifyProperty(Object.prototype, "toString", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/valueOf/name.js b/js/src/tests/test262/built-ins/Object/prototype/valueOf/name.js index 7648b4002d..08140e27d9 100644 --- a/js/src/tests/test262/built-ins/Object/prototype/valueOf/name.js +++ b/js/src/tests/test262/built-ins/Object/prototype/valueOf/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.prototype.valueOf.name, "valueOf"); - -verifyNotEnumerable(Object.prototype.valueOf, "name"); -verifyNotWritable(Object.prototype.valueOf, "name"); -verifyConfigurable(Object.prototype.valueOf, "name"); +verifyProperty(Object.prototype.valueOf, "name", { + value: "valueOf", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/prototype/valueOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/prototype/valueOf/not-a-constructor.js index 6db8b1c516..1aaca96dc8 100644 --- a/js/src/tests/test262/built-ins/Object/prototype/valueOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/prototype/valueOf/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Object.prototype.valueOf(); -}, '`new Object.prototype.valueOf()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/configurable-attribute-all-own-properties-set-from-true-to-false-property-are-unaltered.js b/js/src/tests/test262/built-ins/Object/seal/configurable-attribute-all-own-properties-set-from-true-to-false-property-are-unaltered.js index 4b337ca128..2d8f782d8d 100644 --- a/js/src/tests/test262/built-ins/Object/seal/configurable-attribute-all-own-properties-set-from-true-to-false-property-are-unaltered.js +++ b/js/src/tests/test262/built-ins/Object/seal/configurable-attribute-all-own-properties-set-from-true-to-false-property-are-unaltered.js @@ -40,21 +40,20 @@ if (!preCheck) { throw new Test262Error('Expected preCheck to be true, actually ' + preCheck); } - -verifyEqualTo(obj, "foo1", 10); - -verifyWritable(obj, "foo1"); - -verifyEnumerable(obj, "foo1"); - -verifyNotConfigurable(obj, "foo1"); +verifyProperty(obj, "foo1", { + value: 10, + writable: true, + enumerable: true, + configurable: false, +}); verifyEqualTo(obj, "foo2", get_func()); verifyWritable(obj, "foo2", "variableForHelpVerify"); -verifyEnumerable(obj, "foo2"); - -verifyNotConfigurable(obj, "foo2"); +verifyProperty(obj, "foo2", { + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/configurable-attribute-own-accessor-property-set-from-true-to-false-property-are-unaltered.js b/js/src/tests/test262/built-ins/Object/seal/configurable-attribute-own-accessor-property-set-from-true-to-false-property-are-unaltered.js index 5c28cf68a4..fa49cab540 100644 --- a/js/src/tests/test262/built-ins/Object/seal/configurable-attribute-own-accessor-property-set-from-true-to-false-property-are-unaltered.js +++ b/js/src/tests/test262/built-ins/Object/seal/configurable-attribute-own-accessor-property-set-from-true-to-false-property-are-unaltered.js @@ -37,8 +37,9 @@ verifyEqualTo(obj, "foo", getFunc()); verifyWritable(obj, "foo", "variableForHelpVerify"); -verifyEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/length.js b/js/src/tests/test262/built-ins/Object/seal/length.js index 114de5fd88..515d284d28 100644 --- a/js/src/tests/test262/built-ins/Object/seal/length.js +++ b/js/src/tests/test262/built-ins/Object/seal/length.js @@ -14,10 +14,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.seal.length, 1); - -verifyNotEnumerable(Object.seal, "length"); -verifyNotWritable(Object.seal, "length"); -verifyConfigurable(Object.seal, "length"); +verifyProperty(Object.seal, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/name.js b/js/src/tests/test262/built-ins/Object/seal/name.js index 3b7047d2c1..eb76408886 100644 --- a/js/src/tests/test262/built-ins/Object/seal/name.js +++ b/js/src/tests/test262/built-ins/Object/seal/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.seal.name, "seal"); - -verifyNotEnumerable(Object.seal, "name"); -verifyNotWritable(Object.seal, "name"); -verifyConfigurable(Object.seal, "name"); +verifyProperty(Object.seal, "name", { + value: "seal", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/seal/not-a-constructor.js index 97ade868fe..8ea819dbd5 100644 --- a/js/src/tests/test262/built-ins/Object/seal/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/seal/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Object.seal), false, 'isConstructor(Object.seal) assert.throws(TypeError, () => { new Object.seal(); -}, '`new Object.seal()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-all-own-properties-of-o-are-already-non-configurable.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-all-own-properties-of-o-are-already-non-configurable.js index 563b4d318e..65276afb2b 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-all-own-properties-of-o-are-already-non-configurable.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-all-own-properties-of-o-are-already-non-configurable.js @@ -43,19 +43,20 @@ if (Object.isExtensible(obj)) { throw new Test262Error('Expected obj NOT to be extensible, actually ' + Object.isExtensible(obj)); } -verifyEqualTo(obj, "foo1", 10); - -verifyWritable(obj, "foo1"); - -verifyEnumerable(obj, "foo1"); +verifyProperty(obj, "foo1", { + value: 10, + writable: true, + enumerable: true, + configurable: false, +}); -verifyNotConfigurable(obj, "foo1"); verifyEqualTo(obj, "foo2", get_func()); verifyWritable(obj, "foo2", "variableForHelpVerify"); -verifyEnumerable(obj, "foo2"); - -verifyNotConfigurable(obj, "foo2"); +verifyProperty(obj, "foo2", { + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-configurable-attribute-of-own-data-property-of-o-is-set-from-true-to-false-and-other-attributes-of-the-property-are-unaltered.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-configurable-attribute-of-own-data-property-of-o-is-set-from-true-to-false-and-other-attributes-of-the-property-are-unaltered.js index 0d59c51bca..3ab85abfc6 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-configurable-attribute-of-own-data-property-of-o-is-set-from-true-to-false-and-other-attributes-of-the-property-are-unaltered.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-configurable-attribute-of-own-data-property-of-o-is-set-from-true-to-false-and-other-attributes-of-the-property-are-unaltered.js @@ -25,12 +25,11 @@ if (!preCheck) { throw new Test262Error('Expected preCheck to be true, actually ' + preCheck); } -verifyEqualTo(obj, "foo", 10); - -verifyWritable(obj, "foo"); - -verifyEnumerable(obj, "foo"); - -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + value: 10, + writable: true, + enumerable: true, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-non-enumerable-own-property-of-o-is-sealed.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-non-enumerable-own-property-of-o-is-sealed.js index 02501ec379..ef2a857c7a 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-non-enumerable-own-property-of-o-is-sealed.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-non-enumerable-own-property-of-o-is-sealed.js @@ -18,7 +18,8 @@ Object.defineProperty(obj, "foo", { assert(Object.isExtensible(obj)); Object.seal(obj); -assert(obj.hasOwnProperty("foo")); -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-accessor-property-that-overrides-an-inherited-accessor-property.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-accessor-property-that-overrides-an-inherited-accessor-property.js index 7f5c68979e..7aea052abe 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-accessor-property-that-overrides-an-inherited-accessor-property.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-accessor-property-that-overrides-an-inherited-accessor-property.js @@ -33,7 +33,10 @@ Object.defineProperty(obj, "foo", { assert(Object.isExtensible(obj)); Object.seal(obj); -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + configurable: false, +}); + assert.sameValue(obj.foo, 10); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-accessor-property-that-overrides-an-inherited-data-property.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-accessor-property-that-overrides-an-inherited-data-property.js index e3a3707431..f155e7975f 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-accessor-property-that-overrides-an-inherited-data-property.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-accessor-property-that-overrides-an-inherited-data-property.js @@ -31,7 +31,10 @@ Object.defineProperty(obj, "foo", { assert(Object.isExtensible(obj)); Object.seal(obj); -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + configurable: false, +}); + assert.sameValue(obj.foo, 10); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-accessor-property.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-accessor-property.js index 3704d492ba..43b4e402d1 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-accessor-property.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-accessor-property.js @@ -19,7 +19,10 @@ Object.defineProperty(obj, "foo", { assert(Object.isExtensible(obj)); Object.seal(obj); -verifyNotConfigurable(obj, "foo"); +verifyProperty(obj, "foo", { + configurable: false, +}); + assert.sameValue(obj.foo, 10); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-data-property-that-overrides-an-inherited-accessor-property.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-data-property-that-overrides-an-inherited-accessor-property.js index e146af8558..32125f67c4 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-data-property-that-overrides-an-inherited-accessor-property.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-data-property-that-overrides-an-inherited-accessor-property.js @@ -30,7 +30,9 @@ Object.defineProperty(obj, "foo", { assert(Object.isExtensible(obj)); Object.seal(obj); -verifyNotConfigurable(obj, "foo"); -assert.sameValue(obj.foo, 10); +verifyProperty(obj, "foo", { + value: 10, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-data-property-that-overrides-an-inherited-data-property.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-data-property-that-overrides-an-inherited-data-property.js index e62e3fb902..10127134e7 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-data-property-that-overrides-an-inherited-data-property.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-data-property-that-overrides-an-inherited-data-property.js @@ -25,7 +25,9 @@ Object.defineProperty(obj, "foo", { assert(Object.isExtensible(obj)); Object.seal(obj); -verifyNotConfigurable(obj, "foo"); -assert.sameValue(obj.foo, 10); +verifyProperty(obj, "foo", { + value: 10, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-data-property.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-data-property.js index d19e947979..953710ace7 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-data-property.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-data-property.js @@ -14,7 +14,9 @@ obj.foo = 10; // default [[Configurable]] attribute value of foo: true assert(Object.isExtensible(obj)); Object.seal(obj); -verifyNotConfigurable(obj, "foo"); -assert.sameValue(obj.foo, 10); +verifyProperty(obj, "foo", { + value: 10, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-boolean-object-that-uses-object-s-get-own-property.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-boolean-object-that-uses-object-s-get-own-property.js index 20d4898020..5a2c970b25 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-boolean-object-that-uses-object-s-get-own-property.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-boolean-object-that-uses-object-s-get-own-property.js @@ -16,7 +16,9 @@ obj.foo = 10; assert(Object.isExtensible(obj)); Object.seal(obj); -verifyNotConfigurable(obj, "foo"); -assert.sameValue(obj.foo, 10); +verifyProperty(obj, "foo", { + value: 10, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-date-object-that-uses-object-s-get-own-property.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-date-object-that-uses-object-s-get-own-property.js index 2517e70bc0..77a161b71e 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-date-object-that-uses-object-s-get-own-property.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-date-object-that-uses-object-s-get-own-property.js @@ -16,7 +16,9 @@ obj.foo = 10; assert(Object.isExtensible(obj)); Object.seal(obj); -verifyNotConfigurable(obj, "foo"); -assert.sameValue(obj.foo, 10); +verifyProperty(obj, "foo", { + value: 10, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-function-object-that-uses-object-s-get-own-property.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-function-object-that-uses-object-s-get-own-property.js index 18c786075d..db8ba4f6d3 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-function-object-that-uses-object-s-get-own-property.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-function-object-that-uses-object-s-get-own-property.js @@ -16,7 +16,9 @@ obj.foo = 10; assert(Object.isExtensible(obj)); Object.seal(obj); -verifyNotConfigurable(obj, "foo"); -assert.sameValue(obj.foo, 10); +verifyProperty(obj, "foo", { + value: 10, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-number-object-that-uses-object-s-get-own-property.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-number-object-that-uses-object-s-get-own-property.js index 9db2104ff6..d577097702 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-number-object-that-uses-object-s-get-own-property.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-number-object-that-uses-object-s-get-own-property.js @@ -16,7 +16,9 @@ obj.foo = 10; assert(Object.isExtensible(obj)); Object.seal(obj); -verifyNotConfigurable(obj, "foo"); -assert.sameValue(obj.foo, 10); +verifyProperty(obj, "foo", { + value: 10, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-reg-exp-object-that-uses-object-s-get-own-property.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-reg-exp-object-that-uses-object-s-get-own-property.js index 839ce7dd37..7fefac239a 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-reg-exp-object-that-uses-object-s-get-own-property.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-reg-exp-object-that-uses-object-s-get-own-property.js @@ -16,7 +16,9 @@ obj.foo = 10; assert(Object.isExtensible(obj)); Object.seal(obj); -verifyNotConfigurable(obj, "foo"); -assert.sameValue(obj.foo, 10); +verifyProperty(obj, "foo", { + value: 10, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-string-object-which-implements-its-own-get-own-property.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-string-object-which-implements-its-own-get-own-property.js index 7561754fd0..a3badbcd63 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-string-object-which-implements-its-own-get-own-property.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-a-string-object-which-implements-its-own-get-own-property.js @@ -16,7 +16,9 @@ obj.foo = 10; assert(Object.isExtensible(obj)); Object.seal(obj); -verifyNotConfigurable(obj, "foo"); -assert.sameValue(obj.foo, 10); +verifyProperty(obj, "foo", { + value: 10, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-an-arguments-object-which-implements-its-own-get-own-property.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-an-arguments-object-which-implements-its-own-get-own-property.js index 39853c155f..0b9a0ddc9c 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-an-arguments-object-which-implements-its-own-get-own-property.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-an-arguments-object-which-implements-its-own-get-own-property.js @@ -18,7 +18,9 @@ obj.foo = 10; assert(Object.isExtensible(obj)); Object.seal(obj); -verifyNotConfigurable(obj, "foo"); -assert.sameValue(obj.foo, 10); +verifyProperty(obj, "foo", { + value: 10, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-an-array-object-that-uses-object-s-get-own-property.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-an-array-object-that-uses-object-s-get-own-property.js index 26e19643df..8c7c2fd0fb 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-an-array-object-that-uses-object-s-get-own-property.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-an-array-object-that-uses-object-s-get-own-property.js @@ -16,7 +16,9 @@ obj.foo = 10; assert(Object.isExtensible(obj)); Object.seal(obj); -verifyNotConfigurable(obj, "foo"); -assert.sameValue(obj.foo, 10); +verifyProperty(obj, "foo", { + value: 10, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-an-error-object-that-uses-object-s-get-own-property.js b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-an-error-object-that-uses-object-s-get-own-property.js index 045b2c0248..7989899aa8 100644 --- a/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-an-error-object-that-uses-object-s-get-own-property.js +++ b/js/src/tests/test262/built-ins/Object/seal/object-seal-p-is-own-property-of-an-error-object-that-uses-object-s-get-own-property.js @@ -16,7 +16,9 @@ obj.foo = 10; assert(Object.isExtensible(obj)); Object.seal(obj); -verifyNotConfigurable(obj, "foo"); -assert.sameValue(obj.foo, 10); +verifyProperty(obj, "foo", { + value: 10, + configurable: false, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/setPrototypeOf/length.js b/js/src/tests/test262/built-ins/Object/setPrototypeOf/length.js index f2f8d611b9..7640d3f587 100644 --- a/js/src/tests/test262/built-ins/Object/setPrototypeOf/length.js +++ b/js/src/tests/test262/built-ins/Object/setPrototypeOf/length.js @@ -18,14 +18,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Object.setPrototypeOf.length, - 2, - 'The value of `Object.setPrototypeOf.length` is `2`' -); - -verifyNotEnumerable(Object.setPrototypeOf, 'length'); -verifyNotWritable(Object.setPrototypeOf, 'length'); -verifyConfigurable(Object.setPrototypeOf, 'length'); +verifyProperty(Object.setPrototypeOf, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/setPrototypeOf/name.js b/js/src/tests/test262/built-ins/Object/setPrototypeOf/name.js index 1c9ab55a58..e5a46daee0 100644 --- a/js/src/tests/test262/built-ins/Object/setPrototypeOf/name.js +++ b/js/src/tests/test262/built-ins/Object/setPrototypeOf/name.js @@ -19,14 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - Object.setPrototypeOf.name, - 'setPrototypeOf', - 'The value of `Object.setPrototypeOf.name` is `"setPrototypeOf"`' -); - -verifyNotEnumerable(Object.setPrototypeOf, 'name'); -verifyNotWritable(Object.setPrototypeOf, 'name'); -verifyConfigurable(Object.setPrototypeOf, 'name'); +verifyProperty(Object.setPrototypeOf, "name", { + value: "setPrototypeOf", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/setPrototypeOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/setPrototypeOf/not-a-constructor.js index 625f438f4a..da7d13cba6 100644 --- a/js/src/tests/test262/built-ins/Object/setPrototypeOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/setPrototypeOf/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Object.setPrototypeOf({}, {}); -}, '`new Object.setPrototypeOf({}, {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/setPrototypeOf/property-descriptor.js b/js/src/tests/test262/built-ins/Object/setPrototypeOf/property-descriptor.js index 946db0ad9c..9c04d4c683 100644 --- a/js/src/tests/test262/built-ins/Object/setPrototypeOf/property-descriptor.js +++ b/js/src/tests/test262/built-ins/Object/setPrototypeOf/property-descriptor.js @@ -12,8 +12,10 @@ includes: [propertyHelper.js] assert.sameValue(typeof Object.setPrototypeOf, 'function'); -verifyNotEnumerable(Object, 'setPrototypeOf'); -verifyWritable(Object, 'setPrototypeOf'); -verifyConfigurable(Object, 'setPrototypeOf'); +verifyProperty(Object, "setPrototypeOf", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/values/function-length.js b/js/src/tests/test262/built-ins/Object/values/function-length.js index bb3ede0e3c..93d6a66639 100644 --- a/js/src/tests/test262/built-ins/Object/values/function-length.js +++ b/js/src/tests/test262/built-ins/Object/values/function-length.js @@ -8,10 +8,11 @@ author: Jordan Harband includes: [propertyHelper.js] ---*/ -assert.sameValue(Object.values.length, 1, 'Expected Object.values.length to be 1'); - -verifyNotEnumerable(Object.values, 'length'); -verifyNotWritable(Object.values, 'length'); -verifyConfigurable(Object.values, 'length'); +verifyProperty(Object.values, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/values/function-name.js b/js/src/tests/test262/built-ins/Object/values/function-name.js index 6535fd2db4..a008546f02 100644 --- a/js/src/tests/test262/built-ins/Object/values/function-name.js +++ b/js/src/tests/test262/built-ins/Object/values/function-name.js @@ -8,14 +8,11 @@ author: Jordan Harband includes: [propertyHelper.js] ---*/ -assert.sameValue( - Object.values.name, - 'values', - 'Expected Object.values.name to be "values"' -); - -verifyNotEnumerable(Object.values, 'name'); -verifyNotWritable(Object.values, 'name'); -verifyConfigurable(Object.values, 'name'); +verifyProperty(Object.values, "name", { + value: "values", + writable: false, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/values/function-property-descriptor.js b/js/src/tests/test262/built-ins/Object/values/function-property-descriptor.js index ebd062c347..fb6a12c5b9 100644 --- a/js/src/tests/test262/built-ins/Object/values/function-property-descriptor.js +++ b/js/src/tests/test262/built-ins/Object/values/function-property-descriptor.js @@ -8,8 +8,10 @@ author: Jordan Harband includes: [propertyHelper.js] ---*/ -verifyNotEnumerable(Object, 'values'); -verifyWritable(Object, 'values'); -verifyConfigurable(Object, 'values'); +verifyProperty(Object, "values", { + writable: true, + enumerable: false, + configurable: true, +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/values/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/values/not-a-constructor.js index 632d285a49..5c647f604f 100644 --- a/js/src/tests/test262/built-ins/Object/values/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Object/values/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Object.values), false, 'isConstructor(Object.valu assert.throws(TypeError, () => { new Object.values({}); -}, '`new Object.values({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/Symbol.species/length.js b/js/src/tests/test262/built-ins/Promise/Symbol.species/length.js index a2556d0a44..72a2e3ce6c 100644 --- a/js/src/tests/test262/built-ins/Promise/Symbol.species/length.js +++ b/js/src/tests/test262/built-ins/Promise/Symbol.species/length.js @@ -25,10 +25,11 @@ features: [Symbol.species] var desc = Object.getOwnPropertyDescriptor(Promise, Symbol.species); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/all/length.js b/js/src/tests/test262/built-ins/Promise/all/length.js index 7769497c7c..38e64b125d 100644 --- a/js/src/tests/test262/built-ins/Promise/all/length.js +++ b/js/src/tests/test262/built-ins/Promise/all/length.js @@ -18,10 +18,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Promise.all.length, 1); - -verifyNotEnumerable(Promise.all, 'length'); -verifyNotWritable(Promise.all, 'length'); -verifyConfigurable(Promise.all, 'length'); +verifyProperty(Promise.all, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/all/name.js b/js/src/tests/test262/built-ins/Promise/all/name.js index 552ba841dd..7a6ddaa9a4 100644 --- a/js/src/tests/test262/built-ins/Promise/all/name.js +++ b/js/src/tests/test262/built-ins/Promise/all/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Promise.all.name, 'all'); - -verifyNotEnumerable(Promise.all, 'name'); -verifyNotWritable(Promise.all, 'name'); -verifyConfigurable(Promise.all, 'name'); +verifyProperty(Promise.all, "name", { + value: "all", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/all/not-a-constructor.js b/js/src/tests/test262/built-ins/Promise/all/not-a-constructor.js index 9ab0f8e49e..b7c377d84f 100644 --- a/js/src/tests/test262/built-ins/Promise/all/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Promise/all/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Promise.all), false, 'isConstructor(Promise.all) assert.throws(TypeError, () => { new Promise.all([]); -}, '`new Promise.all([])` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/all/resolve-element-function-length.js b/js/src/tests/test262/built-ins/Promise/all/resolve-element-function-length.js index 6a3568870b..4f3f963e28 100644 --- a/js/src/tests/test262/built-ins/Promise/all/resolve-element-function-length.js +++ b/js/src/tests/test262/built-ins/Promise/all/resolve-element-function-length.js @@ -29,10 +29,11 @@ NotPromise.resolve = function(v) { }; Promise.all.call(NotPromise, [thenable]); -assert.sameValue(resolveElementFunction.length, 1); - -verifyNotEnumerable(resolveElementFunction, "length"); -verifyNotWritable(resolveElementFunction, "length"); -verifyConfigurable(resolveElementFunction, "length"); +verifyProperty(resolveElementFunction, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/allSettled/not-a-constructor.js b/js/src/tests/test262/built-ins/Promise/allSettled/not-a-constructor.js index 98dc3d6401..4da60aa86b 100644 --- a/js/src/tests/test262/built-ins/Promise/allSettled/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Promise/allSettled/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Promise.allSettled), false, 'isConstructor(Promis assert.throws(TypeError, () => { new Promise.allSettled(); -}, '`new Promise.allSettled()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/any/not-a-constructor.js b/js/src/tests/test262/built-ins/Promise/any/not-a-constructor.js index 94e37ef3ba..3acdd7ee0c 100644 --- a/js/src/tests/test262/built-ins/Promise/any/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Promise/any/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Promise.any), false, 'isConstructor(Promise.any) assert.throws(TypeError, () => { new Promise.any([1]); -}, '`new Promise.any([1])` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/create-resolving-functions-reject.js b/js/src/tests/test262/built-ins/Promise/create-resolving-functions-reject.js index 05297b7993..294b48491a 100644 --- a/js/src/tests/test262/built-ins/Promise/create-resolving-functions-reject.js +++ b/js/src/tests/test262/built-ins/Promise/create-resolving-functions-reject.js @@ -24,7 +24,7 @@ Promise.prototype.then = function(resolve, reject) { assert.sameValue(isConstructor(reject), false, 'isConstructor(reject) must return false'); assert.throws(TypeError, () => { new reject(); - }, '`new reject()` throws TypeError'); + }); assert.sameValue(reject.length, 1, 'The value of reject.length is 1'); assert.sameValue(reject.name, '', 'The value of reject.name is ""'); diff --git a/js/src/tests/test262/built-ins/Promise/create-resolving-functions-resolve.js b/js/src/tests/test262/built-ins/Promise/create-resolving-functions-resolve.js index c2c4dc60d2..4460e28fcf 100644 --- a/js/src/tests/test262/built-ins/Promise/create-resolving-functions-resolve.js +++ b/js/src/tests/test262/built-ins/Promise/create-resolving-functions-resolve.js @@ -24,7 +24,7 @@ Promise.prototype.then = function(resolve, reject) { assert.sameValue(isConstructor(resolve), false, 'isConstructor(resolve) must return false'); assert.throws(TypeError, () => { new resolve(); - }, '`new resolve()` throws TypeError'); + }); assert.sameValue(resolve.length, 1, 'The value of resolve.length is 1'); assert.sameValue(resolve.name, '', 'The value of resolve.name is ""'); diff --git a/js/src/tests/test262/built-ins/Promise/executor-function-length.js b/js/src/tests/test262/built-ins/Promise/executor-function-length.js index 1aa7f25e45..9867fb08b0 100644 --- a/js/src/tests/test262/built-ins/Promise/executor-function-length.js +++ b/js/src/tests/test262/built-ins/Promise/executor-function-length.js @@ -22,10 +22,11 @@ function NotPromise(executor) { } Promise.resolve.call(NotPromise); -assert.sameValue(executorFunction.length, 2); - -verifyNotEnumerable(executorFunction, "length"); -verifyNotWritable(executorFunction, "length"); -verifyConfigurable(executorFunction, "length"); +verifyProperty(executorFunction, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/executor-function-not-a-constructor.js b/js/src/tests/test262/built-ins/Promise/executor-function-not-a-constructor.js index 5e1f360112..a4002a6ee1 100644 --- a/js/src/tests/test262/built-ins/Promise/executor-function-not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Promise/executor-function-not-a-constructor.js @@ -30,7 +30,7 @@ assert.sameValue(isConstructor(executorFunction), false, 'isConstructor(executor assert.throws(TypeError, () => { new executorFunction(); -}, '`new executorFunction()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/length.js b/js/src/tests/test262/built-ins/Promise/length.js index 52923a039c..2173d41d91 100644 --- a/js/src/tests/test262/built-ins/Promise/length.js +++ b/js/src/tests/test262/built-ins/Promise/length.js @@ -18,10 +18,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Promise.length, 1); - -verifyNotEnumerable(Promise, 'length'); -verifyNotWritable(Promise, 'length'); -verifyConfigurable(Promise, 'length'); +verifyProperty(Promise, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/name.js b/js/src/tests/test262/built-ins/Promise/name.js index 715bc448f2..1b52152e54 100644 --- a/js/src/tests/test262/built-ins/Promise/name.js +++ b/js/src/tests/test262/built-ins/Promise/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Promise.name, 'Promise'); - -verifyNotEnumerable(Promise, 'name'); -verifyNotWritable(Promise, 'name'); -verifyConfigurable(Promise, 'name'); +verifyProperty(Promise, "name", { + value: "Promise", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/prototype/catch/length.js b/js/src/tests/test262/built-ins/Promise/prototype/catch/length.js index 1b487e62d9..aa4a89d144 100644 --- a/js/src/tests/test262/built-ins/Promise/prototype/catch/length.js +++ b/js/src/tests/test262/built-ins/Promise/prototype/catch/length.js @@ -18,10 +18,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Promise.prototype.catch.length, 1); - -verifyNotEnumerable(Promise.prototype.catch, 'length'); -verifyNotWritable(Promise.prototype.catch, 'length'); -verifyConfigurable(Promise.prototype.catch, 'length'); +verifyProperty(Promise.prototype.catch, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/prototype/catch/name.js b/js/src/tests/test262/built-ins/Promise/prototype/catch/name.js index 25a93a3bb9..4df2947d2d 100644 --- a/js/src/tests/test262/built-ins/Promise/prototype/catch/name.js +++ b/js/src/tests/test262/built-ins/Promise/prototype/catch/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Promise.prototype.catch.name, 'catch'); - -verifyNotEnumerable(Promise.prototype.catch, 'name'); -verifyNotWritable(Promise.prototype.catch, 'name'); -verifyConfigurable(Promise.prototype.catch, 'name'); +verifyProperty(Promise.prototype.catch, "name", { + value: "catch", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/prototype/catch/not-a-constructor.js b/js/src/tests/test262/built-ins/Promise/prototype/catch/not-a-constructor.js index 2ff5558742..3afa8a1021 100644 --- a/js/src/tests/test262/built-ins/Promise/prototype/catch/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Promise/prototype/catch/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let p = new Promise(() => {}); new p.catch(); -}, '`let p = new Promise(() => {}); new p.catch()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/prototype/finally/invokes-then-with-function.js b/js/src/tests/test262/built-ins/Promise/prototype/finally/invokes-then-with-function.js index c4597f9cb8..033051d03c 100644 --- a/js/src/tests/test262/built-ins/Promise/prototype/finally/invokes-then-with-function.js +++ b/js/src/tests/test262/built-ins/Promise/prototype/finally/invokes-then-with-function.js @@ -48,7 +48,7 @@ assert.sameValue(resolve.name, '', 'The value of resolve.name is ""'); assert.sameValue(isConstructor(resolve), false, 'isConstructor(resolve) must return false'); assert.throws(TypeError, () => { new resolve(); -}, '`new resolve()` throws TypeError'); +}); assert.sameValue( @@ -62,7 +62,7 @@ assert.sameValue(reject.name, '', 'The value of reject.name is ""'); assert.sameValue(isConstructor(reject), false, 'isConstructor(reject) must return false'); assert.throws(TypeError, () => { new reject(); -}, '`new reject()` throws TypeError'); +}); assert.sameValue(result, returnValue, 'The value of `result` is expected to equal the value of returnValue'); diff --git a/js/src/tests/test262/built-ins/Promise/prototype/finally/name.js b/js/src/tests/test262/built-ins/Promise/prototype/finally/name.js index 82020c1381..ad825c9f53 100644 --- a/js/src/tests/test262/built-ins/Promise/prototype/finally/name.js +++ b/js/src/tests/test262/built-ins/Promise/prototype/finally/name.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] features: [Promise.prototype.finally] ---*/ -assert.sameValue(Promise.prototype.finally.name, 'finally'); - -verifyNotEnumerable(Promise.prototype.finally, 'name'); -verifyNotWritable(Promise.prototype.finally, 'name'); -verifyConfigurable(Promise.prototype.finally, 'name'); +verifyProperty(Promise.prototype.finally, "name", { + value: "finally", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/prototype/finally/not-a-constructor.js b/js/src/tests/test262/built-ins/Promise/prototype/finally/not-a-constructor.js index 25bb9a6554..61ba99df53 100644 --- a/js/src/tests/test262/built-ins/Promise/prototype/finally/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Promise/prototype/finally/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let p = new Promise(() => {}); new p.finally(); -}, '`let p = new Promise(() => {}); new p.finally()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/prototype/finally/rejected-observable-then-calls-argument.js b/js/src/tests/test262/built-ins/Promise/prototype/finally/rejected-observable-then-calls-argument.js index 4d183bf248..49cb4840ff 100644 --- a/js/src/tests/test262/built-ins/Promise/prototype/finally/rejected-observable-then-calls-argument.js +++ b/js/src/tests/test262/built-ins/Promise/prototype/finally/rejected-observable-then-calls-argument.js @@ -59,7 +59,7 @@ Promise.prototype.then = function(resolve, reject) { assert.sameValue(isConstructor(reject), false, 'isConstructor(reject) must return false'); assert.throws(TypeError, () => { new reject(); - }, '`new reject()` throws TypeError'); + }); assert.sameValue(arguments.length, 2, '`then` invoked with two arguments'); } diff --git a/js/src/tests/test262/built-ins/Promise/prototype/finally/resolved-observable-then-calls-argument.js b/js/src/tests/test262/built-ins/Promise/prototype/finally/resolved-observable-then-calls-argument.js index ab7eedb192..0f9fc558c5 100644 --- a/js/src/tests/test262/built-ins/Promise/prototype/finally/resolved-observable-then-calls-argument.js +++ b/js/src/tests/test262/built-ins/Promise/prototype/finally/resolved-observable-then-calls-argument.js @@ -35,7 +35,7 @@ Promise.prototype.then = function(resolve) { assert.sameValue(isConstructor(resolve), false, 'isConstructor(resolve) must return false'); assert.throws(TypeError, () => { new resolve(); - }, '`new resolve()` throws TypeError'); + }); assert.sameValue( resolve.length, diff --git a/js/src/tests/test262/built-ins/Promise/prototype/then/length.js b/js/src/tests/test262/built-ins/Promise/prototype/then/length.js index 1e865b0460..2ada466b80 100644 --- a/js/src/tests/test262/built-ins/Promise/prototype/then/length.js +++ b/js/src/tests/test262/built-ins/Promise/prototype/then/length.js @@ -18,10 +18,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Promise.prototype.then.length, 2); - -verifyNotEnumerable(Promise.prototype.then, 'length'); -verifyNotWritable(Promise.prototype.then, 'length'); -verifyConfigurable(Promise.prototype.then, 'length'); +verifyProperty(Promise.prototype.then, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/prototype/then/name.js b/js/src/tests/test262/built-ins/Promise/prototype/then/name.js index b1c97f9956..82402ea992 100644 --- a/js/src/tests/test262/built-ins/Promise/prototype/then/name.js +++ b/js/src/tests/test262/built-ins/Promise/prototype/then/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Promise.prototype.then.name, 'then'); - -verifyNotEnumerable(Promise.prototype.then, 'name'); -verifyNotWritable(Promise.prototype.then, 'name'); -verifyConfigurable(Promise.prototype.then, 'name'); +verifyProperty(Promise.prototype.then, "name", { + value: "then", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/prototype/then/not-a-constructor.js b/js/src/tests/test262/built-ins/Promise/prototype/then/not-a-constructor.js index d943772f86..d04c89e111 100644 --- a/js/src/tests/test262/built-ins/Promise/prototype/then/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Promise/prototype/then/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let p = new Promise(() => {}); new p.then(); -}, '`let p = new Promise(() => {}); new p.then()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/race/length.js b/js/src/tests/test262/built-ins/Promise/race/length.js index 0fa1f53d8e..7807708403 100644 --- a/js/src/tests/test262/built-ins/Promise/race/length.js +++ b/js/src/tests/test262/built-ins/Promise/race/length.js @@ -18,10 +18,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Promise.race.length, 1); - -verifyNotEnumerable(Promise.race, 'length'); -verifyNotWritable(Promise.race, 'length'); -verifyConfigurable(Promise.race, 'length'); +verifyProperty(Promise.race, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/race/name.js b/js/src/tests/test262/built-ins/Promise/race/name.js index e88d3384ef..d4644e0992 100644 --- a/js/src/tests/test262/built-ins/Promise/race/name.js +++ b/js/src/tests/test262/built-ins/Promise/race/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Promise.race.name, 'race'); - -verifyNotEnumerable(Promise.race, 'name'); -verifyNotWritable(Promise.race, 'name'); -verifyConfigurable(Promise.race, 'name'); +verifyProperty(Promise.race, "name", { + value: "race", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/race/not-a-constructor.js b/js/src/tests/test262/built-ins/Promise/race/not-a-constructor.js index a6e0f33d59..732dd53f1d 100644 --- a/js/src/tests/test262/built-ins/Promise/race/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Promise/race/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Promise.race), false, 'isConstructor(Promise.race assert.throws(TypeError, () => { new Promise.race([]); -}, '`new Promise.race([])` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/reject-function-length.js b/js/src/tests/test262/built-ins/Promise/reject-function-length.js index 76bcb1f5c3..ef48faf0e7 100644 --- a/js/src/tests/test262/built-ins/Promise/reject-function-length.js +++ b/js/src/tests/test262/built-ins/Promise/reject-function-length.js @@ -19,10 +19,11 @@ new Promise(function(resolve, reject) { rejectFunction = reject; }); -assert.sameValue(rejectFunction.length, 1); - -verifyNotEnumerable(rejectFunction, "length"); -verifyNotWritable(rejectFunction, "length"); -verifyConfigurable(rejectFunction, "length"); +verifyProperty(rejectFunction, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/reject/length.js b/js/src/tests/test262/built-ins/Promise/reject/length.js index 1773dfca57..af9c16e33c 100644 --- a/js/src/tests/test262/built-ins/Promise/reject/length.js +++ b/js/src/tests/test262/built-ins/Promise/reject/length.js @@ -18,10 +18,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Promise.reject.length, 1); - -verifyNotEnumerable(Promise.reject, 'length'); -verifyNotWritable(Promise.reject, 'length'); -verifyConfigurable(Promise.reject, 'length'); +verifyProperty(Promise.reject, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/reject/name.js b/js/src/tests/test262/built-ins/Promise/reject/name.js index eb0e4c630f..12db66b706 100644 --- a/js/src/tests/test262/built-ins/Promise/reject/name.js +++ b/js/src/tests/test262/built-ins/Promise/reject/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Promise.reject.name, 'reject'); - -verifyNotEnumerable(Promise.reject, 'name'); -verifyNotWritable(Promise.reject, 'name'); -verifyConfigurable(Promise.reject, 'name'); +verifyProperty(Promise.reject, "name", { + value: "reject", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/reject/not-a-constructor.js b/js/src/tests/test262/built-ins/Promise/reject/not-a-constructor.js index 1fa8864edb..9cccfa8e4d 100644 --- a/js/src/tests/test262/built-ins/Promise/reject/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Promise/reject/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Promise.reject), false, 'isConstructor(Promise.re assert.throws(TypeError, () => { new Promise.reject(); -}, '`new Promise.reject()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/resolve-function-length.js b/js/src/tests/test262/built-ins/Promise/resolve-function-length.js index 9d6ae8ea9e..acac1fef91 100644 --- a/js/src/tests/test262/built-ins/Promise/resolve-function-length.js +++ b/js/src/tests/test262/built-ins/Promise/resolve-function-length.js @@ -19,10 +19,11 @@ new Promise(function(resolve, reject) { resolveFunction = resolve; }); -assert.sameValue(resolveFunction.length, 1); - -verifyNotEnumerable(resolveFunction, "length"); -verifyNotWritable(resolveFunction, "length"); -verifyConfigurable(resolveFunction, "length"); +verifyProperty(resolveFunction, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/resolve/length.js b/js/src/tests/test262/built-ins/Promise/resolve/length.js index a73283a4b2..64ae9e9130 100644 --- a/js/src/tests/test262/built-ins/Promise/resolve/length.js +++ b/js/src/tests/test262/built-ins/Promise/resolve/length.js @@ -18,10 +18,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Promise.resolve.length, 1); - -verifyNotEnumerable(Promise.resolve, 'length'); -verifyNotWritable(Promise.resolve, 'length'); -verifyConfigurable(Promise.resolve, 'length'); +verifyProperty(Promise.resolve, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/resolve/name.js b/js/src/tests/test262/built-ins/Promise/resolve/name.js index b9644562b6..21a6aa62a1 100644 --- a/js/src/tests/test262/built-ins/Promise/resolve/name.js +++ b/js/src/tests/test262/built-ins/Promise/resolve/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(Promise.resolve.name, 'resolve'); - -verifyNotEnumerable(Promise.resolve, 'name'); -verifyNotWritable(Promise.resolve, 'name'); -verifyConfigurable(Promise.resolve, 'name'); +verifyProperty(Promise.resolve, "name", { + value: "resolve", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Promise/resolve/not-a-constructor.js b/js/src/tests/test262/built-ins/Promise/resolve/not-a-constructor.js index e455743938..97e23b1d57 100644 --- a/js/src/tests/test262/built-ins/Promise/resolve/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Promise/resolve/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Promise.resolve), false, 'isConstructor(Promise.r assert.throws(TypeError, () => { new Promise.resolve(); -}, '`new Promise.resolve()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/create-target-is-not-a-constructor.js b/js/src/tests/test262/built-ins/Proxy/create-target-is-not-a-constructor.js index 2bd3fe46c5..47551407f6 100644 --- a/js/src/tests/test262/built-ins/Proxy/create-target-is-not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Proxy/create-target-is-not-a-constructor.js @@ -28,6 +28,6 @@ proxy(); // the Proxy object is callable assert.sameValue(isConstructor(proxy), false, 'isConstructor(proxy) must return false'); assert.throws(TypeError, () => { new proxy(); -}, '`new proxy()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/length.js b/js/src/tests/test262/built-ins/Proxy/length.js index 9bacc49713..01b9b1407e 100644 --- a/js/src/tests/test262/built-ins/Proxy/length.js +++ b/js/src/tests/test262/built-ins/Proxy/length.js @@ -11,10 +11,11 @@ includes: [propertyHelper.js] features: [Proxy] ---*/ -assert.sameValue(Proxy.length, 2, "The value of `Proxy.length` is `2`"); - -verifyNotEnumerable(Proxy, "length"); -verifyNotWritable(Proxy, "length"); -verifyConfigurable(Proxy, "length"); +verifyProperty(Proxy, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/name.js b/js/src/tests/test262/built-ins/Proxy/name.js index 31d3ec097d..abdf0dda73 100644 --- a/js/src/tests/test262/built-ins/Proxy/name.js +++ b/js/src/tests/test262/built-ins/Proxy/name.js @@ -11,10 +11,11 @@ includes: [propertyHelper.js] features: [Proxy] ---*/ -assert.sameValue(Proxy.name, "Proxy", "The value of `Proxy.name` is `'Proxy'`"); - -verifyNotEnumerable(Proxy, "name"); -verifyNotWritable(Proxy, "name"); -verifyConfigurable(Proxy, "name"); +verifyProperty(Proxy, "name", { + value: "Proxy", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/length.js b/js/src/tests/test262/built-ins/Proxy/revocable/length.js index 8c1b055371..1b5dfc85c3 100644 --- a/js/src/tests/test262/built-ins/Proxy/revocable/length.js +++ b/js/src/tests/test262/built-ins/Proxy/revocable/length.js @@ -23,10 +23,11 @@ includes: [propertyHelper.js] features: [Proxy] ---*/ -assert.sameValue(Proxy.revocable.length, 2); - -verifyNotEnumerable(Proxy.revocable, "length"); -verifyNotWritable(Proxy.revocable, "length"); -verifyConfigurable(Proxy.revocable, "length"); +verifyProperty(Proxy.revocable, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/name.js b/js/src/tests/test262/built-ins/Proxy/revocable/name.js index 0e7ce54890..71690c482b 100644 --- a/js/src/tests/test262/built-ins/Proxy/revocable/name.js +++ b/js/src/tests/test262/built-ins/Proxy/revocable/name.js @@ -20,10 +20,11 @@ includes: [propertyHelper.js] features: [Proxy] ---*/ -assert.sameValue(Proxy.revocable.name, "revocable"); - -verifyNotEnumerable(Proxy.revocable, "name"); -verifyNotWritable(Proxy.revocable, "name"); -verifyConfigurable(Proxy.revocable, "name"); +verifyProperty(Proxy.revocable, "name", { + value: "revocable", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/not-a-constructor.js b/js/src/tests/test262/built-ins/Proxy/revocable/not-a-constructor.js index 0d1e9bdff5..95fb044f82 100644 --- a/js/src/tests/test262/built-ins/Proxy/revocable/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Proxy/revocable/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Proxy.revocable), false, 'isConstructor(Proxy.rev assert.throws(TypeError, () => { new Proxy.revocable({}, {}); -}, '`new Proxy.revocable({}, {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-length.js b/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-length.js index ac59134301..2460658438 100644 --- a/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-length.js +++ b/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-length.js @@ -17,10 +17,11 @@ features: [Proxy] var revocationFunction = Proxy.revocable({}, {}).revoke; -assert.sameValue(revocationFunction.length, 0); - -verifyNotEnumerable(revocationFunction, "length"); -verifyNotWritable(revocationFunction, "length"); -verifyConfigurable(revocationFunction, "length"); +verifyProperty(revocationFunction, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-not-a-constructor.js b/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-not-a-constructor.js index 643c7e57c2..40fdf658ea 100644 --- a/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Proxy/revocable/revocation-function-not-a-constructor.js @@ -23,7 +23,7 @@ assert.sameValue( assert.sameValue(isConstructor(revocationFunction), false, 'isConstructor(revocationFunction) must return false'); assert.throws(TypeError, () => { new revocationFunction(); -}, '`new revocationFunction()` throws TypeError'); +}); diff --git a/js/src/tests/test262/built-ins/Reflect/apply/length.js b/js/src/tests/test262/built-ins/Reflect/apply/length.js index 3499bc3355..2b65f5502e 100644 --- a/js/src/tests/test262/built-ins/Reflect/apply/length.js +++ b/js/src/tests/test262/built-ins/Reflect/apply/length.js @@ -8,13 +8,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.apply.length, 3, - 'The value of `Reflect.apply.length` is `3`' -); - -verifyNotEnumerable(Reflect.apply, 'length'); -verifyNotWritable(Reflect.apply, 'length'); -verifyConfigurable(Reflect.apply, 'length'); +verifyProperty(Reflect.apply, "length", { + value: 3, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/apply/name.js b/js/src/tests/test262/built-ins/Reflect/apply/name.js index 5da83c4d24..d574475c5b 100644 --- a/js/src/tests/test262/built-ins/Reflect/apply/name.js +++ b/js/src/tests/test262/built-ins/Reflect/apply/name.js @@ -13,13 +13,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.apply.name, 'apply', - 'The value of `Reflect.apply.name` is `"apply"`' -); - -verifyNotEnumerable(Reflect.apply, 'name'); -verifyNotWritable(Reflect.apply, 'name'); -verifyConfigurable(Reflect.apply, 'name'); +verifyProperty(Reflect.apply, "name", { + value: "apply", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/apply/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/apply/not-a-constructor.js index 4e4aa65254..8809107995 100644 --- a/js/src/tests/test262/built-ins/Reflect/apply/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Reflect/apply/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Reflect.apply), false, 'isConstructor(Reflect.app assert.throws(TypeError, () => { new Reflect.apply(() => {}, undefined, []); -}, '`new Reflect.apply(() => {}, undefined, [])` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/construct/length.js b/js/src/tests/test262/built-ins/Reflect/construct/length.js index 72e142753f..07b9663e53 100644 --- a/js/src/tests/test262/built-ins/Reflect/construct/length.js +++ b/js/src/tests/test262/built-ins/Reflect/construct/length.js @@ -12,13 +12,11 @@ includes: [propertyHelper.js] features: [Reflect, Reflect.construct] ---*/ -assert.sameValue( - Reflect.construct.length, 2, - 'The value of `Reflect.construct.length` is `2`' -); - -verifyNotEnumerable(Reflect.construct, 'length'); -verifyNotWritable(Reflect.construct, 'length'); -verifyConfigurable(Reflect.construct, 'length'); +verifyProperty(Reflect.construct, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/construct/name.js b/js/src/tests/test262/built-ins/Reflect/construct/name.js index ff1d6c51c5..61f2e5e74c 100644 --- a/js/src/tests/test262/built-ins/Reflect/construct/name.js +++ b/js/src/tests/test262/built-ins/Reflect/construct/name.js @@ -13,13 +13,11 @@ includes: [propertyHelper.js] features: [Reflect, Reflect.construct] ---*/ -assert.sameValue( - Reflect.construct.name, 'construct', - 'The value of `Reflect.construct.name` is `"construct"`' -); - -verifyNotEnumerable(Reflect.construct, 'name'); -verifyNotWritable(Reflect.construct, 'name'); -verifyConfigurable(Reflect.construct, 'name'); +verifyProperty(Reflect.construct, "name", { + value: "construct", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/construct/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/construct/not-a-constructor.js index 16b99500a9..6d0f286fbb 100644 --- a/js/src/tests/test262/built-ins/Reflect/construct/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Reflect/construct/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Reflect.construct), false, 'isConstructor(Reflect assert.throws(TypeError, () => { new Reflect.construct(Function, [], Function); -}, '`new Reflect.construct(Function, [], Function)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/defineProperty/length.js b/js/src/tests/test262/built-ins/Reflect/defineProperty/length.js index 2b5b742918..f83f561d79 100644 --- a/js/src/tests/test262/built-ins/Reflect/defineProperty/length.js +++ b/js/src/tests/test262/built-ins/Reflect/defineProperty/length.js @@ -8,13 +8,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.defineProperty.length, 3, - 'The value of `Reflect.defineProperty.length` is `3`' -); - -verifyNotEnumerable(Reflect.defineProperty, 'length'); -verifyNotWritable(Reflect.defineProperty, 'length'); -verifyConfigurable(Reflect.defineProperty, 'length'); +verifyProperty(Reflect.defineProperty, "length", { + value: 3, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/defineProperty/name.js b/js/src/tests/test262/built-ins/Reflect/defineProperty/name.js index 5315b9d272..29214c37b5 100644 --- a/js/src/tests/test262/built-ins/Reflect/defineProperty/name.js +++ b/js/src/tests/test262/built-ins/Reflect/defineProperty/name.js @@ -13,13 +13,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.defineProperty.name, 'defineProperty', - 'The value of `Reflect.defineProperty.name` is `"defineProperty"`' -); - -verifyNotEnumerable(Reflect.defineProperty, 'name'); -verifyNotWritable(Reflect.defineProperty, 'name'); -verifyConfigurable(Reflect.defineProperty, 'name'); +verifyProperty(Reflect.defineProperty, "name", { + value: "defineProperty", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/defineProperty/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/defineProperty/not-a-constructor.js index c878ad4756..a343891cdc 100644 --- a/js/src/tests/test262/built-ins/Reflect/defineProperty/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Reflect/defineProperty/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Reflect.defineProperty({}, ''); -}, '`new Reflect.defineProperty({}, \'\')` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/deleteProperty/length.js b/js/src/tests/test262/built-ins/Reflect/deleteProperty/length.js index f340de07b5..c4f219e377 100644 --- a/js/src/tests/test262/built-ins/Reflect/deleteProperty/length.js +++ b/js/src/tests/test262/built-ins/Reflect/deleteProperty/length.js @@ -8,13 +8,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.deleteProperty.length, 2, - 'The value of `Reflect.deleteProperty.length` is `2`' -); - -verifyNotEnumerable(Reflect.deleteProperty, 'length'); -verifyNotWritable(Reflect.deleteProperty, 'length'); -verifyConfigurable(Reflect.deleteProperty, 'length'); +verifyProperty(Reflect.deleteProperty, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/deleteProperty/name.js b/js/src/tests/test262/built-ins/Reflect/deleteProperty/name.js index 8f6a2ead5b..a3f31b0b6a 100644 --- a/js/src/tests/test262/built-ins/Reflect/deleteProperty/name.js +++ b/js/src/tests/test262/built-ins/Reflect/deleteProperty/name.js @@ -13,13 +13,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.deleteProperty.name, 'deleteProperty', - 'The value of `Reflect.deleteProperty.name` is `"deleteProperty"`' -); - -verifyNotEnumerable(Reflect.deleteProperty, 'name'); -verifyNotWritable(Reflect.deleteProperty, 'name'); -verifyConfigurable(Reflect.deleteProperty, 'name'); +verifyProperty(Reflect.deleteProperty, "name", { + value: "deleteProperty", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/deleteProperty/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/deleteProperty/not-a-constructor.js index afbc5ae119..53fd473101 100644 --- a/js/src/tests/test262/built-ins/Reflect/deleteProperty/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Reflect/deleteProperty/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Reflect.deleteProperty({}, ''); -}, '`new Reflect.deleteProperty({}, \'\')` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/get/length.js b/js/src/tests/test262/built-ins/Reflect/get/length.js index 615f35d6cc..7a2caa9205 100644 --- a/js/src/tests/test262/built-ins/Reflect/get/length.js +++ b/js/src/tests/test262/built-ins/Reflect/get/length.js @@ -12,13 +12,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.get.length, 2, - 'The value of `Reflect.get.length` is `2`' -); - -verifyNotEnumerable(Reflect.get, 'length'); -verifyNotWritable(Reflect.get, 'length'); -verifyConfigurable(Reflect.get, 'length'); +verifyProperty(Reflect.get, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/get/name.js b/js/src/tests/test262/built-ins/Reflect/get/name.js index d474d98e0f..1d573c56ac 100644 --- a/js/src/tests/test262/built-ins/Reflect/get/name.js +++ b/js/src/tests/test262/built-ins/Reflect/get/name.js @@ -13,13 +13,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.get.name, 'get', - 'The value of `Reflect.get.name` is `"get"`' -); - -verifyNotEnumerable(Reflect.get, 'name'); -verifyNotWritable(Reflect.get, 'name'); -verifyConfigurable(Reflect.get, 'name'); +verifyProperty(Reflect.get, "name", { + value: "get", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/get/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/get/not-a-constructor.js index 73635058ff..66b468dc80 100644 --- a/js/src/tests/test262/built-ins/Reflect/get/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Reflect/get/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Reflect.get), false, 'isConstructor(Reflect.get) assert.throws(TypeError, () => { new Reflect.get({}, ''); -}, '`new Reflect.get({}, \'\')` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/length.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/length.js index 47bc4d2b9b..bce7e7cfb5 100644 --- a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/length.js +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/length.js @@ -8,13 +8,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.getOwnPropertyDescriptor.length, 2, - 'The value of `Reflect.getOwnPropertyDescriptor.length` is `2`' -); - -verifyNotEnumerable(Reflect.getOwnPropertyDescriptor, 'length'); -verifyNotWritable(Reflect.getOwnPropertyDescriptor, 'length'); -verifyConfigurable(Reflect.getOwnPropertyDescriptor, 'length'); +verifyProperty(Reflect.getOwnPropertyDescriptor, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/name.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/name.js index 521736be82..6b4925d2e0 100644 --- a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/name.js +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/name.js @@ -13,13 +13,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.getOwnPropertyDescriptor.name, 'getOwnPropertyDescriptor', - 'The value of `Reflect.getOwnPropertyDescriptor.name` is `"getOwnPropertyDescriptor"`' -); - -verifyNotEnumerable(Reflect.getOwnPropertyDescriptor, 'name'); -verifyNotWritable(Reflect.getOwnPropertyDescriptor, 'name'); -verifyConfigurable(Reflect.getOwnPropertyDescriptor, 'name'); +verifyProperty(Reflect.getOwnPropertyDescriptor, "name", { + value: "getOwnPropertyDescriptor", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/not-a-constructor.js index 62c4d5511e..02ccf0f7af 100644 --- a/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Reflect/getOwnPropertyDescriptor/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Reflect.getOwnPropertyDescriptor({}, ''); -}, '`new Reflect.getOwnPropertyDescriptor({}, \'\')` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getPrototypeOf/length.js b/js/src/tests/test262/built-ins/Reflect/getPrototypeOf/length.js index 30e3ba0e5d..66203e4532 100644 --- a/js/src/tests/test262/built-ins/Reflect/getPrototypeOf/length.js +++ b/js/src/tests/test262/built-ins/Reflect/getPrototypeOf/length.js @@ -8,13 +8,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.getPrototypeOf.length, 1, - 'The value of `Reflect.getPrototypeOf.length` is `1`' -); - -verifyNotEnumerable(Reflect.getPrototypeOf, 'length'); -verifyNotWritable(Reflect.getPrototypeOf, 'length'); -verifyConfigurable(Reflect.getPrototypeOf, 'length'); +verifyProperty(Reflect.getPrototypeOf, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getPrototypeOf/name.js b/js/src/tests/test262/built-ins/Reflect/getPrototypeOf/name.js index 6d6e1df287..8384aa8e67 100644 --- a/js/src/tests/test262/built-ins/Reflect/getPrototypeOf/name.js +++ b/js/src/tests/test262/built-ins/Reflect/getPrototypeOf/name.js @@ -13,13 +13,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.getPrototypeOf.name, 'getPrototypeOf', - 'The value of `Reflect.getPrototypeOf.name` is `"getPrototypeOf"`' -); - -verifyNotEnumerable(Reflect.getPrototypeOf, 'name'); -verifyNotWritable(Reflect.getPrototypeOf, 'name'); -verifyConfigurable(Reflect.getPrototypeOf, 'name'); +verifyProperty(Reflect.getPrototypeOf, "name", { + value: "getPrototypeOf", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/getPrototypeOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/getPrototypeOf/not-a-constructor.js index 6ce18c7913..199f3bd72a 100644 --- a/js/src/tests/test262/built-ins/Reflect/getPrototypeOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Reflect/getPrototypeOf/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Reflect.getPrototypeOf({}); -}, '`new Reflect.getPrototypeOf({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/has/length.js b/js/src/tests/test262/built-ins/Reflect/has/length.js index a5a0fc4a0b..5779efca57 100644 --- a/js/src/tests/test262/built-ins/Reflect/has/length.js +++ b/js/src/tests/test262/built-ins/Reflect/has/length.js @@ -8,13 +8,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.has.length, 2, - 'The value of `Reflect.has.length` is `2`' -); - -verifyNotEnumerable(Reflect.has, 'length'); -verifyNotWritable(Reflect.has, 'length'); -verifyConfigurable(Reflect.has, 'length'); +verifyProperty(Reflect.has, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/has/name.js b/js/src/tests/test262/built-ins/Reflect/has/name.js index 62e68d8983..3b1a3db14f 100644 --- a/js/src/tests/test262/built-ins/Reflect/has/name.js +++ b/js/src/tests/test262/built-ins/Reflect/has/name.js @@ -13,13 +13,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.has.name, 'has', - 'The value of `Reflect.has.name` is `"has"`' -); - -verifyNotEnumerable(Reflect.has, 'name'); -verifyNotWritable(Reflect.has, 'name'); -verifyConfigurable(Reflect.has, 'name'); +verifyProperty(Reflect.has, "name", { + value: "has", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/has/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/has/not-a-constructor.js index 714c8ef861..0e7fa26991 100644 --- a/js/src/tests/test262/built-ins/Reflect/has/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Reflect/has/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Reflect.has), false, 'isConstructor(Reflect.has) assert.throws(TypeError, () => { new Reflect.has(); -}, '`new Reflect.has()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/isExtensible/length.js b/js/src/tests/test262/built-ins/Reflect/isExtensible/length.js index 31dd4d802a..61f564113e 100644 --- a/js/src/tests/test262/built-ins/Reflect/isExtensible/length.js +++ b/js/src/tests/test262/built-ins/Reflect/isExtensible/length.js @@ -8,13 +8,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.isExtensible.length, 1, - 'The value of `Reflect.isExtensible.length` is `1`' -); - -verifyNotEnumerable(Reflect.isExtensible, 'length'); -verifyNotWritable(Reflect.isExtensible, 'length'); -verifyConfigurable(Reflect.isExtensible, 'length'); +verifyProperty(Reflect.isExtensible, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/isExtensible/name.js b/js/src/tests/test262/built-ins/Reflect/isExtensible/name.js index 04ba531667..ef8820258b 100644 --- a/js/src/tests/test262/built-ins/Reflect/isExtensible/name.js +++ b/js/src/tests/test262/built-ins/Reflect/isExtensible/name.js @@ -13,13 +13,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.isExtensible.name, 'isExtensible', - 'The value of `Reflect.isExtensible.name` is `"isExtensible"`' -); - -verifyNotEnumerable(Reflect.isExtensible, 'name'); -verifyNotWritable(Reflect.isExtensible, 'name'); -verifyConfigurable(Reflect.isExtensible, 'name'); +verifyProperty(Reflect.isExtensible, "name", { + value: "isExtensible", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/isExtensible/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/isExtensible/not-a-constructor.js index e45a445b84..a8205bf113 100644 --- a/js/src/tests/test262/built-ins/Reflect/isExtensible/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Reflect/isExtensible/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Reflect.isExtensible), false, 'isConstructor(Refl assert.throws(TypeError, () => { new Reflect.isExtensible({}); -}, '`new Reflect.isExtensible({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/length.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/length.js index 7f84f0b49a..6f83f2ce49 100644 --- a/js/src/tests/test262/built-ins/Reflect/ownKeys/length.js +++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/length.js @@ -8,13 +8,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.ownKeys.length, 1, - 'The value of `Reflect.ownKeys.length` is `1`' -); - -verifyNotEnumerable(Reflect.ownKeys, 'length'); -verifyNotWritable(Reflect.ownKeys, 'length'); -verifyConfigurable(Reflect.ownKeys, 'length'); +verifyProperty(Reflect.ownKeys, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/name.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/name.js index 77a757dfc5..1de47e9efc 100644 --- a/js/src/tests/test262/built-ins/Reflect/ownKeys/name.js +++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/name.js @@ -13,13 +13,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.ownKeys.name, 'ownKeys', - 'The value of `Reflect.ownKeys.name` is `"ownKeys"`' -); - -verifyNotEnumerable(Reflect.ownKeys, 'name'); -verifyNotWritable(Reflect.ownKeys, 'name'); -verifyConfigurable(Reflect.ownKeys, 'name'); +verifyProperty(Reflect.ownKeys, "name", { + value: "ownKeys", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/not-a-constructor.js index 9419d7cdd5..384ceb94df 100644 --- a/js/src/tests/test262/built-ins/Reflect/ownKeys/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Reflect.ownKeys), false, 'isConstructor(Reflect.o assert.throws(TypeError, () => { new Reflect.ownKeys({}); -}, '`new Reflect.ownKeys({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/preventExtensions/length.js b/js/src/tests/test262/built-ins/Reflect/preventExtensions/length.js index ee474224bf..35fa687d4c 100644 --- a/js/src/tests/test262/built-ins/Reflect/preventExtensions/length.js +++ b/js/src/tests/test262/built-ins/Reflect/preventExtensions/length.js @@ -8,13 +8,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.preventExtensions.length, 1, - 'The value of `Reflect.preventExtensions.length` is `1`' -); - -verifyNotEnumerable(Reflect.preventExtensions, 'length'); -verifyNotWritable(Reflect.preventExtensions, 'length'); -verifyConfigurable(Reflect.preventExtensions, 'length'); +verifyProperty(Reflect.preventExtensions, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/preventExtensions/name.js b/js/src/tests/test262/built-ins/Reflect/preventExtensions/name.js index 802a6efbb6..62148cd873 100644 --- a/js/src/tests/test262/built-ins/Reflect/preventExtensions/name.js +++ b/js/src/tests/test262/built-ins/Reflect/preventExtensions/name.js @@ -13,13 +13,11 @@ includes: [propertyHelper.js] features: [Reflect] ---*/ -assert.sameValue( - Reflect.preventExtensions.name, 'preventExtensions', - 'The value of `Reflect.preventExtensions.name` is `"preventExtensions"`' -); - -verifyNotEnumerable(Reflect.preventExtensions, 'name'); -verifyNotWritable(Reflect.preventExtensions, 'name'); -verifyConfigurable(Reflect.preventExtensions, 'name'); +verifyProperty(Reflect.preventExtensions, "name", { + value: "preventExtensions", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/preventExtensions/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/preventExtensions/not-a-constructor.js index 9157e1a265..ae86ac9ee5 100644 --- a/js/src/tests/test262/built-ins/Reflect/preventExtensions/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Reflect/preventExtensions/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Reflect.preventExtensions({}); -}, '`new Reflect.preventExtensions({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/set/length.js b/js/src/tests/test262/built-ins/Reflect/set/length.js index e8e0d537c7..cab048f500 100644 --- a/js/src/tests/test262/built-ins/Reflect/set/length.js +++ b/js/src/tests/test262/built-ins/Reflect/set/length.js @@ -12,13 +12,11 @@ includes: [propertyHelper.js] features: [Reflect, Reflect.set] ---*/ -assert.sameValue( - Reflect.set.length, 3, - 'The value of `Reflect.set.length` is `3`' -); - -verifyNotEnumerable(Reflect.set, 'length'); -verifyNotWritable(Reflect.set, 'length'); -verifyConfigurable(Reflect.set, 'length'); +verifyProperty(Reflect.set, "length", { + value: 3, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/set/name.js b/js/src/tests/test262/built-ins/Reflect/set/name.js index 999e652586..26db6f5186 100644 --- a/js/src/tests/test262/built-ins/Reflect/set/name.js +++ b/js/src/tests/test262/built-ins/Reflect/set/name.js @@ -13,13 +13,11 @@ includes: [propertyHelper.js] features: [Reflect, Reflect.set] ---*/ -assert.sameValue( - Reflect.set.name, 'set', - 'The value of `Reflect.set.name` is `"set"`' -); - -verifyNotEnumerable(Reflect.set, 'name'); -verifyNotWritable(Reflect.set, 'name'); -verifyConfigurable(Reflect.set, 'name'); +verifyProperty(Reflect.set, "name", { + value: "set", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/set/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/set/not-a-constructor.js index c632ce534f..ae57a7c824 100644 --- a/js/src/tests/test262/built-ins/Reflect/set/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Reflect/set/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Reflect.set), false, 'isConstructor(Reflect.set) assert.throws(TypeError, () => { new Reflect.set({}); -}, '`new Reflect.set({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/setPrototypeOf/length.js b/js/src/tests/test262/built-ins/Reflect/setPrototypeOf/length.js index 51e4fff9c4..4b7b768317 100644 --- a/js/src/tests/test262/built-ins/Reflect/setPrototypeOf/length.js +++ b/js/src/tests/test262/built-ins/Reflect/setPrototypeOf/length.js @@ -8,13 +8,11 @@ includes: [propertyHelper.js] features: [Reflect, Reflect.setPrototypeOf] ---*/ -assert.sameValue( - Reflect.setPrototypeOf.length, 2, - 'The value of `Reflect.setPrototypeOf.length` is `2`' -); - -verifyNotEnumerable(Reflect.setPrototypeOf, 'length'); -verifyNotWritable(Reflect.setPrototypeOf, 'length'); -verifyConfigurable(Reflect.setPrototypeOf, 'length'); +verifyProperty(Reflect.setPrototypeOf, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/setPrototypeOf/name.js b/js/src/tests/test262/built-ins/Reflect/setPrototypeOf/name.js index bbbca0a855..3c89e4b12f 100644 --- a/js/src/tests/test262/built-ins/Reflect/setPrototypeOf/name.js +++ b/js/src/tests/test262/built-ins/Reflect/setPrototypeOf/name.js @@ -12,13 +12,11 @@ includes: [propertyHelper.js] features: [Reflect, Reflect.setPrototypeOf] ---*/ -assert.sameValue( - Reflect.setPrototypeOf.name, 'setPrototypeOf', - 'The value of `Reflect.setPrototypeOf.name` is `"setPrototypeOf"`' -); - -verifyNotEnumerable(Reflect.setPrototypeOf, 'name'); -verifyNotWritable(Reflect.setPrototypeOf, 'name'); -verifyConfigurable(Reflect.setPrototypeOf, 'name'); +verifyProperty(Reflect.setPrototypeOf, "name", { + value: "setPrototypeOf", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Reflect/setPrototypeOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/setPrototypeOf/not-a-constructor.js index e7e1f90120..ff732d9e5b 100644 --- a/js/src/tests/test262/built-ins/Reflect/setPrototypeOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Reflect/setPrototypeOf/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new Reflect.setPrototypeOf({}, {}); -}, '`new Reflect.setPrototypeOf({}, {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/Symbol.species/length.js b/js/src/tests/test262/built-ins/RegExp/Symbol.species/length.js index c38cb495a3..5330173b20 100644 --- a/js/src/tests/test262/built-ins/RegExp/Symbol.species/length.js +++ b/js/src/tests/test262/built-ins/RegExp/Symbol.species/length.js @@ -25,10 +25,11 @@ features: [Symbol.species] var desc = Object.getOwnPropertyDescriptor(RegExp, Symbol.species); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/Symbol.species/symbol-species-name.js b/js/src/tests/test262/built-ins/RegExp/Symbol.species/symbol-species-name.js index c7069365a6..5502462c6e 100644 --- a/js/src/tests/test262/built-ins/RegExp/Symbol.species/symbol-species-name.js +++ b/js/src/tests/test262/built-ins/RegExp/Symbol.species/symbol-species-name.js @@ -15,13 +15,11 @@ includes: [propertyHelper.js] var descriptor = Object.getOwnPropertyDescriptor(RegExp, Symbol.species); -assert.sameValue( - descriptor.get.name, - 'get [Symbol.species]' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get [Symbol.species]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-code-point-repeat-i-1.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-code-point-repeat-i-1.js new file mode 100644 index 0000000000..cc4d99e0cd --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-code-point-repeat-i-1.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?ii:a)", ""); +}, 'RegExp("(?ii:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-code-point-repeat-i-2.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-code-point-repeat-i-2.js new file mode 100644 index 0000000000..24a85269ad --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-code-point-repeat-i-2.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?imsi:a)", ""); +}, 'RegExp("(?imsi:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-arbitrary.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-arbitrary.js new file mode 100644 index 0000000000..d67bb46e14 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-arbitrary.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?1:a)", ""); +}, 'RegExp("(?1:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-i.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-i.js new file mode 100644 index 0000000000..d309c29c20 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?iͥ:a)", ""); +}, 'RegExp("(?iͥ:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-m.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-m.js new file mode 100644 index 0000000000..38d57aca09 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-m.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?mͫ:a)", ""); +}, 'RegExp("(?mͫ:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-s.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-s.js new file mode 100644 index 0000000000..325d6cce13 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s̀:a)", ""); +}, 'RegExp("(?s̀:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-d.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-d.js new file mode 100644 index 0000000000..27d3dcc71a --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-d.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?d:a)", ""); +}, 'RegExp("(?d:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-g.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-g.js new file mode 100644 index 0000000000..e2805673f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-g.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?g:a)", ""); +}, 'RegExp("(?g:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-display-1.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-display-1.js Binary files differnew file mode 100644 index 0000000000..d2d2223eb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-display-1.js diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-display-2.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-display-2.js new file mode 100644 index 0000000000..9e05cb67f3 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-display-2.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s:a)", ""); +}, 'RegExp("(?s:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-flag.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-flag.js new file mode 100644 index 0000000000..87ee26e9ca --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-flag.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?Q:a)", ""); +}, 'RegExp("(?Q:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-u.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-u.js new file mode 100644 index 0000000000..82c45b61f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-u.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?u:a)", ""); +}, 'RegExp("(?u:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-uppercase-I.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-uppercase-I.js new file mode 100644 index 0000000000..17e23af60b --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-uppercase-I.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?I:a)", ""); +}, 'RegExp("(?I:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-y.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-y.js new file mode 100644 index 0000000000..829ec8a69f --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-y.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?y:a)", ""); +}, 'RegExp("(?y:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwj.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwj.js new file mode 100644 index 0000000000..e7877d64c1 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwj.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s:a)", ""); +}, 'RegExp("(?s:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwnbsp.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwnbsp.js new file mode 100644 index 0000000000..0a44ee1551 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwnbsp.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s:a)", ""); +}, 'RegExp("(?s:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwnj.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwnj.js new file mode 100644 index 0000000000..233c5aa9dd --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwnj.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s:a)", ""); +}, 'RegExp("(?s:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-i.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-i.js new file mode 100644 index 0000000000..bbe8e845e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?I:a)", "i"); +}, 'RegExp("(?I:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-m.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-m.js new file mode 100644 index 0000000000..61068122a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-m.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?M:a)", "i"); +}, 'RegExp("(?M:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-s.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-s.js new file mode 100644 index 0000000000..464666a010 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?S:a)", "i"); +}, 'RegExp("(?S:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-unicode-case-fold-i.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-unicode-case-fold-i.js new file mode 100644 index 0000000000..3140f4e4de --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-unicode-case-fold-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?İ:a)", "iu"); +}, 'RegExp("(?İ:a)", "iu"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-unicode-case-fold-s.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-unicode-case-fold-s.js new file mode 100644 index 0000000000..939793f5ed --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-unicode-case-fold-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?ſ:a)", "u"); +}, 'RegExp("(?ſ:a)", "u"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/length.js index ea84d3ce40..b8c3c34a02 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/length.js @@ -19,10 +19,11 @@ includes: [propertyHelper.js] features: [Symbol.match] ---*/ -assert.sameValue(RegExp.prototype[Symbol.match].length, 1); - -verifyNotEnumerable(RegExp.prototype[Symbol.match], 'length'); -verifyNotWritable(RegExp.prototype[Symbol.match], 'length'); -verifyConfigurable(RegExp.prototype[Symbol.match], 'length'); +verifyProperty(RegExp.prototype[Symbol.match], "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/name.js index 2c676dba2f..a0629a0c73 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/name.js @@ -17,10 +17,11 @@ includes: [propertyHelper.js] features: [Symbol.match] ---*/ -assert.sameValue(RegExp.prototype[Symbol.match].name, '[Symbol.match]'); - -verifyNotEnumerable(RegExp.prototype[Symbol.match], 'name'); -verifyNotWritable(RegExp.prototype[Symbol.match], 'name'); -verifyConfigurable(RegExp.prototype[Symbol.match], 'name'); +verifyProperty(RegExp.prototype[Symbol.match], "name", { + value: "[Symbol.match]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/not-a-constructor.js index f56be3391f..727add9892 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let re = new RegExp(''); new re[Symbol.match](); -}, '`let re = new RegExp(\'\'); new re[Symbol.match]()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/length.js index ec522ab2f5..70284e43e6 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/length.js @@ -23,10 +23,11 @@ includes: [propertyHelper.js] features: [Symbol.matchAll] ---*/ -assert.sameValue(RegExp.prototype[Symbol.matchAll].length, 1); - -verifyNotEnumerable(RegExp.prototype[Symbol.matchAll], 'length'); -verifyNotWritable(RegExp.prototype[Symbol.matchAll], 'length'); -verifyConfigurable(RegExp.prototype[Symbol.matchAll], 'length'); +verifyProperty(RegExp.prototype[Symbol.matchAll], "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/name.js index f9a1e9bf87..4ce81b923f 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/name.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] features: [Symbol.matchAll] ---*/ -assert.sameValue(RegExp.prototype[Symbol.matchAll].name, '[Symbol.matchAll]'); - -verifyNotEnumerable(RegExp.prototype[Symbol.matchAll], 'name'); -verifyNotWritable(RegExp.prototype[Symbol.matchAll], 'name'); -verifyConfigurable(RegExp.prototype[Symbol.matchAll], 'name'); +verifyProperty(RegExp.prototype[Symbol.matchAll], "name", { + value: "[Symbol.matchAll]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/not-a-constructor.js index 03009bf3de..956881d1c6 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let re = new RegExp(''); new re[Symbol.matchAll](); -}, '`let re = new RegExp(\'\'); new re[Symbol.matchAll]()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/length.js index fe89e2265b..7dce30b819 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/length.js @@ -19,10 +19,11 @@ includes: [propertyHelper.js] features: [Symbol.replace] ---*/ -assert.sameValue(RegExp.prototype[Symbol.replace].length, 2); - -verifyNotEnumerable(RegExp.prototype[Symbol.replace], 'length'); -verifyNotWritable(RegExp.prototype[Symbol.replace], 'length'); -verifyConfigurable(RegExp.prototype[Symbol.replace], 'length'); +verifyProperty(RegExp.prototype[Symbol.replace], "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/name.js index 5d6dbb13e7..512c11a769 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/name.js @@ -17,10 +17,11 @@ includes: [propertyHelper.js] features: [Symbol.replace] ---*/ -assert.sameValue(RegExp.prototype[Symbol.replace].name, '[Symbol.replace]'); - -verifyNotEnumerable(RegExp.prototype[Symbol.replace], 'name'); -verifyNotWritable(RegExp.prototype[Symbol.replace], 'name'); -verifyConfigurable(RegExp.prototype[Symbol.replace], 'name'); +verifyProperty(RegExp.prototype[Symbol.replace], "name", { + value: "[Symbol.replace]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/not-a-constructor.js index 8fe7bd03bb..07c7a0b7a1 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let re = new RegExp(''); new re[Symbol.replace](); -}, '`let re = new RegExp(\'\'); new re[Symbol.replace]()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/length.js index 86a0b3051c..5be85a3bf4 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/length.js @@ -20,10 +20,11 @@ features: [Symbol.search] includes: [propertyHelper.js] ---*/ -assert.sameValue(RegExp.prototype[Symbol.search].length, 1); - -verifyNotEnumerable(RegExp.prototype[Symbol.search], 'length'); -verifyNotWritable(RegExp.prototype[Symbol.search], 'length'); -verifyConfigurable(RegExp.prototype[Symbol.search], 'length'); +verifyProperty(RegExp.prototype[Symbol.search], "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/name.js index 08a4452f48..4f3861d650 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/name.js @@ -17,10 +17,11 @@ features: [Symbol.search] includes: [propertyHelper.js] ---*/ -assert.sameValue(RegExp.prototype[Symbol.search].name, '[Symbol.search]'); - -verifyNotEnumerable(RegExp.prototype[Symbol.search], 'name'); -verifyNotWritable(RegExp.prototype[Symbol.search], 'name'); -verifyConfigurable(RegExp.prototype[Symbol.search], 'name'); +verifyProperty(RegExp.prototype[Symbol.search], "name", { + value: "[Symbol.search]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/not-a-constructor.js index 0403b2e6da..8d13663998 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let re = new RegExp(''); new re[Symbol.search](); -}, '`let re = new RegExp(\'\'); new re[Symbol.search]()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/length.js index 546f056ca0..5fe2ff49c4 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/length.js @@ -17,10 +17,11 @@ includes: [propertyHelper.js] features: [Symbol.split] ---*/ -assert.sameValue(RegExp.prototype[Symbol.split].length, 2); - -verifyNotEnumerable(RegExp.prototype[Symbol.split], 'length'); -verifyNotWritable(RegExp.prototype[Symbol.split], 'length'); -verifyConfigurable(RegExp.prototype[Symbol.split], 'length'); +verifyProperty(RegExp.prototype[Symbol.split], "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/name.js index aac4f253a1..5284f94f57 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/name.js @@ -17,10 +17,11 @@ includes: [propertyHelper.js] features: [Symbol.split] ---*/ -assert.sameValue(RegExp.prototype[Symbol.split].name, '[Symbol.split]'); - -verifyNotEnumerable(RegExp.prototype[Symbol.split], 'name'); -verifyNotWritable(RegExp.prototype[Symbol.split], 'name'); -verifyConfigurable(RegExp.prototype[Symbol.split], 'name'); +verifyProperty(RegExp.prototype[Symbol.split], "name", { + value: "[Symbol.split]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/not-a-constructor.js index 4623db96ba..88094c421a 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let re = new RegExp(''); new re[Symbol.split](); -}, '`let re = new RegExp(\'\'); new re[Symbol.split]()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/exec/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/exec/name.js index 89d0243a20..ef865729a9 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/exec/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/exec/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(RegExp.prototype.exec.name, "exec"); - -verifyNotEnumerable(RegExp.prototype.exec, "name"); -verifyNotWritable(RegExp.prototype.exec, "name"); -verifyConfigurable(RegExp.prototype.exec, "name"); +verifyProperty(RegExp.prototype.exec, "name", { + value: "exec", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/exec/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/exec/not-a-constructor.js index c4492952dd..9578cd6777 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/exec/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/exec/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let re = new RegExp(''); new re.exec(); -}, '`let re = new RegExp(\'\'); new re.exec()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/global/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/global/length.js index d2802441f3..181dc3f2c4 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/global/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/global/length.js @@ -24,10 +24,11 @@ includes: [propertyHelper.js] var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, "global"); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/global/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/global/name.js index ba8ace9def..fb76ce7121 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/global/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/global/name.js @@ -14,13 +14,11 @@ includes: [propertyHelper.js] var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'global'); -assert.sameValue( - descriptor.get.name, - 'get global' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get global", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/ignoreCase/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/ignoreCase/length.js index 3707ec5ad1..fcb51bc8d7 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/ignoreCase/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/ignoreCase/length.js @@ -24,10 +24,11 @@ includes: [propertyHelper.js] var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, "ignoreCase"); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/ignoreCase/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/ignoreCase/name.js index 1f3894cbbe..4f7dc92846 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/ignoreCase/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/ignoreCase/name.js @@ -14,13 +14,11 @@ includes: [propertyHelper.js] var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'ignoreCase'); -assert.sameValue( - descriptor.get.name, - 'get ignoreCase' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get ignoreCase", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/multiline/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/multiline/length.js index 08105090e0..c79cb88c99 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/multiline/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/multiline/length.js @@ -24,10 +24,11 @@ includes: [propertyHelper.js] var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, "multiline"); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/multiline/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/multiline/name.js index 674dec6f70..3fd0e3bce7 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/multiline/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/multiline/name.js @@ -14,13 +14,11 @@ includes: [propertyHelper.js] var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'multiline'); -assert.sameValue( - descriptor.get.name, - 'get multiline' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get multiline", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/sticky/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/sticky/length.js index 220cf0a901..178f62270b 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/sticky/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/sticky/length.js @@ -24,10 +24,11 @@ includes: [propertyHelper.js] var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, "sticky"); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/sticky/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/sticky/name.js index 8fa5b1ac0f..b1c2120e47 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/sticky/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/sticky/name.js @@ -14,13 +14,11 @@ includes: [propertyHelper.js] var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'sticky'); -assert.sameValue( - descriptor.get.name, - 'get sticky' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get sticky", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/name.js index 7ee8a9a2e7..dcfb6f1e1a 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/test/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(RegExp.prototype.test.name, "test"); - -verifyNotEnumerable(RegExp.prototype.test, "name"); -verifyNotWritable(RegExp.prototype.test, "name"); -verifyConfigurable(RegExp.prototype.test, "name"); +verifyProperty(RegExp.prototype.test, "name", { + value: "test", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/not-a-constructor.js index ee6ce0aeaf..60422aca55 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/test/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let re = new RegExp(''); new re.test(); -}, '`let re = new RegExp(\'\'); new re.test()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/toString/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/toString/name.js index 91fe5a8809..46da2536c2 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/toString/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/toString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(RegExp.prototype.toString.name, "toString"); - -verifyNotEnumerable(RegExp.prototype.toString, "name"); -verifyNotWritable(RegExp.prototype.toString, "name"); -verifyConfigurable(RegExp.prototype.toString, "name"); +verifyProperty(RegExp.prototype.toString, "name", { + value: "toString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/toString/not-a-constructor.js index f064aaf64d..76b48034ed 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/toString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/toString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let re = new RegExp(''); new re.toString(); -}, '`let re = new RegExp(\'\'); new re.toString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/unicode/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/unicode/length.js index 127e2d0428..c661157d48 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/unicode/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/unicode/length.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] var getter = Object.getOwnPropertyDescriptor(RegExp.prototype, 'unicode').get; -assert.sameValue(getter.length, 0); - -verifyNotEnumerable(getter, 'length'); -verifyNotWritable(getter, 'length'); -verifyConfigurable(getter, 'length'); +verifyProperty(getter, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/unicode/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/unicode/name.js index 1e1858b46d..a152d919b5 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/unicode/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/unicode/name.js @@ -28,10 +28,11 @@ includes: [propertyHelper.js] var getter = Object.getOwnPropertyDescriptor(RegExp.prototype, 'unicode').get; -assert.sameValue(getter.name, 'get unicode'); - -verifyNotEnumerable(getter, 'name'); -verifyNotWritable(getter, 'name'); -verifyConfigurable(getter, 'name'); +verifyProperty(getter, "name", { + value: "get unicode", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-dotAll-property.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-dotAll-property.js new file mode 100644 index 0000000000..7edf9b90a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-dotAll-property.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding dotAll (`s`) modifier does not affect RegExp instance `dotAll` property. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?s:)/; +assert(!re1.dotAll, "RegExp instance dotAll flag should not be set"); + +var re2 = new RegExp("(?s:)"); +assert(!re2.dotAll, "RegExp instance dotAll flag should not be set"); + +var re3 = /(?s-:)/; +assert(!re3.dotAll, "RegExp instance dotAll flag should not be set"); + +var re4 = new RegExp("(?s-:)"); +assert(!re4.dotAll, "RegExp instance dotAll flag should not be set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-ignoreCase-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-ignoreCase-flag.js new file mode 100644 index 0000000000..1ebb730625 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-ignoreCase-flag.js @@ -0,0 +1,67 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding dotAll (`s`) modifier in group should not affect ignoreCase (`i`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?s:.es)/; +assert(re1.test("aes"), "s should match s in modified group"); +assert(re1.test("\nes"), "s should match s in modified group"); +assert(!re1.test("aeS"), "s should not match S in modified group"); +assert(!re1.test("\neS"), "s should not match S in modified group"); + +var re2 = /(?s:.es)/i; +assert(re2.test("aes"), "s should match s in modified group"); +assert(re2.test("aeS"), "s should match S in modified group"); +assert(re2.test("\nes"), "s should match s in modified group"); +assert(re2.test("\neS"), "s should match S in modified group"); + +var re3 = /(?s-:.es)/; +assert(re3.test("aes"), "s should match s in modified group"); +assert(re3.test("\nes"), "s should match s in modified group"); +assert(!re3.test("aeS"), "s should not match S in modified group"); +assert(!re3.test("\neS"), "s should not match S in modified group"); + +var re4 = /(?s-:.es)/i; +assert(re4.test("aes"), "s should match s in modified group"); +assert(re4.test("aeS"), "s should match S in modified group"); +assert(re4.test("\nes"), "s should match s in modified group"); +assert(re4.test("\neS"), "s should match S in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-multiline-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-multiline-flag.js new file mode 100644 index 0000000000..2f9adf75e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-multiline-flag.js @@ -0,0 +1,59 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding dotAll (`s`) modifier in group should not affect multiline (`m`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?s:.es$)/; +assert(re1.test("\nes"), ". should match newline in modified group"); +assert(!re1.test("\nes\nz"), "$ should not match newline in modified group"); + +var re2 = /(?s:.es$)/m; +assert(re2.test("\nes"), ". should match newline in modified group"); +assert(re2.test("\nes\nz"), "$ should match newline in modified group"); + +var re3 = /(?s-:.es$)/; +assert(re3.test("\nes"), ". should match newline in modified group"); +assert(!re3.test("\nes\nz"), "$ should not match newline in modified group"); + +var re4 = /(?s-:.es$)/m; +assert(re4.test("\nes"), ". should match newline in modified group"); +assert(re4.test("\nes\nz"), "$ should match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll.js new file mode 100644 index 0000000000..8c163adf54 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll.js @@ -0,0 +1,105 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + dotAll (`s`) modifier can be added via `(?s:)` or `(?s-:)`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?s:^.$)/; +assert(re1.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re1.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re1.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re1.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(re1.test("\n"), "Pattern character '.' should match line terminators in modified group"); +assert(re1.test("\r"), "Pattern character '.' should match line terminators in modified group"); +assert(re1.test("\u2028"), "Pattern character '.' should match line terminators in modified group"); +assert(re1.test("\u2029"), "Pattern character '.' should match line terminators in modified group"); +assert(re1.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +var re2 = new RegExp("(?s:^.$)"); +assert(re2.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re2.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re2.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re2.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(re2.test("\n"), "Pattern character '.' should match line terminators in modified group"); +assert(re2.test("\r"), "Pattern character '.' should match line terminators in modified group"); +assert(re2.test("\u2028"), "Pattern character '.' should match line terminators in modified group"); +assert(re2.test("\u2029"), "Pattern character '.' should match line terminators in modified group"); +assert(re2.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +var re3 = /(?s-:^.$)/; +assert(re3.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re3.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re3.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re3.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re3.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re3.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re3.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re3.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re3.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(re3.test("\n"), "Pattern character '.' should match line terminators in modified group"); +assert(re3.test("\r"), "Pattern character '.' should match line terminators in modified group"); +assert(re3.test("\u2028"), "Pattern character '.' should match line terminators in modified group"); +assert(re3.test("\u2029"), "Pattern character '.' should match line terminators in modified group"); +assert(re3.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re3.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +var re4 = new RegExp("(?s-:^.$)"); +assert(re4.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re4.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re4.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re4.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re4.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re4.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re4.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re4.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re4.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(re4.test("\n"), "Pattern character '.' should match line terminators in modified group"); +assert(re4.test("\r"), "Pattern character '.' should match line terminators in modified group"); +assert(re4.test("\u2028"), "Pattern character '.' should match line terminators in modified group"); +assert(re4.test("\u2029"), "Pattern character '.' should match line terminators in modified group"); +assert(re4.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re4.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-backreferences.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-backreferences.js new file mode 100644 index 0000000000..53e9ecb991 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-backreferences.js @@ -0,0 +1,55 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier in group affects backreferences in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(a)(?i:\1)/; +assert(!re1.test("AA"), "a should not match first A"); +assert(!re1.test("Aa"), "a should not match A"); +assert(re1.test("aa"), "a matches first a, so \\1 should match second a"); +assert(re1.test("aA"), "a matches a, so \\1 should match A (ignores case)"); + +var re2 = /(a)(?i-:\1)/; +assert(!re2.test("AA"), "a should not match first A"); +assert(!re2.test("Aa"), "a should not match A"); +assert(re2.test("aa"), "a matches first a, so \\1 should match second a"); +assert(re2.test("aA"), "a matches a, so \\1 should match A (ignores case)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-characterClasses.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-characterClasses.js new file mode 100644 index 0000000000..75c50a97fa --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-characterClasses.js @@ -0,0 +1,67 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier in group affects character classes in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:[ab])c/; +assert(re1.test("ac"), "[ab] should match a"); +assert(re1.test("Ac"), "[ab] should match A"); +assert(re1.test("bc"), "[ab] should match b"); +assert(re1.test("Bc"), "[ab] should match B"); + +var re2 = /(?i-:[ab])c/; +assert(re2.test("ac"), "[ab] should match a"); +assert(re2.test("Ac"), "[ab] should match A"); +assert(re2.test("bc"), "[ab] should match b"); +assert(re2.test("Bc"), "[ab] should match B"); + +var re3 = /(?i:[^ab])c/; +assert(!re3.test("ac"), "[^ab] should not match a"); +assert(!re3.test("Ac"), "[^ab] should not match A"); +assert(!re3.test("bc"), "[^ab] should not match b"); +assert(!re3.test("Bc"), "[^ab] should not match B"); + +var re4 = /(?i-:[^ab])c/; +assert(!re4.test("ac"), "[^ab] should not match a"); +assert(!re4.test("Ac"), "[^ab] should not match A"); +assert(!re4.test("bc"), "[^ab] should not match b"); +assert(!re4.test("Bc"), "[^ab] should not match B"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-characterEscapes.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-characterEscapes.js new file mode 100644 index 0000000000..98fa435027 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-characterEscapes.js @@ -0,0 +1,67 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier in group affects character escapes in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:\x61)b/; +assert(re1.test("ab"), "\\x61 should match a"); +assert(re1.test("Ab"), "\\x61 should match A"); + +var re2 = /(?i:\u0061)b/; +assert(re2.test("ab"), "\\u0061 should match a"); +assert(re2.test("Ab"), "\\u0061 should match A"); + +var re3 = /(?i:\u{0061})b/u; +assert(re3.test("ab"), "\\u0061 should match a"); +assert(re3.test("Ab"), "\\u0061 should match A"); + +var re4 = /(?i-:\x61)b/; +assert(re4.test("ab"), "\\x61 should match a"); +assert(re4.test("Ab"), "\\x61 should match A"); + +var re5 = /(?i-:\u0061)b/; +assert(re5.test("ab"), "\\u0061 should match a"); +assert(re5.test("Ab"), "\\u0061 should match A"); + +var re6 = /(?i-:\u{0061})b/u; +assert(re6.test("ab"), "\\u0061 should match a"); +assert(re6.test("Ab"), "\\u0061 should match A"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-b.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-b.js new file mode 100644 index 0000000000..a3f5b9f009 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-b.js @@ -0,0 +1,77 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier affects matching for `\b`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:\b)/; +assert(re1.test("A"), "\\b should match after A"); +assert(re1.test("a"), "\\b should match after a"); +assert(re1.test("z"), "\\b should match after z"); +assert(re1.test("Z"), "\\b should match after Z"); + +var re2 = /(?i:\b)/u; +assert(re2.test("A"), "\\b should match after A"); +assert(re2.test("a"), "\\b should match after a"); +assert(re2.test("z"), "\\b should match after z"); +assert(re2.test("Z"), "\\b should match after Z"); +assert(re2.test("\u017f"), "\\b should match after \u017f"); +assert(re2.test("\u212a"), "\\b should match after \u212a"); + +var re3 = /(?i-:\b)/; +assert(re3.test("A"), "\\b should match after A"); +assert(re3.test("a"), "\\b should match after a"); +assert(re3.test("z"), "\\b should match after z"); +assert(re3.test("Z"), "\\b should match after Z"); + +var re4 = /(?i-:\b)/u; +assert(re4.test("A"), "\\b should match after A"); +assert(re4.test("a"), "\\b should match after a"); +assert(re4.test("z"), "\\b should match after z"); +assert(re4.test("Z"), "\\b should match after Z"); +assert(re4.test("\u017f"), "\\b should match after \u017f"); +assert(re4.test("\u212a"), "\\b should match after \u212a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-p.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-p.js new file mode 100644 index 0000000000..41788082ee --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-p.js @@ -0,0 +1,61 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier affects matching for `\p{}`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:\p{Lu})/u; +assert(re1.test("A"), "\\p{Lu} should match A"); +assert(re1.test("a"), "\\p{Lu} should match a (ignores case)"); +assert(re1.test("Z"), "\\p{Lu} should match Z"); +assert(re1.test("z"), "\\p{Lu} should match z (ignores case)"); + +var re2 = /(?i-:\p{Lu})/u; +assert(re2.test("A"), "\\p{Lu} should match A"); +assert(re2.test("a"), "\\p{Lu} should match a (ignores case)"); +assert(re2.test("Z"), "\\p{Lu} should match Z"); +assert(re2.test("z"), "\\p{Lu} should match z (ignores case)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-w.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-w.js new file mode 100644 index 0000000000..324961d782 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-w.js @@ -0,0 +1,77 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier affects matching for `\w`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:\w)/; +assert(re1.test("A"), "\\w should match A"); +assert(re1.test("a"), "\\w should match a"); +assert(re1.test("z"), "\\w should match z"); +assert(re1.test("Z"), "\\w should match Z"); + +var re2 = /(?i:\w)/u; +assert(re2.test("A"), "\\w should match A"); +assert(re2.test("a"), "\\w should match a"); +assert(re2.test("z"), "\\w should match z"); +assert(re2.test("Z"), "\\w should match Z"); +assert(re2.test("\u017f"), "\\w should match \u017f"); +assert(re2.test("\u212a"), "\\w should match \u212a"); + +var re3 = /(?i-:\w)/; +assert(re3.test("A"), "\\w should match A"); +assert(re3.test("a"), "\\w should match a"); +assert(re3.test("z"), "\\w should match z"); +assert(re3.test("Z"), "\\w should match Z"); + +var re4 = /(?i-:\w)/u; +assert(re4.test("A"), "\\w should match A"); +assert(re4.test("a"), "\\w should match a"); +assert(re4.test("z"), "\\w should match z"); +assert(re4.test("Z"), "\\w should match Z"); +assert(re4.test("\u017f"), "\\w should match \u017f"); +assert(re4.test("\u212a"), "\\w should match \u212a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-b.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-b.js new file mode 100644 index 0000000000..ffb346277f --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-b.js @@ -0,0 +1,57 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier affects matching for `\B`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:Z\B)/u; +assert(re1.test("Z\u017f"), "\\B should match between Z and \u017f"); +assert(re1.test("Z\u212a"), "\\B should match between Z and \u212a"); + +var re2 = /(?i-:Z\B)/u; +assert(re2.test("Z\u017f"), "\\B should match between Z and \u017f"); +assert(re2.test("Z\u212a"), "\\B should match between Z and \u212a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-p.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-p.js new file mode 100644 index 0000000000..d5f30655cb --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-p.js @@ -0,0 +1,63 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier affects matching for `\P{}`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:\P{Lu})/u; +assert(re1.test("A"), "\\P{Lu} should match A (ignores case)"); +assert(re1.test("a"), "\\P{Lu} should match a"); +assert(re1.test("Z"), "\\P{Lu} should match Z (ignores case)"); +assert(re1.test("z"), "\\P{Lu} should match z"); +assert(re1.test("0"), "\\P{Lu} should match 0"); + +var re2 = /(?i-:\P{Lu})/u; +assert(re2.test("A"), "\\P{Lu} should match A (ignores case)"); +assert(re2.test("a"), "\\P{Lu} should match a"); +assert(re2.test("Z"), "\\P{Lu} should match Z (ignores case)"); +assert(re2.test("z"), "\\P{Lu} should match z"); +assert(re2.test("0"), "\\P{Lu} should match 0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-w.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-w.js new file mode 100644 index 0000000000..a0c527efa2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-w.js @@ -0,0 +1,57 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier affects matching for `\W`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:\W)/u; +assert(!re1.test("\u017f"), "\\W should not match \u017f"); +assert(!re1.test("\u212a"), "\\W should not match \u212a"); + +var re2 = /(?i-:\W)/u; +assert(!re2.test("\u017f"), "\\W should not match \u017f"); +assert(!re2.test("\u212a"), "\\W should not match \u212a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-dotAll-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-dotAll-flag.js new file mode 100644 index 0000000000..999598c492 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-dotAll-flag.js @@ -0,0 +1,67 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier in group should not affect dotAll (`s`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:.es)/; +assert(re1.test("aes"), ". should match a in modified group"); +assert(re1.test("aeS"), ". should match a in modified group"); +assert(!re1.test("\nes"), ". should not match newline in modified group"); +assert(!re1.test("\neS"), ". should not match newline in modified group"); + +var re2 = /(?i:.es)/s; +assert(re2.test("aes"), ". should match a in modified group"); +assert(re2.test("aeS"), ". should match a in modified group"); +assert(re2.test("\nes"), ". should match newline in modified group"); +assert(re2.test("\neS"), ". should match newline in modified group"); + +var re3 = /(?i-:.es)/; +assert(re3.test("aes"), ". should match a in modified group"); +assert(re3.test("aeS"), ". should match a in modified group"); +assert(!re3.test("\nes"), ". should not match newline in modified group"); +assert(!re3.test("\neS"), ". should not match newline in modified group"); + +var re4 = /(?i-:.es)/s; +assert(re4.test("aes"), ". should match a in modified group"); +assert(re4.test("aeS"), ". should match a in modified group"); +assert(re4.test("\nes"), ". should match newline in modified group"); +assert(re4.test("\neS"), ". should match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-ignoreCase-property.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-ignoreCase-property.js new file mode 100644 index 0000000000..24da245c46 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-ignoreCase-property.js @@ -0,0 +1,55 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier does not affect RegExp instance `ignoreCase` property. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:)/; +assert(!re1.ignoreCase, "RegExp instance ignoreCase property should not be set"); + +var re2 = new RegExp("(?i:)"); +assert(!re2.ignoreCase, "RegExp instance ignoreCase property should not be set"); + +var re3 = /(?i-:)/; +assert(!re3.ignoreCase, "RegExp instance ignoreCase property should not be set"); + +var re4 = new RegExp("(?i-:)"); +assert(!re4.ignoreCase, "RegExp instance ignoreCase property should not be set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-multiline-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-multiline-flag.js new file mode 100644 index 0000000000..692cfd9f2f --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-multiline-flag.js @@ -0,0 +1,67 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier in group should not affect multiline (`m`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:es$)/; +assert(re1.test("es"), "s should match s in modified group"); +assert(re1.test("eS"), "s should match S in modified group"); +assert(!re1.test("es\nz"), "$ should not match newline in modified group"); +assert(!re1.test("eS\nz"), "$ should not match newline in modified group"); + +var re2 = /(?i:es$)/m; +assert(re2.test("es"), "s should match s in modified group"); +assert(re2.test("eS"), "s should match S in modified group"); +assert(re2.test("es\nz"), "$ should match newline in modified group"); +assert(re2.test("eS\nz"), "$ should match newline in modified group"); + +var re3 = /(?i-:es$)/; +assert(re3.test("es"), "s should match s in modified group"); +assert(re3.test("eS"), "s should match S in modified group"); +assert(!re3.test("es\nz"), "$ should not match newline in modified group"); +assert(!re3.test("eS\nz"), "$ should not match newline in modified group"); + +var re4 = /(?i-:es$)/m; +assert(re4.test("es"), "s should match s in modified group"); +assert(re4.test("eS"), "s should match S in modified group"); +assert(re4.test("es\nz"), "$ should match newline in modified group"); +assert(re4.test("eS\nz"), "$ should match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase.js new file mode 100644 index 0000000000..bd07e7aa22 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase.js @@ -0,0 +1,47 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + ignoreCase (`i`) modifier can be added via `(?i:)` or `(?i-:)`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:a)b/; +assert(!re1.test("AB"), "b should not match B in AB"); +assert(re1.test("Ab"), "a should match A in AB"); +assert(re1.test("ab"), "should match AB"); + +var re2 = new RegExp("(?i:a)b"); +assert(!re2.test("AB"), "b should not match B in AB"); +assert(re2.test("Ab"), "a should match A in AB"); +assert(re2.test("ab"), "should match AB"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-dotAll-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-dotAll-flag.js new file mode 100644 index 0000000000..c065d293ac --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-dotAll-flag.js @@ -0,0 +1,59 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding multiline (`m`) modifier in group should not affect dotAll (`s`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?m:es.$)/; +assert(re1.test("esz\n"), "$ should match newline in modified group"); +assert(!re1.test("es\n\n"), ". should not match newline in modified group"); + +var re2 = /(?m:es.$)/s; +assert(re2.test("esz\n"), "$ should match newline in modified group"); +assert(re2.test("es\n\n"), ". should match newline in modified group"); + +var re3 = /(?m-:es.$)/; +assert(re3.test("esz\n"), "$ should match newline in modified group"); +assert(!re3.test("es\n\n"), ". should not match newline in modified group"); + +var re4 = /(?m-:es.$)/s; +assert(re4.test("esz\n"), "$ should match newline in modified group"); +assert(re4.test("es\n\n"), ". should match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-ignoreCase-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-ignoreCase-flag.js new file mode 100644 index 0000000000..b8b33e9c22 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-ignoreCase-flag.js @@ -0,0 +1,67 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding multiline (`m`) modifier in group should not affect ignoreCase (`i`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?m:es$)/; +assert(re1.test("es"), "s should match s in modified group"); +assert(!re1.test("eS"), "s should not match S in modified group"); +assert(re1.test("es\nz"), "$ should match newline in modified group"); +assert(!re1.test("eS\nz"), "s should not match S in modified group"); + +var re2 = /(?m:es$)/i; +assert(re2.test("es"), "s should match s in modified group"); +assert(re2.test("eS"), "s should match S in modified group"); +assert(re2.test("es\nz"), "$ should match newline in modified group"); +assert(re2.test("eS\nz"), "$ should match newline in modified group"); + +var re3 = /(?m-:es$)/; +assert(re3.test("es"), "s should match s in modified group"); +assert(!re3.test("eS"), "s should not match S in modified group"); +assert(re3.test("es\nz"), "$ should match newline in modified group"); +assert(!re3.test("eS\nz"), "s should not match S in modified group"); + +var re4 = /(?m-:es$)/i; +assert(re4.test("es"), "s should match s in modified group"); +assert(re4.test("eS"), "s should match S in modified group"); +assert(re4.test("es\nz"), "$ should match newline in modified group"); +assert(re4.test("eS\nz"), "$ should match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-multiline-property.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-multiline-property.js new file mode 100644 index 0000000000..3b960f5a6c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-multiline-property.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding multiline (`m`) modifier does not affect RegExp instance `multiline` property. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?m:)/; +assert(!re1.multiline, "RegExp instance multiline flag should not be set"); + +var re2 = new RegExp("(?m:)"); +assert(!re2.multiline, "RegExp instance multiline flag should not be set"); + +var re3 = /(?m-:)/; +assert(!re3.multiline, "RegExp instance multiline flag should not be set"); + +var re4 = new RegExp("(?m-:)"); +assert(!re4.multiline, "RegExp instance multiline flag should not be set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline.js new file mode 100644 index 0000000000..ee1d0a65cc --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + multiline (`m`) modifier can be added via `(?m:)` or `(?m-:)`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?m:es$)/; +assert(re1.test("es\ns"), "$ should match newline in modified group"); + +var re2 = new RegExp("(?m:es$)"); +assert(re2.test("es\ns"), "$ should match newline in modified group"); + +var re3 = /(?m-:es$)/; +assert(re3.test("es\ns"), "$ should match newline in modified group"); + +var re4 = new RegExp("(?m-:es$)"); +assert(re4.test("es\ns"), "$ should match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-remove-modifiers.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-remove-modifiers.js new file mode 100644 index 0000000000..68e4761cfc --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-remove-modifiers.js @@ -0,0 +1,45 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers can be both added and removed via `(?ims-ims:)`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?m-i:^a$)/i; +assert(!re1.test("A\n"), "Should not match 'A\\n'"); +assert(re1.test("a\n"), "Should match 'a\\n'"); + +var re2 = new RegExp("(?m-i:^a$)", "i"); +assert(!re2.test("A\n"), "Should not match 'A\\n'"); +assert(re2.test("a\n"), "Should match 'a\\n'"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/browser.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/browser.js diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-dotAll-flag-does-not-affect-dotAll-modifier.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-dotAll-flag-does-not-affect-dotAll-modifier.js new file mode 100644 index 0000000000..b275621155 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-dotAll-flag-does-not-affect-dotAll-modifier.js @@ -0,0 +1,77 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + New dotAll (`s`) flag from RegExp constructor does not affect dotAll modifier in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = new RegExp(/(?s:^.$)/s, ""); +assert(re1.test("a"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re1.test("3"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re1.test("π"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re1.test("\u2027"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re1.test("\u0085"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re1.test("\v"), "Pattern character '.' still should match mon-line terminators in modified group"); +assert(re1.test("\f"), "Pattern character '.' still should match mon-line terminators in modified group"); +assert(re1.test("\u180E"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(!re1.test("\u{10300}"), "Supplementary plane still not matched by a single ."); +assert(re1.test("\n"), "Pattern character '.' still should match line terminators in modified group"); +assert(re1.test("\r"), "Pattern character '.' still should match line terminators in modified group"); +assert(re1.test("\u2028"), "Pattern character '.' still should match line terminators in modified group"); +assert(re1.test("\u2029"), "Pattern character '.' still should match line terminators in modified group"); +assert(re1.test("\uD800"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re1.test("\uDFFF"), "Pattern character '.' still should match non-line terminators in modified group"); + +var re2 = new RegExp(/(?-s:^.$)/, "s"); +assert(re2.test("a"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re2.test("3"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re2.test("π"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re2.test("\u2027"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re2.test("\u0085"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re2.test("\v"), "Pattern character '.' still should match mon-line terminators in modified group"); +assert(re2.test("\f"), "Pattern character '.' still should match mon-line terminators in modified group"); +assert(re2.test("\u180E"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(!re2.test("\u{10300}"), "Supplementary plane still not matched by a single ."); +assert(!re2.test("\n"), "Pattern character '.' still should not match '\\n' in modified group"); +assert(!re2.test("\r"), "Pattern character '.' still should not match '\\r' in modified group"); +assert(!re2.test("\u2028"), "Pattern character '.' still should not match '\\u2028' in modified group"); +assert(!re2.test("\u2029"), "Pattern character '.' still should not match '\\u2029' in modified group"); +assert(re2.test("\uD800"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re2.test("\uDFFF"), "Pattern character '.' still should match non-line terminators in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-ignoreCase-flag-does-not-affect-ignoreCase-modifier.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-ignoreCase-flag-does-not-affect-ignoreCase-modifier.js new file mode 100644 index 0000000000..8db72f0742 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-ignoreCase-flag-does-not-affect-ignoreCase-modifier.js @@ -0,0 +1,55 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + New ignoreCase (`i`) flag from RegExp constructor does not affect ignoreCase modifier in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = new RegExp(/(?i:aB)/i, ""); +assert(re1.test("AB"), "still should ignore case in modified group"); +assert(re1.test("Ab"), "still should ignore case in modified group"); +assert(re1.test("aB"), "still should ignore case in modified group"); +assert(re1.test("ab"), "still should ignore case in modified group"); + +var re2 = new RegExp(/(?-i:aB)/, "i"); +assert(!re2.test("AB"), "still should preserve case in modified group"); +assert(!re2.test("Ab"), "still should preserve case in modified group"); +assert(!re2.test("ab"), "still should preserve case in modified group"); +assert(re2.test("aB"), "still should preserve case in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-multiline-flag-does-not-affect-multiline-modifier.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-multiline-flag-does-not-affect-multiline-modifier.js new file mode 100644 index 0000000000..b890200b21 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-multiline-flag-does-not-affect-multiline-modifier.js @@ -0,0 +1,51 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + New multiline (`m`) flag from RegExp constructor does not affect multiline modifier in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = new RegExp(/(?m:es$)/m, ""); +assert(re1.test("es"), "$ still should match end of input in modified group"); +assert(re1.test("es\ns"), "$ still should match newline in modified group"); + +var re2 = new RegExp(/^(?-m:es$)/, "m"); +assert(re2.test("es"), "$ still should match end of input in modified group"); +assert(!re2.test("es\ns"), "$ still should not match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nested-add-remove-modifiers.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nested-add-remove-modifiers.js new file mode 100644 index 0000000000..f2e1052643 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nested-add-remove-modifiers.js @@ -0,0 +1,45 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers can be nested. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?m:^(?-i:a)$)/i; +assert(!re1.test("A\n"), "Should not match 'A\\n'"); +assert(re1.test("a\n"), "Should match 'a\\n'"); + +var re2 = new RegExp("(?m:^(?-i:a)$)", "i"); +assert(!re2.test("A\n"), "Should not match 'A\\n'"); +assert(re2.test("a\n"), "Should match 'a\\n'"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-dotAll-within-remove-dotAll.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-dotAll-within-remove-dotAll.js new file mode 100644 index 0000000000..26b7d760b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-dotAll-within-remove-dotAll.js @@ -0,0 +1,71 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Can add multiline (`m`) modifier for group nested within a group that removes multiline modifier. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-s:(?s:^.$))/s; +assert(re1.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re1.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re1.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re1.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(re1.test("\n"), "Pattern character '.' should match line terminators in modified group"); +assert(re1.test("\r"), "Pattern character '.' should match line terminators in modified group"); +assert(re1.test("\u2028"), "Pattern character '.' should match line terminators in modified group"); +assert(re1.test("\u2029"), "Pattern character '.' should match line terminators in modified group"); +assert(re1.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +var re2 = /(?-s:(?s-:^.$))/s; +assert(re2.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re2.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re2.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re2.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(re2.test("\n"), "Pattern character '.' should match line terminators in modified group"); +assert(re2.test("\r"), "Pattern character '.' should match line terminators in modified group"); +assert(re2.test("\u2028"), "Pattern character '.' should match line terminators in modified group"); +assert(re2.test("\u2029"), "Pattern character '.' should match line terminators in modified group"); +assert(re2.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-ignoreCase-within-remove-ignoreCase.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-ignoreCase-within-remove-ignoreCase.js new file mode 100644 index 0000000000..04103802c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-ignoreCase-within-remove-ignoreCase.js @@ -0,0 +1,45 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Can add ignoreCase (`i`) modifier for group nested within a group that removes ignoreCase modifier. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:a(?i:b))c/i; +assert(!re1.test("ABC"), "a should not match A in ABC"); +assert(!re1.test("ABc"), "a should not match A in ABc"); +assert(!re1.test("Abc"), "a should not match A in Abc"); +assert(re1.test("aBc"), "b should match B in aBc"); +assert(re1.test("abC"), "c should match C in abC"); +assert(re1.test("abc"), "should match abc"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-multiline-within-remove-multiline.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-multiline-within-remove-multiline.js new file mode 100644 index 0000000000..dcf7504067 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-multiline-within-remove-multiline.js @@ -0,0 +1,47 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Can add multiline (`m`) modifier for group nested within a group that removes multiline modifier. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-m:es(?m:$)|js$)/m; +assert(re1.test("es\ns"), "$ should match newline in modified group"); +assert(re1.test("js"), "$ should match end of input in nested modified group"); +assert(!re1.test("js\ns"), "$ should not match newline in nested modified group"); + +var re2 = /(?-m:es(?m-:$)|js$)/m; +assert(re2.test("es\ns"), "$ should match newline in modified group"); +assert(re2.test("js"), "$ should match end of input in nested modified group"); +assert(!re2.test("js\ns"), "$ should not match newline in nested modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-dotAll-within-add-dotAll.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-dotAll-within-add-dotAll.js new file mode 100644 index 0000000000..e62290bedd --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-dotAll-within-add-dotAll.js @@ -0,0 +1,71 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Can remove multiline (`m`) modifier for group nested within a group that adds multiline modifier. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?s:(?-s:^.$))/; +assert(re1.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re1.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re1.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re1.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(!re1.test("\n"), "Pattern character '.' should not match '\\n' in modified group"); +assert(!re1.test("\r"), "Pattern character '.' should not match '\\r' in modified group"); +assert(!re1.test("\u2028"), "Pattern character '.' should not match '\\u2028' in modified group"); +assert(!re1.test("\u2029"), "Pattern character '.' should not match '\\u2029' in modified group"); +assert(re1.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +var re2 = /(?s-:(?-s:^.$))/; +assert(re2.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re2.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re2.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re2.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(!re2.test("\n"), "Pattern character '.' should not match '\\n' in modified group"); +assert(!re2.test("\r"), "Pattern character '.' should not match '\\r' in modified group"); +assert(!re2.test("\u2028"), "Pattern character '.' should not match '\\u2028' in modified group"); +assert(!re2.test("\u2029"), "Pattern character '.' should not match '\\u2029' in modified group"); +assert(re2.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-ignoreCase-within-add-ignoreCase.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-ignoreCase-within-add-ignoreCase.js new file mode 100644 index 0000000000..6b260ab2cc --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-ignoreCase-within-add-ignoreCase.js @@ -0,0 +1,45 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Can remove ignoreCase (`i`) modifier for group nested within a group that adds ignoreCase modifier. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:a(?i:b))c/i; +assert(!re1.test("ABC"), "a should not match A in ABC"); +assert(!re1.test("ABc"), "a should not match A in ABc"); +assert(!re1.test("Abc"), "a should not match A in Abc"); +assert(re1.test("aBc"), "b should match B in aBc"); +assert(re1.test("abC"), "c should match C in abC"); +assert(re1.test("abc"), "should match abc"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-multiline-within-add-multiline.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-multiline-within-add-multiline.js new file mode 100644 index 0000000000..b7aa1b9895 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-multiline-within-add-multiline.js @@ -0,0 +1,47 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Can remove multiline (`m`) modifier for group nested within a group that adds multiline modifier. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?m:es$|(?-m:js$))/; +assert(re1.test("es\ns"), "first $ should match newline in modified group"); +assert(re1.test("js"), "second $ should match end of input in nested modified group"); +assert(!re1.test("js\ns"), "second $ should not match newline in nested modified group"); + +var re2 = /(?m-:es$|(?-m:js$))/; +assert(re2.test("es\ns"), "first $ should match newline in modified group"); +assert(re2.test("js"), "second $ should match end of input in nested modified group"); +assert(!re2.test("js\ns"), "second $ should not match newline in nested modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-dotAll-property.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-dotAll-property.js new file mode 100644 index 0000000000..23e607be8d --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-dotAll-property.js @@ -0,0 +1,43 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing dotAll (`s`) modifier does not affect RegExp instance `dotAll` property. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-s:^.$)/s; +assert(re1.dotAll, "RegExp instance dotAll flag should still be set"); + +var re2 = new RegExp("(?-s:^.$)", "s"); +assert(re2.dotAll, "RegExp instance dotAll flag should still be set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-ignoreCase-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-ignoreCase-flag.js new file mode 100644 index 0000000000..2ccd21b4e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-ignoreCase-flag.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing dotAll (`s`) modifier in group should not affect ignoreCase (`i`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-s:.es)/s; +assert(re1.test("aes"), "s should match s in modified group"); +assert(!re1.test("aeS"), "s should not match S in modified group"); +assert(!re1.test("\nes"), ". should not match newline in modified group"); +assert(!re1.test("\neS"), ". should not match newline in modified group"); + +var re2 = /(?-s:.es)/si; +assert(re2.test("aes"), "s should match s in modified group"); +assert(re2.test("aeS"), "s should match S in modified group"); +assert(!re2.test("\nes"), ". should not match newline in modified group"); +assert(!re2.test("\neS"), ". should not match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-multiline-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-multiline-flag.js new file mode 100644 index 0000000000..1f73afc52c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-multiline-flag.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing dotAll (`s`) modifier in group should not affect multiline (`m`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-s:.es$)/s; +assert(re1.test("aes"), ". should match a in modified group"); +assert(!re1.test("aes\nz"), "$ should not match newline in modified group"); +assert(!re1.test("\nes"), ". should not match newline in modified group"); +assert(!re1.test("\nes\nz"), "$ should not match newline in modified group"); + +var re2 = /(?-s:.es$)/sm; +assert(re2.test("aes"), ". should match a in modified group"); +assert(re2.test("aes\nz"), "$ should match newline in modified group"); +assert(!re2.test("\nes"), ". should not match newline in modified group"); +assert(!re2.test("\nes\nz"), ". should not match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll.js new file mode 100644 index 0000000000..8abed77808 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll.js @@ -0,0 +1,71 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + dotAll (`s`) modifier can be added via `(?s:)` or `(?s-:)`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-s:^.$)/s; +assert(re1.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re1.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re1.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re1.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(!re1.test("\n"), "Pattern character '.' should not match '\\n' in modified group"); +assert(!re1.test("\r"), "Pattern character '.' should not match '\\r' in modified group"); +assert(!re1.test("\u2028"), "Pattern character '.' should not match '\\u2028' in modified group"); +assert(!re1.test("\u2029"), "Pattern character '.' should not match '\\u2029' in modified group"); +assert(re1.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +var re2 = new RegExp("(?-s:^.$)", "s"); +assert(re2.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re2.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re2.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re2.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(!re2.test("\n"), "Pattern character '.' should not match '\\n' in modified group"); +assert(!re2.test("\r"), "Pattern character '.' should not match '\\r' in modified group"); +assert(!re2.test("\u2028"), "Pattern character '.' should not match '\\u2028' in modified group"); +assert(!re2.test("\u2029"), "Pattern character '.' should not match '\\u2029' in modified group"); +assert(re2.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-backreferences.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-backreferences.js new file mode 100644 index 0000000000..1d1767651b --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-backreferences.js @@ -0,0 +1,43 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier in group affects backreferences in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(a)(?-i:\1)/i; +assert(re1.test("AA"), "a matches first A, so \\1 should match second A"); +assert(!re1.test("aA"), "a matches a, so \\1 should not match A (preserves case)"); +assert(!re1.test("Aa"), "a matches A, so \\1 should not match a (preserves case)"); +assert(re1.test("aa"), "a matches first a, so \\1 should match second a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-characterClasses.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-characterClasses.js new file mode 100644 index 0000000000..fbe2d16256 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-characterClasses.js @@ -0,0 +1,55 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier in group affects character classes in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:[ab])c/i; +assert(re1.test("ac"), "[ab] should match a"); +assert(!re1.test("Ac"), "[ab] should not match A"); +assert(re1.test("bc"), "[ab] should match b"); +assert(!re1.test("Bc"), "[ab] should not match B"); + +var re2 = /(?-i:[^ab])c/i; +assert(!re2.test("ac"), "[^ab] should not match a"); +assert(re2.test("Ac"), "[^ab] should match A"); +assert(!re2.test("bc"), "[^ab] should not match b"); +assert(re2.test("Bc"), "[^ab] should match B"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-characterEscapes.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-characterEscapes.js new file mode 100644 index 0000000000..1edb2d2124 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-characterEscapes.js @@ -0,0 +1,52 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier in group affects character escapes in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:\x61)b/i; +assert(re1.test("ab"), "\\x61 should match a"); +assert(re1.test("aB"), "b should match B"); +assert(!re1.test("Ab"), "\\x61 should not match A"); + +var re2 = /(?-i:\u0061)b/i; +assert(re2.test("ab"), "\\u0061 should match a"); +assert(re2.test("aB"), "b should match B"); +assert(!re2.test("Ab"), "\\u0061 should not match A"); + +var re3 = /(?-i:\u{0061})b/iu; +assert(re3.test("ab"), "\\u0061 should match a"); +assert(re3.test("aB"), "b should match B"); +assert(!re3.test("Ab"), "\\u0061 should not match A"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-b.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-b.js new file mode 100644 index 0000000000..b8b51d794b --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-b.js @@ -0,0 +1,53 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier affects matching for `\b`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:\b)/ui; +assert(!re1.test("\u017f"), "\\b should not match after \u017f"); +assert(!re1.test("\u212a"), "\\b should not match after \u212a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-p.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-p.js new file mode 100644 index 0000000000..2a0167b689 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-p.js @@ -0,0 +1,55 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier affects matching for `\p{}`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:\p{Lu})/ui; +assert(re1.test("A"), "\\p{Lu} should match A"); +assert(!re1.test("a"), "\\p{Lu} should not match a"); +assert(re1.test("Z"), "\\p{Lu} should match Z"); +assert(!re1.test("z"), "\\p{Lu} should not match z"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-w.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-w.js new file mode 100644 index 0000000000..e8686f2e9d --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-w.js @@ -0,0 +1,53 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier affects matching for `\w`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:\w)/ui; +assert(!re1.test("\u017f"), "\\w should not match \u017f"); +assert(!re1.test("\u212a"), "\\w should not match \u212a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-b.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-b.js new file mode 100644 index 0000000000..9ed611bbe9 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-b.js @@ -0,0 +1,53 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier affects matching for `\B`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:Z\B)/ui; +assert(!re1.test("Z\u017f"), "\\B should not match between Z and \u017f"); +assert(!re1.test("Z\u212a"), "\\B should not match between Z and \u212a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-p.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-p.js new file mode 100644 index 0000000000..c764e66610 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-p.js @@ -0,0 +1,56 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier affects matching for `\P{}`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:\P{Lu})/ui; +assert(!re1.test("A"), "\\P{Lu} should not match A"); +assert(re1.test("a"), "\\P{Lu} should match a"); +assert(!re1.test("Z"), "\\P{Lu} should not match Z"); +assert(re1.test("z"), "\\P{Lu} should match z"); +assert(re1.test("0"), "\\P{Lu} should match 0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-w.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-w.js new file mode 100644 index 0000000000..fe2a24a2a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-w.js @@ -0,0 +1,53 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier affects matching for `\W`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:\W)/ui; +assert(re1.test("\u017f"), "\\W should match \u017f"); +assert(re1.test("\u212a"), "\\W should match \u212a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-dotAll-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-dotAll-flag.js new file mode 100644 index 0000000000..f66c8f0857 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-dotAll-flag.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier in group should not affect dotAll (`s`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:.es)/i; +assert(re1.test("aes"), "s should match s in modified group"); +assert(!re1.test("aeS"), "s should not match S in modified group"); +assert(!re1.test("\nes"), ". should not match newline in modified group"); +assert(!re1.test("\neS"), ". should not match newline in modified group"); + +var re2 = /(?-i:.es)/is; +assert(re2.test("aes"), "s should match s in modified group"); +assert(!re2.test("aeS"), "s should not match S in modified group"); +assert(re2.test("\nes"), ". should match newline in modified group"); +assert(!re2.test("\neS"), "s should not match S in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-ignoreCase-property.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-ignoreCase-property.js new file mode 100644 index 0000000000..4b68807d35 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-ignoreCase-property.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier does not affect RegExp instance `ignoreCase` property. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:)/i; +assert(re1.ignoreCase, "RegExp instance ignoreCase property should still be set"); + +var re2 = new RegExp("(?-i:)", "i"); +assert(re2.ignoreCase, "RegExp instance ignoreCase property should still be set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-multiline-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-multiline-flag.js new file mode 100644 index 0000000000..26bc3278b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-multiline-flag.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier in group should not affect multiline (`m`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:es$)/i; +assert(re1.test("es"), "s should match s in modified group"); +assert(!re1.test("eS"), "s should not match S in modified group"); +assert(!re1.test("es\nz"), "$ should not match newline in modified group"); +assert(!re1.test("eS\nz"), "s should not match S in modified group"); + +var re2 = /(?-i:es$)/im; +assert(re2.test("es"), "s should match s in modified group"); +assert(!re2.test("eS"), "s should not match S in modified group"); +assert(re2.test("es\nz"), "$ should match newline in modified group"); +assert(!re2.test("eS\nz"), "s should not match S in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase.js new file mode 100644 index 0000000000..87fa013049 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + ignoreCase (`i`) modifier can be removed via `(?i:)` or `(?i-:)`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:fo)o/i; +assert(!re1.test("FOO"), "Pattern should not match as modified group does not ignore case"); +assert(!re1.test("FOo"), "Pattern should not match as modified group does not ignore case"); +assert(re1.test("foo"), "Pattern should not ignore case in modified group"); +assert(re1.test("foO"), "Pattern should not ignore case in modified group"); + +var re2 = new RegExp("(?-i:fo)o", "i"); +assert(!re2.test("FOO"), "Pattern should not match as modified group does not ignore case"); +assert(!re2.test("FOo"), "Pattern should not match as modified group does not ignore case"); +assert(re2.test("foo"), "Pattern should not ignore case in modified group"); +assert(re2.test("foO"), "Pattern should not ignore case in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-dotAll-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-dotAll-flag.js new file mode 100644 index 0000000000..b28b545cc0 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-dotAll-flag.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing multiline (`m`) modifier in group should not affect dotAll (`s`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-m:es.$)/m; +assert(re1.test("esz"), ". should match z in modified group"); +assert(!re1.test("es\n"), ". should not match newline in modified group"); +assert(!re1.test("esz\n"), "$ should not match newline in modified group"); +assert(!re1.test("es\n\n"), "$ should not match newline in modified group"); + +var re2 = /(?-m:es.$)/ms; +assert(re2.test("esz"), ". should match z in modified group"); +assert(re2.test("es\n"), ". should match newline in modified group"); +assert(!re2.test("esz\n"), "$ should not match newline in modified group"); +assert(!re2.test("es\n\n"), "$ should not match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-ignoreCase-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-ignoreCase-flag.js new file mode 100644 index 0000000000..a482105dee --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-ignoreCase-flag.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing multiline (`m`) modifier in group should not affect ignoreCase (`i`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-m:es$)/m; +assert(re1.test("es"), "s should match s in modified group"); +assert(!re1.test("eS"), "s should not match S in modified group"); +assert(!re1.test("es\nz"), "$ should not match newline in modified group"); +assert(!re1.test("eS\nz"), "s should not match S in modified group"); + +var re2 = /(?-m:es$)/mi; +assert(re2.test("es"), "s should match s in modified group"); +assert(re2.test("eS"), "s should match S in modified group"); +assert(!re2.test("es\nz"), "$ should not match newline in modified group"); +assert(!re2.test("eS\nz"), "$ should not match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-multiline-property.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-multiline-property.js new file mode 100644 index 0000000000..885ae9b242 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-multiline-property.js @@ -0,0 +1,43 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing multiline (`m`) modifier does not affect RegExp instance `multiline` property. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-m:)/m; +assert(re1.multiline, "RegExp instance multiline flag should still be set"); + +var re2 = new RegExp("(?-m:)", "m"); +assert(re2.multiline, "RegExp instance multiline flag should still be set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline.js new file mode 100644 index 0000000000..730888a662 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline.js @@ -0,0 +1,45 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + multiline (`m`) modifier can be removed via `(?-m:)`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /^(?-m:es$)/m; +assert(!re1.test("\nes\ns"), "$ should not match newline in modified group"); +assert(re1.test("\nes"), "$ should match end of input in modified group"); + +var re2 = new RegExp("^(?-m:es$)", "m"); +assert(!re2.test("\nes\ns"), "$ should not match newline in modified group"); +assert(re2.test("\nes"), "$ should match end of input in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/shell.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/shell.js diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/browser.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/browser.js diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/shell.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/shell.js diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-and-remove-modifiers-can-have-empty-remove-modifiers.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-and-remove-modifiers-can-have-empty-remove-modifiers.js new file mode 100644 index 0000000000..9d5fd6c879 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-and-remove-modifiers-can-have-empty-remove-modifiers.js @@ -0,0 +1,68 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers syntax `(?ims-:)` is legal. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +/(?i-:)/; +/(?is-:)/; +/(?im-:)/; +/(?s-:)/; +/(?si-:)/; +/(?sm-:)/; +/(?m-:)/; +/(?mi-:)/; +/(?ms-:)/; +/(?ims-:)/; +/(?ism-:)/; +/(?sim-:)/; +/(?smi-:)/; +/(?mis-:)/; +/(?msi-:)/; +new RegExp("(?i-:)"); +new RegExp("(?is-:)"); +new RegExp("(?im-:)"); +new RegExp("(?s-:)"); +new RegExp("(?si-:)"); +new RegExp("(?sm-:)"); +new RegExp("(?m-:)"); +new RegExp("(?mi-:)"); +new RegExp("(?ms-:)"); +new RegExp("(?ims-:)"); +new RegExp("(?ism-:)"); +new RegExp("(?sim-:)"); +new RegExp("(?smi-:)"); +new RegExp("(?mis-:)"); +new RegExp("(?msi-:)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-and-remove-modifiers.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-and-remove-modifiers.js new file mode 100644 index 0000000000..728d47d3a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-and-remove-modifiers.js @@ -0,0 +1,74 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers syntax `(?im-s:)` (and similar) is legal, as long as they do not overlap. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +/(?i-s:)/; +/(?i-sm:)/; +/(?i-m:)/; +/(?i-ms:)/; +/(?s-i:)/; +/(?s-im:)/; +/(?s-m:)/; +/(?s-mi:)/; +/(?m-i:)/; +/(?m-is:)/; +/(?m-s:)/; +/(?m-si:)/; +/(?is-m:)/; +/(?im-s:)/; +/(?si-m:)/; +/(?sm-i:)/; +/(?mi-s:)/; +/(?ms-i:)/; +new RegExp("(?i-s:)"); +new RegExp("(?i-sm:)"); +new RegExp("(?i-m:)"); +new RegExp("(?i-ms:)"); +new RegExp("(?s-i:)"); +new RegExp("(?s-im:)"); +new RegExp("(?s-m:)"); +new RegExp("(?s-mi:)"); +new RegExp("(?m-i:)"); +new RegExp("(?m-is:)"); +new RegExp("(?m-s:)"); +new RegExp("(?m-si:)"); +new RegExp("(?is-m:)"); +new RegExp("(?im-s:)"); +new RegExp("(?si-m:)"); +new RegExp("(?sm-i:)"); +new RegExp("(?mi-s:)"); +new RegExp("(?ms-i:)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-nested.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-nested.js new file mode 100644 index 0000000000..278633d304 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-nested.js @@ -0,0 +1,44 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers syntax `(?ims:)` is legal, even when modifiers are already set via an outer non-capturing group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +/(?i:(?i:))/; +/(?s:(?s:))/; +/(?m:(?m:))/; +new RegExp("(?i:(?i:))"); +new RegExp("(?s:(?s:))"); +new RegExp("(?m:(?m:))"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-not-set-as-flags.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-not-set-as-flags.js new file mode 100644 index 0000000000..e288c833c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-not-set-as-flags.js @@ -0,0 +1,68 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers syntax `(?ims:)` is legal. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +/(?i:)/; +/(?is:)/; +/(?im:)/; +/(?s:)/; +/(?si:)/; +/(?sm:)/; +/(?m:)/; +/(?mi:)/; +/(?ms:)/; +/(?ims:)/; +/(?ism:)/; +/(?sim:)/; +/(?smi:)/; +/(?mis:)/; +/(?msi:)/; +new RegExp("(?i:)"); +new RegExp("(?is:)"); +new RegExp("(?im:)"); +new RegExp("(?s:)"); +new RegExp("(?si:)"); +new RegExp("(?sm:)"); +new RegExp("(?m:)"); +new RegExp("(?mi:)"); +new RegExp("(?ms:)"); +new RegExp("(?ims:)"); +new RegExp("(?ism:)"); +new RegExp("(?sim:)"); +new RegExp("(?smi:)"); +new RegExp("(?mis:)"); +new RegExp("(?msi:)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-set-as-flags.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-set-as-flags.js new file mode 100644 index 0000000000..f1d5cedc83 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-set-as-flags.js @@ -0,0 +1,46 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers syntax `(?ims:)` is legal, even when modifiers are already set via flags. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +/(?i:)/i; +/(?s:)/s; +/(?m:)/m; +/(?ims:)/ims; +new RegExp("(?i:)", "i"); +new RegExp("(?s:)", "s"); +new RegExp("(?m:)", "m"); +new RegExp("(?ims:)", "ims"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/browser.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/browser.js diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-nested.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-nested.js new file mode 100644 index 0000000000..90d5e5e606 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-nested.js @@ -0,0 +1,44 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers syntax `(?-ims:)` is legal, even when modifiers are already cleared via an outer non-capturing group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +/(?-i:(?-i:))/; +/(?-s:(?-s:))/; +/(?-m:(?-m:))/; +new RegExp("(?-i:(?-i:))"); +new RegExp("(?-s:(?-s:))"); +new RegExp("(?-m:(?-m:))"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-not-set-as-flags.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-not-set-as-flags.js new file mode 100644 index 0000000000..397e94ce6b --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-not-set-as-flags.js @@ -0,0 +1,68 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers syntax `(?-ims:)` is legal, even when not set as flags. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +/(?-i:)/; +/(?-is:)/; +/(?-im:)/; +/(?-s:)/; +/(?-si:)/; +/(?-sm:)/; +/(?-m:)/; +/(?-mi:)/; +/(?-ms:)/; +/(?-ims:)/; +/(?-ism:)/; +/(?-smi:)/; +/(?-sim:)/; +/(?-mis:)/; +/(?-msi:)/; +new RegExp("(?-i:)"); +new RegExp("(?-is:)"); +new RegExp("(?-im:)"); +new RegExp("(?-s:)"); +new RegExp("(?-si:)"); +new RegExp("(?-sm:)"); +new RegExp("(?-m:)"); +new RegExp("(?-mi:)"); +new RegExp("(?-ms:)"); +new RegExp("(?-ims:)"); +new RegExp("(?-ism:)"); +new RegExp("(?-smi:)"); +new RegExp("(?-sim:)"); +new RegExp("(?-mis:)"); +new RegExp("(?-msi:)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-set-as-flags.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-set-as-flags.js new file mode 100644 index 0000000000..1b96c747a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-set-as-flags.js @@ -0,0 +1,68 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers syntax `(?-ims:)` is legal. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +/(?-i:)/i; +/(?-is:)/is; +/(?-im:)/im; +/(?-s:)/s; +/(?-si:)/si; +/(?-sm:)/sm; +/(?-m:)/m; +/(?-mi:)/mi; +/(?-ms:)/ms; +/(?-ims:)/ims; +/(?-ism:)/ism; +/(?-sim:)/sim; +/(?-smi:)/smi; +/(?-mis:)/mis; +/(?-msi:)/msi; +new RegExp("(?-i:)", "i"); +new RegExp("(?-is:)", "is"); +new RegExp("(?-im:)", "im"); +new RegExp("(?-s:)", "s"); +new RegExp("(?-si:)", "si"); +new RegExp("(?-sm:)", "sm"); +new RegExp("(?-m:)", "m"); +new RegExp("(?-mi:)", "mi"); +new RegExp("(?-ms:)", "ms"); +new RegExp("(?-ims:)", "ims"); +new RegExp("(?-ism:)", "ism"); +new RegExp("(?-sim:)", "sim"); +new RegExp("(?-smi:)", "smi"); +new RegExp("(?-mis:)", "mis"); +new RegExp("(?-msi:)", "msi"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/shell.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/shell.js diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-i.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-i.js new file mode 100644 index 0000000000..36e5757c2c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?i-i:a)", ""); +}, 'RegExp("(?i-i:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-m.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-m.js new file mode 100644 index 0000000000..96df538289 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-m.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?m-m:a)", ""); +}, 'RegExp("(?m-m:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-multi-duplicate.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-multi-duplicate.js new file mode 100644 index 0000000000..c566dd7a84 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-multi-duplicate.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?ims-m:a)", ""); +}, 'RegExp("(?ims-m:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-s-escape.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-s-escape.js new file mode 100644 index 0000000000..3efc2308c1 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-s-escape.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?\u{0073}-s:a)", ""); +}, 'RegExp("(?\u{0073}-s:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-s.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-s.js new file mode 100644 index 0000000000..b745f7f6aa --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s-s:a)", ""); +}, 'RegExp("(?s-s:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-both-empty.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-both-empty.js new file mode 100644 index 0000000000..5ce55095fc --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-both-empty.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by the first RegularExpressionFlags and the source text matched by the second RegularExpressionFlags are both empty. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-:a)", ""); +}, 'RegExp("(?-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-code-point-repeat-i-1.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-code-point-repeat-i-1.js new file mode 100644 index 0000000000..3aa6a30d89 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-code-point-repeat-i-1.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-ii:a)", ""); +}, 'RegExp("(?-ii:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-code-point-repeat-i-2.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-code-point-repeat-i-2.js new file mode 100644 index 0000000000..d494df0113 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-code-point-repeat-i-2.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-imsi:a)", ""); +}, 'RegExp("(?-imsi:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-arbitrary.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-arbitrary.js new file mode 100644 index 0000000000..f5e3b26dd1 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-arbitrary.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-1:a)", ""); +}, 'RegExp("(?-1:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-i.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-i.js new file mode 100644 index 0000000000..8a2eb982b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-iͥ:a)", ""); +}, 'RegExp("(?-iͥ:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-m.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-m.js new file mode 100644 index 0000000000..086271affb --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-m.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-mͫ:a)", ""); +}, 'RegExp("(?-mͫ:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-s.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-s.js new file mode 100644 index 0000000000..ccf4152844 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-s̀:a)", ""); +}, 'RegExp("(?-s̀:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-d.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-d.js new file mode 100644 index 0000000000..c8ee295463 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-d.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-d:a)", ""); +}, 'RegExp("(?-d:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-g.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-g.js new file mode 100644 index 0000000000..9e52eb067f --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-g.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-g:a)", ""); +}, 'RegExp("(?-g:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-display-1.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-display-1.js Binary files differnew file mode 100644 index 0000000000..8ae9398003 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-display-1.js diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-display-2.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-display-2.js new file mode 100644 index 0000000000..888fd17adc --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-display-2.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-s:a)", ""); +}, 'RegExp("(?-s:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-flag.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-flag.js new file mode 100644 index 0000000000..fa899733ff --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-flag.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-Q:a)", ""); +}, 'RegExp("(?-Q:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-u.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-u.js new file mode 100644 index 0000000000..9174df4eaa --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-u.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-u:a)", ""); +}, 'RegExp("(?-u:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-uppercase-I.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-uppercase-I.js new file mode 100644 index 0000000000..f51bdcd561 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-uppercase-I.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-I:a)", ""); +}, 'RegExp("(?-I:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-y.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-y.js new file mode 100644 index 0000000000..c5f981ef7b --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-y.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-y:a)", ""); +}, 'RegExp("(?-y:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwj.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwj.js new file mode 100644 index 0000000000..6dc54400f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwj.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-s:a)", ""); +}, 'RegExp("(?-s:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwnbsp.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwnbsp.js new file mode 100644 index 0000000000..626fcead1b --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwnbsp.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-s:a)", ""); +}, 'RegExp("(?-s:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwnj.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwnj.js new file mode 100644 index 0000000000..eac16a0439 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwnj.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-s:a)", ""); +}, 'RegExp("(?-s:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-i.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-i.js new file mode 100644 index 0000000000..36e5757c2c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?i-i:a)", ""); +}, 'RegExp("(?i-i:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-m.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-m.js new file mode 100644 index 0000000000..96df538289 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-m.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?m-m:a)", ""); +}, 'RegExp("(?m-m:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-multi-duplicate.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-multi-duplicate.js new file mode 100644 index 0000000000..8e9c608e4a --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-multi-duplicate.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?m-ims:a)", ""); +}, 'RegExp("(?m-ims:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-s-escape.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-s-escape.js new file mode 100644 index 0000000000..3bb3e4a89f --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-s-escape.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s-\u{0073}:a)", ""); +}, 'RegExp("(?s-\u{0073}:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-s.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-s.js new file mode 100644 index 0000000000..b745f7f6aa --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s-s:a)", ""); +}, 'RegExp("(?s-s:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-code-point-repeat-i-1.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-code-point-repeat-i-1.js new file mode 100644 index 0000000000..1aee0a56f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-code-point-repeat-i-1.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?ii-:a)", ""); +}, 'RegExp("(?ii-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-code-point-repeat-i-2.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-code-point-repeat-i-2.js new file mode 100644 index 0000000000..8ae4960441 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-code-point-repeat-i-2.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?imsi-:a)", ""); +}, 'RegExp("(?imsi-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-arbitrary.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-arbitrary.js new file mode 100644 index 0000000000..70e24b4e22 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-arbitrary.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?1-:a)", ""); +}, 'RegExp("(?1-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-i.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-i.js new file mode 100644 index 0000000000..7cf8d11d2c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?iͥ-:a)", ""); +}, 'RegExp("(?iͥ-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-m.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-m.js new file mode 100644 index 0000000000..5023bcb573 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-m.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?mͫ-:a)", ""); +}, 'RegExp("(?mͫ-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-s.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-s.js new file mode 100644 index 0000000000..f2edc9f211 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s̀-:a)", ""); +}, 'RegExp("(?s̀-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-d.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-d.js new file mode 100644 index 0000000000..ccbda94c89 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-d.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?d-:a)", ""); +}, 'RegExp("(?d-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-g.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-g.js new file mode 100644 index 0000000000..f89699072b --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-g.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?g-:a)", ""); +}, 'RegExp("(?g-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-display-1.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-display-1.js Binary files differnew file mode 100644 index 0000000000..16c0162a9a --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-display-1.js diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-display-2.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-display-2.js new file mode 100644 index 0000000000..9b8d348b31 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-display-2.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s-:a)", ""); +}, 'RegExp("(?s-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-flag.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-flag.js new file mode 100644 index 0000000000..d52249217c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-flag.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?Q-:a)", ""); +}, 'RegExp("(?Q-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-u.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-u.js new file mode 100644 index 0000000000..1f7d261897 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-u.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?u-:a)", ""); +}, 'RegExp("(?u-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-uppercase-I.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-uppercase-I.js new file mode 100644 index 0000000000..a9d284f5c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-uppercase-I.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?I-:a)", ""); +}, 'RegExp("(?I-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-y.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-y.js new file mode 100644 index 0000000000..bc13bdfb1c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-y.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?y-:a)", ""); +}, 'RegExp("(?y-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwj.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwj.js new file mode 100644 index 0000000000..4b16df3743 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwj.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s-:a)", ""); +}, 'RegExp("(?s-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwnbsp.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwnbsp.js new file mode 100644 index 0000000000..f1a4373aef --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwnbsp.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s-:a)", ""); +}, 'RegExp("(?s-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwnj.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwnj.js new file mode 100644 index 0000000000..11c119eae4 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwnj.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s-:a)", ""); +}, 'RegExp("(?s-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-i.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-i.js new file mode 100644 index 0000000000..667d2408bb --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?I-:a)", "i"); +}, 'RegExp("(?I-:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-m.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-m.js new file mode 100644 index 0000000000..4fb69935ed --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-m.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?M-:a)", "i"); +}, 'RegExp("(?M-:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-s.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-s.js new file mode 100644 index 0000000000..f678b0c532 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?S-:a)", "i"); +}, 'RegExp("(?S-:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-i.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-i.js new file mode 100644 index 0000000000..fedb79a4f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?İ-:a)", "iu"); +}, 'RegExp("(?İ-:a)", "iu"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-s.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-s.js new file mode 100644 index 0000000000..0cd8418bae --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?ſ-:a)", "u"); +}, 'RegExp("(?ſ-:a)", "u"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-i.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-i.js new file mode 100644 index 0000000000..4021cd675e --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-I:a)", "i"); +}, 'RegExp("(?-I:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-m.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-m.js new file mode 100644 index 0000000000..9dff9ce51a --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-m.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-M:a)", "i"); +}, 'RegExp("(?-M:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-s.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-s.js new file mode 100644 index 0000000000..0a78e61909 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-S:a)", "i"); +}, 'RegExp("(?-S:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-unicode-case-fold-i.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-unicode-case-fold-i.js new file mode 100644 index 0000000000..7f38b553f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-unicode-case-fold-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-İ:a)", "iu"); +}, 'RegExp("(?-İ:a)", "iu"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-unicode-case-fold-s.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-unicode-case-fold-s.js new file mode 100644 index 0000000000..f826ffe544 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-unicode-case-fold-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-ſ:a)", "u"); +}, 'RegExp("(?-ſ:a)", "u"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/length.js b/js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/length.js index da310cd3f2..552d81019e 100644 --- a/js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/length.js +++ b/js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/length.js @@ -26,10 +26,11 @@ features: [Symbol.matchAll] var RegExpStringIteratorProto = Object.getPrototypeOf(/./[Symbol.matchAll]('')); -assert.sameValue(RegExpStringIteratorProto.next.length, 0); - -verifyNotEnumerable(RegExpStringIteratorProto.next, 'length'); -verifyNotWritable(RegExpStringIteratorProto.next, 'length'); -verifyConfigurable(RegExpStringIteratorProto.next, 'length'); +verifyProperty(RegExpStringIteratorProto.next, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/name.js b/js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/name.js index bd178670f9..78fc8682dc 100644 --- a/js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/name.js +++ b/js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/name.js @@ -24,10 +24,11 @@ features: [Symbol.matchAll] var RegExpStringIteratorProto = Object.getPrototypeOf(/./[Symbol.matchAll]('')); -assert.sameValue(RegExpStringIteratorProto.next.name, 'next'); - -verifyNotEnumerable(RegExpStringIteratorProto.next, 'name'); -verifyNotWritable(RegExpStringIteratorProto.next, 'name'); -verifyConfigurable(RegExpStringIteratorProto.next, 'name'); +verifyProperty(RegExpStringIteratorProto.next, "name", { + value: "next", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/Symbol.species/length.js b/js/src/tests/test262/built-ins/Set/Symbol.species/length.js index a4fc6ac666..1620be6bb3 100644 --- a/js/src/tests/test262/built-ins/Set/Symbol.species/length.js +++ b/js/src/tests/test262/built-ins/Set/Symbol.species/length.js @@ -25,10 +25,11 @@ features: [Symbol.species] var desc = Object.getOwnPropertyDescriptor(Set, Symbol.species); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/length.js b/js/src/tests/test262/built-ins/Set/length.js index 7e42877423..6b1f4090c1 100644 --- a/js/src/tests/test262/built-ins/Set/length.js +++ b/js/src/tests/test262/built-ins/Set/length.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Set.length, 0, "The value of `Set.length` is `0`"); - -verifyNotEnumerable(Set, "length"); -verifyNotWritable(Set, "length"); -verifyConfigurable(Set, "length"); +verifyProperty(Set, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/name.js b/js/src/tests/test262/built-ins/Set/name.js index c4f6ac72ef..aefb516ac5 100644 --- a/js/src/tests/test262/built-ins/Set/name.js +++ b/js/src/tests/test262/built-ins/Set/name.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Set.name, "Set", "The value of `Set.name` is `'Set'`"); - -verifyNotEnumerable(Set, "name"); -verifyNotWritable(Set, "name"); -verifyConfigurable(Set, "name"); +verifyProperty(Set, "name", { + value: "Set", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/not-a-constructor.js index 8db788f9c0..62db65ee42 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let s = new Set([]); new s[Symbol.iterator](); -}, '`let s = new Set([]); new s[Symbol.iterator]()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/length.js b/js/src/tests/test262/built-ins/Set/prototype/add/length.js index 88b79c7dae..8b3ccae745 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/add/length.js +++ b/js/src/tests/test262/built-ins/Set/prototype/add/length.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Set.prototype.add.length, 1, "The value of `Set.prototype.add.length` is `1`"); - -verifyNotEnumerable(Set.prototype.add, "length"); -verifyNotWritable(Set.prototype.add, "length"); -verifyConfigurable(Set.prototype.add, "length"); +verifyProperty(Set.prototype.add, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/name.js b/js/src/tests/test262/built-ins/Set/prototype/add/name.js index f8f5441845..ae4e54bbe1 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/add/name.js +++ b/js/src/tests/test262/built-ins/Set/prototype/add/name.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Set.prototype.add.name, "add", "The value of `Set.prototype.add.name` is `'add'`"); - -verifyNotEnumerable(Set.prototype.add, "name"); -verifyNotWritable(Set.prototype.add, "name"); -verifyConfigurable(Set.prototype.add, "name"); +verifyProperty(Set.prototype.add, "name", { + value: "add", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/add/not-a-constructor.js index c1ba69377d..1b8d1af562 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/add/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Set/prototype/add/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Set.prototype.add), false, 'isConstructor(Set.pro assert.throws(TypeError, () => { let s = new Set([]); new s.add(); -}, '`let s = new Set([]); new s.add()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/length.js b/js/src/tests/test262/built-ins/Set/prototype/clear/length.js index 84e1dd1146..b275b85aa1 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/clear/length.js +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/length.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Set.prototype.clear.length, 0, "The value of `Set.prototype.clear.length` is `0`"); - -verifyNotEnumerable(Set.prototype.clear, "length"); -verifyNotWritable(Set.prototype.clear, "length"); -verifyConfigurable(Set.prototype.clear, "length"); +verifyProperty(Set.prototype.clear, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/name.js b/js/src/tests/test262/built-ins/Set/prototype/clear/name.js index 722a8af8f1..f6c25d3f21 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/clear/name.js +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/name.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Set.prototype.clear.name, "clear", "The value of `Set.prototype.clear.name` is `'clear'`"); - -verifyNotEnumerable(Set.prototype.clear, "name"); -verifyNotWritable(Set.prototype.clear, "name"); -verifyConfigurable(Set.prototype.clear, "name"); +verifyProperty(Set.prototype.clear, "name", { + value: "clear", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/clear/not-a-constructor.js index 16f0ebd97c..26e25a8d0f 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/clear/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Set.prototype.clear), false, 'isConstructor(Set.p assert.throws(TypeError, () => { let s = new Set([]); new s.clear(); -}, '`let s = new Set([]); new s.clear()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/length.js b/js/src/tests/test262/built-ins/Set/prototype/delete/length.js index 5d28a0ad40..491a0a7706 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/delete/length.js +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/length.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Set.prototype.delete.length, 1, "The value of `Set.prototype.delete.length` is `1`"); - -verifyNotEnumerable(Set.prototype.delete, "length"); -verifyNotWritable(Set.prototype.delete, "length"); -verifyConfigurable(Set.prototype.delete, "length"); +verifyProperty(Set.prototype.delete, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/name.js b/js/src/tests/test262/built-ins/Set/prototype/delete/name.js index 538d7b4370..e54dd71baf 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/delete/name.js +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/name.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Set.prototype.delete.name, "delete", "The value of `Set.prototype.delete.name` is `'delete'`"); - -verifyNotEnumerable(Set.prototype.delete, "name"); -verifyNotWritable(Set.prototype.delete, "name"); -verifyConfigurable(Set.prototype.delete, "name"); +verifyProperty(Set.prototype.delete, "name", { + value: "delete", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/delete/not-a-constructor.js index 3c978d44f0..401cff6bf7 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/delete/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Set.prototype.delete), false, 'isConstructor(Set. assert.throws(TypeError, () => { let s = new Set([]); new s.delete(); -}, '`let s = new Set([]); new s.delete()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/difference/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/difference/not-a-constructor.js index eb8765cfb2..cd57acf6ab 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/difference/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Set/prototype/difference/not-a-constructor.js @@ -18,8 +18,6 @@ assert.throws( TypeError, () => { new Set.prototype.difference(); - }, - "`new Set.prototype.difference()` throws TypeError" -); + }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/length.js b/js/src/tests/test262/built-ins/Set/prototype/entries/length.js index 5f7ab9dd4c..9f3c5a39c5 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/entries/length.js +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/length.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Set.prototype.entries.length, 0, "The value of `Set.prototype.entries.length` is `0`"); - -verifyNotEnumerable(Set.prototype.entries, "length"); -verifyNotWritable(Set.prototype.entries, "length"); -verifyConfigurable(Set.prototype.entries, "length"); +verifyProperty(Set.prototype.entries, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/name.js b/js/src/tests/test262/built-ins/Set/prototype/entries/name.js index ffcfec6df1..e29b78e96f 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/entries/name.js +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/name.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Set.prototype.entries.name, "entries", "The value of `Set.prototype.entries.name` is `'entries'`"); - -verifyNotEnumerable(Set.prototype.entries, "name"); -verifyNotWritable(Set.prototype.entries, "name"); -verifyConfigurable(Set.prototype.entries, "name"); +verifyProperty(Set.prototype.entries, "name", { + value: "entries", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/entries/not-a-constructor.js index cd385a7077..d2ac4f4845 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/entries/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let s = new Set([]); new s.entries(); -}, '`let s = new Set([]); new s.entries()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/length.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/length.js index 8304c78447..b831b6c0ee 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/forEach/length.js +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/length.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Set.prototype.forEach.length, 1, "The value of `Set.prototype.forEach.length` is `1`"); - -verifyNotEnumerable(Set.prototype.forEach, "length"); -verifyNotWritable(Set.prototype.forEach, "length"); -verifyConfigurable(Set.prototype.forEach, "length"); +verifyProperty(Set.prototype.forEach, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/name.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/name.js index 390b016c64..176ef0d84b 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/forEach/name.js +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/name.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Set.prototype.forEach.name, "forEach", "The value of `Set.prototype.forEach.name` is `'forEach'`"); - -verifyNotEnumerable(Set.prototype.forEach, "name"); -verifyNotWritable(Set.prototype.forEach, "name"); -verifyConfigurable(Set.prototype.forEach, "name"); +verifyProperty(Set.prototype.forEach, "name", { + value: "forEach", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/not-a-constructor.js index 96509bf80a..fd62129107 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/forEach/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let s = new Set([]); new s.forEach(() => {}); -}, '`let s = new Set([]); new s.forEach(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/length.js b/js/src/tests/test262/built-ins/Set/prototype/has/length.js index 93326a3565..e12231b9d4 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/has/length.js +++ b/js/src/tests/test262/built-ins/Set/prototype/has/length.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Set.prototype.has.length, 1, "The value of `Set.prototype.has.length` is `1`"); - -verifyNotEnumerable(Set.prototype.has, "length"); -verifyNotWritable(Set.prototype.has, "length"); -verifyConfigurable(Set.prototype.has, "length"); +verifyProperty(Set.prototype.has, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/name.js b/js/src/tests/test262/built-ins/Set/prototype/has/name.js index c95b4ff0b5..72f4ee68b2 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/has/name.js +++ b/js/src/tests/test262/built-ins/Set/prototype/has/name.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Set.prototype.has.name, "has", "The value of `Set.prototype.has.name` is `'has'`"); - -verifyNotEnumerable(Set.prototype.has, "name"); -verifyNotWritable(Set.prototype.has, "name"); -verifyConfigurable(Set.prototype.has, "name"); +verifyProperty(Set.prototype.has, "name", { + value: "has", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/has/not-a-constructor.js index 8f41ff0c1f..d1e82f6939 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/has/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Set/prototype/has/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Set.prototype.has), false, 'isConstructor(Set.pro assert.throws(TypeError, () => { let s = new Set([]); new s.has(); -}, '`let s = new Set([]); new s.has()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/intersection/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/intersection/not-a-constructor.js index 0a8b82b058..3b759e2cea 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/intersection/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Set/prototype/intersection/not-a-constructor.js @@ -18,8 +18,6 @@ assert.throws( TypeError, () => { new Set.prototype.intersection(); - }, - "`new Set.prototype.intersection()` throws TypeError" -); + }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/isDisjointFrom/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/isDisjointFrom/not-a-constructor.js index bcb7d8f159..c5bf872a96 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/isDisjointFrom/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Set/prototype/isDisjointFrom/not-a-constructor.js @@ -18,8 +18,6 @@ assert.throws( TypeError, () => { new Set.prototype.isDisjointFrom(); - }, - "`new Set.prototype.isDisjointFrom()` throws TypeError" -); + }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/isSubsetOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/isSubsetOf/not-a-constructor.js index 9bb00a7a45..6b81688532 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/isSubsetOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Set/prototype/isSubsetOf/not-a-constructor.js @@ -18,8 +18,6 @@ assert.throws( TypeError, () => { new Set.prototype.isSubsetOf(); - }, - "`new Set.prototype.isSubsetOf()` throws TypeError" -); + }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/isSupersetOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/isSupersetOf/not-a-constructor.js index 9ce1d37913..00860eb9ab 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/isSupersetOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Set/prototype/isSupersetOf/not-a-constructor.js @@ -18,8 +18,6 @@ assert.throws( TypeError, () => { new Set.prototype.isSupersetOf(); - }, - "`new Set.prototype.isSupersetOf()` throws TypeError" -); + }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/length.js b/js/src/tests/test262/built-ins/Set/prototype/size/length.js index 4b0b0675dd..288787106e 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/size/length.js +++ b/js/src/tests/test262/built-ins/Set/prototype/size/length.js @@ -13,10 +13,11 @@ includes: [propertyHelper.js] var descriptor = Object.getOwnPropertyDescriptor(Set.prototype, "size"); -assert.sameValue(descriptor.get.length, 0, "The value of `Set.prototype.size.length` is `0`"); - -verifyNotEnumerable(descriptor.get, "length"); -verifyNotWritable(descriptor.get, "length"); -verifyConfigurable(descriptor.get, "length"); +verifyProperty(descriptor.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/name.js b/js/src/tests/test262/built-ins/Set/prototype/size/name.js index 79723d8f0e..baf6fa968a 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/size/name.js +++ b/js/src/tests/test262/built-ins/Set/prototype/size/name.js @@ -16,10 +16,11 @@ includes: [propertyHelper.js] var descriptor = Object.getOwnPropertyDescriptor(Set.prototype, "size"); -assert.sameValue(descriptor.get.name, "get size", "The value of `descriptor.get.name` is `'get size'`"); - -verifyNotEnumerable(descriptor.get, "name"); -verifyNotWritable(descriptor.get, "name"); -verifyConfigurable(descriptor.get, "name"); +verifyProperty(descriptor.get, "name", { + value: "get size", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/symmetricDifference/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/symmetricDifference/not-a-constructor.js index 495beeac4b..7b3234c5a9 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/symmetricDifference/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Set/prototype/symmetricDifference/not-a-constructor.js @@ -18,8 +18,6 @@ assert.throws( TypeError, () => { new Set.prototype.symmetricDifference(); - }, - "`new Set.prototype.symmetricDifference()` throws TypeError" -); + }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/union/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/union/not-a-constructor.js index 9c4f4d7baf..f57bcb02f8 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/union/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Set/prototype/union/not-a-constructor.js @@ -18,8 +18,6 @@ assert.throws( TypeError, () => { new Set.prototype.union(); - }, - "`new Set.prototype.union()` throws TypeError" -); + }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/length.js b/js/src/tests/test262/built-ins/Set/prototype/values/length.js index 8e49d1bc51..e65ada6a4c 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/values/length.js +++ b/js/src/tests/test262/built-ins/Set/prototype/values/length.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Set.prototype.values.length, 0, "The value of `Set.prototype.values.length` is `0`"); - -verifyNotEnumerable(Set.prototype.values, "length"); -verifyNotWritable(Set.prototype.values, "length"); -verifyConfigurable(Set.prototype.values, "length"); +verifyProperty(Set.prototype.values, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/name.js b/js/src/tests/test262/built-ins/Set/prototype/values/name.js index a2458e9505..0f55f2ea0d 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/values/name.js +++ b/js/src/tests/test262/built-ins/Set/prototype/values/name.js @@ -10,10 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(Set.prototype.values.name, "values", "The value of `Set.prototype.values.name` is `'values'`"); - -verifyNotEnumerable(Set.prototype.values, "name"); -verifyNotWritable(Set.prototype.values, "name"); -verifyConfigurable(Set.prototype.values, "name"); +verifyProperty(Set.prototype.values, "name", { + value: "values", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/values/not-a-constructor.js index f21399ca9f..10d52e40de 100644 --- a/js/src/tests/test262/built-ins/Set/prototype/values/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Set/prototype/values/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Set.prototype.values), false, 'isConstructor(Set. assert.throws(TypeError, () => { let s = new Set([]); new s.values(); -}, '`let s = new Set([]); new s.values()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/SetIteratorPrototype/next/length.js b/js/src/tests/test262/built-ins/SetIteratorPrototype/next/length.js index 8d1afa8e61..7ecff0d6bd 100644 --- a/js/src/tests/test262/built-ins/SetIteratorPrototype/next/length.js +++ b/js/src/tests/test262/built-ins/SetIteratorPrototype/next/length.js @@ -24,10 +24,11 @@ includes: [propertyHelper.js] var SetIteratorProto = Object.getPrototypeOf(new Set().values()); -assert.sameValue(SetIteratorProto.next.length, 0); - -verifyNotEnumerable(SetIteratorProto.next, "length"); -verifyNotWritable(SetIteratorProto.next, "length"); -verifyConfigurable(SetIteratorProto.next, "length"); +verifyProperty(SetIteratorProto.next, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/SetIteratorPrototype/next/name.js b/js/src/tests/test262/built-ins/SetIteratorPrototype/next/name.js index 1792ccd461..81b5158661 100644 --- a/js/src/tests/test262/built-ins/SetIteratorPrototype/next/name.js +++ b/js/src/tests/test262/built-ins/SetIteratorPrototype/next/name.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] var SetIteratorProto = Object.getPrototypeOf(new Set().values()); -assert.sameValue(SetIteratorProto.next.name, "next"); - -verifyNotEnumerable(SetIteratorProto.next, "name"); -verifyNotWritable(SetIteratorProto.next, "name"); -verifyConfigurable(SetIteratorProto.next, "name"); +verifyProperty(SetIteratorProto.next, "name", { + value: "next", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/not-constructor.js b/js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/not-constructor.js index 7530d84d93..897670bfeb 100644 --- a/js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/not-constructor.js +++ b/js/src/tests/test262/built-ins/ShadowRealm/prototype/evaluate/not-constructor.js @@ -23,7 +23,7 @@ assert.sameValue( assert.throws(TypeError, () => { new ShadowRealm.prototype.evaluate(""); -}, '`new ShadowRealm.prototype.evaluate("")` throws TypeError'); +}); const r = new ShadowRealm(); r.evaluate('globalThis.x = 0'); diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/options-maxbytelength-allocation-limit.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/options-maxbytelength-allocation-limit.js new file mode 100644 index 0000000000..4462981d9e --- /dev/null +++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/options-maxbytelength-allocation-limit.js @@ -0,0 +1,41 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!this.hasOwnProperty('SharedArrayBuffer')||!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- SharedArrayBuffer,resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sharedarraybuffer-length +description: > + Throws a RangeError if the requested Data Block is too large. +info: | + SharedArrayBuffer ( length [ , options ] ) + + ... + 4. Return ? AllocateSharedArrayBuffer(NewTarget, byteLength, requestedMaxByteLength). + + AllocateSharedArrayBuffer ( constructor, byteLength [ , maxByteLength ] ) + + ... + 7. Let block be ? CreateSharedByteDataBlock(allocLength). + ... + + CreateSharedByteDataBlock ( size ) + + 1. Let db be a new Shared Data Block value consisting of size bytes. If it is + impossible to create such a Shared Data Block, throw a RangeError exception. + +features: [SharedArrayBuffer, resizable-arraybuffer] +---*/ + +assert.throws(RangeError, function() { + // Allocating 7 PiB should fail with a RangeError. + // Math.pow(1024, 5) = 1125899906842624 + new SharedArrayBuffer(0, {maxByteLength: 7 * 1125899906842624}); +}, "`maxByteLength` option is 7 PiB"); + +assert.throws(RangeError, function() { + // Allocating almost 8 PiB should fail with a RangeError. + // Math.pow(2, 53) = 9007199254740992 + new SharedArrayBuffer(0, {maxByteLength: 9007199254740992 - 1}); +}, "`maxByteLength` option is Math.pow(2, 53) - 1"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/options-maxbytelength-compared-before-object-creation.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/options-maxbytelength-compared-before-object-creation.js new file mode 100644 index 0000000000..89544d6fa3 --- /dev/null +++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/options-maxbytelength-compared-before-object-creation.js @@ -0,0 +1,43 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!this.hasOwnProperty('SharedArrayBuffer')||!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- SharedArrayBuffer,resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sharedarraybuffer-length +description: > + The byteLength argument is validated before OrdinaryCreateFromConstructor. +info: | + SharedArrayBuffer ( length [ , options ] ) + + ... + 4. Return ? AllocateSharedArrayBuffer(NewTarget, byteLength, requestedMaxByteLength). + + AllocateSharedArrayBuffer ( constructor, byteLength [ , maxByteLength ] ) + + ... + 3. If allocatingGrowableBuffer is true, then + a. If byteLength > maxByteLength, throw a RangeError exception. + ... + 5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%SharedArrayBuffer.prototype%", slots). + ... + +features: [SharedArrayBuffer, resizable-arraybuffer, Reflect.construct] +---*/ + +let newTarget = Object.defineProperty(function(){}.bind(null), "prototype", { + get() { + throw new Test262Error(); + } +}); + +assert.throws(RangeError, function() { + let byteLength = 10; + let options = { + maxByteLength: 0, + }; + + // Throws a RangeError, because `byteLength` is larger than `options.maxByteLength`. + Reflect.construct(SharedArrayBuffer, [byteLength, options], newTarget); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js new file mode 100644 index 0000000000..58e9748609 --- /dev/null +++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js @@ -0,0 +1,45 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!this.hasOwnProperty('SharedArrayBuffer')||!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- SharedArrayBuffer,resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sharedarraybuffer-length +description: > + The new SharedArrayBuffer instance is created prior to allocating the Data Block. +info: | + SharedArrayBuffer ( length [ , options ] ) + + ... + 4. Return ? AllocateSharedArrayBuffer(NewTarget, byteLength, requestedMaxByteLength). + + AllocateSharedArrayBuffer( constructor, byteLength ) + + ... + 5. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%SharedArrayBuffer.prototype%", slots). + ... + 7. Let block be ? CreateSharedByteDataBlock(allocLength). + ... + +features: [SharedArrayBuffer, resizable-arraybuffer, Reflect.construct] +---*/ + +function DummyError() {} + +let newTarget = Object.defineProperty(function(){}.bind(null), "prototype", { + get() { + throw new DummyError(); + } +}); + +assert.throws(DummyError, function() { + let byteLength = 0; + let options = { + maxByteLength: 7 * 1125899906842624 + }; + + // Allocating 7 PiB should fail with a RangeError. + // Math.pow(1024, 5) = 1125899906842624 + Reflect.construct(SharedArrayBuffer, [], newTarget); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/byteLength/length.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/byteLength/length.js index 22a944cb3c..2133165fa9 100644 --- a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/byteLength/length.js +++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/byteLength/length.js @@ -12,10 +12,11 @@ features: [SharedArrayBuffer] var desc = Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength"); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/byteLength/name.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/byteLength/name.js index 28dff46979..b5312ca087 100644 --- a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/byteLength/name.js +++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/byteLength/name.js @@ -14,13 +14,11 @@ var descriptor = Object.getOwnPropertyDescriptor( SharedArrayBuffer.prototype, 'byteLength' ); -assert.sameValue( - descriptor.get.name, 'get byteLength', - 'The value of `descriptor.get.name` is `"get byteLength"`' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get byteLength", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/slice/length.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/slice/length.js index 6760427fb6..d9396865e1 100644 --- a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/slice/length.js +++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/slice/length.js @@ -24,10 +24,11 @@ includes: [propertyHelper.js] features: [SharedArrayBuffer] ---*/ -assert.sameValue(SharedArrayBuffer.prototype.slice.length, 2); - -verifyNotEnumerable(SharedArrayBuffer.prototype.slice, "length"); -verifyNotWritable(SharedArrayBuffer.prototype.slice, "length"); -verifyConfigurable(SharedArrayBuffer.prototype.slice, "length"); +verifyProperty(SharedArrayBuffer.prototype.slice, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/slice/name.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/slice/name.js index a3407d4b8a..56b2c85c1b 100644 --- a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/slice/name.js +++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/slice/name.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] features: [SharedArrayBuffer] ---*/ -assert.sameValue(SharedArrayBuffer.prototype.slice.name, "slice"); - -verifyNotEnumerable(SharedArrayBuffer.prototype.slice, "name"); -verifyNotWritable(SharedArrayBuffer.prototype.slice, "name"); -verifyConfigurable(SharedArrayBuffer.prototype.slice, "name"); +verifyProperty(SharedArrayBuffer.prototype.slice, "name", { + value: "slice", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/slice/not-a-constructor.js b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/slice/not-a-constructor.js index 49713162b8..c12b163b0b 100644 --- a/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/slice/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/SharedArrayBuffer/prototype/slice/not-a-constructor.js @@ -30,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let sab = new SharedArrayBuffer(1); new sab.slice(); -}, '`let sab = new SharedArrayBuffer(1); new sab.slice()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/name.js b/js/src/tests/test262/built-ins/String/fromCharCode/name.js index aad7ed2c18..97cce062e6 100644 --- a/js/src/tests/test262/built-ins/String/fromCharCode/name.js +++ b/js/src/tests/test262/built-ins/String/fromCharCode/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.fromCharCode.name, "fromCharCode"); - -verifyNotEnumerable(String.fromCharCode, "name"); -verifyNotWritable(String.fromCharCode, "name"); -verifyConfigurable(String.fromCharCode, "name"); +verifyProperty(String.fromCharCode, "name", { + value: "fromCharCode", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/not-a-constructor.js b/js/src/tests/test262/built-ins/String/fromCharCode/not-a-constructor.js index 2076c9b6ab..f7db50fa33 100644 --- a/js/src/tests/test262/built-ins/String/fromCharCode/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/fromCharCode/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(String.fromCharCode), false, 'isConstructor(Strin assert.throws(TypeError, () => { new String.fromCharCode(); -}, '`new String.fromCharCode()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/length.js b/js/src/tests/test262/built-ins/String/fromCodePoint/length.js index 5708d475e6..a6e1710e1d 100644 --- a/js/src/tests/test262/built-ins/String/fromCodePoint/length.js +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/length.js @@ -8,13 +8,11 @@ includes: [propertyHelper.js] features: [String.fromCodePoint] ---*/ -assert.sameValue( - String.fromCodePoint.length, 1, - 'The value of `String.fromCodePoint.length` is `1`' -); - -verifyNotEnumerable(String.fromCodePoint, 'length'); -verifyNotWritable(String.fromCodePoint, 'length'); -verifyConfigurable(String.fromCodePoint, 'length'); +verifyProperty(String.fromCodePoint, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/name.js b/js/src/tests/test262/built-ins/String/fromCodePoint/name.js index 306ca1041d..0253149ffb 100644 --- a/js/src/tests/test262/built-ins/String/fromCodePoint/name.js +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/name.js @@ -12,13 +12,11 @@ includes: [propertyHelper.js] features: [String.fromCodePoint] ---*/ -assert.sameValue( - String.fromCodePoint.name, 'fromCodePoint', - 'The value of `String.fromCodePoint.name` is "fromCodePoint"' -); - -verifyNotEnumerable(String.fromCodePoint, 'name'); -verifyNotWritable(String.fromCodePoint, 'name'); -verifyConfigurable(String.fromCodePoint, 'name'); +verifyProperty(String.fromCodePoint, "name", { + value: "fromCodePoint", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/not-a-constructor.js b/js/src/tests/test262/built-ins/String/fromCodePoint/not-a-constructor.js index ad07f88425..9144fe2bfc 100644 --- a/js/src/tests/test262/built-ins/String/fromCodePoint/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(String.fromCodePoint), false, 'isConstructor(Stri assert.throws(TypeError, () => { new String.fromCodePoint(); -}, '`new String.fromCodePoint()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/length.js b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/length.js index c7b43eed8a..20e1065b81 100644 --- a/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/length.js +++ b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/length.js @@ -19,10 +19,11 @@ features: [Symbol.iterator] includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype[Symbol.iterator].length, 0); - -verifyNotEnumerable(String.prototype[Symbol.iterator], 'length'); -verifyNotWritable(String.prototype[Symbol.iterator], 'length'); -verifyConfigurable(String.prototype[Symbol.iterator], 'length'); +verifyProperty(String.prototype[Symbol.iterator], "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/name.js b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/name.js index 29f1ffc52e..a4471724c5 100644 --- a/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/name.js @@ -22,10 +22,11 @@ features: [Symbol.iterator] includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype[Symbol.iterator].name, '[Symbol.iterator]'); - -verifyNotEnumerable(String.prototype[Symbol.iterator], 'name'); -verifyNotWritable(String.prototype[Symbol.iterator], 'name'); -verifyConfigurable(String.prototype[Symbol.iterator], 'name'); +verifyProperty(String.prototype[Symbol.iterator], "name", { + value: "[Symbol.iterator]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/not-a-constructor.js index 33fdc254d4..8c7a28d690 100644 --- a/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype[Symbol.iterator](); -}, '`new String.prototype[Symbol.iterator]()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/at/index-non-numeric-argument-tointeger-invalid.js b/js/src/tests/test262/built-ins/String/prototype/at/index-non-numeric-argument-tointeger-invalid.js index 64a31c0120..80fc06db0c 100644 --- a/js/src/tests/test262/built-ins/String/prototype/at/index-non-numeric-argument-tointeger-invalid.js +++ b/js/src/tests/test262/built-ins/String/prototype/at/index-non-numeric-argument-tointeger-invalid.js @@ -17,6 +17,6 @@ let s = "01"; assert.throws(TypeError, () => { s.at(Symbol()); -}, '`s.at(Symbol())` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/at/length.js b/js/src/tests/test262/built-ins/String/prototype/at/length.js index d552c459bd..c27076b9d4 100644 --- a/js/src/tests/test262/built-ins/String/prototype/at/length.js +++ b/js/src/tests/test262/built-ins/String/prototype/at/length.js @@ -14,13 +14,11 @@ features: [String.prototype.at] ---*/ assert.sameValue(typeof String.prototype.at, 'function'); -assert.sameValue( - String.prototype.at.length, 1, - 'The value of String.prototype.at.length is 1' -); - -verifyNotEnumerable(String.prototype.at, 'length'); -verifyNotWritable(String.prototype.at, 'length'); -verifyConfigurable(String.prototype.at, 'length'); +verifyProperty(String.prototype.at, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/at/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/String/prototype/at/return-abrupt-from-this.js index 0dc4011fce..f9222d733e 100644 --- a/js/src/tests/test262/built-ins/String/prototype/at/return-abrupt-from-this.js +++ b/js/src/tests/test262/built-ins/String/prototype/at/return-abrupt-from-this.js @@ -15,10 +15,10 @@ assert.sameValue(typeof String.prototype.at, 'function'); assert.throws(TypeError, () => { String.prototype.at.call(undefined); -}, '`String.prototype.at.call(undefined)` throws TypeError'); +}); assert.throws(TypeError, () => { String.prototype.at.call(null); -}, '`String.prototype.at.call(null)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/name.js b/js/src/tests/test262/built-ins/String/prototype/charAt/name.js index 13a245e2fc..d158385939 100644 --- a/js/src/tests/test262/built-ins/String/prototype/charAt/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.charAt.name, "charAt"); - -verifyNotEnumerable(String.prototype.charAt, "name"); -verifyNotWritable(String.prototype.charAt, "name"); -verifyConfigurable(String.prototype.charAt, "name"); +verifyProperty(String.prototype.charAt, "name", { + value: "charAt", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/charAt/not-a-constructor.js index 6e00163a90..84d27e581b 100644 --- a/js/src/tests/test262/built-ins/String/prototype/charAt/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.charAt(); -}, '`new String.prototype.charAt()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/name.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/name.js index 9916d17abf..4e877b4c7b 100644 --- a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.charCodeAt.name, "charCodeAt"); - -verifyNotEnumerable(String.prototype.charCodeAt, "name"); -verifyNotWritable(String.prototype.charCodeAt, "name"); -verifyConfigurable(String.prototype.charCodeAt, "name"); +verifyProperty(String.prototype.charCodeAt, "name", { + value: "charCodeAt", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/not-a-constructor.js index 282fcb0b55..caee3a678f 100644 --- a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.charCodeAt(); -}, '`new String.prototype.charCodeAt()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/length.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/length.js index 99acb42698..95046c634f 100644 --- a/js/src/tests/test262/built-ins/String/prototype/codePointAt/length.js +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - String.prototype.codePointAt.length, 1, - 'The value of `String.prototype.codePointAt.length` is `1`' -); - -verifyNotEnumerable(String.prototype.codePointAt, 'length'); -verifyNotWritable(String.prototype.codePointAt, 'length'); -verifyConfigurable(String.prototype.codePointAt, 'length'); +verifyProperty(String.prototype.codePointAt, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/name.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/name.js index db3ce58ddc..f1ff47b316 100644 --- a/js/src/tests/test262/built-ins/String/prototype/codePointAt/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - String.prototype.codePointAt.name, 'codePointAt', - 'The value of `String.prototype.codePointAt.name` is `"codePointAt"`' -); - -verifyNotEnumerable(String.prototype.codePointAt, 'name'); -verifyNotWritable(String.prototype.codePointAt, 'name'); -verifyConfigurable(String.prototype.codePointAt, 'name'); +verifyProperty(String.prototype.codePointAt, "name", { + value: "codePointAt", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/not-a-constructor.js index 56d31f5280..e47b22bf17 100644 --- a/js/src/tests/test262/built-ins/String/prototype/codePointAt/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.codePointAt(); -}, '`new String.prototype.codePointAt()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/name.js b/js/src/tests/test262/built-ins/String/prototype/concat/name.js index 6a4181b098..0fb7b7da0e 100644 --- a/js/src/tests/test262/built-ins/String/prototype/concat/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/concat/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.concat.name, "concat"); - -verifyNotEnumerable(String.prototype.concat, "name"); -verifyNotWritable(String.prototype.concat, "name"); -verifyConfigurable(String.prototype.concat, "name"); +verifyProperty(String.prototype.concat, "name", { + value: "concat", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/concat/not-a-constructor.js index e0287c912b..048d524256 100644 --- a/js/src/tests/test262/built-ins/String/prototype/concat/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/concat/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.concat(); -}, '`new String.prototype.concat()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/length.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/length.js index d5040bab96..edfe1585f0 100644 --- a/js/src/tests/test262/built-ins/String/prototype/endsWith/length.js +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/length.js @@ -13,13 +13,11 @@ includes: [propertyHelper.js] features: [String.prototype.endsWith] ---*/ -assert.sameValue( - String.prototype.endsWith.length, 1, - 'The value of `String.prototype.endsWith.length` is `1`' -); - -verifyNotEnumerable(String.prototype.endsWith, 'length'); -verifyNotWritable(String.prototype.endsWith, 'length'); -verifyConfigurable(String.prototype.endsWith, 'length'); +verifyProperty(String.prototype.endsWith, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/name.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/name.js index d4aa6ee5f5..27b35d7bf3 100644 --- a/js/src/tests/test262/built-ins/String/prototype/endsWith/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/name.js @@ -13,13 +13,11 @@ includes: [propertyHelper.js] features: [String.prototype.endsWith] ---*/ -assert.sameValue( - String.prototype.endsWith.name, 'endsWith', - 'The value of `String.prototype.endsWith.name` is `"endsWith"`' -); - -verifyNotEnumerable(String.prototype.endsWith, 'name'); -verifyNotWritable(String.prototype.endsWith, 'name'); -verifyConfigurable(String.prototype.endsWith, 'name'); +verifyProperty(String.prototype.endsWith, "name", { + value: "endsWith", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/not-a-constructor.js index 2112ea842d..52076bb384 100644 --- a/js/src/tests/test262/built-ins/String/prototype/endsWith/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.endsWith(); -}, '`new String.prototype.endsWith()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/length.js b/js/src/tests/test262/built-ins/String/prototype/includes/length.js index c74ad3f706..8ee6ae06e9 100644 --- a/js/src/tests/test262/built-ins/String/prototype/includes/length.js +++ b/js/src/tests/test262/built-ins/String/prototype/includes/length.js @@ -13,13 +13,11 @@ includes: [propertyHelper.js] features: [String.prototype.includes] ---*/ -assert.sameValue( - String.prototype.includes.length, 1, - 'The value of `String.prototype.includes.length` is `1`' -); - -verifyNotEnumerable(String.prototype.includes, 'length'); -verifyNotWritable(String.prototype.includes, 'length'); -verifyConfigurable(String.prototype.includes, 'length'); +verifyProperty(String.prototype.includes, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/name.js b/js/src/tests/test262/built-ins/String/prototype/includes/name.js index 24bf088db4..fe8cdc1d5d 100644 --- a/js/src/tests/test262/built-ins/String/prototype/includes/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/includes/name.js @@ -13,13 +13,11 @@ includes: [propertyHelper.js] features: [String.prototype.includes] ---*/ -assert.sameValue( - String.prototype.includes.name, 'includes', - 'The value of `String.prototype.includes.name` is `"includes"`' -); - -verifyNotEnumerable(String.prototype.includes, 'name'); -verifyNotWritable(String.prototype.includes, 'name'); -verifyConfigurable(String.prototype.includes, 'name'); +verifyProperty(String.prototype.includes, "name", { + value: "includes", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/includes/not-a-constructor.js index f276a53f92..ccc6ce782d 100644 --- a/js/src/tests/test262/built-ins/String/prototype/includes/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/includes/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.includes(1); -}, '`new String.prototype.includes(1)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/name.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/name.js index ff0064a42f..cce21bf05c 100644 --- a/js/src/tests/test262/built-ins/String/prototype/indexOf/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.indexOf.name, "indexOf"); - -verifyNotEnumerable(String.prototype.indexOf, "name"); -verifyNotWritable(String.prototype.indexOf, "name"); -verifyConfigurable(String.prototype.indexOf, "name"); +verifyProperty(String.prototype.indexOf, "name", { + value: "indexOf", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/not-a-constructor.js index 6cc8bc2efb..c21805ebdd 100644 --- a/js/src/tests/test262/built-ins/String/prototype/indexOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.indexOf(); -}, '`new String.prototype.indexOf()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/isWellFormed/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/not-a-constructor.js index 6943b3c2e8..d3cd1f6325 100644 --- a/js/src/tests/test262/built-ins/String/prototype/isWellFormed/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/not-a-constructor.js @@ -29,6 +29,6 @@ assert.sameValue( assert.throws(TypeError, function () { new String.prototype.isWellFormed(); -}, '`new String.prototype.isWellFormed()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/isWellFormed/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/return-abrupt-from-this.js index c883015d19..900b901076 100644 --- a/js/src/tests/test262/built-ins/String/prototype/isWellFormed/return-abrupt-from-this.js +++ b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/return-abrupt-from-this.js @@ -15,10 +15,10 @@ assert.sameValue(typeof String.prototype.isWellFormed, 'function'); assert.throws(TypeError, function () { String.prototype.isWellFormed.call(undefined); -}, '`String.prototype.isWellFormed.call(undefined)` throws TypeError'); +}); assert.throws(TypeError, function () { String.prototype.isWellFormed.call(null); -}, '`String.prototype.isWellFormed.call(null)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/name.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/name.js index 62353147a8..003da3f8f0 100644 --- a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.lastIndexOf.name, "lastIndexOf"); - -verifyNotEnumerable(String.prototype.lastIndexOf, "name"); -verifyNotWritable(String.prototype.lastIndexOf, "name"); -verifyConfigurable(String.prototype.lastIndexOf, "name"); +verifyProperty(String.prototype.lastIndexOf, "name", { + value: "lastIndexOf", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/not-a-constructor.js index 14485de716..34a943e4f3 100644 --- a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.lastIndexOf(); -}, '`new String.prototype.lastIndexOf()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/localeCompare/name.js b/js/src/tests/test262/built-ins/String/prototype/localeCompare/name.js index 81a2062386..e6e3b4f8cf 100644 --- a/js/src/tests/test262/built-ins/String/prototype/localeCompare/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/localeCompare/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.localeCompare.name, "localeCompare"); - -verifyNotEnumerable(String.prototype.localeCompare, "name"); -verifyNotWritable(String.prototype.localeCompare, "name"); -verifyConfigurable(String.prototype.localeCompare, "name"); +verifyProperty(String.prototype.localeCompare, "name", { + value: "localeCompare", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/localeCompare/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/localeCompare/not-a-constructor.js index c335172ddc..8b6f0b874c 100644 --- a/js/src/tests/test262/built-ins/String/prototype/localeCompare/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/localeCompare/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.localeCompare(); -}, '`new String.prototype.localeCompare()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/name.js b/js/src/tests/test262/built-ins/String/prototype/match/name.js index 09c3133348..87ba9960ed 100644 --- a/js/src/tests/test262/built-ins/String/prototype/match/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/match/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.match.name, "match"); - -verifyNotEnumerable(String.prototype.match, "name"); -verifyNotWritable(String.prototype.match, "name"); -verifyConfigurable(String.prototype.match, "name"); +verifyProperty(String.prototype.match, "name", { + value: "match", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/match/not-a-constructor.js index 91f5ec5a8e..5199da96e9 100644 --- a/js/src/tests/test262/built-ins/String/prototype/match/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/match/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.match(); -}, '`new String.prototype.match()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/length.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/length.js index 49fc24912e..40121111fb 100644 --- a/js/src/tests/test262/built-ins/String/prototype/matchAll/length.js +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/length.js @@ -23,10 +23,11 @@ includes: [propertyHelper.js] features: [String.prototype.matchAll] ---*/ -assert.sameValue(String.prototype.matchAll.length, 1); - -verifyNotEnumerable(String.prototype.matchAll, 'length'); -verifyNotWritable(String.prototype.matchAll, 'length'); -verifyConfigurable(String.prototype.matchAll, 'length'); +verifyProperty(String.prototype.matchAll, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/name.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/name.js index efab01207f..8044946076 100644 --- a/js/src/tests/test262/built-ins/String/prototype/matchAll/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/name.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] features: [String.prototype.matchAll] ---*/ -assert.sameValue(String.prototype.matchAll.name, 'matchAll'); - -verifyNotEnumerable(String.prototype.matchAll, 'name'); -verifyNotWritable(String.prototype.matchAll, 'name'); -verifyConfigurable(String.prototype.matchAll, 'name'); +verifyProperty(String.prototype.matchAll, "name", { + value: "matchAll", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/not-a-constructor.js index e4a6ba973c..a895cd6797 100644 --- a/js/src/tests/test262/built-ins/String/prototype/matchAll/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.matchAll(); -}, '`new String.prototype.matchAll()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/length.js b/js/src/tests/test262/built-ins/String/prototype/normalize/length.js index f95c97046e..7ce057a565 100644 --- a/js/src/tests/test262/built-ins/String/prototype/normalize/length.js +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - String.prototype.normalize.length, 0, - 'The value of `String.prototype.normalize.length` is `0`' -); - -verifyNotEnumerable(String.prototype.normalize, 'length'); -verifyNotWritable(String.prototype.normalize, 'length'); -verifyConfigurable(String.prototype.normalize, 'length'); +verifyProperty(String.prototype.normalize, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/name.js b/js/src/tests/test262/built-ins/String/prototype/normalize/name.js index e3d3ef3acc..9ed6fc9119 100644 --- a/js/src/tests/test262/built-ins/String/prototype/normalize/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - String.prototype.normalize.name, 'normalize', - 'The value of `String.prototype.normalize.name` is `"normalize"`' -); - -verifyNotEnumerable(String.prototype.normalize, 'name'); -verifyNotWritable(String.prototype.normalize, 'name'); -verifyConfigurable(String.prototype.normalize, 'name'); +verifyProperty(String.prototype.normalize, "name", { + value: "normalize", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/normalize/not-a-constructor.js index e1c16b4e10..3e7e6c65cd 100644 --- a/js/src/tests/test262/built-ins/String/prototype/normalize/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.normalize(); -}, '`new String.prototype.normalize()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/function-length.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/function-length.js index 4b38c5a4a4..267e983c0c 100644 --- a/js/src/tests/test262/built-ins/String/prototype/padEnd/function-length.js +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/function-length.js @@ -8,10 +8,11 @@ author: Jordan Harband includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.padEnd.length, 1, 'Expected String#padEnd.length to be 1'); - -verifyNotEnumerable(String.prototype.padEnd, 'length'); -verifyNotWritable(String.prototype.padEnd, 'length'); -verifyConfigurable(String.prototype.padEnd, 'length'); +verifyProperty(String.prototype.padEnd, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/function-name.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/function-name.js index cf0c201497..1ffb11b8fe 100644 --- a/js/src/tests/test262/built-ins/String/prototype/padEnd/function-name.js +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/function-name.js @@ -8,14 +8,11 @@ author: Jordan Harband includes: [propertyHelper.js] ---*/ -assert.sameValue( - String.prototype.padEnd.name, - 'padEnd', - 'Expected String#padEnd.name to be "padEnd"' -); - -verifyNotEnumerable(String.prototype.padEnd, 'name'); -verifyNotWritable(String.prototype.padEnd, 'name'); -verifyConfigurable(String.prototype.padEnd, 'name'); +verifyProperty(String.prototype.padEnd, "name", { + value: "padEnd", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/not-a-constructor.js index ed5f84458c..4041e6386f 100644 --- a/js/src/tests/test262/built-ins/String/prototype/padEnd/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.padEnd(); -}, '`new String.prototype.padEnd()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/function-length.js b/js/src/tests/test262/built-ins/String/prototype/padStart/function-length.js index 056e797a01..63f28d092b 100644 --- a/js/src/tests/test262/built-ins/String/prototype/padStart/function-length.js +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/function-length.js @@ -8,10 +8,11 @@ author: Jordan Harband includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.padStart.length, 1, 'Expected String#padStart.length to be 1'); - -verifyNotEnumerable(String.prototype.padStart, 'length'); -verifyNotWritable(String.prototype.padStart, 'length'); -verifyConfigurable(String.prototype.padStart, 'length'); +verifyProperty(String.prototype.padStart, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/function-name.js b/js/src/tests/test262/built-ins/String/prototype/padStart/function-name.js index f7fb59889b..07de295a58 100644 --- a/js/src/tests/test262/built-ins/String/prototype/padStart/function-name.js +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/function-name.js @@ -8,14 +8,11 @@ author: Jordan Harband includes: [propertyHelper.js] ---*/ -assert.sameValue( - String.prototype.padStart.name, - 'padStart', - 'Expected String#padStart.name to be "padStart"' -); - -verifyNotEnumerable(String.prototype.padStart, 'name'); -verifyNotWritable(String.prototype.padStart, 'name'); -verifyConfigurable(String.prototype.padStart, 'name'); +verifyProperty(String.prototype.padStart, "name", { + value: "padStart", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/padStart/not-a-constructor.js index 22ae62b3b1..21e77ab9da 100644 --- a/js/src/tests/test262/built-ins/String/prototype/padStart/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.padStart(); -}, '`new String.prototype.padStart()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/length.js b/js/src/tests/test262/built-ins/String/prototype/repeat/length.js index 2151718be9..3a2663feb6 100644 --- a/js/src/tests/test262/built-ins/String/prototype/repeat/length.js +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - String.prototype.repeat.length, 1, - 'The value of `String.prototype.repeat.length` is `1`' -); - -verifyNotEnumerable(String.prototype.repeat, 'length'); -verifyNotWritable(String.prototype.repeat, 'length'); -verifyConfigurable(String.prototype.repeat, 'length'); +verifyProperty(String.prototype.repeat, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/name.js b/js/src/tests/test262/built-ins/String/prototype/repeat/name.js index 3c640857de..5be524f0c7 100644 --- a/js/src/tests/test262/built-ins/String/prototype/repeat/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - String.prototype.repeat.name, 'repeat', - 'The value of `String.prototype.repeat.name` is `"repeat"`' -); - -verifyNotEnumerable(String.prototype.repeat, 'name'); -verifyNotWritable(String.prototype.repeat, 'name'); -verifyConfigurable(String.prototype.repeat, 'name'); +verifyProperty(String.prototype.repeat, "name", { + value: "repeat", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/repeat/not-a-constructor.js index b8acfb0e7f..ca9c878ce7 100644 --- a/js/src/tests/test262/built-ins/String/prototype/repeat/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.repeat(); -}, '`new String.prototype.repeat()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/name.js b/js/src/tests/test262/built-ins/String/prototype/replace/name.js index 7e783a3585..c81cbe79d6 100644 --- a/js/src/tests/test262/built-ins/String/prototype/replace/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/replace/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.replace.name, "replace"); - -verifyNotEnumerable(String.prototype.replace, "name"); -verifyNotWritable(String.prototype.replace, "name"); -verifyConfigurable(String.prototype.replace, "name"); +verifyProperty(String.prototype.replace, "name", { + value: "replace", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/replace/not-a-constructor.js index c28df5ae80..b8be7a68c2 100644 --- a/js/src/tests/test262/built-ins/String/prototype/replace/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/replace/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.replace(); -}, '`new String.prototype.replace()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/not-a-constructor.js index b3b9ca6503..6aa72e106a 100644 --- a/js/src/tests/test262/built-ins/String/prototype/replaceAll/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.replaceAll(); -}, '`new String.prototype.replaceAll()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/name.js b/js/src/tests/test262/built-ins/String/prototype/search/name.js index ad555b4841..b8dd108625 100644 --- a/js/src/tests/test262/built-ins/String/prototype/search/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/search/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.search.name, "search"); - -verifyNotEnumerable(String.prototype.search, "name"); -verifyNotWritable(String.prototype.search, "name"); -verifyConfigurable(String.prototype.search, "name"); +verifyProperty(String.prototype.search, "name", { + value: "search", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/search/not-a-constructor.js index c61e4f3b16..ef329bad51 100644 --- a/js/src/tests/test262/built-ins/String/prototype/search/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/search/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.search(); -}, '`new String.prototype.search()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/name.js b/js/src/tests/test262/built-ins/String/prototype/slice/name.js index 24ea647443..f0c60ab056 100644 --- a/js/src/tests/test262/built-ins/String/prototype/slice/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/slice/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.slice.name, "slice"); - -verifyNotEnumerable(String.prototype.slice, "name"); -verifyNotWritable(String.prototype.slice, "name"); -verifyConfigurable(String.prototype.slice, "name"); +verifyProperty(String.prototype.slice, "name", { + value: "slice", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/slice/not-a-constructor.js index e4220ef5b3..8a9bb9e794 100644 --- a/js/src/tests/test262/built-ins/String/prototype/slice/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/slice/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.slice(); -}, '`new String.prototype.slice()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/name.js b/js/src/tests/test262/built-ins/String/prototype/split/name.js index e5ab74fed8..c9d3bf7809 100644 --- a/js/src/tests/test262/built-ins/String/prototype/split/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/split/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.split.name, "split"); - -verifyNotEnumerable(String.prototype.split, "name"); -verifyNotWritable(String.prototype.split, "name"); -verifyConfigurable(String.prototype.split, "name"); +verifyProperty(String.prototype.split, "name", { + value: "split", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/split/not-a-constructor.js index 09e41d6233..b69a0796ee 100644 --- a/js/src/tests/test262/built-ins/String/prototype/split/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/split/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.split(); -}, '`new String.prototype.split()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/length.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/length.js index 3e19e74994..5f27578aba 100644 --- a/js/src/tests/test262/built-ins/String/prototype/startsWith/length.js +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - String.prototype.startsWith.length, 1, - 'The value of `String.prototype.startsWith.length` is `1`' -); - -verifyNotEnumerable(String.prototype.startsWith, 'length'); -verifyNotWritable(String.prototype.startsWith, 'length'); -verifyConfigurable(String.prototype.startsWith, 'length'); +verifyProperty(String.prototype.startsWith, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/name.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/name.js index 4baa4a3076..ba8907b725 100644 --- a/js/src/tests/test262/built-ins/String/prototype/startsWith/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - String.prototype.startsWith.name, 'startsWith', - 'The value of `String.prototype.startsWith.name` is `"startsWith"`' -); - -verifyNotEnumerable(String.prototype.startsWith, 'name'); -verifyNotWritable(String.prototype.startsWith, 'name'); -verifyConfigurable(String.prototype.startsWith, 'name'); +verifyProperty(String.prototype.startsWith, "name", { + value: "startsWith", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/not-a-constructor.js index a286537efc..33f51122fe 100644 --- a/js/src/tests/test262/built-ins/String/prototype/startsWith/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.startsWith(); -}, '`new String.prototype.startsWith()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/name.js b/js/src/tests/test262/built-ins/String/prototype/substring/name.js index bbfb54a254..144a1a72ac 100644 --- a/js/src/tests/test262/built-ins/String/prototype/substring/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/substring/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.substring.name, "substring"); - -verifyNotEnumerable(String.prototype.substring, "name"); -verifyNotWritable(String.prototype.substring, "name"); -verifyConfigurable(String.prototype.substring, "name"); +verifyProperty(String.prototype.substring, "name", { + value: "substring", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/substring/not-a-constructor.js index 981b8cd665..2f2f2b2058 100644 --- a/js/src/tests/test262/built-ins/String/prototype/substring/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/substring/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.substring(); -}, '`new String.prototype.substring()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/name.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/name.js index 0293ba687b..be7e29d94b 100644 --- a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.toLocaleLowerCase.name, "toLocaleLowerCase"); - -verifyNotEnumerable(String.prototype.toLocaleLowerCase, "name"); -verifyNotWritable(String.prototype.toLocaleLowerCase, "name"); -verifyConfigurable(String.prototype.toLocaleLowerCase, "name"); +verifyProperty(String.prototype.toLocaleLowerCase, "name", { + value: "toLocaleLowerCase", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/not-a-constructor.js index c6b26ea910..9842bef5ba 100644 --- a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.toLocaleLowerCase(); -}, '`new String.prototype.toLocaleLowerCase()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/name.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/name.js index e20dd69220..b9d7ac4611 100644 --- a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.toLocaleUpperCase.name, "toLocaleUpperCase"); - -verifyNotEnumerable(String.prototype.toLocaleUpperCase, "name"); -verifyNotWritable(String.prototype.toLocaleUpperCase, "name"); -verifyConfigurable(String.prototype.toLocaleUpperCase, "name"); +verifyProperty(String.prototype.toLocaleUpperCase, "name", { + value: "toLocaleUpperCase", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/not-a-constructor.js index 2dbfcb12e1..382177d2be 100644 --- a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.toLocaleUpperCase(); -}, '`new String.prototype.toLocaleUpperCase()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/name.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/name.js index 48f9222ed5..cdd2ba2acd 100644 --- a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.toLowerCase.name, "toLowerCase"); - -verifyNotEnumerable(String.prototype.toLowerCase, "name"); -verifyNotWritable(String.prototype.toLowerCase, "name"); -verifyConfigurable(String.prototype.toLowerCase, "name"); +verifyProperty(String.prototype.toLowerCase, "name", { + value: "toLowerCase", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/not-a-constructor.js index e9d92daf54..3e13c9136d 100644 --- a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.toLowerCase(); -}, '`new String.prototype.toLowerCase()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/toString/not-a-constructor.js index 59cdfc18e5..01da771f46 100644 --- a/js/src/tests/test262/built-ins/String/prototype/toString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/toString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.toString(); -}, '`new String.prototype.toString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/name.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/name.js index 9e2922beb0..f44b3b259f 100644 --- a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.toUpperCase.name, "toUpperCase"); - -verifyNotEnumerable(String.prototype.toUpperCase, "name"); -verifyNotWritable(String.prototype.toUpperCase, "name"); -verifyConfigurable(String.prototype.toUpperCase, "name"); +verifyProperty(String.prototype.toUpperCase, "name", { + value: "toUpperCase", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/not-a-constructor.js index 4820c87b12..38fa7fe5e4 100644 --- a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.toUpperCase(); -}, '`new String.prototype.toUpperCase()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toWellFormed/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/not-a-constructor.js index ccd3bc63a7..b83a6022e7 100644 --- a/js/src/tests/test262/built-ins/String/prototype/toWellFormed/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/not-a-constructor.js @@ -29,6 +29,6 @@ assert.sameValue( assert.throws(TypeError, function () { new String.prototype.toWellFormed(); -}, '`new String.prototype.toWellFormed()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toWellFormed/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/return-abrupt-from-this.js index f39c858f6f..0ebf8a227f 100644 --- a/js/src/tests/test262/built-ins/String/prototype/toWellFormed/return-abrupt-from-this.js +++ b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/return-abrupt-from-this.js @@ -15,10 +15,10 @@ assert.sameValue(typeof String.prototype.toWellFormed, 'function'); assert.throws(TypeError, function () { String.prototype.toWellFormed.call(undefined); -}, '`String.prototype.toWellFormed.call(undefined)` throws TypeError'); +}); assert.throws(TypeError, function () { String.prototype.toWellFormed.call(null); -}, '`String.prototype.toWellFormed.call(null)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/name.js b/js/src/tests/test262/built-ins/String/prototype/trim/name.js index 3f983c303c..995e4e5265 100644 --- a/js/src/tests/test262/built-ins/String/prototype/trim/name.js +++ b/js/src/tests/test262/built-ins/String/prototype/trim/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(String.prototype.trim.name, "trim"); - -verifyNotEnumerable(String.prototype.trim, "name"); -verifyNotWritable(String.prototype.trim, "name"); -verifyConfigurable(String.prototype.trim, "name"); +verifyProperty(String.prototype.trim, "name", { + value: "trim", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/trim/not-a-constructor.js index 20118ff8fc..38fe47625f 100644 --- a/js/src/tests/test262/built-ins/String/prototype/trim/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/trim/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.trim(); -}, '`new String.prototype.trim()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/not-a-constructor.js index 0d8bea1970..151f5baad5 100644 --- a/js/src/tests/test262/built-ins/String/prototype/trimEnd/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.trimEnd(); -}, '`new String.prototype.trimEnd()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/not-a-constructor.js index fe6ba1ca22..f1c36d37c0 100644 --- a/js/src/tests/test262/built-ins/String/prototype/trimStart/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.trimStart(); -}, '`new String.prototype.trimStart()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/valueOf/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/valueOf/not-a-constructor.js index 81afa416d4..fe9e189d3b 100644 --- a/js/src/tests/test262/built-ins/String/prototype/valueOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/prototype/valueOf/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { new String.prototype.valueOf(); -}, '`new String.prototype.valueOf()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/length.js b/js/src/tests/test262/built-ins/String/raw/length.js index deb433fde5..7af20ab224 100644 --- a/js/src/tests/test262/built-ins/String/raw/length.js +++ b/js/src/tests/test262/built-ins/String/raw/length.js @@ -11,13 +11,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - String.raw.length, 1, - 'The value of `String.raw.length` is `1`' -); - -verifyNotEnumerable(String.raw, 'length'); -verifyNotWritable(String.raw, 'length'); -verifyConfigurable(String.raw, 'length'); +verifyProperty(String.raw, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/name.js b/js/src/tests/test262/built-ins/String/raw/name.js index c7533e923b..c9c7f8a518 100644 --- a/js/src/tests/test262/built-ins/String/raw/name.js +++ b/js/src/tests/test262/built-ins/String/raw/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - String.raw.name, 'raw', - 'The value of `String.raw.name` is `"raw"`' -); - -verifyNotEnumerable(String.raw, 'name'); -verifyNotWritable(String.raw, 'name'); -verifyConfigurable(String.raw, 'name'); +verifyProperty(String.raw, "name", { + value: "raw", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/not-a-constructor.js b/js/src/tests/test262/built-ins/String/raw/not-a-constructor.js index 6beda7f32f..d0c324b883 100644 --- a/js/src/tests/test262/built-ins/String/raw/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/String/raw/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(String.raw), false, 'isConstructor(String.raw) mu assert.throws(TypeError, () => { new String.raw({raw: []}, []); -}, '`new String.raw({raw: []}, [])` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/StringIteratorPrototype/next/length.js b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/length.js index 6facc1101b..74deed54d3 100644 --- a/js/src/tests/test262/built-ins/StringIteratorPrototype/next/length.js +++ b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/length.js @@ -25,10 +25,11 @@ features: [Symbol.iterator] var StringIteratorProto = Object.getPrototypeOf(new String()[Symbol.iterator]()); -assert.sameValue(StringIteratorProto.next.length, 0); - -verifyNotEnumerable(StringIteratorProto.next, "length"); -verifyNotWritable(StringIteratorProto.next, "length"); -verifyConfigurable(StringIteratorProto.next, "length"); +verifyProperty(StringIteratorProto.next, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/StringIteratorPrototype/next/name.js b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/name.js index f990a85d2f..3947cf00da 100644 --- a/js/src/tests/test262/built-ins/StringIteratorPrototype/next/name.js +++ b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/name.js @@ -22,10 +22,11 @@ features: [Symbol.iterator] var StringIteratorProto = Object.getPrototypeOf(new String()[Symbol.iterator]()); -assert.sameValue(StringIteratorProto.next.name, "next"); - -verifyNotEnumerable(StringIteratorProto.next, "name"); -verifyNotWritable(StringIteratorProto.next, "name"); -verifyConfigurable(StringIteratorProto.next, "name"); +verifyProperty(StringIteratorProto.next, "name", { + value: "next", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/for/length.js b/js/src/tests/test262/built-ins/Symbol/for/length.js index 5875d22702..17c82f8979 100644 --- a/js/src/tests/test262/built-ins/Symbol/for/length.js +++ b/js/src/tests/test262/built-ins/Symbol/for/length.js @@ -23,10 +23,11 @@ includes: [propertyHelper.js] features: [Symbol] ---*/ -assert.sameValue(Symbol.for.length, 1); - -verifyNotEnumerable(Symbol.for, "length"); -verifyNotWritable(Symbol.for, "length"); -verifyConfigurable(Symbol.for, "length"); +verifyProperty(Symbol.for, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/for/name.js b/js/src/tests/test262/built-ins/Symbol/for/name.js index fce43732c0..d7674139e5 100644 --- a/js/src/tests/test262/built-ins/Symbol/for/name.js +++ b/js/src/tests/test262/built-ins/Symbol/for/name.js @@ -20,10 +20,11 @@ includes: [propertyHelper.js] features: [Symbol] ---*/ -assert.sameValue(Symbol.for.name, "for"); - -verifyNotEnumerable(Symbol.for, "name"); -verifyNotWritable(Symbol.for, "name"); -verifyConfigurable(Symbol.for, "name"); +verifyProperty(Symbol.for, "name", { + value: "for", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/for/not-a-constructor.js b/js/src/tests/test262/built-ins/Symbol/for/not-a-constructor.js index a90a09e9a3..3e88dd3a7b 100644 --- a/js/src/tests/test262/built-ins/Symbol/for/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Symbol/for/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Symbol.for), false, 'isConstructor(Symbol.for) mu assert.throws(TypeError, () => { new Symbol.for(); -}, '`new Symbol.for()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/keyFor/length.js b/js/src/tests/test262/built-ins/Symbol/keyFor/length.js index 8f1296daf6..b01ae0f8bf 100644 --- a/js/src/tests/test262/built-ins/Symbol/keyFor/length.js +++ b/js/src/tests/test262/built-ins/Symbol/keyFor/length.js @@ -23,10 +23,11 @@ includes: [propertyHelper.js] features: [Symbol] ---*/ -assert.sameValue(Symbol.keyFor.length, 1); - -verifyNotEnumerable(Symbol.keyFor, "length"); -verifyNotWritable(Symbol.keyFor, "length"); -verifyConfigurable(Symbol.keyFor, "length"); +verifyProperty(Symbol.keyFor, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/keyFor/name.js b/js/src/tests/test262/built-ins/Symbol/keyFor/name.js index 10adeeb674..9bbd98a48d 100644 --- a/js/src/tests/test262/built-ins/Symbol/keyFor/name.js +++ b/js/src/tests/test262/built-ins/Symbol/keyFor/name.js @@ -20,10 +20,11 @@ includes: [propertyHelper.js] features: [Symbol] ---*/ -assert.sameValue(Symbol.keyFor.name, "keyFor"); - -verifyNotEnumerable(Symbol.keyFor, "name"); -verifyNotWritable(Symbol.keyFor, "name"); -verifyConfigurable(Symbol.keyFor, "name"); +verifyProperty(Symbol.keyFor, "name", { + value: "keyFor", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/keyFor/not-a-constructor.js b/js/src/tests/test262/built-ins/Symbol/keyFor/not-a-constructor.js index 61d6b676d6..ac45a99ffe 100644 --- a/js/src/tests/test262/built-ins/Symbol/keyFor/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Symbol/keyFor/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(Symbol.keyFor), false, 'isConstructor(Symbol.keyF assert.throws(TypeError, () => { new Symbol.keyFor(Symbol()); -}, '`new Symbol.keyFor(Symbol())` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/length.js b/js/src/tests/test262/built-ins/Symbol/length.js index f50c96667d..d9caf91980 100644 --- a/js/src/tests/test262/built-ins/Symbol/length.js +++ b/js/src/tests/test262/built-ins/Symbol/length.js @@ -12,10 +12,11 @@ includes: [propertyHelper.js] features: [Symbol] ---*/ -assert.sameValue(Symbol.length, 0, "The value of `Symbol.length` is `0`"); - -verifyNotEnumerable(Symbol, "length"); -verifyNotWritable(Symbol, "length"); -verifyConfigurable(Symbol, "length"); +verifyProperty(Symbol, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/name.js b/js/src/tests/test262/built-ins/Symbol/name.js index c639fc142d..834756a954 100644 --- a/js/src/tests/test262/built-ins/Symbol/name.js +++ b/js/src/tests/test262/built-ins/Symbol/name.js @@ -10,10 +10,11 @@ includes: [propertyHelper.js] features: [Symbol] ---*/ -assert.sameValue(Symbol.name, "Symbol", "The value of `Symbol.name` is `'Symbol'`"); - -verifyNotEnumerable(Symbol, "name"); -verifyNotWritable(Symbol, "name"); -verifyConfigurable(Symbol, "name"); +verifyProperty(Symbol, "name", { + value: "Symbol", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/Symbol.toPrimitive/length.js b/js/src/tests/test262/built-ins/Symbol/prototype/Symbol.toPrimitive/length.js index b2cf331005..55b25f33c4 100644 --- a/js/src/tests/test262/built-ins/Symbol/prototype/Symbol.toPrimitive/length.js +++ b/js/src/tests/test262/built-ins/Symbol/prototype/Symbol.toPrimitive/length.js @@ -20,10 +20,11 @@ features: [Symbol.toPrimitive] includes: [propertyHelper.js] ---*/ -assert.sameValue(Symbol.prototype[Symbol.toPrimitive].length, 1); - -verifyNotEnumerable(Symbol.prototype[Symbol.toPrimitive], 'length'); -verifyNotWritable(Symbol.prototype[Symbol.toPrimitive], 'length'); -verifyConfigurable(Symbol.prototype[Symbol.toPrimitive], 'length'); +verifyProperty(Symbol.prototype[Symbol.toPrimitive], "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/Symbol.toPrimitive/name.js b/js/src/tests/test262/built-ins/Symbol/prototype/Symbol.toPrimitive/name.js index 58579822e7..c31147ac68 100644 --- a/js/src/tests/test262/built-ins/Symbol/prototype/Symbol.toPrimitive/name.js +++ b/js/src/tests/test262/built-ins/Symbol/prototype/Symbol.toPrimitive/name.js @@ -17,12 +17,11 @@ features: [Symbol.toPrimitive] includes: [propertyHelper.js] ---*/ -assert.sameValue( - Symbol.prototype[Symbol.toPrimitive].name, '[Symbol.toPrimitive]' -); - -verifyNotEnumerable(Symbol.prototype[Symbol.toPrimitive], 'name'); -verifyNotWritable(Symbol.prototype[Symbol.toPrimitive], 'name'); -verifyConfigurable(Symbol.prototype[Symbol.toPrimitive], 'name'); +verifyProperty(Symbol.prototype[Symbol.toPrimitive], "name", { + value: "[Symbol.toPrimitive]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/toString/length.js b/js/src/tests/test262/built-ins/Symbol/prototype/toString/length.js index 84e95cf747..22cc78485f 100644 --- a/js/src/tests/test262/built-ins/Symbol/prototype/toString/length.js +++ b/js/src/tests/test262/built-ins/Symbol/prototype/toString/length.js @@ -23,10 +23,11 @@ includes: [propertyHelper.js] features: [Symbol] ---*/ -assert.sameValue(Symbol.prototype.toString.length, 0); - -verifyNotEnumerable(Symbol.prototype.toString, "length"); -verifyNotWritable(Symbol.prototype.toString, "length"); -verifyConfigurable(Symbol.prototype.toString, "length"); +verifyProperty(Symbol.prototype.toString, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/toString/name.js b/js/src/tests/test262/built-ins/Symbol/prototype/toString/name.js index 705eb779f6..d6aa21719e 100644 --- a/js/src/tests/test262/built-ins/Symbol/prototype/toString/name.js +++ b/js/src/tests/test262/built-ins/Symbol/prototype/toString/name.js @@ -20,10 +20,11 @@ includes: [propertyHelper.js] features: [Symbol] ---*/ -assert.sameValue(Symbol.prototype.toString.name, "toString"); - -verifyNotEnumerable(Symbol.prototype.toString, "name"); -verifyNotWritable(Symbol.prototype.toString, "name"); -verifyConfigurable(Symbol.prototype.toString, "name"); +verifyProperty(Symbol.prototype.toString, "name", { + value: "toString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/Symbol/prototype/toString/not-a-constructor.js index 58914a60d2..c590ca39e0 100644 --- a/js/src/tests/test262/built-ins/Symbol/prototype/toString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Symbol/prototype/toString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let symbol = Symbol(); new symbol.toString(); -}, '`let symbol = Symbol(); new symbol.toString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/length.js b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/length.js index 0134f86d03..3fe32533ba 100644 --- a/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/length.js +++ b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/length.js @@ -23,10 +23,11 @@ includes: [propertyHelper.js] features: [Symbol] ---*/ -assert.sameValue(Symbol.prototype.valueOf.length, 0); - -verifyNotEnumerable(Symbol.prototype.valueOf, "length"); -verifyNotWritable(Symbol.prototype.valueOf, "length"); -verifyConfigurable(Symbol.prototype.valueOf, "length"); +verifyProperty(Symbol.prototype.valueOf, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/name.js b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/name.js index a9104cd8a8..4ff3ef9dfa 100644 --- a/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/name.js +++ b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/name.js @@ -20,10 +20,11 @@ includes: [propertyHelper.js] features: [Symbol] ---*/ -assert.sameValue(Symbol.prototype.valueOf.name, "valueOf"); - -verifyNotEnumerable(Symbol.prototype.valueOf, "name"); -verifyNotWritable(Symbol.prototype.valueOf, "name"); -verifyConfigurable(Symbol.prototype.valueOf, "name"); +verifyProperty(Symbol.prototype.valueOf, "name", { + value: "valueOf", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/not-a-constructor.js index e9edf778b8..7d0dbb5390 100644 --- a/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let symbol = Symbol(); new symbol.valueOf(); -}, '`let symbol = Symbol(); new symbol.valueOf()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/from/calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Calendar/from/calendar-iso-string.js new file mode 100644 index 0000000000..1b8ebe9921 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/from/calendar-iso-string.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.from +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +for (const arg of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const result = Temporal.Calendar.from(arg); + assert.sameValue(result.id, "iso8601", `Calendar created from string "${arg}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..70e4e25b5f --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.dateadd +description: An ISO 8601 string can be converted to a calendar ID in Calendar +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.dateAdd(arg, new Temporal.Duration()); + TemporalHelpers.assertPlainDate(result, 1976, 11, "M11", 18, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-number.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-number.js index 80b3fcd76f..736c6dd4a9 100644 --- a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-number.js +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-number.js @@ -8,7 +8,7 @@ description: A number as calendar in a property bag is not accepted features: [Temporal] ---*/ -const instance = new Temporal.PlainDate(1976, 11, 18); +const instance = new Temporal.Calendar("iso8601"); const numbers = [ 1, @@ -16,6 +16,7 @@ const numbers = [ -19970327, 1234567890, ]; + for (const calendar of numbers) { const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; assert.throws( diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-year-zero.js index 2a93ec4ea9..2724dbf8cc 100644 --- a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.dateAdd(arg, new Temporal.Duration()), diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..c67b09ebcc --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.dateadd +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.dateAdd(arg, new Temporal.Duration()), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..1afad6f499 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,31 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.dateuntil +description: An ISO 8601 string can be converted to a calendar ID in Calendar +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result1 = instance.dateUntil(arg, new Temporal.PlainDate(1976, 11, 19)); + TemporalHelpers.assertDuration(result1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}" (first argument)`); + const result2 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 19), arg); + TemporalHelpers.assertDuration(result2, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}" (second argument)`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..23b19e9bfc --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.dateuntil +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), + `annotation keys must be lowercase: ${arg} - ${descr} (first argument)` + ); + assert.throws( + RangeError, + () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), + `annotation keys must be lowercase: ${arg} - ${descr} (second argument)` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..47be8c3a73 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.day +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.day(arg); + assert.sameValue(result, 18, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-year-zero.js index 454c6a68de..6338e62891 100644 --- a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.day(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/day/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/day/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..d377a25e9d --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/day/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.day +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.day(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..c9f21ef479 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.dayofweek +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.dayOfWeek(arg); + assert.sameValue(result, 4, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-year-zero.js index 767b87d15d..0f344803c2 100644 --- a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.dayOfWeek(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..34093a68f3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.dayofweek +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.dayOfWeek(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..5195cd886d --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.dayofyear +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.dayOfYear(arg); + assert.sameValue(result, 323, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-year-zero.js index 7f06c31917..88fa0c5943 100644 --- a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.dayOfYear(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..f2d9dad0fa --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.dayofyear +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.dayOfYear(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..43fc09859c --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.daysinmonth +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.daysInMonth(arg); + assert.sameValue(result, 30, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-year-zero.js index 8a6f651473..b6cd325c2e 100644 --- a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.daysInMonth(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..c3db32b57b --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.daysinmonth +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.daysInMonth(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..48ca5287e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.daysinweek +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.daysInWeek(arg); + assert.sameValue(result, 7, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-year-zero.js index 7d8395c074..6330524f58 100644 --- a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.daysInWeek(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..6dec3595a1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.daysinweek +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.daysInWeek(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..436cb1d1ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.daysinyear +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.daysInYear(arg); + assert.sameValue(result, 366, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-year-zero.js index 18d81a4c17..ce5d9ad77d 100644 --- a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.daysInYear(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..0464d68688 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.daysinyear +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.daysInYear(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..9cb59aa80a --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.inleapyear +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.inLeapYear(arg); + assert.sameValue(result, true, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-year-zero.js index 0835539959..a82d22bbfe 100644 --- a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.inLeapYear(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..075c05f59a --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.inleapyear +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.inLeapYear(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..a9c95173bc --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.month +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.month(arg); + assert.sameValue(result, 11, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-year-zero.js index 81bd484995..86b60ce29c 100644 --- a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.month(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/month/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/month/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..9a166ae68b --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/month/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.month +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.month(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..b4106f48e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.monthcode +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.monthCode(arg); + assert.sameValue(result, "M11", `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-year-zero.js index 24178dfdb9..c07ef5ec26 100644 --- a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.monthCode(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..69e854b1cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.monthcode +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.monthCode(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..bf5ce2c86a --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.monthsinyear +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.monthsInYear(arg); + assert.sameValue(result, 12, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-year-zero.js index c05540c245..517784b934 100644 --- a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.monthsInYear(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..75cd954103 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.monthsinyear +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.monthsInYear(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..97fa05fdca --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.weekofyear +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.weekOfYear(arg); + assert.sameValue(result, 47, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-year-zero.js index 023b2ca730..3465289d38 100644 --- a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.weekOfYear(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..f32b39605e --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.weekofyear +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.weekOfYear(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/weekOfYear/custom-calendar-weekofyear.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/weekOfYear/custom-calendar-weekofyear.js new file mode 100644 index 0000000000..c7f69b11d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/weekOfYear/custom-calendar-weekofyear.js @@ -0,0 +1,26 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.weekofyear +description: > + Temporal.Calendar.prototype.weekOfYear returns undefined for all + custom calendars where weekOfYear() returns undefined. +features: [Temporal] +---*/ + +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + weekOfYear() { + return undefined; + } +} + +const calendar = new CustomCalendar(); +const customCalendarDate = { month: 1, day: 1, year: 2024, calendar}; +assert.sameValue(calendar.weekOfYear({...customCalendarDate}), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..d56ec21d0b --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.year +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.year(arg); + assert.sameValue(result, 1976, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-year-zero.js index 742326e600..81e2cc5f75 100644 --- a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.year(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/year/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/year/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..ab698cfd86 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/year/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.year +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.year(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..cf2ffb511d --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.yearofweek +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.yearOfWeek(arg); + assert.sameValue(result, 1976, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-year-zero.js index ad33245788..d3a054c682 100644 --- a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.yearOfWeek(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..2293852bdc --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.yearofweek +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.yearOfWeek(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearOfWeek/custom-calendar-weekofyear.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearOfWeek/custom-calendar-weekofyear.js new file mode 100644 index 0000000000..6d618ae608 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearOfWeek/custom-calendar-weekofyear.js @@ -0,0 +1,26 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.yearofweek +description: > + Temporal.Calendar.prototype.yearOfWeek returns undefined for all + custom calendars where yearOfWeek() returns undefined. +features: [Temporal] +---*/ + +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + yearOfWeek() { + return undefined; + } +} + +const calendar = new CustomCalendar(); +const customCalendarDate = { month: 1, day: 1, year: 2024, calendar}; +assert.sameValue(calendar.yearOfWeek({...customCalendarDate}), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/compare/duration-out-of-range-added-to-relativeto.js b/js/src/tests/test262/built-ins/Temporal/Duration/compare/duration-out-of-range-added-to-relativeto.js new file mode 100644 index 0000000000..cb8c1157d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Duration/compare/duration-out-of-range-added-to-relativeto.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.compare +description: RangeError thrown when calendar part of duration added to relativeTo is out of range +features: [Temporal] +info: | + UnbalanceDateDurationRelative: + 11. Let _yearsMonthsWeeksDuration_ be ! CreateTemporalDuration(_years_, _months_, _weeks_, 0, 0, 0, 0, 0, 0, 0). + 12. Let _later_ be ? CalendarDateAdd(_calendaRec_, _plainRelativeTo_, _yearsMonthsWeeksDuration_). + 13. Let _yearsMonthsWeeksInDays_ be DaysUntil(_plainRelativeTo_, _later_). + 14. Return ? CreateDateDurationRecord(0, 0, 0, _days_ + _yearsMonthsWeeksInDays_). +---*/ + +// Based on a test case by André Bargull <andre.bargull@gmail.com> + +const relativeTo = new Temporal.PlainDate(2000, 1, 1); +const zero = new Temporal.Duration(); + +const instance = new Temporal.Duration(0, 0, /* weeks = */ 1, /* days = */ Math.trunc((2 ** 53) / 86_400)); +assert.throws(RangeError, () => Temporal.Duration.compare(instance, zero, {relativeTo}), "weeks + days out of range, positive, first argument"); +assert.throws(RangeError, () => Temporal.Duration.compare(zero, instance, {relativeTo}), "weeks + days out of range, positive, second argument"); + +const negInstance = new Temporal.Duration(0, 0, /* weeks = */ -1, /* days = */ -Math.trunc((2 ** 53) / 86_400)); +assert.throws(RangeError, () => Temporal.Duration.compare(negInstance, zero, {relativeTo}), "weeks + days out of range, negative, first argument"); +assert.throws(RangeError, () => Temporal.Duration.compare(zero, negInstance, {relativeTo}), "weeks + days out of range, negative, second argument"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/compare/relativeto-propertybag-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/Duration/compare/relativeto-propertybag-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..98fb6b5ef9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Duration/compare/relativeto-propertybag-out-of-range-backward-offset-shift.js @@ -0,0 +1,51 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.compare +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const relativeTo = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; +const duration1 = new Temporal.Duration(1); +const duration2 = new Temporal.Duration(2); + +assert.throws(RangeError, () => Temporal.Duration.compare(duration1, duration2, {relativeTo: relativeTo}), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/compare/relativeto-propertybag-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/Duration/compare/relativeto-propertybag-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..cbfca704c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Duration/compare/relativeto-propertybag-out-of-range-forward-offset-shift.js @@ -0,0 +1,46 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.compare +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const relativeTo = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; +const duration1 = new Temporal.Duration(1); +const duration2 = new Temporal.Duration(2); + +assert.throws(RangeError, () => Temporal.Duration.compare(duration1, duration2, {relativeTo: relativeTo}), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/from/argument-duration-max.js b/js/src/tests/test262/built-ins/Temporal/Duration/from/argument-duration-max.js index 0a4043d391..af9f721949 100644 --- a/js/src/tests/test262/built-ins/Temporal/Duration/from/argument-duration-max.js +++ b/js/src/tests/test262/built-ins/Temporal/Duration/from/argument-duration-max.js @@ -11,7 +11,7 @@ features: [Temporal] const maxCases = [ ["P4294967295Y104249991374DT7H36M31.999999999S", "string with max years"], [{ years: 4294967295, days: 104249991374, nanoseconds: 27391999999999 }, "property bag with max years"], - ["P4294967295M104249991374DT7H36M31.999999999S", "string with max weeks"], + ["P4294967295M104249991374DT7H36M31.999999999S", "string with max months"], [{ months: 4294967295, days: 104249991374, nanoseconds: 27391999999999 }, "property bag with max months"], ["P4294967295W104249991374DT7H36M31.999999999S", "string with max weeks"], [{ weeks: 4294967295, days: 104249991374, nanoseconds: 27391999999999 }, "property bag with max weeks"], diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/calendar-dateadd-called-with-options-undefined.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/calendar-dateadd-called-with-options-undefined.js index 4955abacdd..84079298ce 100644 --- a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/calendar-dateadd-called-with-options-undefined.js +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/calendar-dateadd-called-with-options-undefined.js @@ -15,6 +15,6 @@ const calendar = TemporalHelpers.calendarDateAddUndefinedOptions(); const timeZone = TemporalHelpers.oneShiftTimeZone(new Temporal.Instant(0n), 3600e9); const instance = new Temporal.Duration(1, 1, 1, 1); instance.add(instance, { relativeTo: new Temporal.ZonedDateTime(0n, timeZone, calendar) }); -assert.sameValue(calendar.dateAddCallCount, 3); +assert.sameValue(calendar.dateAddCallCount, 2); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/differencezoneddatetime-inconsistent-custom-calendar.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/differencezoneddatetime-inconsistent-custom-calendar.js new file mode 100644 index 0000000000..01bf6c756e --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/differencezoneddatetime-inconsistent-custom-calendar.js @@ -0,0 +1,55 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.duration.prototype.add +description: > + Throws a RangeError when custom calendar method returns inconsistent result +info: | + DifferenceZonedDateTime ( ... ) + 8. Repeat 3 times: + ... + g. If _sign_ = 0, or _timeSign_ = 0, or _sign_ = _timeSign_, then + ... + viii. Return ? CreateNormalizedDurationRecord(_dateDifference_.[[Years]], + _dateDifference_.[[Months]], _dateDifference_.[[Weeks]], + _dateDifference_.[[Days]], _norm_). + h. Set _dayCorrection_ to _dayCorrection_ + 1. + 9. NOTE: This step is only reached when custom calendar or time zone methods + return inconsistent values. + 10. Throw a *RangeError* exception. +features: [Temporal] +---*/ + +// Based partly on a test case by André Bargull + +const duration1 = new Temporal.Duration(0, 0, /* weeks = */ 7, 0, /* hours = */ 12); +const duration2 = new Temporal.Duration(0, 0, 0, /* days = */ 1); + +{ + const tz = new (class extends Temporal.TimeZone { + getPossibleInstantsFor(dateTime) { + return super.getPossibleInstantsFor(dateTime.add({ days: 3 })); + } + })("UTC"); + + const relativeTo = new Temporal.ZonedDateTime(0n, tz); + + assert.throws(RangeError, () => duration1.add(duration2, { relativeTo }), + "Calendar calculation where more than 2 days correction is needed should cause RangeError"); +} + +{ + const cal = new (class extends Temporal.Calendar { + dateUntil(one, two, options) { + return super.dateUntil(one, two, options).negated(); + } + })("iso8601"); + + const relativeTo = new Temporal.ZonedDateTime(0n, "UTC", cal); + + assert.throws(RangeError, () => duration1.add(duration2, { relativeTo }), + "Calendar calculation causing mixed-sign values should cause RangeError"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/normalized-time-duration-to-days-loop-arbitrarily.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/normalized-time-duration-to-days-loop-arbitrarily.js deleted file mode 100644 index 62833e87c6..0000000000 --- a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/normalized-time-duration-to-days-loop-arbitrarily.js +++ /dev/null @@ -1,78 +0,0 @@ -// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.add -description: > - NormalizedTimeDurationToDays can loop arbitrarily up to max safe integer -info: | - NormalizedTimeDurationToDays ( norm, zonedRelativeTo, timeZoneRec [ , precalculatedPlainDatetime ] ) - ... - 21. Repeat, while done is false, - a. Let oneDayFarther be ? AddDaysToZonedDateTime(relativeResult.[[Instant]], - relativeResult.[[DateTime]], timeZoneRec, zonedRelativeTo.[[Calendar]], sign). - b. Set dayLengthNs to NormalizedTimeDurationFromEpochNanosecondsDifference(oneDayFarther.[[EpochNanoseconds]], - relativeResult.[[EpochNanoseconds]]). - c. Let oneDayLess be ? SubtractNormalizedTimeDuration(norm, dayLengthNs). - c. If NormalizedTimeDurationSign(oneDayLess) × sign ≥ 0, then - i. Set norm to oneDayLess. - ii. Set relativeResult to oneDayFarther. - iii. Set days to days + sign. - d. Else, - i. Set done to true. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calls = []; -const duration = Temporal.Duration.from({ days: 1 }); - -function createRelativeTo(count) { - const dayLengthNs = 86400000000000n; - const dayInstant = new Temporal.Instant(dayLengthNs); - const substitutions = []; - const timeZone = new Temporal.TimeZone("UTC"); - // Return constant value for first _count_ calls - TemporalHelpers.substituteMethod( - timeZone, - "getPossibleInstantsFor", - substitutions - ); - substitutions.length = count; - let i = 0; - for (i = 0; i < substitutions.length; i++) { - // (this value) - substitutions[i] = [dayInstant]; - } - // Record calls in calls[] - TemporalHelpers.observeMethod(calls, timeZone, "getPossibleInstantsFor"); - return new Temporal.ZonedDateTime(0n, timeZone); -} - -let zdt = createRelativeTo(50); -calls.splice(0); // Reset calls list after ZonedDateTime construction -duration.add(duration, { - relativeTo: zdt, -}); -assert.sameValue( - calls.length, - 50 + 1, - "Expected duration.add to call getPossibleInstantsFor correct number of times" -); - -zdt = createRelativeTo(100); -calls.splice(0); // Reset calls list after previous loop + ZonedDateTime construction -duration.add(duration, { - relativeTo: zdt, -}); -assert.sameValue( - calls.length, - 100 + 1, - "Expected duration.add to call getPossibleInstantsFor correct number of times" -); - -zdt = createRelativeTo(107); -assert.throws(RangeError, () => duration.add(duration, { relativeTo: zdt }), "107-2 days > 2⁵³ ns"); - -reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/order-of-operations.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/order-of-operations.js index a530ba55e9..c3a2f2c4a9 100644 --- a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/order-of-operations.js +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/order-of-operations.js @@ -339,18 +339,8 @@ const expectedOpsForZonedRelativeTo = expected.concat([ "call options.relativeTo.timeZone.getPossibleInstantsFor", // AddDuration → DifferenceZonedDateTime "call options.relativeTo.timeZone.getOffsetNanosecondsFor", - // AddDuration → DifferenceZonedDateTime → DifferenceISODateTime - "call options.relativeTo.calendar.dateUntil", - // AddDuration → DifferenceZonedDateTime → AddZonedDateTime - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.timeZone.getPossibleInstantsFor", - // AddDuration → DifferenceZonedDateTime → NanosecondsToDays - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", - // AddDuration → DifferenceZonedDateTime → NanosecondsToDays → AddZonedDateTime 1 - "call options.relativeTo.timeZone.getPossibleInstantsFor", - // AddDuration → DifferenceZonedDateTime → NanosecondsToDays → AddZonedDateTime 2 "call options.relativeTo.timeZone.getPossibleInstantsFor", + "call options.relativeTo.calendar.dateUntil", ]); const zonedRelativeTo = TemporalHelpers.propertyBagObserver(actual, { diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..a8506addba --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-out-of-range-backward-offset-shift.js @@ -0,0 +1,50 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.add +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const relativeTo = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; + +const instance = new Temporal.Duration(1, 0, 0, 1); +assert.throws(RangeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..705327b70e --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-out-of-range-forward-offset-shift.js @@ -0,0 +1,45 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.add +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const relativeTo = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; + +const instance = new Temporal.Duration(1, 0, 0, 1); +assert.throws(RangeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js deleted file mode 100644 index 7acd5929b6..0000000000 --- a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/add/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js +++ /dev/null @@ -1,146 +0,0 @@ -// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.prototype.add -description: > - Abstract operation NormalizedTimeDurationToDays can throw four different - RangeErrors. -info: | - NormalizedTimeDurationToDays ( norm, zonedRelativeTo, timeZoneRec [ , precalculatedPlainDateTime ] ) - 22. If days < 0 and sign = 1, throw a RangeError exception. - 23. If days > 0 and sign = -1, throw a RangeError exception. - ... - 25. If NormalizedTimeDurationSign(_norm_) = 1 and sign = -1, throw a RangeError exception. - ... - 28. If dayLength ≥ 2⁵³, throw a RangeError exception. -features: [Temporal, BigInt] -includes: [temporalHelpers.js] ----*/ - -const dayNs = 86_400_000_000_000; -const dayDuration = Temporal.Duration.from({ days: 1 }); -const epochInstant = new Temporal.Instant(0n); - -function timeZoneSubstituteValues( - getPossibleInstantsFor, - getOffsetNanosecondsFor -) { - const tz = new Temporal.TimeZone("UTC"); - TemporalHelpers.substituteMethod( - tz, - "getPossibleInstantsFor", - getPossibleInstantsFor - ); - TemporalHelpers.substituteMethod( - tz, - "getOffsetNanosecondsFor", - getOffsetNanosecondsFor - ); - return tz; -} - -// Step 22: days < 0 and sign = 1 -let zdt = new Temporal.ZonedDateTime( - -1n, // Set DifferenceZonedDateTime _ns1_ - timeZoneSubstituteValues( - [ - TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally for first call, AddDuration step 15 - [epochInstant], // Returned in AddDuration step 16, setting _endNs_ -> DifferenceZonedDateTime _ns2_ - [epochInstant], // Returned in step 16, setting _relativeResult_ - ], - [ - // Behave normally in 3 calls made prior to NormalizedTimeDurationToDays - TemporalHelpers.SUBSTITUTE_SKIP, - TemporalHelpers.SUBSTITUTE_SKIP, - TemporalHelpers.SUBSTITUTE_SKIP, - dayNs - 1, // Returned in step 8, setting _startDateTime_ - -dayNs + 1, // Returned in step 9, setting _endDateTime_ - ] - ) -); -assert.throws(RangeError, () => - // Adding day to day sets largestUnit to 'day', avoids having any week/month/year components in differences - dayDuration.add(dayDuration, { - relativeTo: zdt, - }), - "days < 0 and sign = 1" -); - -// Step 23: days > 0 and sign = -1 -zdt = new Temporal.ZonedDateTime( - 1n, // Set DifferenceZonedDateTime _ns1_ - timeZoneSubstituteValues( - [ - TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally for first call, AddDuration step 15 - [epochInstant], // Returned in AddDuration step 16, setting _endNs_ -> DifferenceZonedDateTime _ns2_ - [epochInstant], // Returned in step 16, setting _relativeResult_ - ], - [ - // Behave normally in 3 calls made prior to NanosecondsToDays - TemporalHelpers.SUBSTITUTE_SKIP, - TemporalHelpers.SUBSTITUTE_SKIP, - TemporalHelpers.SUBSTITUTE_SKIP, - -dayNs + 1, // Returned in step 8, setting _startDateTime_ - dayNs - 1, // Returned in step 9, setting _endDateTime_ - ] - ) -); -assert.throws(RangeError, () => - // Adding day to day sets largestUnit to 'day', avoids having any week/month/year components in differences - dayDuration.add(dayDuration, { - relativeTo: zdt, - }), - "days > 0 and sign = -1" -); - -// Step 25: nanoseconds > 0 and sign = -1 -zdt = new Temporal.ZonedDateTime( - 0n, // Set DifferenceZonedDateTime _ns1_ - timeZoneSubstituteValues( - [ - TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally for first call, AddDuration step 15 - [new Temporal.Instant(-1n)], // Returned in AddDuration step 16, setting _endNs_ -> DifferenceZonedDateTime _ns2_ - [new Temporal.Instant(-2n)], // Returned in step 16, setting _relativeResult_ - [new Temporal.Instant(-4n)], // Returned in step 21.a, setting _oneDayFarther_ - ], - [ - // Behave normally in 3 calls made prior to NanosecondsToDays - TemporalHelpers.SUBSTITUTE_SKIP, - TemporalHelpers.SUBSTITUTE_SKIP, - TemporalHelpers.SUBSTITUTE_SKIP, - dayNs - 1, // Returned in step 8, setting _startDateTime_ - -dayNs + 1, // Returned in step 9, setting _endDateTime_ - ] - ) -); -assert.throws(RangeError, () => - // Adding day to day sets largestUnit to 'day', avoids having any week/month/year components in differences - dayDuration.add(dayDuration, { - relativeTo: zdt, - }), - "nanoseconds > 0 and sign = -1" -); - -// Step 28: day length is an unsafe integer -zdt = new Temporal.ZonedDateTime( - 0n, - timeZoneSubstituteValues( - [ - TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally for AddDuration step 15 - TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally for AddDuration step 16 - TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally for step 16, setting _relativeResult_ - // Returned in step 21.a, making _oneDayFarther_ 2^53 ns later than _relativeResult_ - [new Temporal.Instant(2n ** 53n + 2n * BigInt(dayNs))], - ], - [] - ) -); -assert.throws(RangeError, () => - dayDuration.add(dayDuration, { - relativeTo: zdt, - }), - "Should throw RangeError when time zone calculates an outrageous day length" -); - -reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/dst-rounding-result.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/dst-rounding-result.js new file mode 100644 index 0000000000..daff4e93f6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/dst-rounding-result.js @@ -0,0 +1,48 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.duration.prototype.round +description: > + Rounding the resulting duration takes the time zone's UTC offset shifts + into account +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); + +// Based on a test case by Adam Shaw + +{ + // Date part of duration lands on skipped DST hour, causing disambiguation + const duration = new Temporal.Duration(0, 1, 0, 15, 12); + const relativeTo = new Temporal.ZonedDateTime( + 950868000_000_000_000n /* = 2000-02-18T10Z */, + timeZone); /* = 2000-02-18T02-08 in local time */ + + TemporalHelpers.assertDuration(duration.round({ smallestUnit: "months", relativeTo }), + 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, + "1 month 15 days 12 hours should be exactly 1.5 months, which rounds up to 2 months"); + TemporalHelpers.assertDuration(duration.round({ smallestUnit: "months", roundingMode: 'halfTrunc', relativeTo }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + "1 month 15 days 12 hours should be exactly 1.5 months, which rounds down to 1 month"); +} + +{ + // Month-only part of duration lands on skipped DST hour, should not cause + // disambiguation + const duration = new Temporal.Duration(0, 1, 0, 15); + const relativeTo = new Temporal.ZonedDateTime( + 951991200_000_000_000n /* = 2000-03-02T10Z */, + timeZone); /* = 2000-03-02T02-08 in local time */ + + TemporalHelpers.assertDuration(duration.round({ smallestUnit: "months", relativeTo }), + 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, + "1 month 15 days should be exactly 1.5 months, which rounds up to 2 months"); + TemporalHelpers.assertDuration(duration.round({ smallestUnit: "months", roundingMode: 'halfTrunc', relativeTo }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + "1 month 15 days should be exactly 1.5 months, which rounds down to 1 month"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/duration-out-of-range-added-to-relativeto.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/duration-out-of-range-added-to-relativeto.js index b564b27eb4..f63eb3b789 100644 --- a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/duration-out-of-range-added-to-relativeto.js +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/duration-out-of-range-added-to-relativeto.js @@ -8,21 +8,44 @@ description: RangeError thrown when calendar part of duration added to relativeT features: [Temporal] info: | RoundDuration: - 8.k. Let _isoResult_ be ! AddISODate(_plainRelativeTo_.[[ISOYear]]. _plainRelativeTo_.[[ISOMonth]], _plainRelativeTo_.[[ISODay]], 0, 0, 0, truncate(_fractionalDays_), *"constrain"*). - l. Let _wholeDaysLater_ be ? CreateTemporalDate(_isoResult_.[[Year]], _isoResult_.[[Month]], _isoResult_.[[Day]], _calendar_). + 10.h. Let _isoResult_ be ! AddISODate(_plainRelativeTo_.[[ISOYear]]. _plainRelativeTo_.[[ISOMonth]], _plainRelativeTo_.[[ISODay]], 0, 0, 0, truncate(_fractionalDays_), *"constrain"*). + i. Let _wholeDaysLater_ be ? CreateTemporalDate(_isoResult_.[[Year]], _isoResult_.[[Month]], _isoResult_.[[Day]], _calendar_). + ... + 11.h. Let _isoResult_ be ! AddISODate(_plainRelativeTo_.[[ISOYear]]. _plainRelativeTo_.[[ISOMonth]], _plainRelativeTo_.[[ISODay]], 0, 0, 0, truncate(_fractionalDays_), *"constrain"*). + i. Let _wholeDaysLater_ be ? CreateTemporalDate(_isoResult_.[[Year]], _isoResult_.[[Month]], _isoResult_.[[Day]], _calendar_). + ... + 12.a. Let _isoResult_ be ! AddISODate(_plainRelativeTo_.[[ISOYear]]. _plainRelativeTo_.[[ISOMonth]], _plainRelativeTo_.[[ISODay]], 0, 0, 0, truncate(_fractionalDays_), *"constrain"*). + b. Let _wholeDaysLater_ be ? CreateTemporalDate(_isoResult_.[[Year]], _isoResult_.[[Month]], _isoResult_.[[Day]], _calendar_). + + UnbalanceDateDurationRelative: + 11. Let _yearsMonthsWeeksDuration_ be ! CreateTemporalDuration(_years_, _months_, _weeks_, 0, 0, 0, 0, 0, 0, 0). + 12. Let _later_ be ? CalendarDateAdd(_calendaRec_, _plainRelativeTo_, _yearsMonthsWeeksDuration_). + 13. Let _yearsMonthsWeeksInDays_ be DaysUntil(_plainRelativeTo_, _later_). + 14. Return ? CreateDateDurationRecord(0, 0, 0, _days_ + _yearsMonthsWeeksInDays_). ---*/ // Based on a test case by André Bargull <andre.bargull@gmail.com> -const instance = new Temporal.Duration(0, 0, 0, /* days = */ 500_000_000); const relativeTo = new Temporal.PlainDate(2000, 1, 1); -assert.throws(RangeError, () => instance.round({relativeTo, smallestUnit: "years"})); -assert.throws(RangeError, () => instance.round({relativeTo, smallestUnit: "months"})); -assert.throws(RangeError, () => instance.round({relativeTo, smallestUnit: "weeks"})); - -const negInstance = new Temporal.Duration(0, 0, 0, /* days = */ -500_000_000); -assert.throws(RangeError, () => negInstance.round({relativeTo, smallestUnit: "years"})); -assert.throws(RangeError, () => negInstance.round({relativeTo, smallestUnit: "months"})); -assert.throws(RangeError, () => negInstance.round({relativeTo, smallestUnit: "weeks"})); + +{ + const instance = new Temporal.Duration(0, 0, 0, /* days = */ 500_000_000); + assert.throws(RangeError, () => instance.round({relativeTo, smallestUnit: "years"}), "days out of range, positive, smallestUnit years"); + assert.throws(RangeError, () => instance.round({relativeTo, smallestUnit: "months"}), "days out of range, positive, smallestUnit months"); + assert.throws(RangeError, () => instance.round({relativeTo, smallestUnit: "weeks"}), "days out of range, positive, smallestUnit weeks"); + + const negInstance = new Temporal.Duration(0, 0, 0, /* days = */ -500_000_000); + assert.throws(RangeError, () => negInstance.round({relativeTo, smallestUnit: "years"}), "days out of range, negative, smallestUnit years"); + assert.throws(RangeError, () => negInstance.round({relativeTo, smallestUnit: "months"}), "days out of range, negative, smallestUnit months"); + assert.throws(RangeError, () => negInstance.round({relativeTo, smallestUnit: "weeks"}), "days out of range, negative, smallestUnit weeks"); +} + +{ + const instance = new Temporal.Duration(0, 0, /* weeks = */ 1, /* days = */ Math.trunc((2 ** 53) / 86_400)); + assert.throws(RangeError, () => instance.round({relativeTo, largestUnit: "days"}), "weeks + days out of range, positive"); + + const negInstance = new Temporal.Duration(0, 0, /* weeks = */ -1, /* days = */ -Math.trunc((2 ** 53) / 86_400)); + assert.throws(RangeError, () => instance.round({relativeTo, largestUnit: "days"}), "weeks + days out of range, negative"); +} reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/normalized-time-duration-to-days-loop-arbitrarily.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/normalized-time-duration-to-days-loop-arbitrarily.js index 923d788246..ed63026c0a 100644 --- a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/normalized-time-duration-to-days-loop-arbitrarily.js +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/normalized-time-duration-to-days-loop-arbitrarily.js @@ -4,76 +4,44 @@ /*--- esid: sec-temporal.duration.prototype.round description: > - NormalizedTimeDurationToDays can loop arbitrarily up to max safe integer + NormalizedTimeDurationToDays should not be able to loop arbitrarily. info: | NormalizedTimeDurationToDays ( norm, zonedRelativeTo, timeZoneRec [ , precalculatedPlainDatetime ] ) ... - 21. Repeat, while done is false, - a. Let oneDayFarther be ? AddDaysToZonedDateTime(relativeResult.[[Instant]], - relativeResult.[[DateTime]], timeZoneRec, zonedRelativeTo.[[Calendar]], sign). - b. Set dayLengthNs to NormalizedTimeDurationFromEpochNanosecondsDifference(oneDayFarther.[[EpochNanoseconds]], - relativeResult.[[EpochNanoseconds]]). - c. Let oneDayLess be ? SubtractNormalizedTimeDuration(norm, dayLengthNs). - c. If NormalizedTimeDurationSign(oneDayLess) × sign ≥ 0, then - i. Set norm to oneDayLess. - ii. Set relativeResult to oneDayFarther. - iii. Set days to days + sign. - d. Else, - i. Set done to true. -includes: [temporalHelpers.js] + 22. If NormalizedTimeDurationSign(_oneDayLess_) × _sign_ ≥ 0, then + a. Set _norm_ to _oneDayLess_. + b. Set _relativeResult_ to _oneDayFarther_. + c. Set _days_ to _days_ + _sign_. + d. Set _oneDayFarther_ to ? AddDaysToZonedDateTime(_relativeResult_.[[Instant]], _relativeResult_.[[DateTime]], _timeZoneRec_, _zonedRelativeTo_.[[Calendar]], _sign_). + e. Set dayLengthNs to NormalizedTimeDurationFromEpochNanosecondsDifference(_oneDayFarther.[[EpochNanoseconds]], relativeResult.[[EpochNanoseconds]]). + f. If NormalizedTimeDurationSign(? SubtractNormalizedTimeDuration(_norm_, _dayLengthNs_)) × _sign_ ≥ 0, then + i. Throw a *RangeError* exception. features: [Temporal] ---*/ -const calls = []; const duration = Temporal.Duration.from({ days: 1 }); -function createRelativeTo(count) { - const dayLengthNs = 86400000000000n; - const dayInstant = new Temporal.Instant(dayLengthNs); - const substitutions = []; - const timeZone = new Temporal.TimeZone("UTC"); - // Return constant value for first _count_ calls - TemporalHelpers.substituteMethod( - timeZone, - "getPossibleInstantsFor", - substitutions - ); - substitutions.length = count; - let i = 0; - for (i = 0; i < substitutions.length; i++) { - // (this value) - substitutions[i] = [dayInstant]; +const dayLengthNs = 86400000000000n; +const dayInstant = new Temporal.Instant(dayLengthNs); +let calls = 0; +const timeZone = new class extends Temporal.TimeZone { + getPossibleInstantsFor() { + calls++; + return [dayInstant]; } - // Record calls in calls[] - TemporalHelpers.observeMethod(calls, timeZone, "getPossibleInstantsFor"); - return new Temporal.ZonedDateTime(0n, timeZone); -} +}("UTC"); -let zdt = createRelativeTo(50); -calls.splice(0); // Reset calls list after ZonedDateTime construction -duration.round({ - smallestUnit: "days", - relativeTo: zdt, -}); -assert.sameValue( - calls.length, - 50 + 1, - "Expected duration.round to call getPossibleInstantsFor correct number of times" -); +const relativeTo = new Temporal.ZonedDateTime(0n, timeZone); -zdt = createRelativeTo(100); -calls.splice(0); // Reset calls list after previous loop + ZonedDateTime construction -duration.round({ - smallestUnit: "days", - relativeTo: zdt, -}); -assert.sameValue( - calls.length, - 100 + 1, - "Expected duration.round to call getPossibleInstantsFor correct number of times" -); - -zdt = createRelativeTo(107); -assert.throws(RangeError, () => duration.round({ smallestUnit: "days", relativeTo: zdt }), "107-2 days > 2⁵³ ns"); +assert.throws(RangeError, () => duration.round({ smallestUnit: "days", relativeTo }), "indefinite loop is prevented"); +assert.sameValue(calls, 5, "getPossibleInstantsFor is not called indefinitely"); + // Expected calls: + // RoundDuration -> MoveRelativeZonedDateTime -> AddZonedDateTime (1) + // BalanceTimeDurationRelative -> + // AddZonedDateTime (2) + // NormalizedTimeDurationToDays -> + // AddDaysToZonedDateTime (3, step 12) + // AddDaysToZonedDateTime (4, step 15) + // AddDaysToZonedDateTime (5, step 18.d) reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/out-of-range-when-adjusting-rounded-days.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/out-of-range-when-adjusting-rounded-days.js new file mode 100644 index 0000000000..cd6c307e5b --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/out-of-range-when-adjusting-rounded-days.js @@ -0,0 +1,32 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.round +description: > + When adjusting the rounded days after rounding relative to a ZonedDateTime, + the duration may go out of range +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +// Based on a test case by André Bargull + +const d = new Temporal.Duration(0, 0, 0, /* days = */ 1, 0, 0, /* s = */ Number.MAX_SAFE_INTEGER - 86400, 0, 0, /* ns = */ 999_999_999); + +const timeZone = new Temporal.TimeZone("UTC"); +TemporalHelpers.substituteMethod(timeZone, 'getPossibleInstantsFor', [ + TemporalHelpers.SUBSTITUTE_SKIP, + [new Temporal.Instant(1n)], +]); + +const relativeTo = new Temporal.ZonedDateTime(0n, timeZone); + +assert.throws(RangeError, () => d.round({ + largestUnit: 'nanoseconds', + roundingIncrement: 2, + relativeTo +})); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/out-of-range-when-converting-from-normalized-duration.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/out-of-range-when-converting-from-normalized-duration.js index 4fde761351..d4f973d639 100644 --- a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/out-of-range-when-converting-from-normalized-duration.js +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/out-of-range-when-converting-from-normalized-duration.js @@ -14,6 +14,6 @@ const d = new Temporal.Duration(0, 0, 0, 0, 0, 0, /* s = */ Number.MAX_SAFE_INTE assert.throws(RangeError, () => d.round({ largestUnit: "nanoseconds", roundingIncrement: 1, -}), "nanoseconds component is an unsafe integer after balancing"); +}), "nanoseconds component after balancing as a float64-representable integer is out of range"); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..e147558077 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-out-of-range-backward-offset-shift.js @@ -0,0 +1,50 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.round +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const relativeTo = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; + +const instance = new Temporal.Duration(1, 0, 0, 0, 24); +assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo }), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..f3b8d604ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-out-of-range-forward-offset-shift.js @@ -0,0 +1,45 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.round +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const relativeTo = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; + +const instance = new Temporal.Duration(1, 0, 0, 0, 24); +assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo }), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js index 150f9f419e..9c04b2991e 100644 --- a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js @@ -8,12 +8,12 @@ description: > RangeErrors. info: | NormalizedTimeDurationToDays ( norm, zonedRelativeTo, timeZoneRec [ , precalculatedPlainDateTime ] ) - 22. If days < 0 and sign = 1, throw a RangeError exception. - 23. If days > 0 and sign = -1, throw a RangeError exception. + 23. If days < 0 and sign = 1, throw a RangeError exception. + 24. If days > 0 and sign = -1, throw a RangeError exception. ... - 25. If NormalizedTimeDurationSign(_norm_) = 1 and sign = -1, throw a RangeError exception. + 26. If NormalizedTimeDurationSign(_norm_) = 1 and sign = -1, throw a RangeError exception. ... - 28. If dayLength ≥ 2⁵³, throw a RangeError exception. + 29. If dayLength ≥ 2⁵³, throw a RangeError exception. features: [Temporal, BigInt] includes: [temporalHelpers.js] ---*/ @@ -41,7 +41,7 @@ function timeZoneSubstituteValues( return tz; } -// Step 22: days < 0 and sign = 1 +// Step 23: days < 0 and sign = 1 let zdt = new Temporal.ZonedDateTime( 0n, // Sets _startNs_ to 0 timeZoneSubstituteValues( @@ -62,7 +62,7 @@ assert.throws(RangeError, () => "RangeError when days < 0 and sign = 1" ); -// Step 23: days > 0 and sign = -1 +// Step 24: days > 0 and sign = -1 zdt = new Temporal.ZonedDateTime( 0n, // Sets _startNs_ to 0 timeZoneSubstituteValues( @@ -83,13 +83,13 @@ assert.throws(RangeError, () => "RangeError when days > 0 and sign = -1" ); -// Step 25: nanoseconds > 0 and sign = -1 +// Step 26: nanoseconds > 0 and sign = -1 zdt = new Temporal.ZonedDateTime( 0n, // Sets _startNs_ to 0 timeZoneSubstituteValues( [ [new Temporal.Instant(-2n)], // Returned in step 16, setting _relativeResult_ - [new Temporal.Instant(-4n)], // Returned in step 21.a, setting _oneDayFarther_ + [new Temporal.Instant(-4n)], // Returned in step 19, setting _oneDayFarther_ ], [ TemporalHelpers.SUBSTITUTE_SKIP, // Pre-conversion in Duration.p.round @@ -107,12 +107,12 @@ assert.throws(RangeError, () => "RangeError when nanoseconds > 0 and sign = -1" ); -// Step 28: day length is an unsafe integer +// Step 29: day length is an unsafe integer zdt = new Temporal.ZonedDateTime( 0n, timeZoneSubstituteValues( // Not called in step 16 because _days_ = 0 - // Returned in step 21.a, making _oneDayFarther_ 2^53 ns later than _relativeResult_ + // Returned in step 19, making _oneDayFarther_ 2^53 ns later than _relativeResult_ [[new Temporal.Instant(2n ** 53n)]], [] ) diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/calendar-dateadd-called-with-options-undefined.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/calendar-dateadd-called-with-options-undefined.js index 5f5155e292..e0c22a689e 100644 --- a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/calendar-dateadd-called-with-options-undefined.js +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/calendar-dateadd-called-with-options-undefined.js @@ -15,6 +15,6 @@ const calendar = TemporalHelpers.calendarDateAddUndefinedOptions(); const timeZone = TemporalHelpers.oneShiftTimeZone(new Temporal.Instant(0n), 3600e9); const instance = new Temporal.Duration(1, 1, 1, 1); instance.subtract(new Temporal.Duration(-1, -1, -1, -1), { relativeTo: new Temporal.ZonedDateTime(0n, timeZone, calendar) }); -assert.sameValue(calendar.dateAddCallCount, 3); +assert.sameValue(calendar.dateAddCallCount, 2); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/differencezoneddatetime-inconsistent-custom-calendar.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/differencezoneddatetime-inconsistent-custom-calendar.js new file mode 100644 index 0000000000..e2c543c7d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/differencezoneddatetime-inconsistent-custom-calendar.js @@ -0,0 +1,55 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.duration.prototype.subtract +description: > + Throws a RangeError when custom calendar method returns inconsistent result +info: | + DifferenceZonedDateTime ( ... ) + 8. Repeat 3 times: + ... + g. If _sign_ = 0, or _timeSign_ = 0, or _sign_ = _timeSign_, then + ... + viii. Return ? CreateNormalizedDurationRecord(_dateDifference_.[[Years]], + _dateDifference_.[[Months]], _dateDifference_.[[Weeks]], + _dateDifference_.[[Days]], _norm_). + h. Set _dayCorrection_ to _dayCorrection_ + 1. + 9. NOTE: This step is only reached when custom calendar or time zone methods + return inconsistent values. + 10. Throw a *RangeError* exception. +features: [Temporal] +---*/ + +// Based partly on a test case by André Bargull + +const duration1 = new Temporal.Duration(0, 0, /* weeks = */ 7, 0, /* hours = */ 12); +const duration2 = new Temporal.Duration(0, 0, 0, /* days = */ -1); + +{ + const tz = new (class extends Temporal.TimeZone { + getPossibleInstantsFor(dateTime) { + return super.getPossibleInstantsFor(dateTime.add({ days: 3 })); + } + })("UTC"); + + const relativeTo = new Temporal.ZonedDateTime(0n, tz); + + assert.throws(RangeError, () => duration1.subtract(duration2, { relativeTo }), + "Calendar calculation where more than 2 days correction is needed should cause RangeError"); +} + +{ + const cal = new (class extends Temporal.Calendar { + dateUntil(one, two, options) { + return super.dateUntil(one, two, options).negated(); + } + })("iso8601"); + + const relativeTo = new Temporal.ZonedDateTime(0n, "UTC", cal); + + assert.throws(RangeError, () => duration1.subtract(duration2, { relativeTo }), + "Calendar calculation causing mixed-sign values should cause RangeError"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/normalized-time-duration-to-days-loop-arbitrarily.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/normalized-time-duration-to-days-loop-arbitrarily.js deleted file mode 100644 index 8873380037..0000000000 --- a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/normalized-time-duration-to-days-loop-arbitrarily.js +++ /dev/null @@ -1,78 +0,0 @@ -// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.subtract -description: > - NormalizedTimeDurationToDays can loop arbitrarily up to max safe integer -info: | - NormalizedTimeDurationToDays ( norm, zonedRelativeTo, timeZoneRec [ , precalculatedPlainDatetime ] ) - ... - 21. Repeat, while done is false, - a. Let oneDayFarther be ? AddDaysToZonedDateTime(relativeResult.[[Instant]], - relativeResult.[[DateTime]], timeZoneRec, zonedRelativeTo.[[Calendar]], sign). - b. Set dayLengthNs to NormalizedTimeDurationFromEpochNanosecondsDifference(oneDayFarther.[[EpochNanoseconds]], - relativeResult.[[EpochNanoseconds]]). - c. Let oneDayLess be ? SubtractNormalizedTimeDuration(norm, dayLengthNs). - c. If NormalizedTimeDurationSign(oneDayLess) × sign ≥ 0, then - i. Set norm to oneDayLess. - ii. Set relativeResult to oneDayFarther. - iii. Set days to days + sign. - d. Else, - i. Set done to true. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calls = []; -const duration = Temporal.Duration.from({ days: 1 }); - -function createRelativeTo(count) { - const dayLengthNs = 86400000000000n; - const dayInstant = new Temporal.Instant(dayLengthNs); - const substitutions = []; - const timeZone = new Temporal.TimeZone("UTC"); - // Return constant value for first _count_ calls - TemporalHelpers.substituteMethod( - timeZone, - "getPossibleInstantsFor", - substitutions - ); - substitutions.length = count; - let i = 0; - for (i = 0; i < substitutions.length; i++) { - // (this value) - substitutions[i] = [dayInstant]; - } - // Record calls in calls[] - TemporalHelpers.observeMethod(calls, timeZone, "getPossibleInstantsFor"); - return new Temporal.ZonedDateTime(0n, timeZone); -} - -let zdt = createRelativeTo(50); -calls.splice(0); // Reset calls list after ZonedDateTime construction -duration.subtract(duration, { - relativeTo: zdt, -}); -assert.sameValue( - calls.length, - 50 + 1, - "Expected duration.subtract to call getPossibleInstantsFor correct number of times" -); - -zdt = createRelativeTo(100); -calls.splice(0); // Reset calls list after previous loop + ZonedDateTime construction -duration.subtract(duration, { - relativeTo: zdt, -}); -assert.sameValue( - calls.length, - 100 + 1, - "Expected duration.subtract to call getPossibleInstantsFor correct number of times" -); - -zdt = createRelativeTo(107); -assert.throws(RangeError, () => duration.subtract(duration, { relativeTo: zdt }), "107-2 days > 2⁵³ ns"); - -reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/order-of-operations.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/order-of-operations.js index 988835838f..55438a2b97 100644 --- a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/order-of-operations.js +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/order-of-operations.js @@ -339,18 +339,8 @@ const expectedOpsForZonedRelativeTo = expected.concat([ "call options.relativeTo.timeZone.getPossibleInstantsFor", // AddDuration → DifferenceZonedDateTime "call options.relativeTo.timeZone.getOffsetNanosecondsFor", - // AddDuration → DifferenceZonedDateTime → DifferenceISODateTime - "call options.relativeTo.calendar.dateUntil", - // AddDuration → DifferenceZonedDateTime → AddZonedDateTime - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.timeZone.getPossibleInstantsFor", - // AddDuration → DifferenceZonedDateTime → NanosecondsToDays - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", - // AddDuration → DifferenceZonedDateTime → NanosecondsToDays → AddZonedDateTime 1 - "call options.relativeTo.timeZone.getPossibleInstantsFor", - // AddDuration → DifferenceZonedDateTime → NanosecondsToDays → AddZonedDateTime 2 "call options.relativeTo.timeZone.getPossibleInstantsFor", + "call options.relativeTo.calendar.dateUntil", ]); const zonedRelativeTo = TemporalHelpers.propertyBagObserver(actual, { diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/relativeto-propertybag-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/relativeto-propertybag-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..193c09e806 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/relativeto-propertybag-out-of-range-backward-offset-shift.js @@ -0,0 +1,50 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.subtract +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const relativeTo = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; + +const instance = new Temporal.Duration(1, 0, 0, 1); +assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/relativeto-propertybag-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/relativeto-propertybag-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..3d1d6262f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/relativeto-propertybag-out-of-range-forward-offset-shift.js @@ -0,0 +1,45 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.subtract +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const relativeTo = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; + +const instance = new Temporal.Duration(1, 0, 0, 1); +assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js deleted file mode 100644 index 46307bcaf9..0000000000 --- a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/subtract/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js +++ /dev/null @@ -1,144 +0,0 @@ -// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.prototype.subtract -description: > - Abstract operation NormalizedTimeDurationToDays can throw four different - RangeErrors. -info: | - NormalizedTimeDurationToDays ( norm, zonedRelativeTo, timeZoneRec [ , precalculatedPlainDateTime ] ) - 22. If days < 0 and sign = 1, throw a RangeError exception. - 23. If days > 0 and sign = -1, throw a RangeError exception. - ... - 25. If NormalizedTimeDurationSign(_norm_) = 1 and sign = -1, throw a RangeError exception. - ... - 28. If dayLength ≥ 2⁵³, throw a RangeError exception. -features: [Temporal, BigInt] -includes: [temporalHelpers.js] ----*/ - -const dayNs = 86_400_000_000_000; -const dayDuration = Temporal.Duration.from({ days: 1 }); -const epochInstant = new Temporal.Instant(0n); - -function timeZoneSubstituteValues( - getPossibleInstantsFor, - getOffsetNanosecondsFor -) { - const tz = new Temporal.TimeZone("UTC"); - TemporalHelpers.substituteMethod( - tz, - "getPossibleInstantsFor", - getPossibleInstantsFor - ); - TemporalHelpers.substituteMethod( - tz, - "getOffsetNanosecondsFor", - getOffsetNanosecondsFor - ); - return tz; -} - -// Step 22: days < 0 and sign = 1 -let zdt = new Temporal.ZonedDateTime( - -1n, // Set DifferenceZonedDateTime _ns1_ - timeZoneSubstituteValues( - [ - TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally for first call, AddDuration step 15 - [epochInstant], // Returned in AddDuration step 16, setting _endNs_ -> DifferenceZonedDateTime _ns2_ - [epochInstant], // Returned in step 16, setting _relativeResult_ - ], - [ - // Behave normally in 3 calls made prior to NormalizedTimeDurationToDays - TemporalHelpers.SUBSTITUTE_SKIP, - TemporalHelpers.SUBSTITUTE_SKIP, - TemporalHelpers.SUBSTITUTE_SKIP, - dayNs - 1, // Returned in step 8, setting _startDateTime_ - -dayNs + 1, // Returned in step 9, setting _endDateTime_ - ] - ) -); -assert.throws(RangeError, () => - // Subtracting day from day sets largestUnit to 'day', avoids having any week/month/year components in difference - dayDuration.subtract(dayDuration, { - relativeTo: zdt, - }) -); - -// Step 23: days > 0 and sign = -1 -zdt = new Temporal.ZonedDateTime( - 1n, // Set DifferenceZonedDateTime _ns1_ - timeZoneSubstituteValues( - [ - TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally for first call, AddDuration step 15 - [epochInstant], // Returned in AddDuration step 16, setting _endNs_ -> DifferenceZonedDateTime _ns2_ - [epochInstant], // Returned in step 16, setting _relativeResult_ - ], - [ - // Behave normally in 3 calls made prior to NanosecondsToDays - TemporalHelpers.SUBSTITUTE_SKIP, - TemporalHelpers.SUBSTITUTE_SKIP, - TemporalHelpers.SUBSTITUTE_SKIP, - -dayNs + 1, // Returned in step 8, setting _startDateTime_ - dayNs - 1, // Returned in step 9, setting _endDateTime_ - ] - ) -); -assert.throws(RangeError, () => - // Subtracting day from day sets largestUnit to 'day', avoids having any week/month/year components in difference - dayDuration.subtract(dayDuration, { - relativeTo: zdt, - }) -); - -// Step 25: nanoseconds > 0 and sign = -1 -zdt = new Temporal.ZonedDateTime( - 0n, // Set DifferenceZonedDateTime _ns1_ - timeZoneSubstituteValues( - [ - TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally for first call, AddDuration step 15 - [new Temporal.Instant(-1n)], // Returned in AddDuration step 16, setting _endNs_ -> DifferenceZonedDateTime _ns2_ - [new Temporal.Instant(-2n)], // Returned in step 16, setting _relativeResult_ - [new Temporal.Instant(-4n)], // Returned in step 21.a, setting _oneDayFarther_ - ], - [ - // Behave normally in 3 calls made prior to NanosecondsToDays - TemporalHelpers.SUBSTITUTE_SKIP, - TemporalHelpers.SUBSTITUTE_SKIP, - TemporalHelpers.SUBSTITUTE_SKIP, - dayNs - 1, // Returned in step 8, setting _startDateTime_ - -dayNs + 1, // Returned in step 9, setting _endDateTime_ - ] - ) -); -assert.throws(RangeError, () => - // Subtracting day from day sets largestUnit to 'day', avoids having any week/month/year components in difference - dayDuration.subtract(dayDuration, { - relativeTo: zdt, - }) -); - -// Step 28: day length is an unsafe integer -zdt = new Temporal.ZonedDateTime( - 0n, - timeZoneSubstituteValues( - [ - TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally for AddDuration step 15 - TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally for AddDuration step 16 - TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally for step 16, setting _relativeResult_ - // Returned in step 21.a, making _oneDayFarther_ 2^53 ns later than _relativeResult_ - [new Temporal.Instant(2n ** 53n - 3n * BigInt(dayNs))], - ], - [] - ) -); -const twoDaysDuration = new Temporal.Duration(0, 0, 0, 2); -assert.throws(RangeError, () => - dayDuration.subtract(twoDaysDuration, { - relativeTo: zdt, - }), - "Should throw RangeError when time zone calculates an outrageous day length" -); - -reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/dst-rounding-result.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/dst-rounding-result.js new file mode 100644 index 0000000000..b2b4daf2de --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/dst-rounding-result.js @@ -0,0 +1,40 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.duration.prototype.total +description: > + Rounding the resulting duration takes the time zone's UTC offset shifts + into account +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); + +// Based on a test case by Adam Shaw + +{ + // Date part of duration lands on skipped DST hour, causing disambiguation + const duration = new Temporal.Duration(0, 1, 0, 15, 12); + const relativeTo = new Temporal.ZonedDateTime( + 950868000_000_000_000n /* = 2000-02-18T10Z */, + timeZone); /* = 2000-02-18T02-08 in local time */ + + assert.sameValue(duration.total({ unit: "months", relativeTo }), 1.5, + "1 month 15 days 12 hours should be exactly 1.5 months"); +} + +{ + // Month-only part of duration lands on skipped DST hour, should not cause + // disambiguation + const duration = new Temporal.Duration(0, 1, 0, 15); + const relativeTo = new Temporal.ZonedDateTime( + 951991200_000_000_000n /* = 2000-03-02T10Z */, + timeZone); /* = 2000-03-02T02-08 in local time */ + + assert.sameValue(duration.total({ unit: "months", relativeTo }), 1.5, + "1 month 15 days should be exactly 1.5 months"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/duration-out-of-range-added-to-relativeto.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/duration-out-of-range-added-to-relativeto.js index 2abd469541..cf33d39b0e 100644 --- a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/duration-out-of-range-added-to-relativeto.js +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/duration-out-of-range-added-to-relativeto.js @@ -8,21 +8,44 @@ description: RangeError thrown when calendar part of duration added to relativeT features: [Temporal] info: | RoundDuration: - 8.k. Let _isoResult_ be ! AddISODate(_plainRelativeTo_.[[ISOYear]]. _plainRelativeTo_.[[ISOMonth]], _plainRelativeTo_.[[ISODay]], 0, 0, 0, truncate(_fractionalDays_), *"constrain"*). - l. Let _wholeDaysLater_ be ? CreateTemporalDate(_isoResult_.[[Year]], _isoResult_.[[Month]], _isoResult_.[[Day]], _calendar_). + 10.h. Let _isoResult_ be ! AddISODate(_plainRelativeTo_.[[ISOYear]]. _plainRelativeTo_.[[ISOMonth]], _plainRelativeTo_.[[ISODay]], 0, 0, 0, truncate(_fractionalDays_), *"constrain"*). + i. Let _wholeDaysLater_ be ? CreateTemporalDate(_isoResult_.[[Year]], _isoResult_.[[Month]], _isoResult_.[[Day]], _calendar_). + ... + 11.h. Let _isoResult_ be ! AddISODate(_plainRelativeTo_.[[ISOYear]]. _plainRelativeTo_.[[ISOMonth]], _plainRelativeTo_.[[ISODay]], 0, 0, 0, truncate(_fractionalDays_), *"constrain"*). + i. Let _wholeDaysLater_ be ? CreateTemporalDate(_isoResult_.[[Year]], _isoResult_.[[Month]], _isoResult_.[[Day]], _calendar_). + ... + 12.a. Let _isoResult_ be ! AddISODate(_plainRelativeTo_.[[ISOYear]]. _plainRelativeTo_.[[ISOMonth]], _plainRelativeTo_.[[ISODay]], 0, 0, 0, truncate(_fractionalDays_), *"constrain"*). + b. Let _wholeDaysLater_ be ? CreateTemporalDate(_isoResult_.[[Year]], _isoResult_.[[Month]], _isoResult_.[[Day]], _calendar_). + + UnbalanceDateDurationRelative: + 11. Let _yearsMonthsWeeksDuration_ be ! CreateTemporalDuration(_years_, _months_, _weeks_, 0, 0, 0, 0, 0, 0, 0). + 12. Let _later_ be ? CalendarDateAdd(_calendaRec_, _plainRelativeTo_, _yearsMonthsWeeksDuration_). + 13. Let _yearsMonthsWeeksInDays_ be DaysUntil(_plainRelativeTo_, _later_). + 14. Return ? CreateDateDurationRecord(0, 0, 0, _days_ + _yearsMonthsWeeksInDays_). ---*/ // Based on a test case by André Bargull <andre.bargull@gmail.com> -const instance = new Temporal.Duration(0, 0, 0, /* days = */ 500_000_000); const relativeTo = new Temporal.PlainDate(2000, 1, 1); -assert.throws(RangeError, () => instance.total({relativeTo, unit: "years"})); -assert.throws(RangeError, () => instance.total({relativeTo, unit: "months"})); -assert.throws(RangeError, () => instance.total({relativeTo, unit: "weeks"})); - -const negInstance = new Temporal.Duration(0, 0, 0, /* days = */ -500_000_000); -assert.throws(RangeError, () => negInstance.total({relativeTo, unit: "years"})); -assert.throws(RangeError, () => negInstance.total({relativeTo, unit: "months"})); -assert.throws(RangeError, () => negInstance.total({relativeTo, unit: "weeks"})); + +{ + const instance = new Temporal.Duration(0, 0, 0, /* days = */ 500_000_000); + assert.throws(RangeError, () => instance.total({relativeTo, unit: "years"}), "days out of range, positive, unit years"); + assert.throws(RangeError, () => instance.total({relativeTo, unit: "months"}), "days out of range, positive, unit months"); + assert.throws(RangeError, () => instance.total({relativeTo, unit: "weeks"}), "days out of range, positive, unit weeks"); + + const negInstance = new Temporal.Duration(0, 0, 0, /* days = */ -500_000_000); + assert.throws(RangeError, () => negInstance.total({relativeTo, unit: "years"}), "days out of range, negative, unit years"); + assert.throws(RangeError, () => negInstance.total({relativeTo, unit: "months"}), "days out of range, negative, unit months"); + assert.throws(RangeError, () => negInstance.total({relativeTo, unit: "weeks"}), "days out of range, negative, unit weeks"); +} + +{ + const instance = new Temporal.Duration(0, 0, /* weeks = */ 1, /* days = */ Math.trunc((2 ** 53) / 86_400)); + assert.throws(RangeError, () => instance.total({relativeTo, unit: "days"}), "weeks + days out of range, positive"); + + const negInstance = new Temporal.Duration(0, 0, /* weeks = */ -1, /* days = */ -Math.trunc((2 ** 53) / 86_400)); + assert.throws(RangeError, () => instance.total({relativeTo, unit: "days"}), "weeks + days out of range, negative"); +} reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/normalized-time-duration-to-days-loop-arbitrarily.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/normalized-time-duration-to-days-loop-arbitrarily.js index 72260abd68..c4d685113d 100644 --- a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/normalized-time-duration-to-days-loop-arbitrarily.js +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/normalized-time-duration-to-days-loop-arbitrarily.js @@ -5,76 +5,42 @@ /*--- esid: sec-temporal.duration.prototype.total description: > - NormalizedTimeDurationToDays can loop arbitrarily up to max safe integer + NormalizedTimeDurationToDays should not be able to loop arbitrarily. info: | NormalizedTimeDurationToDays ( norm, zonedRelativeTo, timeZoneRec [ , precalculatedPlainDatetime ] ) ... - 21. Repeat, while done is false, - a. Let oneDayFarther be ? AddDaysToZonedDateTime(relativeResult.[[Instant]], - relativeResult.[[DateTime]], timeZoneRec, zonedRelativeTo.[[Calendar]], sign). - b. Set dayLengthNs to NormalizedTimeDurationFromEpochNanosecondsDifference(oneDayFarther.[[EpochNanoseconds]], - relativeResult.[[EpochNanoseconds]]). - c. Let oneDayLess be ? SubtractNormalizedTimeDuration(norm, dayLengthNs). - c. If NormalizedTimeDurationSign(oneDayLess) × sign ≥ 0, then - i. Set norm to oneDayLess. - ii. Set relativeResult to oneDayFarther. - iii. Set days to days + sign. - d. Else, - i. Set done to true. -includes: [temporalHelpers.js] + 22. If NormalizedTimeDurationSign(_oneDayLess_) × _sign_ ≥ 0, then + a. Set _norm_ to _oneDayLess_. + b. Set _relativeResult_ to _oneDayFarther_. + c. Set _days_ to _days_ + _sign_. + d. Set _oneDayFarther_ to ? AddDaysToZonedDateTime(_relativeResult_.[[Instant]], _relativeResult_.[[DateTime]], _timeZoneRec_, _zonedRelativeTo_.[[Calendar]], _sign_). + e. Set dayLengthNs to NormalizedTimeDurationFromEpochNanosecondsDifference(_oneDayFarther.[[EpochNanoseconds]], relativeResult.[[EpochNanoseconds]]). + f. If NormalizedTimeDurationSign(? SubtractNormalizedTimeDuration(_norm_, _dayLengthNs_)) × _sign_ ≥ 0, then + i. Throw a *RangeError* exception. features: [Temporal] ---*/ -const calls = []; const duration = Temporal.Duration.from({ days: 1 }); -function createRelativeTo(count) { - const dayLengthNs = 86400000000000n; - const dayInstant = new Temporal.Instant(dayLengthNs); - const substitutions = []; - const timeZone = new Temporal.TimeZone("UTC"); - // Return constant value for first _count_ calls - TemporalHelpers.substituteMethod( - timeZone, - "getPossibleInstantsFor", - substitutions - ); - substitutions.length = count; - let i = 0; - for (i = 0; i < substitutions.length; i++) { - // (this value) - substitutions[i] = [dayInstant]; +const dayLengthNs = 86400000000000n; +const dayInstant = new Temporal.Instant(dayLengthNs); +let calls = 0; +const timeZone = new class extends Temporal.TimeZone { + getPossibleInstantsFor() { + calls++; + return [dayInstant]; } - // Record calls in calls[] - TemporalHelpers.observeMethod(calls, timeZone, "getPossibleInstantsFor"); - return new Temporal.ZonedDateTime(0n, timeZone); -} +}("UTC"); -let zdt = createRelativeTo(50); -calls.splice(0); // Reset calls list after ZonedDateTime construction -duration.total({ - unit: "day", - relativeTo: zdt, -}); -assert.sameValue( - calls.length, - 50 + 2, - "Expected duration.total to call getPossibleInstantsFor correct number of times" -); +const relativeTo = new Temporal.ZonedDateTime(0n, timeZone); -zdt = createRelativeTo(100); -calls.splice(0); // Reset calls list after previous loop + ZonedDateTime construction -duration.total({ - unit: "day", - relativeTo: zdt, -}); -assert.sameValue( - calls.length, - 100 + 2, - "Expected duration.total to call getPossibleInstantsFor correct number of times" -); - -zdt = createRelativeTo(106); -assert.throws(RangeError, () => duration.total({ unit: "day", relativeTo: zdt }), "106-1 days > 2⁵³ ns"); +assert.throws(RangeError, () => duration.total({ unit: "days", relativeTo }), "indefinite loop is prevented"); +assert.sameValue(calls, 4, "getPossibleInstantsFor is not called indefinitely"); + // Expected calls: + // AddZonedDateTime (1) + // NormalizedTimeDurationToDays -> + // AddDaysToZonedDateTime (2, step 12) + // AddDaysToZonedDateTime (3, step 15) + // AddDaysToZonedDateTime (4, step 18.d) reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/precision-exact-mathematical-values-3.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/precision-exact-mathematical-values-3.js index ab3fd772cc..9f00233078 100644 --- a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/precision-exact-mathematical-values-3.js +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/precision-exact-mathematical-values-3.js @@ -71,7 +71,7 @@ function f64Repr(f) { const tz = new (class extends Temporal.TimeZone { getPossibleInstantsFor() { - // Called in NormalizedTimeDurationToDays 21.a from RoundDuration 7.b. + // Called in NormalizedTimeDurationToDays 19 from RoundDuration 7.b. // Sets _result_.[[DayLength]] to 2⁵³ - 1 ns, its largest possible value return [new Temporal.Instant(-86400_0000_0000_000_000_000n + 2n ** 53n - 1n)]; } diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..83878fb1b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-out-of-range-backward-offset-shift.js @@ -0,0 +1,50 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.total +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const relativeTo = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; + +const instance = new Temporal.Duration(1, 0, 0, 0, 24); +assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo }), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..0012871d85 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-out-of-range-forward-offset-shift.js @@ -0,0 +1,45 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.total +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const relativeTo = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; + +const instance = new Temporal.Duration(1, 0, 0, 0, 24); +assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo }), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js index d415117f89..3150c81852 100644 --- a/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js +++ b/js/src/tests/test262/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-normalized-time-duration-to-days-range-errors.js @@ -8,12 +8,12 @@ description: > RangeErrors. info: | NormalizedTimeDurationToDays ( norm, zonedRelativeTo, timeZoneRec [ , precalculatedPlainDateTime ] ) - 22. If days < 0 and sign = 1, throw a RangeError exception. - 23. If days > 0 and sign = -1, throw a RangeError exception. + 23. If days < 0 and sign = 1, throw a RangeError exception. + 24. If days > 0 and sign = -1, throw a RangeError exception. ... - 25. If NormalizedTimeDurationSign(_norm_) = 1 and sign = -1, throw a RangeError exception. + 26. If NormalizedTimeDurationSign(_norm_) = 1 and sign = -1, throw a RangeError exception. ... - 28. If dayLength ≥ 2⁵³, throw a RangeError exception. + 29. If dayLength ≥ 2⁵³, throw a RangeError exception. features: [Temporal, BigInt] includes: [temporalHelpers.js] ---*/ @@ -41,7 +41,7 @@ function timeZoneSubstituteValues( return tz; } -// Step 22: days < 0 and sign = 1 +// Step 23: days < 0 and sign = 1 let zdt = new Temporal.ZonedDateTime( 0n, // Sets _startNs_ to 0 timeZoneSubstituteValues( @@ -62,7 +62,7 @@ assert.throws(RangeError, () => "RangeError when days < 0 and sign = 1" ); -// Step 23: days > 0 and sign = -1 +// Step 24: days > 0 and sign = -1 zdt = new Temporal.ZonedDateTime( 0n, // Sets _startNs_ to 0 timeZoneSubstituteValues( @@ -83,13 +83,13 @@ assert.throws(RangeError, () => "RangeError when days > 0 and sign = -1" ); -// Step 25: nanoseconds > 0 and sign = -1 +// Step 26: nanoseconds > 0 and sign = -1 zdt = new Temporal.ZonedDateTime( 0n, // Sets _startNs_ to 0 timeZoneSubstituteValues( [ [new Temporal.Instant(-2n)], // Returned in step 16, setting _relativeResult_ - [new Temporal.Instant(-4n)], // Returned in step 21.a, setting _oneDayFarther_ + [new Temporal.Instant(-4n)], // Returned in step 19, setting _oneDayFarther_ ], [ TemporalHelpers.SUBSTITUTE_SKIP, // pre-conversion in Duration.p.total @@ -107,12 +107,12 @@ assert.throws(RangeError, () => "RangeError when nanoseconds > 0 and sign = -1" ); -// Step 28: day length is an unsafe integer +// Step 29: day length is an unsafe integer zdt = new Temporal.ZonedDateTime( 0n, timeZoneSubstituteValues( // Not called in step 16 because _days_ = 0 - // Returned in step 21.a, making _oneDayFarther_ 2^53 ns later than _relativeResult_ + // Returned in step 19, making _oneDayFarther_ 2^53 ns later than _relativeResult_ [[new Temporal.Instant(2n ** 53n)]], [] ) diff --git a/js/src/tests/test262/built-ins/Temporal/Instant/compare/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Instant/compare/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..a0863e12f6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Instant/compare/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,32 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.compare +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const epoch = new Temporal.Instant(0n); + +const invalidStrings = [ + ["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"], +]; + +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => Temporal.Instant.compare(arg, epoch), + `annotation keys must be lowercase: ${arg} - ${descr} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.Instant.compare(epoch, arg), + `annotation keys must be lowercase: ${arg} - ${descr} (second argument)` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Instant/from/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Instant/from/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..635ffb4ed9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Instant/from/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.from +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"], +]; + +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => Temporal.Instant.from(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Instant/prototype/equals/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Instant/prototype/equals/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..7ee8e3fc30 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Instant/prototype/equals/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.prototype.equals +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Instant(0n); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Instant/prototype/since/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Instant/prototype/since/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..946f44ffa9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Instant/prototype/since/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.prototype.since +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Instant(0n); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.since(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-iso-string.js new file mode 100644 index 0000000000..b067a5b62c --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-iso-string.js @@ -0,0 +1,27 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.prototype.tozoneddatetime +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(1_000_000_000_000_000_000n); + +for (const arg of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const result = instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" }); + assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Instant/prototype/until/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/Instant/prototype/until/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..4e9df646e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Instant/prototype/until/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.prototype.until +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Instant(0n); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.until(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Now/plainDate/calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Now/plainDate/calendar-iso-string.js new file mode 100644 index 0000000000..1414eb207b --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Now/plainDate/calendar-iso-string.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.now.plaindate +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +for (const arg of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const result = Temporal.Now.plainDate(arg); + assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Now/plainDateTime/calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Now/plainDateTime/calendar-iso-string.js new file mode 100644 index 0000000000..d093635a30 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Now/plainDateTime/calendar-iso-string.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.now.plaindatetime +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +for (const arg of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const result = Temporal.Now.plainDateTime(arg); + assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/Now/zonedDateTime/calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/Now/zonedDateTime/calendar-iso-string.js new file mode 100644 index 0000000000..09da5820f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Now/zonedDateTime/calendar-iso-string.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.now.zoneddatetime +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +for (const arg of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const result = Temporal.Now.zonedDateTime(arg); + assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..81bf074b6b --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.compare +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result1 = Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18)); + assert.sameValue(result1, 0, `Calendar created from string "${calendar}" (first argument)`); + const result2 = Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg); + assert.sameValue(result2, 0, `Calendar created from string "${calendar}" (second argument)`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/compare/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/compare/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..909b9e4348 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/compare/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.compare +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; + +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18)), + `annotation keys must be lowercase: ${arg} - ${descr} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg), + `annotation keys must be lowercase: ${arg} - ${descr} (second argument)` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..b635736960 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.from +description: An ISO 8601 string can be converted to a calendar ID in Calendar +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = Temporal.PlainDate.from(arg); + TemporalHelpers.assertPlainDate(result, 1976, 11, "M11", 18, `Calendar created from string "${calendar}"`); + assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-year-zero.js index fc65d8fd12..8f7002c4e6 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => Temporal.PlainDate.from(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/from/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/from/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..9cbfff7fb8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/from/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.from +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; + +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => Temporal.PlainDate.from(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/equals/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/equals/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..6c6f568ceb --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/equals/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.equals +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDate(1976, 11, 18); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.equals(arg); + assert.sameValue(result, true, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/equals/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/equals/argument-propertybag-calendar-year-zero.js index dc0a12c58a..a9e5c6d9d7 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/equals/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/equals/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.PlainDate(2000, 5, 2); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.equals(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/equals/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/equals/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..50b0ad9b55 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/equals/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.equals +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..720267d753 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.since +description: An ISO 8601 string can be converted to a calendar ID in Calendar +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDate(1976, 11, 18); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.since(arg); + TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-year-zero.js index 13b4a25387..d5eda02a0e 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.PlainDate(2000, 5, 2); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.since(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/since/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/since/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..d804238767 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/since/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.since +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.since(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/since/wrapping-at-end-of-month.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/since/wrapping-at-end-of-month.js new file mode 100644 index 0000000000..11d3bef1b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/since/wrapping-at-end-of-month.js @@ -0,0 +1,120 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.since +description: Tests balancing of days to months at end of month +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Difference between end of longer month to end of following shorter month +{ + const end = new Temporal.PlainDate(1970, 2, 28); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 1, 28).since(end, { largestUnit }), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, + "Jan 28th to Feb 28th is one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 1, 29).since(end, { largestUnit }), + 0, 0, 0, -30, 0, 0, 0, 0, 0, 0, + "Jan 29th to Feb 28th is 30 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 1, 30).since(end, { largestUnit }), + 0, 0, 0, -29, 0, 0, 0, 0, 0, 0, + "Jan 30th to Feb 28th is 29 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 1, 31).since(end, { largestUnit }), + 0, 0, 0, -28, 0, 0, 0, 0, 0, 0, + "Jan 31st to Feb 28th is 28 days, not one month" + ); + } +} + +// Difference between end of leap-year January to end of leap-year February +{ + const end = new Temporal.PlainDate(1972, 2, 29); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1972, 1, 29).since(end, { largestUnit }), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, + "Jan 29th to Feb 29th is one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1972, 1, 30).since(end, { largestUnit }), + 0, 0, 0, -30, 0, 0, 0, 0, 0, 0, + "Jan 30th to Feb 29th is 30 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1972, 1, 31).since(end, { largestUnit }), + 0, 0, 0, -29, 0, 0, 0, 0, 0, 0, + "Jan 31st to Feb 29th is 29 days, not one month" + ); + } +} + +// Difference between end of longer month to end of not-immediately-following +// shorter month +{ + const end = new Temporal.PlainDate(1970, 11, 30); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 8, 30).since(end, { largestUnit }), + 0, -3, 0, 0, 0, 0, 0, 0, 0, 0, + "Aug 30th to Nov 30th is 3 months" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 8, 31).since(end, { largestUnit }), + 0, -2, 0, -30, 0, 0, 0, 0, 0, 0, + "Aug 31st to Nov 30th is 2 months 30 days, not 3 months" + ); + } +} + +// Difference between end of longer month in one year to shorter month in +// later year +{ + const end = new Temporal.PlainDate(1973, 4, 30); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 12, 30).since(end, { largestUnit: "months" }), + 0, -28, 0, 0, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 28 months" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 12, 30).since(end, { largestUnit: "years" }), + -2, -4, 0, 0, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 2 years, 4 months" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 12, 31).since(end, { largestUnit: "months" }), + 0, -27, 0, -30, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 27 months, 30 days, not 28 months" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 12, 31).since(end, { largestUnit: "years" }), + -2, -3, 0, -30, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 2 years, 3 months, 30 days, not 2 years 4 months" + ); +} + +// Difference where months passes through a month that's the same length or +// shorter than either the start or end month +{ + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 1, 29).since(new Temporal.PlainDate(1970, 3, 28), { largestUnit: "months" }), + 0, -1, 0, -28, 0, 0, 0, 0, 0, 0, + "Jan 29th to Mar 28th is 1 month 28 days, not 58 days" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 1, 31).since(new Temporal.PlainDate(1971, 5, 30), { largestUnit: "years" }), + -1, -3, 0, -30, 0, 0, 0, 0, 0, 0, + "Jan 31st 1970 to May 30th 1971 is 1 year, 3 months, 30 days, not 1 year, 2 months, 60 days" + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..81f05806f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,31 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.toplaindatetime +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["00:00[U-CA=iso8601]", "invalid capitalized key, time-only"], + ["T00:00[U-CA=iso8601]", "invalid capitalized key, time designator"], + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["00:00[u-CA=iso8601]", "invalid partially-capitalized key, time-only"], + ["T00:00[u-CA=iso8601]", "invalid partially-capitalized key, time designator"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["00:00[FOO=bar]", "invalid capitalized unrecognized key, time-only"], + ["T00:00[FOO=bar]", "invalid capitalized unrecognized key, time designator"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.toPlainDateTime(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..20fcdb44c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,31 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.tozoneddatetime +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["00:00[U-CA=iso8601]", "invalid capitalized key, time-only"], + ["T00:00[U-CA=iso8601]", "invalid capitalized key, time designator"], + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["00:00[u-CA=iso8601]", "invalid partially-capitalized key, time-only"], + ["T00:00[u-CA=iso8601]", "invalid partially-capitalized key, time designator"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["00:00[FOO=bar]", "invalid capitalized unrecognized key, time-only"], + ["T00:00[FOO=bar]", "invalid capitalized unrecognized key, time designator"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" }), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js new file mode 100644 index 0000000000..31ca94435d --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.tozoneddatetime +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants can be at most 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + calls++; + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12 })]; + } +} + +const timeZone = new Shift24Hour(); + +const instance = new Temporal.PlainDate(1970, 1, 1); +instance.toZonedDateTime({ timeZone, plainTime: new Temporal.PlainTime(12) }); + +assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..1ab2bc7239 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js @@ -0,0 +1,44 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.tozoneddatetime +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +const instance = new Temporal.PlainDate(1970, 1, 1); +assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone, plainTime: new Temporal.PlainTime(12) }), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js new file mode 100644 index 0000000000..015a36daf9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js @@ -0,0 +1,53 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.tozoneddatetime +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + calls++; + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12 }), + utcInstant.add({ hours: 12 }) + ]; + } +} + +const timeZone = new Shift24Hour(); + +const instance = new Temporal.PlainDate(1970, 1, 1); +instance.toZonedDateTime({ timeZone, plainTime: new Temporal.PlainTime(12) }); + +assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..9d6efeab88 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.tozoneddatetime +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +const instance = new Temporal.PlainDate(1970, 1, 1); +assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone, plainTime: new Temporal.PlainTime(12) }), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/until/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/until/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..2ec1c255b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/until/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.until +description: An ISO 8601 string can be converted to a calendar ID in Calendar +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDate(1976, 11, 18); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.until(arg); + TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/until/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/until/argument-propertybag-calendar-year-zero.js index abe100487e..5111e057ee 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/until/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/until/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.PlainDate(2000, 5, 2); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.until(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/until/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/until/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..38bba39b1d --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/until/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.until +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.until(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/until/largestunit-higher-units.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/until/largestunit-higher-units.js index a8f8812d9d..5962cf31bc 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/until/largestunit-higher-units.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/until/largestunit-higher-units.js @@ -20,10 +20,10 @@ TemporalHelpers.assertDuration(feb20.until(feb21, { largestUnit: "years" }), /* TemporalHelpers.assertDuration(feb20.until(feb21, { largestUnit: "months" }), 0, /* months = */ 12, 0, 0, 0, 0, 0, 0, 0, 0, "start of February, months"); TemporalHelpers.assertDuration(feb20.until(feb21, { largestUnit: "weeks" }), 0, 0, /* weeks = */ 52, /* days = */ 2, 0, 0, 0, 0, 0, 0, "start of February, weeks"); -const lastFeb20 = Temporal.PlainDate.from("2020-02-29"); -const lastFeb21 = Temporal.PlainDate.from("2021-02-28"); -TemporalHelpers.assertDuration(lastFeb20.until(lastFeb21, { largestUnit: "years" }), /* years = */ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "end of February, years"); -TemporalHelpers.assertDuration(lastFeb20.until(lastFeb21, { largestUnit: "months" }), 0, /* months = */ 12, 0, 0, 0, 0, 0, 0, 0, 0, "end of February, months"); -TemporalHelpers.assertDuration(lastFeb20.until(lastFeb21, { largestUnit: "weeks" }), 0, 0, /* weeks = */ 52, /* days = */ 1, 0, 0, 0, 0, 0, 0, "end of February, weeks"); +const lastFeb21 = new Temporal.PlainDate(2021, 2, 28); +const lastFeb22 = new Temporal.PlainDate(2022, 2, 28); +TemporalHelpers.assertDuration(lastFeb21.until(lastFeb22, { largestUnit: "years" }), /* years = */ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "end of February, years"); +TemporalHelpers.assertDuration(lastFeb21.until(lastFeb22, { largestUnit: "months" }), 0, /* months = */ 12, 0, 0, 0, 0, 0, 0, 0, 0, "end of February, months"); +TemporalHelpers.assertDuration(lastFeb21.until(lastFeb22, { largestUnit: "weeks" }), 0, 0, /* weeks = */ 52, /* days = */ 1, 0, 0, 0, 0, 0, 0, "end of February, weeks"); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/until/wrapping-at-end-of-month.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/until/wrapping-at-end-of-month.js new file mode 100644 index 0000000000..082ba05283 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/until/wrapping-at-end-of-month.js @@ -0,0 +1,120 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.until +description: Tests balancing of days to months at end of month +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Difference between end of longer month to end of following shorter month +{ + const end = new Temporal.PlainDate(1970, 2, 28); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 1, 28).until(end, { largestUnit }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + "Jan 28th to Feb 28th is one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 1, 29).until(end, { largestUnit }), + 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, + "Jan 29th to Feb 28th is 30 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 1, 30).until(end, { largestUnit }), + 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, + "Jan 30th to Feb 28th is 29 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 1, 31).until(end, { largestUnit }), + 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, + "Jan 31st to Feb 28th is 28 days, not one month" + ); + } +} + +// Difference between end of leap-year January to end of leap-year February +{ + const end = new Temporal.PlainDate(1972, 2, 29); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1972, 1, 29).until(end, { largestUnit }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + "Jan 29th to Feb 29th is one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1972, 1, 30).until(end, { largestUnit }), + 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, + "Jan 30th to Feb 29th is 30 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1972, 1, 31).until(end, { largestUnit }), + 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, + "Jan 31st to Feb 29th is 29 days, not one month" + ); + } +} + +// Difference between end of longer month to end of not-immediately-following +// shorter month +{ + const end = new Temporal.PlainDate(1970, 11, 30); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 8, 30).until(end, { largestUnit }), + 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, + "Aug 30th to Nov 30th is 3 months" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 8, 31).until(end, { largestUnit }), + 0, 2, 0, 30, 0, 0, 0, 0, 0, 0, + "Aug 31st to Nov 30th is 2 months 30 days, not 3 months" + ); + } +} + +// Difference between end of longer month in one year to shorter month in +// later year +{ + const end = new Temporal.PlainDate(1973, 4, 30); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 12, 30).until(end, { largestUnit: "months" }), + 0, 28, 0, 0, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 28 months" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 12, 30).until(end, { largestUnit: "years" }), + 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 2 years, 4 months" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 12, 31).until(end, { largestUnit: "months" }), + 0, 27, 0, 30, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 27 months, 30 days, not 28 months" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 12, 31).until(end, { largestUnit: "years" }), + 2, 3, 0, 30, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 2 years, 3 months, 30 days, not 2 years 4 months" + ); +} + +// Difference where months passes through a month that's the same length or +// shorter than either the start or end month +{ + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 1, 29).until(new Temporal.PlainDate(1970, 3, 28), { largestUnit: "months" }), + 0, 1, 0, 28, 0, 0, 0, 0, 0, 0, + "Jan 29th to Mar 28th is 1 month 28 days, not 58 days" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDate(1970, 1, 31).until(new Temporal.PlainDate(1971, 5, 30), { largestUnit: "years" }), + 1, 3, 0, 30, 0, 0, 0, 0, 0, 0, + "Jan 31st 1970 to May 30th 1971 is 1 year, 3 months, 30 days, not 1 year, 2 months, 60 days" + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/weekOfYear/custom-calendar-weekofyear.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/weekOfYear/custom-calendar-weekofyear.js new file mode 100644 index 0000000000..724eaa4ccf --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/weekOfYear/custom-calendar-weekofyear.js @@ -0,0 +1,26 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.weekofyear +description: > + Temporal.PlainDate.prototype.weekOfYear returns undefined for all + custom calendars where weekOfYear() returns undefined. +features: [Temporal] +---*/ + +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + weekOfYear() { + return undefined; + } +} + +const calendar = new CustomCalendar(); +const customCalendarDate = new Temporal.PlainDate(2024, 1, 1, calendar); +assert.sameValue(customCalendarDate.weekOfYear, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/weekOfYear/validate-calendar-value.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/weekOfYear/validate-calendar-value.js index 7836bbff10..62faff1a15 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/weekOfYear/validate-calendar-value.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/weekOfYear/validate-calendar-value.js @@ -9,7 +9,6 @@ features: [Temporal] ---*/ const badResults = [ - [undefined, TypeError], [null, TypeError], [false, TypeError], [Infinity, RangeError], diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-iso-string.js new file mode 100644 index 0000000000..e17e975f46 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-iso-string.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.withcalendar +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDate(1976, 11, 18, { + dateAdd() {}, + dateFromFields() {}, + dateUntil() {}, + day() {}, + dayOfWeek() {}, + dayOfYear() {}, + daysInMonth() {}, + daysInWeek() {}, + daysInYear() {}, + fields() {}, + id: "replace-me", + inLeapYear() {}, + mergeFields() {}, + month() {}, + monthCode() {}, + monthDayFromFields() {}, + monthsInYear() {}, + weekOfYear() {}, + year() {}, + yearMonthFromFields() {}, + yearOfWeek() {}, +}); + +for (const arg of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const result = instance.withCalendar(arg); + assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/yearOfWeek/custom-calendar-weekofyear.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/yearOfWeek/custom-calendar-weekofyear.js new file mode 100644 index 0000000000..9e37a85bd7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/yearOfWeek/custom-calendar-weekofyear.js @@ -0,0 +1,26 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.yearofweek +description: > + Temporal.PlainDate.prototype.yearOfWeek returns undefined for all + custom calendars where yearOfWeek() returns undefined. +features: [Temporal] +---*/ + +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + yearOfWeek() { + return undefined; + } +} + +const calendar = new CustomCalendar(); +const customCalendarDate = new Temporal.PlainDate(2024, 1, 1, calendar); +assert.sameValue(customCalendarDate.yearOfWeek, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/yearOfWeek/validate-calendar-value.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/yearOfWeek/validate-calendar-value.js index ec291bd0ff..e00a2cda10 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/yearOfWeek/validate-calendar-value.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/yearOfWeek/validate-calendar-value.js @@ -9,7 +9,6 @@ features: [Temporal] ---*/ const badResults = [ - [undefined, TypeError], [Infinity, RangeError], [-Infinity, RangeError], [Symbol("foo"), TypeError], diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..182ef7beac --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.compare +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result1 = Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18)); + assert.sameValue(result1, 0, `Calendar created from string "${calendar}" (first argument)`); + const result2 = Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg); + assert.sameValue(result2, 0, `Calendar created from string "${calendar}" (second argument)`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/compare/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/compare/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..fa4f9e080c --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/compare/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.compare +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; + +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18)), + `annotation keys must be lowercase: ${arg} - ${descr} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg), + `annotation keys must be lowercase: ${arg} - ${descr} (second argument)` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..f1e298bf4b --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.from +description: An ISO 8601 string can be converted to a calendar ID in Calendar +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = Temporal.PlainDateTime.from(arg); + TemporalHelpers.assertPlainDateTime(result, 1976, 11, "M11", 18, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}"`); + assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-year-zero.js index 8e5bc48a68..bfde3b1c4e 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => Temporal.PlainDateTime.from(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/from/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/from/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..1b69a116d3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/from/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.from +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; + +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => Temporal.PlainDateTime.from(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/equals/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/equals/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..eaa94f9313 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/equals/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.equals +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDateTime(1976, 11, 18); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.equals(arg); + assert.sameValue(result, true, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/equals/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/equals/argument-propertybag-calendar-year-zero.js index 967839b97e..3abda8c843 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/equals/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/equals/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.equals(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..7c1070bcf7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.equals +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..f23d5b2eb0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.since +description: An ISO 8601 string can be converted to a calendar ID in Calendar +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDateTime(1976, 11, 18); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.since(arg); + TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-number.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-number.js index 9c7f65ec05..93932c89d5 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-number.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-number.js @@ -8,7 +8,7 @@ description: A number as calendar in a property bag is not accepted features: [Temporal] ---*/ -const instance = new Temporal.PlainDate(1976, 11, 18); +const instance = new Temporal.PlainDateTime(1976, 11, 18); const numbers = [ 1, @@ -16,6 +16,7 @@ const numbers = [ -19970327, 1234567890, ]; + for (const calendar of numbers) { const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; assert.throws( diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-year-zero.js index 6cd66acaf2..e869362840 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.since(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..b5b7f9ce2c --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.since +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.since(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/result-mixed-sign.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/result-mixed-sign.js new file mode 100644 index 0000000000..838de26784 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/result-mixed-sign.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.since +description: > + RangeError when inconsistent custom calendar method causes mixed signs of + Duration components +features: [Temporal] +---*/ + +// Test case provided by André Bargull + +const cal = new (class extends Temporal.Calendar { + dateAdd(date, duration, options) { + return super.dateAdd(date, duration.negated(), options); + } +})("iso8601"); + +const one = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0, cal); +const two = new Temporal.PlainDateTime(2020, 5, 10, 12, 12, 0, 0, 0, 0, cal); + +assert.throws(RangeError, () => two.since(one, { + largestUnit: "years", + smallestUnit: "hours" +})); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/wrapping-at-end-of-month.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/wrapping-at-end-of-month.js new file mode 100644 index 0000000000..23cecf8d1a --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/since/wrapping-at-end-of-month.js @@ -0,0 +1,120 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.since +description: Tests balancing of days to months at end of month +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Difference between end of longer month to end of following shorter month +{ + const end = new Temporal.PlainDateTime(1970, 2, 28); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 1, 28).since(end, { largestUnit }), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, + "Jan 28th to Feb 28th is one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 1, 29).since(end, { largestUnit }), + 0, 0, 0, -30, 0, 0, 0, 0, 0, 0, + "Jan 29th to Feb 28th is 30 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 1, 30).since(end, { largestUnit }), + 0, 0, 0, -29, 0, 0, 0, 0, 0, 0, + "Jan 30th to Feb 28th is 29 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 1, 31).since(end, { largestUnit }), + 0, 0, 0, -28, 0, 0, 0, 0, 0, 0, + "Jan 31st to Feb 28th is 28 days, not one month" + ); + } +} + +// Difference between end of leap-year January to end of leap-year February +{ + const end = new Temporal.PlainDateTime(1972, 2, 29); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1972, 1, 29).since(end, { largestUnit }), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, + "Jan 29th to Feb 29th is one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1972, 1, 30).since(end, { largestUnit }), + 0, 0, 0, -30, 0, 0, 0, 0, 0, 0, + "Jan 30th to Feb 29th is 30 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1972, 1, 31).since(end, { largestUnit }), + 0, 0, 0, -29, 0, 0, 0, 0, 0, 0, + "Jan 31st to Feb 29th is 29 days, not one month" + ); + } +} + +// Difference between end of longer month to end of not-immediately-following +// shorter month +{ + const end = new Temporal.PlainDateTime(1970, 11, 30); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 8, 30).since(end, { largestUnit }), + 0, -3, 0, 0, 0, 0, 0, 0, 0, 0, + "Aug 30th to Nov 30th is 3 months" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 8, 31).since(end, { largestUnit }), + 0, -2, 0, -30, 0, 0, 0, 0, 0, 0, + "Aug 31st to Nov 30th is 2 months 30 days, not 3 months" + ); + } +} + +// Difference between end of longer month in one year to shorter month in +// later year +{ + const end = new Temporal.PlainDateTime(1973, 4, 30); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 12, 30).since(end, { largestUnit: "months" }), + 0, -28, 0, 0, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 28 months" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 12, 30).since(end, { largestUnit: "years" }), + -2, -4, 0, 0, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 2 years, 4 months" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 12, 31).since(end, { largestUnit: "months" }), + 0, -27, 0, -30, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 27 months, 30 days, not 28 months" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 12, 31).since(end, { largestUnit: "years" }), + -2, -3, 0, -30, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 2 years, 3 months, 30 days, not 2 years 4 months" + ); +} + +// Difference where months passes through a month that's the same length or +// shorter than either the start or end month +{ + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 1, 29).since(new Temporal.PlainDateTime(1970, 3, 28), { largestUnit: "months" }), + 0, -1, 0, -28, 0, 0, 0, 0, 0, 0, + "Jan 29th to Mar 28th is 1 month 28 days, not 58 days" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 1, 31).since(new Temporal.PlainDateTime(1971, 5, 30), { largestUnit: "years" }), + -1, -3, 0, -30, 0, 0, 0, 0, 0, 0, + "Jan 31st 1970 to May 30th 1971 is 1 year, 3 months, 30 days, not 1 year, 2 months, 60 days" + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js new file mode 100644 index 0000000000..af7f128a9c --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tozoneddatetime +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants can be at most 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + calls++; + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12 })]; + } +} + +const timeZone = new Shift24Hour(); + +const instance = new Temporal.PlainDateTime(1970, 1, 1, 12); +instance.toZonedDateTime(timeZone); + +assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..3fe9f52dbf --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js @@ -0,0 +1,44 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tozoneddatetime +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +const instance = new Temporal.PlainDateTime(1970, 1, 1, 12); +assert.throws(RangeError, () => instance.toZonedDateTime(timeZone), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js new file mode 100644 index 0000000000..a1a8898838 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js @@ -0,0 +1,53 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tozoneddatetime +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + calls++; + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12 }), + utcInstant.add({ hours: 12 }) + ]; + } +} + +const timeZone = new Shift24Hour(); + +const instance = new Temporal.PlainDateTime(1970, 1, 1, 12); +instance.toZonedDateTime(timeZone); + +assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..29703ed59f --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tozoneddatetime +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +const instance = new Temporal.PlainDateTime(1970, 1, 1, 12); +assert.throws(RangeError, () => instance.toZonedDateTime(timeZone), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..0f06b77fa8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.until +description: An ISO 8601 string can be converted to a calendar ID in Calendar +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDateTime(1976, 11, 18); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.until(arg); + TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-number.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-number.js index cf43c5a168..ab3cea6b6c 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-number.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-number.js @@ -8,7 +8,7 @@ description: A number as calendar in a property bag is not accepted features: [Temporal] ---*/ -const instance = new Temporal.PlainDate(1976, 11, 18); +const instance = new Temporal.PlainDateTime(1976, 11, 18); const numbers = [ 1, @@ -16,6 +16,7 @@ const numbers = [ -19970327, 1234567890, ]; + for (const calendar of numbers) { const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; assert.throws( diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-year-zero.js index 099de48b51..b1d165cc6e 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.until(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..94dcaf9e99 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.until +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.until(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/no-unnecessary-units.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/no-unnecessary-units.js index 7e311f8dca..8966496ca9 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/no-unnecessary-units.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/no-unnecessary-units.js @@ -9,17 +9,17 @@ features: [Temporal] includes: [temporalHelpers.js] ---*/ -const feb29 = new Temporal.PlainDateTime(2020, 2, 29, 0, 0); -const feb28 = new Temporal.PlainDateTime(2021, 2, 28, 0, 0); +const lastFeb21 = new Temporal.PlainDateTime(2021, 2, 28); +const lastFeb22 = new Temporal.PlainDateTime(2022, 2, 28); TemporalHelpers.assertDuration( - feb29.until(feb28, { largestUnit: "months" }), + lastFeb21.until(lastFeb22, { largestUnit: "months" }), 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, "does not include higher units than necessary (largest unit = months)" ); TemporalHelpers.assertDuration( - feb29.until(feb28, { largestUnit: "years" }), + lastFeb21.until(lastFeb22, { largestUnit: "years" }), 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "does not include higher units than necessary (largest unit = years)" ); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/result-mixed-sign.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/result-mixed-sign.js new file mode 100644 index 0000000000..7287c706b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/result-mixed-sign.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.until +description: > + RangeError when inconsistent custom calendar method causes mixed signs of + Duration components +features: [Temporal] +---*/ + +// Test case provided by André Bargull + +const cal = new (class extends Temporal.Calendar { + dateAdd(date, duration, options) { + return super.dateAdd(date, duration.negated(), options); + } +})("iso8601"); + +const one = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0, cal); +const two = new Temporal.PlainDateTime(2020, 5, 10, 12, 12, 0, 0, 0, 0, cal); + +assert.throws(RangeError, () => one.until(two, { + largestUnit: "years", + smallestUnit: "hours" +})); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/wrapping-at-end-of-month.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/wrapping-at-end-of-month.js new file mode 100644 index 0000000000..3a83eb2138 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/until/wrapping-at-end-of-month.js @@ -0,0 +1,120 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.until +description: Tests balancing of days to months at end of month +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Difference between end of longer month to end of following shorter month +{ + const end = new Temporal.PlainDateTime(1970, 2, 28); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 1, 28).until(end, { largestUnit }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + "Jan 28th to Feb 28th is one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 1, 29).until(end, { largestUnit }), + 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, + "Jan 29th to Feb 28th is 30 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 1, 30).until(end, { largestUnit }), + 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, + "Jan 30th to Feb 28th is 29 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 1, 31).until(end, { largestUnit }), + 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, + "Jan 31st to Feb 28th is 28 days, not one month" + ); + } +} + +// Difference between end of leap-year January to end of leap-year February +{ + const end = new Temporal.PlainDateTime(1972, 2, 29); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1972, 1, 29).until(end, { largestUnit }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + "Jan 29th to Feb 29th is one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1972, 1, 30).until(end, { largestUnit }), + 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, + "Jan 30th to Feb 29th is 30 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1972, 1, 31).until(end, { largestUnit }), + 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, + "Jan 31st to Feb 29th is 29 days, not one month" + ); + } +} + +// Difference between end of longer month to end of not-immediately-following +// shorter month +{ + const end = new Temporal.PlainDateTime(1970, 11, 30); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 8, 30).until(end, { largestUnit }), + 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, + "Aug 30th to Nov 30th is 3 months" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 8, 31).until(end, { largestUnit }), + 0, 2, 0, 30, 0, 0, 0, 0, 0, 0, + "Aug 31st to Nov 30th is 2 months 30 days, not 3 months" + ); + } +} + +// Difference between end of longer month in one year to shorter month in +// later year +{ + const end = new Temporal.PlainDateTime(1973, 4, 30); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 12, 30).until(end, { largestUnit: "months" }), + 0, 28, 0, 0, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 28 months" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 12, 30).until(end, { largestUnit: "years" }), + 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 2 years, 4 months" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 12, 31).until(end, { largestUnit: "months" }), + 0, 27, 0, 30, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 27 months, 30 days, not 28 months" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 12, 31).until(end, { largestUnit: "years" }), + 2, 3, 0, 30, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 2 years, 3 months, 30 days, not 2 years 4 months" + ); +} + +// Difference where months passes through a month that's the same length or +// shorter than either the start or end month +{ + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 1, 29).until(new Temporal.PlainDateTime(1970, 3, 28), { largestUnit: "months" }), + 0, 1, 0, 28, 0, 0, 0, 0, 0, 0, + "Jan 29th to Mar 28th is 1 month 28 days, not 58 days" + ); + TemporalHelpers.assertDuration( + new Temporal.PlainDateTime(1970, 1, 31).until(new Temporal.PlainDateTime(1971, 5, 30), { largestUnit: "years" }), + 1, 3, 0, 30, 0, 0, 0, 0, 0, 0, + "Jan 31st 1970 to May 30th 1971 is 1 year, 3 months, 30 days, not 1 year, 2 months, 60 days" + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/custom-calendar-weekofyear.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/custom-calendar-weekofyear.js new file mode 100644 index 0000000000..97242a19c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/custom-calendar-weekofyear.js @@ -0,0 +1,26 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.weekofyear +description: > + Temporal.PlainDateTime.prototype.weekOfYear returns undefined for all + custom calendars where weekOfYear() returns undefined. +features: [Temporal] +---*/ + +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + weekOfYear() { + return undefined; + } +} + +const calendar = new CustomCalendar(); +const customCalendarDate = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); +assert.sameValue(customCalendarDate.weekOfYear, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/validate-calendar-value.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/validate-calendar-value.js index d1624e1617..89d47a3566 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/validate-calendar-value.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/validate-calendar-value.js @@ -9,7 +9,6 @@ features: [Temporal] ---*/ const badResults = [ - [undefined, TypeError], [null, TypeError], [false, TypeError], [Infinity, RangeError], diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-iso-string.js new file mode 100644 index 0000000000..7ba0d5a207 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-iso-string.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.withcalendar +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, { + dateAdd() {}, + dateFromFields() {}, + dateUntil() {}, + day() {}, + dayOfWeek() {}, + dayOfYear() {}, + daysInMonth() {}, + daysInWeek() {}, + daysInYear() {}, + fields() {}, + id: "replace-me", + inLeapYear() {}, + mergeFields() {}, + month() {}, + monthCode() {}, + monthDayFromFields() {}, + monthsInYear() {}, + weekOfYear() {}, + year() {}, + yearMonthFromFields() {}, + yearOfWeek() {}, +}); + +for (const arg of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const result = instance.withCalendar(arg); + assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..e514b4b7d3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.withplaindate +description: An ISO 8601 string can be converted to a calendar ID in Calendar +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.withPlainDate(arg); + TemporalHelpers.assertPlainDateTime(result, 1976, 11, "M11", 18, 12, 34, 56, 987, 654, 321, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-number.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-number.js index cbd1950207..57c77ae669 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-number.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-number.js @@ -8,7 +8,7 @@ description: A number as calendar in a property bag is not accepted features: [Temporal] ---*/ -const instance = new Temporal.PlainDate(1976, 11, 18); +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); const numbers = [ 1, @@ -16,6 +16,7 @@ const numbers = [ -19970327, 1234567890, ]; + for (const calendar of numbers) { const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; assert.throws( diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js index d39551d616..201aba871b 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.withPlainDate(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..8f9827733c --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.withplaindate +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.withPlainDate(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..5d63e53dc4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,31 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.withplaintime +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["00:00[U-CA=iso8601]", "invalid capitalized key, time-only"], + ["T00:00[U-CA=iso8601]", "invalid capitalized key, time designator"], + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["00:00[u-CA=iso8601]", "invalid partially-capitalized key, time-only"], + ["T00:00[u-CA=iso8601]", "invalid partially-capitalized key, time designator"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["00:00[FOO=bar]", "invalid capitalized unrecognized key, time-only"], + ["T00:00[FOO=bar]", "invalid capitalized unrecognized key, time designator"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.withPlainTime(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/custom-calendar-weekofyear.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/custom-calendar-weekofyear.js new file mode 100644 index 0000000000..81b9ae2086 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/custom-calendar-weekofyear.js @@ -0,0 +1,26 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.yearofweek +description: > + Temporal.PlainDateTime.prototype.yearOfWeek returns undefined for all + custom calendars where yearOfWeek() returns undefined. +features: [Temporal] +---*/ + +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + yearOfWeek() { + return undefined; + } +} + +const calendar = new CustomCalendar(); +const customCalendarDate = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); +assert.sameValue(customCalendarDate.yearOfWeek, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/validate-calendar-value.js b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/validate-calendar-value.js index cd43fd4474..8c67a02491 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/validate-calendar-value.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/validate-calendar-value.js @@ -9,7 +9,6 @@ features: [Temporal] ---*/ const badResults = [ - [undefined, TypeError], [Infinity, RangeError], [-Infinity, RangeError], [Symbol("foo"), TypeError], diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..0f227aa4be --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.from +description: An ISO 8601 string can be converted to a calendar ID in Calendar +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { monthCode: "M11", day: 18, calendar }; + const result = Temporal.PlainMonthDay.from(arg); + TemporalHelpers.assertPlainMonthDay(result, "M11", 18, `Calendar created from string "${calendar}"`); + assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-year-zero.js index 19fb53023f..0b5268347c 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => Temporal.PlainMonthDay.from(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/from/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/from/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..6fce02f500 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/from/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.from +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; + +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => Temporal.PlainMonthDay.from(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..756ea33cf2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.equals +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.PlainMonthDay(11, 18); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { monthCode: "M11", day: 18, calendar }; + const result = instance.equals(arg); + assert.sameValue(result, true, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-propertybag-calendar-year-zero.js index e3303ba1f5..86756fe089 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.PlainMonthDay(5, 2); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.equals(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..bc74d401db --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.equals +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainMonthDay(5, 2); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-fromfields-called-with-undefined-options.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-fromfields-called-with-undefined-options.js new file mode 100644 index 0000000000..996909c664 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-fromfields-called-with-undefined-options.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.toplaindate +description: Calendar.dateFromFields method is called with undefined options +features: [Temporal] +---*/ + +let count = 0; + +const calendar = new class extends Temporal.Calendar { + dateFromFields(fields, options) { + count++; + assert.sameValue(options, undefined, "dateFromFields should be called with undefined options"); + return super.dateFromFields(fields, options); + } +}("iso8601"); + +const instance = new Temporal.PlainMonthDay(5, 2, calendar); +instance.toPlainDate({ year: 2019 }); +assert.sameValue(count, 1, "dateFromFields should have been called on the calendar"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainTime/compare/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainTime/compare/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..8667a8bf8f --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainTime/compare/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,36 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.compare +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["00:00[U-CA=iso8601]", "invalid capitalized key, time-only"], + ["T00:00[U-CA=iso8601]", "invalid capitalized key, time designator"], + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["00:00[u-CA=iso8601]", "invalid partially-capitalized key, time-only"], + ["T00:00[u-CA=iso8601]", "invalid partially-capitalized key, time designator"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["00:00[FOO=bar]", "invalid capitalized unrecognized key, time-only"], + ["T00:00[FOO=bar]", "invalid capitalized unrecognized key, time designator"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; + +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => Temporal.PlainTime.compare(arg, new Temporal.PlainTime(12, 34, 56, 987, 654, 321)), + `annotation keys must be lowercase: ${arg} - ${descr} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.PlainTime.compare(new Temporal.PlainTime(12, 34, 56, 987, 654, 321), arg), + `annotation keys must be lowercase: ${arg} - ${descr} (second argument)` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainTime/from/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainTime/from/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..886c8b6af8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainTime/from/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,31 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.from +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["00:00[U-CA=iso8601]", "invalid capitalized key, time-only"], + ["T00:00[U-CA=iso8601]", "invalid capitalized key, time designator"], + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["00:00[u-CA=iso8601]", "invalid partially-capitalized key, time-only"], + ["T00:00[u-CA=iso8601]", "invalid partially-capitalized key, time designator"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["00:00[FOO=bar]", "invalid capitalized unrecognized key, time-only"], + ["T00:00[FOO=bar]", "invalid capitalized unrecognized key, time designator"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; + +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => Temporal.PlainTime.from(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/equals/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/equals/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..258b4b5c77 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/equals/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,31 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.prototype.equals +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["00:00[U-CA=iso8601]", "invalid capitalized key, time-only"], + ["T00:00[U-CA=iso8601]", "invalid capitalized key, time designator"], + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["00:00[u-CA=iso8601]", "invalid partially-capitalized key, time-only"], + ["T00:00[u-CA=iso8601]", "invalid partially-capitalized key, time designator"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["00:00[FOO=bar]", "invalid capitalized unrecognized key, time-only"], + ["T00:00[FOO=bar]", "invalid capitalized unrecognized key, time designator"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/since/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/since/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..1e2b960f01 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/since/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,31 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.prototype.since +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["00:00[U-CA=iso8601]", "invalid capitalized key, time-only"], + ["T00:00[U-CA=iso8601]", "invalid capitalized key, time designator"], + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["00:00[u-CA=iso8601]", "invalid partially-capitalized key, time-only"], + ["T00:00[u-CA=iso8601]", "invalid partially-capitalized key, time designator"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["00:00[FOO=bar]", "invalid capitalized unrecognized key, time-only"], + ["T00:00[FOO=bar]", "invalid capitalized unrecognized key, time designator"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.since(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..8f2089e661 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.prototype.toplaindatetime +description: An ISO 8601 string can be converted to a calendar ID in Calendar +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.toPlainDateTime(arg); + TemporalHelpers.assertPlainDateTime(result, 1976, 11, "M11", 18, 12, 34, 56, 987, 654, 321, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-number.js b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-number.js index 407773adb4..56d2ffce44 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-number.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-number.js @@ -8,7 +8,7 @@ description: A number as calendar in a property bag is not accepted features: [Temporal] ---*/ -const instance = new Temporal.PlainDate(1976, 11, 18); +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); const numbers = [ 1, @@ -16,6 +16,7 @@ const numbers = [ -19970327, 1234567890, ]; + for (const calendar of numbers) { const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; assert.throws( diff --git a/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-year-zero.js index f9ba398d5f..2bf5796cc3 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.toPlainDateTime(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..84f457f314 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.prototype.toplaindatetime +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.toPlainDateTime(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..512dc81228 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.prototype.tozoneddatetime +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); + assert.sameValue(result.epochNanoseconds, 217_168_496_987_654_321n, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-year-zero.js index 2acf24b30d..ae338a02ba 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), diff --git a/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..6a37c4b726 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.prototype.tozoneddatetime +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js new file mode 100644 index 0000000000..cbafe771e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.prototype.tozoneddatetime +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants can be at most 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + calls++; + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12 })]; + } +} + +const timeZone = new Shift24Hour(); + +const instance = new Temporal.PlainTime(12); +instance.toZonedDateTime({ timeZone, plainDate: new Temporal.PlainDate(1970, 1, 1) }); + +assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..139efa0dcc --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js @@ -0,0 +1,44 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.prototype.tozoneddatetime +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +const instance = new Temporal.PlainTime(12); +assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone, plainDate: new Temporal.PlainDate(1970, 1, 1) }), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js new file mode 100644 index 0000000000..200423dd52 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js @@ -0,0 +1,53 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.prototype.tozoneddatetime +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + calls++; + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12 }), + utcInstant.add({ hours: 12 }) + ]; + } +} + +const timeZone = new Shift24Hour(); + +const instance = new Temporal.PlainTime(12); +instance.toZonedDateTime({ timeZone, plainDate: new Temporal.PlainDate(1970, 1, 1) }); + +assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..968957a05e --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.prototype.tozoneddatetime +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +const instance = new Temporal.PlainTime(12); +assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone, plainDate: new Temporal.PlainDate(1970, 1, 1) }), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/until/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/until/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..48c425a3ef --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainTime/prototype/until/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,31 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.prototype.until +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["00:00[U-CA=iso8601]", "invalid capitalized key, time-only"], + ["T00:00[U-CA=iso8601]", "invalid capitalized key, time designator"], + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["00:00[u-CA=iso8601]", "invalid partially-capitalized key, time-only"], + ["T00:00[u-CA=iso8601]", "invalid partially-capitalized key, time designator"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["00:00[FOO=bar]", "invalid capitalized unrecognized key, time-only"], + ["T00:00[FOO=bar]", "invalid capitalized unrecognized key, time designator"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.until(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..42192ffb4f --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.compare +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 2019, monthCode: "M06", calendar }; + const result1 = Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6)); + assert.sameValue(result1, 0, `Calendar created from string "${calendar}" (first argument)`); + const result2 = Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg); + assert.sameValue(result2, 0, `Calendar created from string "${calendar}" (second argument)`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/compare/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/compare/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..705204f82b --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/compare/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.compare +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; + +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6)), + `annotation keys must be lowercase: ${arg} - ${descr} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg), + `annotation keys must be lowercase: ${arg} - ${descr} (second argument)` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..a94d59d88f --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.from +description: An ISO 8601 string can be converted to a calendar ID in Calendar +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 2019, monthCode: "M06", calendar }; + const result = Temporal.PlainYearMonth.from(arg); + TemporalHelpers.assertPlainYearMonth(result, 2019, 6, "M06", `Calendar created from string "${calendar}"`); + assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-year-zero.js index 9d039d2365..03225ab174 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => Temporal.PlainYearMonth.from(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..15629e5f98 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.from +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; + +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => Temporal.PlainYearMonth.from(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..005d750ff9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.equals +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.PlainYearMonth(2019, 6); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 2019, monthCode: "M06", calendar }; + const result = instance.equals(arg); + assert.sameValue(result, true, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-propertybag-calendar-year-zero.js index 0e652fd79b..be30091e98 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.PlainYearMonth(2000, 5); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.equals(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..98808648b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.equals +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainYearMonth(2000, 5); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..7e7ed39768 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.since +description: An ISO 8601 string can be converted to a calendar ID in Calendar +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainYearMonth(2019, 6); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 2019, monthCode: "M06", calendar }; + const result = instance.since(arg); + TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-number.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-number.js index 08a1caa46b..b458e6d42b 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-number.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-number.js @@ -8,7 +8,7 @@ description: A number as calendar in a property bag is not accepted features: [Temporal] ---*/ -const instance = new Temporal.PlainDate(1976, 11, 18); +const instance = new Temporal.PlainYearMonth(2019, 6); const numbers = [ 1, @@ -16,6 +16,7 @@ const numbers = [ -19970327, 1234567890, ]; + for (const calendar of numbers) { const arg = { year: 2019, monthCode: "M06", calendar }; assert.throws( diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-year-zero.js index 6c0b70f03b..ddca0eaedc 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.PlainYearMonth(2000, 5); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.since(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..1746c55e7a --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.since +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainYearMonth(2000, 5); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.since(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-fromfields-called-with-undefined-options.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-fromfields-called-with-undefined-options.js new file mode 100644 index 0000000000..0edd3b289f --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-fromfields-called-with-undefined-options.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.toplaindate +description: Calendar.dateFromFields method is called with undefined options +features: [Temporal] +---*/ + +let count = 0; + +const calendar = new class extends Temporal.Calendar { + dateFromFields(fields, options) { + count++; + assert.sameValue(options, undefined, "dateFromFields should be called with undefined options"); + return super.dateFromFields(fields, options); + } +}("iso8601"); + +const instance = new Temporal.PlainYearMonth(2000, 5, calendar); +instance.toPlainDate({ day: 24 }); +assert.sameValue(count, 1, "dateFromFields should have been called on the calendar"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..cddfd13793 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.until +description: An ISO 8601 string can be converted to a calendar ID in Calendar +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainYearMonth(2019, 6); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 2019, monthCode: "M06", calendar }; + const result = instance.until(arg); + TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-number.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-number.js index 363d158d7a..ce758e146e 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-number.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-number.js @@ -8,7 +8,7 @@ description: A number as calendar in a property bag is not accepted features: [Temporal] ---*/ -const instance = new Temporal.PlainDate(1976, 11, 18); +const instance = new Temporal.PlainYearMonth(2019, 6); const numbers = [ 1, @@ -16,6 +16,7 @@ const numbers = [ -19970327, 1234567890, ]; + for (const calendar of numbers) { const arg = { year: 2019, monthCode: "M06", calendar }; assert.throws( diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-year-zero.js index 71400ef76d..35789455ba 100644 --- a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.PlainYearMonth(2000, 5); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.until(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..d2f40af228 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.until +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.PlainYearMonth(2000, 5); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.until(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..bf672c3f86 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getinstantfor +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.TimeZone("UTC"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.getInstantFor(arg); + assert.sameValue(result.epochNanoseconds, 217_123_200_000_000_000n, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-year-zero.js index 8065dd55fe..f5cef07a0c 100644 --- a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.getInstantFor(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..5e34035059 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getinstantfor +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.getInstantFor(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/getoffsetnanosecondsfor-maximum-forward-offset-shift.js new file mode 100644 index 0000000000..18a309bc43 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/getoffsetnanosecondsfor-maximum-forward-offset-shift.js @@ -0,0 +1,51 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getinstantfor +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants can be at most 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + calls++; + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12 })]; + } +} + +const timeZone = new Shift24Hour(); + +for (const disambiguation of ["earlier", "later", "compatible"]) { + timeZone.getInstantFor(new Temporal.PlainDateTime(1970, 1, 1, 12), { disambiguation }); + + assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); + calls = 0; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..020151a0d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js @@ -0,0 +1,46 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getinstantfor +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +for (const disambiguation of ["earlier", "later", "compatible"]) { + assert.throws(RangeError, () => timeZone.getInstantFor(new Temporal.PlainDateTime(1970, 1, 1, 12), { disambiguation }), "RangeError should be thrown"); +} + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/getpossibleinstantsfor-maximum-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/getpossibleinstantsfor-maximum-backward-offset-shift.js new file mode 100644 index 0000000000..db12836dba --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/getpossibleinstantsfor-maximum-backward-offset-shift.js @@ -0,0 +1,55 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getinstantfor +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + calls++; + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12 }), + utcInstant.add({ hours: 12 }) + ]; + } +} + +const timeZone = new Shift24Hour(); + +for (const disambiguation of ["earlier", "later", "compatible"]) { + timeZone.getInstantFor(new Temporal.PlainDateTime(1970, 1, 1, 12), { disambiguation }); + + assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); + calls = 0; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/getpossibleinstantsfor-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..c8ad86aa14 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getInstantFor/getpossibleinstantsfor-out-of-range-backward-offset-shift.js @@ -0,0 +1,50 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getinstantfor +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +for (const disambiguation of ["earlier", "later", "compatible"]) { + assert.throws(RangeError, () => timeZone.getInstantFor(new Temporal.PlainDateTime(1970, 1, 1, 12), { disambiguation }), "RangeError should be thrown"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..fd32a4f029 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getnexttransition +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.getNextTransition(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..47d9b20d5a --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.getOffsetNanosecondsFor(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..280857ae31 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getoffsetstringfor +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.getOffsetStringFor(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..069c805881 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getplaindatetimefor +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.getPlainDateTimeFor(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-iso-string.js new file mode 100644 index 0000000000..5f66016904 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-iso-string.js @@ -0,0 +1,27 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getplaindatetimefor +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.TimeZone("UTC"); + +for (const arg of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const result = instance.getPlainDateTimeFor(new Temporal.Instant(0n), arg); + assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..0ffa57e472 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getpossibleinstantsfor +description: An ISO 8601 string can be converted to a calendar ID in Calendar +includes: [compareArray.js] +features: [Temporal] +---*/ + +const instance = new Temporal.TimeZone("UTC"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.getPossibleInstantsFor(arg); + assert.compareArray(result.map(i => i.epochNanoseconds), [217_123_200_000_000_000n], `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-year-zero.js index 0afcf6f978..d112ab2be6 100644 --- a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.getPossibleInstantsFor(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..21cfb938e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getpossibleinstantsfor +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.getPossibleInstantsFor(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..96c81db475 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getprevioustransition +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.getPreviousTransition(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..3a440b4994 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.compare +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const datetime = new Temporal.ZonedDateTime(0n, "UTC"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1970, monthCode: "M01", day: 1, timeZone: "UTC", calendar }; + const result1 = Temporal.ZonedDateTime.compare(arg, datetime); + assert.sameValue(result1, 0, `Calendar created from string "${calendar}" (first argument)`); + const result2 = Temporal.ZonedDateTime.compare(datetime, arg); + assert.sameValue(result2, 0, `Calendar created from string "${calendar}" (second argument)`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..9e09864074 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-out-of-range-backward-offset-shift.js @@ -0,0 +1,51 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.compare +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; +const datetime = new Temporal.ZonedDateTime(0n, timeZone); + +assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(arg, datetime), "RangeError should be thrown (first argument)"); +assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(datetime, arg), "RangeError should be thrown (second argument)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..d2fe4ab99f --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-out-of-range-forward-offset-shift.js @@ -0,0 +1,46 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.compare +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; +const datetime = new Temporal.ZonedDateTime(0n, timeZone); + +assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(arg, datetime), "RangeError should be thrown (first argument)"); +assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(datetime, arg), "RangeError should be thrown (second argument)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/compare/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/compare/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..a3f48aa25a --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/compare/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,32 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.compare +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const datetime = new Temporal.ZonedDateTime(0n, "UTC"); + +const invalidStrings = [ + ["1970-01-01T00:00[UTC][U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[UTC][u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[UTC][FOO=bar]", "invalid capitalized unrecognized key"], +]; + +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare(arg, datetime), + `annotation keys must be lowercase: ${arg} - ${descr} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare(datetime, arg), + `annotation keys must be lowercase: ${arg} - ${descr} (second argument)` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..ea5074b440 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.from +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const timeZone = new Temporal.TimeZone("UTC"); +const arg = { year: 1970, monthCode: "M01", day: 1, timeZone, calendar }; + const result = Temporal.ZonedDateTime.from(arg); + assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${calendar}"`); + assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-year-zero.js index d736edeb21..2741d61844 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => Temporal.ZonedDateTime.from(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..1c4da44c1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-out-of-range-backward-offset-shift.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.from +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; + +assert.throws(RangeError, () => Temporal.ZonedDateTime.from(arg), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..fad0037aae --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-out-of-range-forward-offset-shift.js @@ -0,0 +1,44 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.from +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; + +assert.throws(RangeError, () => Temporal.ZonedDateTime.from(arg), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..1ea7b9aea4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,32 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.from +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[UTC][U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[UTC][u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[UTC][FOO=bar]", "invalid capitalized unrecognized key"], +]; + +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.from(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); + for (const offset of ["use", "prefer", "ignore", "reject"]) { + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.from(arg, { offset }), + `annotation keys must be lowercase: ${arg} - ${descr} (offset ${offset})` + ); + } +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..4ee800c7bc --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.equals +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1970, monthCode: "M01", day: 1, timeZone, calendar }; + const result = instance.equals(arg); + assert.sameValue(result, true, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-year-zero.js index c0230f2f3e..196e992b08 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-year-zero.js @@ -17,7 +17,8 @@ const invalidStrings = [ ]; const timeZone = new Temporal.TimeZone("UTC"); const instance = new Temporal.ZonedDateTime(0n, timeZone); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.equals(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..bf311b856d --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-out-of-range-backward-offset-shift.js @@ -0,0 +1,50 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.equals +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +assert.throws(RangeError, () => instance.equals(arg), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..8b27e78eff --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-out-of-range-forward-offset-shift.js @@ -0,0 +1,45 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.equals +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +assert.throws(RangeError, () => instance.equals(arg), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..89b0d4d509 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.equals +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[UTC][U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[UTC][u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[UTC][FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.ZonedDateTime(0n, "UTC"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getoffsetnanosecondsfor-maximum-forward-offset-shift.js new file mode 100644 index 0000000000..f41e0be158 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getoffsetnanosecondsfor-maximum-forward-offset-shift.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.hoursinday +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants can be at most 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + calls++; + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12 })]; + } +} + +const timeZone = new Shift24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +instance.hoursInDay; + +assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..7a41b9456e --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js @@ -0,0 +1,44 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.hoursinday +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +assert.throws(RangeError, () => instance.hoursInDay, "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getpossibleinstantsfor-maximum-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getpossibleinstantsfor-maximum-backward-offset-shift.js new file mode 100644 index 0000000000..8312ef765b --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getpossibleinstantsfor-maximum-backward-offset-shift.js @@ -0,0 +1,53 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.hoursinday +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + calls++; + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12 }), + utcInstant.add({ hours: 12 }) + ]; + } +} + +const timeZone = new Shift24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +instance.hoursInDay; + +assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getpossibleinstantsfor-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..566b61b2b0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getpossibleinstantsfor-out-of-range-backward-offset-shift.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.hoursinday +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +assert.throws(RangeError, () => instance.hoursInDay, "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/div-zero.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/div-zero.js index 776cb7454f..dd912f46d4 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/div-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/div-zero.js @@ -18,10 +18,8 @@ class TimeZone extends Temporal.TimeZone { } } -const units = ["hour", "minute", "second", "millisecond", "microsecond", "nanosecond"]; -for (const smallestUnit of units) { - const zdt = new Temporal.ZonedDateTime(0n, new TimeZone("UTC")); - assert.throws(RangeError, () => zdt.round({ smallestUnit, roundingIncrement: 2 }), `zero day-length with smallestUnit ${smallestUnit}`); -} +const zdt = new Temporal.ZonedDateTime(0n, new TimeZone("UTC")); + +assert.throws(RangeError, () => zdt.round({ smallestUnit: "day" }), `zero day-length with smallestUnit 'day'`); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/getoffsetnanosecondsfor-maximum-forward-offset-shift.js new file mode 100644 index 0000000000..1d3a5425d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/getoffsetnanosecondsfor-maximum-forward-offset-shift.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.round +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants can be at most 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + calls++; + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12 })]; + } +} + +const timeZone = new Shift24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +instance.round({ smallestUnit: "hours" }); + +assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-called-with-iso8601-calendar.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-called-with-iso8601-calendar.js index 0c622df167..91c8ec7bc2 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-called-with-iso8601-calendar.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-called-with-iso8601-calendar.js @@ -51,8 +51,8 @@ const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); const timeZone = new SkippedDateTime(); const instance = new Temporal.ZonedDateTime(0n, timeZone, nonBuiltinISOCalendar); -instance.round({ smallestUnit: "hours" }); +instance.round({ smallestUnit: "day" }); -assert.sameValue(timeZone.calls, 6, "getPossibleInstantsFor should have been called 6 times"); +assert.sameValue(timeZone.calls, 4, "getPossibleInstantsFor should have been called 4 times"); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-maximum-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-maximum-backward-offset-shift.js new file mode 100644 index 0000000000..0c60d44311 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-maximum-backward-offset-shift.js @@ -0,0 +1,53 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.round +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + calls++; + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12 }), + utcInstant.add({ hours: 12 }) + ]; + } +} + +const timeZone = new Shift24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +instance.round({ smallestUnit: "hours" }); + +assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..dabcfe8ed6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-out-of-range-backward-offset-shift.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.round +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +assert.throws(RangeError, () => instance.round({ smallestUnit: "hours" }), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/order-of-operations.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/order-of-operations.js index 48ca638b39..65fac9036c 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/order-of-operations.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/order-of-operations.js @@ -24,10 +24,6 @@ const expected = [ "get this.timeZone.getPossibleInstantsFor", // GetPlainDateTimeFor on receiver's instant "call this.timeZone.getOffsetNanosecondsFor", - // GetInstantFor on preceding midnight - "call this.timeZone.getPossibleInstantsFor", - // AddDaysToZonedDateTime - "call this.timeZone.getPossibleInstantsFor", // InterpretISODateTimeOffset "call this.timeZone.getPossibleInstantsFor", "call this.timeZone.getOffsetNanosecondsFor", @@ -84,36 +80,8 @@ beforeFallBackInstance.round(nextHourOptions); assert.compareArray(actual, expected, "order of operations with rounding result at repeated wall-clock time"); actual.splice(0); // clear -const expectedSkippedDateTime = [ - "get options.roundingIncrement", - "get options.roundingIncrement.valueOf", - "call options.roundingIncrement.valueOf", - "get options.roundingMode", - "get options.roundingMode.toString", - "call options.roundingMode.toString", - "get options.smallestUnit", - "get options.smallestUnit.toString", - "call options.smallestUnit.toString", - // lookup - "get this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getPossibleInstantsFor", - // GetPlainDateTimeFor on receiver's instant - "call this.timeZone.getOffsetNanosecondsFor", - // GetInstantFor on preceding midnight - "call this.timeZone.getPossibleInstantsFor", - // DisambiguatePossibleInstants - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getPossibleInstantsFor", - // AddZonedDateTime - "call this.timeZone.getPossibleInstantsFor", - // InterpretISODateTimeOffset - "call this.timeZone.getPossibleInstantsFor", - "call this.timeZone.getOffsetNanosecondsFor", -]; - springForwardInstance.round(options); -assert.compareArray(actual, expectedSkippedDateTime, "order of operations with preceding midnight at skipped wall-clock time"); +assert.compareArray(actual, expected, "order of operations with preceding midnight at skipped wall-clock time"); actual.splice(0); // clear const expectedSkippedResult = [ @@ -131,14 +99,6 @@ const expectedSkippedResult = [ "get this.timeZone.getPossibleInstantsFor", // GetPlainDateTimeFor on receiver's instant "call this.timeZone.getOffsetNanosecondsFor", - // GetInstantFor on preceding midnight - "call this.timeZone.getPossibleInstantsFor", - // AddDaysToZonedDateTime - "call this.timeZone.getPossibleInstantsFor", - // DisambiguatePossibleInstants - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getPossibleInstantsFor", // InterpretISODateTimeOffset "call this.timeZone.getPossibleInstantsFor", // DisambiguatePossibleInstants diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/smallest-unit-day-rounding-modes.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/smallest-unit-day-rounding-modes.js index f694712457..435bfa16d8 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/smallest-unit-day-rounding-modes.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/smallest-unit-day-rounding-modes.js @@ -41,21 +41,22 @@ class TimeZone extends Temporal.TimeZone { #count = 0; #nanoseconds; - constructor(nanoseconds) { + constructor(todayEpochNanoseconds, tomorrowEpochNanoseconds) { super("UTC"); - this.#nanoseconds = nanoseconds; + this.#nanoseconds = [todayEpochNanoseconds, tomorrowEpochNanoseconds]; } getPossibleInstantsFor(dateTime) { - if (++this.#count === 2) { - return [new Temporal.Instant(this.#nanoseconds)]; + const nanoseconds = this.#nanoseconds[this.#count++]; + if (nanoseconds === undefined) { + return super.getPossibleInstantsFor(dateTime); } - return super.getPossibleInstantsFor(dateTime); + return [new Temporal.Instant(nanoseconds)]; } } -function test(epochNanoseconds, tomorrowEpochNanoseconds, testCases) { +function test(epochNanoseconds, todayEpochNanoseconds, tomorrowEpochNanoseconds, testCases) { for (let [roundingMode, expected] of Object.entries(testCases)) { - let timeZone = new TimeZone(tomorrowEpochNanoseconds); + let timeZone = new TimeZone(todayEpochNanoseconds, tomorrowEpochNanoseconds); let zoned = new Temporal.ZonedDateTime(epochNanoseconds, timeZone); let result = zoned.round({ smallestUnit: "days", roundingMode }); assert.sameValue(result.epochNanoseconds, expected); @@ -64,31 +65,35 @@ function test(epochNanoseconds, tomorrowEpochNanoseconds, testCases) { const oneDay = 24n * 60n * 60n * 1000n * 1000n * 1000n; -// Test positive divisor (dayLengthNs). -test(3n, 10n, { - ceil: oneDay, +test(3n, undefined, 10n, { + ceil: 10n, // end-of-day according to TimeZone protocol floor: 0n, trunc: 0n, halfExpand: 0n, }); -test(-3n, 10n, { - ceil: 0n, +test(-3n, undefined, 10n, { + ceil: 10n, // end-of-day according to TimeZone protocol floor: -oneDay, trunc: -oneDay, - halfExpand: 0n, + halfExpand: 10n, // end-of-day according to TimeZone protocol }); -test(-3n, -10n, { - ceil: oneDay, - floor: 0n, - trunc: 0n, - halfExpand: 0n, -}); +assert.throws(RangeError, () => { + test(-3n, 0n, 10n, { ceil: undefined }); +}, "instant is before TimeZone protocol's start-of-day"); + +assert.throws(RangeError, () => { + test(-3n, undefined, -10n, { ceil: undefined }); +}, "instant is after TimeZone protocol's end-of-day"); + +assert.throws(RangeError, () => { + test(0n, 0n, 0n, { ceil: undefined }); +}, "instant is within zero-duration day"); // Test values at int64 boundaries. -test(3n, /*INT64_MAX=*/ 9223372036854775807n, { - ceil: oneDay, +test(3n, undefined, /*INT64_MAX=*/ 9223372036854775807n, { + ceil: /*INT64_MAX=*/ 9223372036854775807n, // end-of-day according to TimeZone protocol floor: 0n, trunc: 0n, halfExpand: 0n, diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getpossibleinstantsfor-iterable.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getpossibleinstantsfor-iterable.js index 922b114e0b..28c064e24d 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getpossibleinstantsfor-iterable.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getpossibleinstantsfor-iterable.js @@ -23,8 +23,6 @@ features: [Temporal] ---*/ const expected = [ - "2001-09-09T00:00:00", // called once on midnight of the input datetime - "2001-09-10T00:00:00", // called once on the previous value plus one calendar day "2001-09-09T02:00:00", // called once on the rounding result ]; diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..6eeb874839 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.since +description: An ISO 8601 string can be converted to a calendar ID in Calendar +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1970, monthCode: "M01", day: 1, timeZone, calendar }; + const result = instance.since(arg); + TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-year-zero.js index 52a3aee0f5..b5dc42f348 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-year-zero.js @@ -17,7 +17,8 @@ const invalidStrings = [ ]; const timeZone = new Temporal.TimeZone("UTC"); const instance = new Temporal.ZonedDateTime(0n, timeZone); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.since(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..c5181e85e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-out-of-range-backward-offset-shift.js @@ -0,0 +1,50 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.since +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +assert.throws(RangeError, () => instance.since(arg), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..d6f7970e8a --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-out-of-range-forward-offset-shift.js @@ -0,0 +1,45 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.since +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +assert.throws(RangeError, () => instance.since(arg), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..5d0053cad5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,26 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.since +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[UTC][U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[UTC][u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[UTC][FOO=bar]", "invalid capitalized unrecognized key"], +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.since(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateadd-called-with-options-undefined.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateadd-called-with-options-undefined.js index 7a5367bf29..932847c329 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateadd-called-with-options-undefined.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateadd-called-with-options-undefined.js @@ -14,27 +14,17 @@ features: [Temporal] const calendar = TemporalHelpers.calendarDateAddUndefinedOptions(); const timeZone = TemporalHelpers.oneShiftTimeZone(new Temporal.Instant(0n), 3600e9); const earlier = new Temporal.ZonedDateTime(0n, timeZone, calendar); - -// Basic difference with largestUnit larger than days. -// The call comes from this path: -// ZonedDateTime.since() -> DifferenceZonedDateTime -> AddZonedDateTime -> calendar.dateAdd() - -const later1 = new Temporal.ZonedDateTime(1_213_200_000_000_000n, timeZone, calendar); -later1.since(earlier, { largestUnit: "weeks" }); -assert.sameValue(calendar.dateAddCallCount, 1, "basic difference with largestUnit >days"); +const later = new Temporal.ZonedDateTime(1_213_200_000_000_000n, timeZone, calendar); // Difference with rounding, with smallestUnit a calendar unit. // The calls come from these paths: // ZonedDateTime.since() -> -// DifferenceZonedDateTime -> AddZonedDateTime -> calendar.dateAdd() // RoundDuration -> // MoveRelativeZonedDateTime -> AddZonedDateTime -> calendar.dateAdd() // MoveRelativeDate -> calendar.dateAdd() // BalanceDurationRelative -> MoveRelativeDate -> calendar.dateAdd() -calendar.dateAddCallCount = 0; - -later1.since(earlier, { smallestUnit: "weeks" }); -assert.sameValue(calendar.dateAddCallCount, 4, "rounding difference with calendar smallestUnit"); +later.since(earlier, { smallestUnit: "weeks" }); +assert.sameValue(calendar.dateAddCallCount, 3, "rounding difference with calendar smallestUnit"); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/differencezoneddatetime-inconsistent-custom-calendar.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/differencezoneddatetime-inconsistent-custom-calendar.js new file mode 100644 index 0000000000..391f978f0d --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/differencezoneddatetime-inconsistent-custom-calendar.js @@ -0,0 +1,56 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.zoneddatetime.prototype.since +description: > + Throws a RangeError when custom calendar method returns inconsistent result +info: | + DifferenceZonedDateTime ( ... ) + 8. Repeat 3 times: + ... + g. If _sign_ = 0, or _timeSign_ = 0, or _sign_ = _timeSign_, then + ... + viii. Return ? CreateNormalizedDurationRecord(_dateDifference_.[[Years]], + _dateDifference_.[[Months]], _dateDifference_.[[Weeks]], + _dateDifference_.[[Days]], _norm_). + h. Set _dayCorrection_ to _dayCorrection_ + 1. + 9. NOTE: This step is only reached when custom calendar or time zone methods + return inconsistent values. + 10. Throw a *RangeError* exception. +features: [Temporal] +---*/ + +// Based partly on a test case by André Bargull + +const fiftyDays12Hours = 50n * 86400_000_000_000n + 12n * 3600_000_000_000n; + +{ + const tz = new (class extends Temporal.TimeZone { + getPossibleInstantsFor(dateTime) { + return super.getPossibleInstantsFor(dateTime.subtract({ days: 3 })); + } + })("UTC"); + + const zdt1 = new Temporal.ZonedDateTime(0n, tz); + const zdt2 = new Temporal.ZonedDateTime(fiftyDays12Hours, tz); + + assert.throws(RangeError, () => zdt2.since(zdt1, { largestUnit: "weeks" }), + "Calendar calculation where more than 2 days correction is needed should cause RangeError"); +} + +{ + const cal = new (class extends Temporal.Calendar { + dateUntil(one, two, options) { + return super.dateUntil(one, two, options).negated(); + } + })("iso8601"); + + const zdt1 = new Temporal.ZonedDateTime(0n, "UTC", cal); + const zdt2 = new Temporal.ZonedDateTime(fiftyDays12Hours, "UTC", cal); + + assert.throws(RangeError, () => zdt2.since(zdt1, { largestUnit: "weeks" }), + "Calendar calculation causing mixed-sign values should cause RangeError"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/dst-month-day-boundary.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/dst-month-day-boundary.js new file mode 100644 index 0000000000..c45ebd5aa2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/dst-month-day-boundary.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.since +description: > + Difference with the endpoint being the end of a skipped hour, chooses the + smaller of two possible durations +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Based on a test case by Adam Shaw + +const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); + +const d1 = new Temporal.ZonedDateTime(957258000_000_000_000n /* = 2000-05-02T02:00-07:00 */, timeZone); +const d2 = new Temporal.ZonedDateTime(954669600_000_000_000n /* = 2000-04-02T03:00-07:00 */, timeZone); +// NOTE: nonexistent hour just before d2 + +const result = d1.since(d2, { largestUnit: "months" }); + +TemporalHelpers.assertDuration( + result, 0, 0, 0, 29, 23, 0, 0, 0, 0, 0, + "Result should not balance up to months, but pick the smaller of two possible durations" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/dst-rounding-result.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/dst-rounding-result.js new file mode 100644 index 0000000000..c3a0f3f3a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/dst-rounding-result.js @@ -0,0 +1,48 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.zoneddatetime.prototype.since +description: > + Rounding the resulting duration takes the time zone's UTC offset shifts + into account +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Based on a test case by Adam Shaw + +const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); + +{ + // Month-only part of duration lands on skipped DST hour, should not cause + // disambiguation + const start = new Temporal.ZonedDateTime( + 950868000_000_000_000n /* = 2000-02-18T10Z */, + timeZone); /* = 2000-02-18T02-08 in local time */ + const end = new Temporal.ZonedDateTime( + 954709200_000_000_000n /* = 2000-04-02T21Z */, + timeZone); /* = 2000-04-02T14-07 in local time */ + + const duration = start.since(end, { largestUnit: "months" }); + TemporalHelpers.assertDuration(duration, 0, -1, 0, -15, -11, 0, 0, 0, 0, 0, + "1-month rounding window is shortened by DST"); +} + + +{ + // Month-only part of duration lands on skipped DST hour, should not cause + // disambiguation + const start = new Temporal.ZonedDateTime( + 951991200_000_000_000n /* = 2000-03-02T10Z */, + timeZone); /* = 2000-03-02T02-08 in local time */ + const end = new Temporal.ZonedDateTime( + 956005200_000_000_000n /* = 2000-04-17T21Z */, + timeZone); /* = 2000-04-17T14-07 in local time */ + + const duration = start.since(end, { largestUnit: "months" }); + TemporalHelpers.assertDuration(duration, 0, -1, 0, -15, -12, 0, 0, 0, 0, 0, + "1-month rounding window is not shortened by DST"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/find-intermediate-instant.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/find-intermediate-instant.js new file mode 100644 index 0000000000..7ef187ce3b --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/find-intermediate-instant.js @@ -0,0 +1,84 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.zoneddatetime.prototype.until +description: > + Up to 3 intermediate instants may be tried when calculating ZonedDateTime + difference +includes: [compareArray.js, temporalHelpers.js] +features: [BigInt, Temporal] +---*/ + +const calls = []; + +const springFallZone = TemporalHelpers.springForwardFallBackTimeZone(); +TemporalHelpers.observeMethod(calls, springFallZone, "getPossibleInstantsFor"); + +const dateLineZone = TemporalHelpers.crossDateLineTimeZone(); +TemporalHelpers.observeMethod(calls, dateLineZone, "getPossibleInstantsFor"); + +const zdt2 = new Temporal.ZonedDateTime(946722600_000_000_000n /* = 2000-01-01T02:30 local */, springFallZone); + +// Future -> past, without wall-clock overshoot +// Expects valid intermediate Instant WITHOUT day correction (computed once) +{ + const zdt1 = new Temporal.ZonedDateTime(949442400_000_000_000n /* = 2000-02-01T14:00 local */, springFallZone); + const result = zdt1.since(zdt2, { largestUnit: "years" }); + TemporalHelpers.assertDuration(result, 0, 1, 0, 0, 11, 30, 0, 0, 0, 0, "no wall-clock overshoot, no DST"); + assert.compareArray(calls, [ + "call getPossibleInstantsFor", // first intermediate in DifferenceZonedDateTime + ], "one intermediate should be tried"); +} + +calls.splice(0); // clear + +// Future -> past, WITH wall-clock overshoot +// Expects valid intermediate Instant with guaranteed 1-DAY correction (computed once) +{ + const zdt1 = new Temporal.ZonedDateTime(949395600_000_000_000n /* = 2000-02-01T01:00 local */, springFallZone); + const result = zdt1.since(zdt2, { largestUnit: "years" }); + TemporalHelpers.assertDuration(result, 0, 0, 0, 30, 22, 30, 0, 0, 0, 0, "wall-clock overshoot, no DST"); + assert.compareArray(calls, [ + "call getPossibleInstantsFor", // first intermediate in DifferenceZonedDateTime + ], "one intermediate should be tried"); +} + +calls.splice(0); // clear + +// Future -> past, WITH wall-clock overshoot +// Expects valid intermediate Instant with guaranteed 1-DAY correction (computed once) +// Intermediate Instant falls within spring DST gap and gets pushed forward, +// but since moving from future -> past, not possible to exacerbate overflow, +// so no other day corrections. +{ + const end = new Temporal.ZonedDateTime(957258000_000_000_000n /* = 2000-05-02T02:00 local */, springFallZone); + const start = new Temporal.ZonedDateTime(954671400_000_000_000n /* = 2000-04-02T03:30-07:00 local */, springFallZone); + const result = end.since(start, { largestUnit: "years" }); + TemporalHelpers.assertDuration(result, 0, 0, 0, 29, 22, 30, 0, 0, 0, 0, "wall-clock overshoot, inconsiquential DST"); + assert.compareArray(calls, [ + "call getPossibleInstantsFor", // first intermediate in DifferenceZonedDateTime + ], "one intermediate should be tried"); +} + +calls.splice(0); // clear + +// Past -> future, WITH wall-clock overshoot +// Tries intermediate Instant with 1-DAY correction (first compute) +// Then, ANOTHER day correction because updated intermediate Instant falls within dateline DST gap, +// pushing it forward, causing wall-clock overshoot again +// (Not possible when going backwards) +// (This test is just the same as the corresponding one in until(), but negative) +{ + const start = new Temporal.ZonedDateTime(1325102400_000_000_000n /* = 2011-12-28T10:00 local */, dateLineZone); + const end = new Temporal.ZonedDateTime(1325257200_000_000_000n /* = 2011-12-31T05:00 local */, dateLineZone); + const result = start.since(end, { largestUnit: "days" }); + TemporalHelpers.assertDuration(result, 0, 0, 0, -1, -19, 0, 0, 0, 0, 0, "wall-clock overshoot, consiquential DST"); + assert.compareArray(calls, [ + "call getPossibleInstantsFor", // first intermediate in DifferenceZonedDateTime + "call getPossibleInstantsFor", // second intermediate in DifferenceZonedDateTime + "call getPossibleInstantsFor", // DisambiguatePossibleInstants on second intermediate + ], "two intermediates should be tried, with disambiguation"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/normalized-time-duration-to-days-loop-arbitrarily.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/normalized-time-duration-to-days-loop-arbitrarily.js index 23f993f25f..454d5d216a 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/normalized-time-duration-to-days-loop-arbitrarily.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/normalized-time-duration-to-days-loop-arbitrarily.js @@ -5,74 +5,42 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.since description: > - NormalizedTimeDurationToDays can loop arbitrarily up to max safe integer + NormalizedTimeDurationToDays should not be able to loop arbitrarily. info: | NormalizedTimeDurationToDays ( norm, zonedRelativeTo, timeZoneRec [ , precalculatedPlainDatetime ] ) ... - 21. Repeat, while done is false, - a. Let oneDayFarther be ? AddDaysToZonedDateTime(relativeResult.[[Instant]], - relativeResult.[[DateTime]], timeZoneRec, zonedRelativeTo.[[Calendar]], sign). - b. Set dayLengthNs to NormalizedTimeDurationFromEpochNanosecondsDifference(oneDayFarther.[[EpochNanoseconds]], - relativeResult.[[EpochNanoseconds]]). - c. Let oneDayLess be ? SubtractNormalizedTimeDuration(norm, dayLengthNs). - c. If NormalizedTimeDurationSign(oneDayLess) × sign ≥ 0, then - i. Set norm to oneDayLess. - ii. Set relativeResult to oneDayFarther. - iii. Set days to days + sign. - d. Else, - i. Set done to true. -includes: [temporalHelpers.js] + 22. If NormalizedTimeDurationSign(_oneDayLess_) × _sign_ ≥ 0, then + a. Set _norm_ to _oneDayLess_. + b. Set _relativeResult_ to _oneDayFarther_. + c. Set _days_ to _days_ + _sign_. + d. Set _oneDayFarther_ to ? AddDaysToZonedDateTime(_relativeResult_.[[Instant]], _relativeResult_.[[DateTime]], _timeZoneRec_, _zonedRelativeTo_.[[Calendar]], _sign_). + e. Set dayLengthNs to NormalizedTimeDurationFromEpochNanosecondsDifference(_oneDayFarther.[[EpochNanoseconds]], relativeResult.[[EpochNanoseconds]]). + f. If NormalizedTimeDurationSign(? SubtractNormalizedTimeDuration(_norm_, _dayLengthNs_)) × _sign_ ≥ 0, then + i. Throw a *RangeError* exception. features: [Temporal] ---*/ -const calls = []; const dayLengthNs = 86400000000000n; -const other = new Temporal.ZonedDateTime(dayLengthNs, "UTC", "iso8601"); - -function createRelativeTo(count) { - const dayInstant = new Temporal.Instant(dayLengthNs); - const substitutions = []; - const timeZone = new Temporal.TimeZone("UTC"); - // Return constant value for first _count_ calls - TemporalHelpers.substituteMethod( - timeZone, - "getPossibleInstantsFor", - substitutions - ); - substitutions.length = count; - let i = 0; - for (i = 0; i < substitutions.length; i++) { - // (this value) - substitutions[i] = [dayInstant]; +const dayInstant = new Temporal.Instant(dayLengthNs); +let calls = 0; +const timeZone = new class extends Temporal.TimeZone { + getPossibleInstantsFor() { + calls++; + return [dayInstant]; } - // Record calls in calls[] - TemporalHelpers.observeMethod(calls, timeZone, "getPossibleInstantsFor"); - return new Temporal.ZonedDateTime(0n, timeZone); -} - -let zdt = createRelativeTo(50); -calls.splice(0); // Reset calls list after ZonedDateTime construction -zdt.since(other, { - largestUnit: "day", -}); -assert.sameValue( - calls.length, - 50 + 1, - "Expected ZonedDateTime.since to call getPossibleInstantsFor correct number of times" -); +}("UTC"); -zdt = createRelativeTo(100); -calls.splice(0); // Reset calls list after previous loop + ZonedDateTime construction -zdt.since(other, { - largestUnit: "day", -}); -assert.sameValue( - calls.length, - 100 + 1, - "Expected ZonedDateTime.since to call getPossibleInstantsFor correct number of times" -); +const zdt = new Temporal.ZonedDateTime(0n, timeZone); +const other = new Temporal.ZonedDateTime(dayLengthNs * 2n, "UTC", "iso8601"); -zdt = createRelativeTo(105); -assert.throws(RangeError, () => zdt.since(other, { largestUnit: "day" }), "105 days > 2⁵³ ns"); +assert.throws(RangeError, () => zdt.since(other, { largestUnit: "day", smallestUnit: "second" }), "indefinite loop is prevented"); +assert.sameValue(calls, 4, "getPossibleInstantsFor is not called indefinitely"); + // Expected calls: + // DifferenceTemporalZonedDateTime -> + // DifferenceZonedDateTime -> GetInstantFor (1) + // NormalizedTimeDurationToDays -> + // AddDaysToZonedDateTime (2, step 12) + // AddDaysToZonedDateTime (3, step 15) + // AddDaysToZonedDateTime (4, step 18.d) reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/normalized-time-duration-to-days-range-errors.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/normalized-time-duration-to-days-range-errors.js index 0c0b07f5dc..a6af0a69bc 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/normalized-time-duration-to-days-range-errors.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/normalized-time-duration-to-days-range-errors.js @@ -8,12 +8,12 @@ description: > RangeErrors. info: | NormalizedTimeDurationToDays ( norm, zonedRelativeTo, timeZoneRec [ , precalculatedPlainDateTime ] ) - 22. If days < 0 and sign = 1, throw a RangeError exception. - 23. If days > 0 and sign = -1, throw a RangeError exception. + 23. If days < 0 and sign = 1, throw a RangeError exception. + 24. If days > 0 and sign = -1, throw a RangeError exception. ... - 25. If NormalizedTimeDurationSign(_norm_) = 1 and sign = -1, throw a RangeError exception. + 26. If NormalizedTimeDurationSign(_norm_) = 1 and sign = -1, throw a RangeError exception. ... - 28. If dayLength ≥ 2⁵³, throw a RangeError exception. + 29. If dayLength ≥ 2⁵³, throw a RangeError exception. features: [Temporal, BigInt] includes: [temporalHelpers.js] ---*/ @@ -40,13 +40,16 @@ const dayNs = 86_400_000_000_000; const zeroZDT = new Temporal.ZonedDateTime(0n, "UTC"); const oneZDT = new Temporal.ZonedDateTime(1n, "UTC"); const epochInstant = new Temporal.Instant(0n); -const options = { largestUnit: "days" }; +const options = { largestUnit: "days", smallestUnit: "seconds", roundingMode: "expand" }; -// Step 22: days < 0 and sign = 1 +// Step 23: days < 0 and sign = 1 let start = new Temporal.ZonedDateTime( 0n, // Sets DifferenceZonedDateTime _ns1_ timeZoneSubstituteValues( - [[epochInstant]], // Returned in step 16, setting _relativeResult_ + [ + TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally in DifferenceZonedDateTime + [epochInstant], // Returned in step 16, setting _relativeResult_ + ], [ // Behave normally in 2 calls made prior to NormalizedTimeDurationToDays TemporalHelpers.SUBSTITUTE_SKIP, @@ -60,14 +63,18 @@ assert.throws(RangeError, () => start.since( oneZDT, // Sets DifferenceZonedDateTime _ns2_ options - ) + ), + "days < 0 and sign = 1" ); -// Step 23: days > 0 and sign = -1 +// Step 24: days > 0 and sign = -1 start = new Temporal.ZonedDateTime( 1n, // Sets DifferenceZonedDateTime _ns1_ timeZoneSubstituteValues( - [[epochInstant]], // Returned in step 16, setting _relativeResult_ + [ + TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally in DifferenceZonedDateTime + [epochInstant], // Returned in step 16, setting _relativeResult_ + ], [ // Behave normally in 2 calls made prior to NormalizedTimeDurationToDays TemporalHelpers.SUBSTITUTE_SKIP, @@ -81,14 +88,18 @@ assert.throws(RangeError, () => start.since( zeroZDT, // Sets DifferenceZonedDateTime _ns2_ options - ) + ), + "days > 0 and sign = -1" ); -// Step 25: nanoseconds > 0 and sign = -1 +// Step 26: nanoseconds > 0 and sign = -1 start = new Temporal.ZonedDateTime( 1n, // Sets DifferenceZonedDateTime _ns1_ timeZoneSubstituteValues( - [[new Temporal.Instant(-1n)]], // Returned in step 16, setting _relativeResult_ + [ + TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally in DifferenceZonedDateTime + [new Temporal.Instant(-2_000_000_000n)], // Returned in step 16, setting _relativeResult_ + ], [ // Behave normally in 2 calls made prior to NormalizedTimeDurationToDays TemporalHelpers.SUBSTITUTE_SKIP, @@ -102,16 +113,20 @@ assert.throws(RangeError, () => start.since( zeroZDT, // Sets DifferenceZonedDateTime _ns2_ options - ) + ), + "norm > 0 and sign = -1" ); -// Step 28: day length is an unsafe integer +// Step 29: day length is an unsafe integer start = new Temporal.ZonedDateTime( 0n, timeZoneSubstituteValues( - // Not called in step 16 because _days_ = 0 - // Returned in step 21.a, making _oneDayFarther_ 2^53 ns later than _relativeResult_ - [[new Temporal.Instant(2n ** 53n)]], + [ + TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally in DifferenceZonedDateTime + // Not called in step 16 because _days_ = 0 + // Returned in step 19, making _oneDayFarther_ 2^53 ns later than _relativeResult_ + [new Temporal.Instant(2n ** 53n)], + ], [] ) ); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js index 566a1ce192..90fc1e0475 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js @@ -306,10 +306,6 @@ assert.compareArray(actual, [ // DifferenceZonedDateTime "call this.timeZone.getOffsetNanosecondsFor", "call this.timeZone.getOffsetNanosecondsFor", - // NanosecondsToDays - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - // NanosecondsToDays → AddDaysToZonedDateTime "call this.timeZone.getPossibleInstantsFor", ], "order of operations with identical wall-clock times and largestUnit a calendar unit"); actual.splice(0); // clear @@ -328,17 +324,8 @@ const expectedOpsForCalendarDifference = [ "call this.timeZone.getOffsetNanosecondsFor", // DifferenceZonedDateTime "call this.timeZone.getOffsetNanosecondsFor", - // DifferenceISODateTime - "call this.calendar.dateUntil", - // AddZonedDateTime - "call this.calendar.dateAdd", - "call this.timeZone.getPossibleInstantsFor", - // NanosecondsToDays - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - // NanosecondsToDays → AddDaysToZonedDateTime - "call this.timeZone.getPossibleInstantsFor", "call this.timeZone.getPossibleInstantsFor", + "call this.calendar.dateUntil", ]; const expectedOpsForCalendarRounding = [ diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/wrapping-at-end-of-month.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/wrapping-at-end-of-month.js new file mode 100644 index 0000000000..3fddf0d09b --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/since/wrapping-at-end-of-month.js @@ -0,0 +1,120 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.since +description: Tests balancing of days to months at end of month +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Difference between end of longer month to end of following shorter month +{ + const end = new Temporal.ZonedDateTime(5011200_000_000_000n /* = 1970-02-28T00Z */, "UTC"); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(2332800_000_000_000n /* = 1970-01-28T00Z */, "UTC").since(end, { largestUnit }), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, + "Jan 28th to Feb 28th is one month" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(2419200_000_000_000n /* = 1970-01-29T00Z */, "UTC").since(end, { largestUnit }), + 0, 0, 0, -30, 0, 0, 0, 0, 0, 0, + "Jan 29th to Feb 28th is 30 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(2505600_000_000_000n /* = 1970-01-30T00Z */, "UTC").since(end, { largestUnit }), + 0, 0, 0, -29, 0, 0, 0, 0, 0, 0, + "Jan 30th to Feb 28th is 29 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(2592000_000_000_000n /* = 1970-01-31T00Z */, "UTC").since(end, { largestUnit }), + 0, 0, 0, -28, 0, 0, 0, 0, 0, 0, + "Jan 31st to Feb 28th is 28 days, not one month" + ); + } +} + +// Difference between end of leap-year January to end of leap-year February +{ + const end = new Temporal.ZonedDateTime(68169600_000_000_000n /* = 1972-02-29T00Z */, "UTC"); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(65491200_000_000_000n /* = 1972-01-29T00Z */, "UTC").since(end, { largestUnit }), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, + "Jan 29th to Feb 29th is one month" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(65577600_000_000_000n /* = 1972-01-30T00Z */, "UTC").since(end, { largestUnit }), + 0, 0, 0, -30, 0, 0, 0, 0, 0, 0, + "Jan 30th to Feb 29th is 30 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(65664000_000_000_000n /* = 1972-01-31T00Z */, "UTC").since(end, { largestUnit }), + 0, 0, 0, -29, 0, 0, 0, 0, 0, 0, + "Jan 31st to Feb 29th is 29 days, not one month" + ); + } +} + +// Difference between end of longer month to end of not-immediately-following +// shorter month +{ + const end = new Temporal.ZonedDateTime(28771200_000_000_000n /* = 1970-11-30T00Z */, "UTC"); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(20822400_000_000_000n /* = 1970-08-30T00Z */, "UTC").since(end, { largestUnit }), + 0, -3, 0, 0, 0, 0, 0, 0, 0, 0, + "Aug 30th to Nov 30th is 3 months" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(20908800_000_000_000n /* = 1970-08-31T00Z */, "UTC").since(end, { largestUnit }), + 0, -2, 0, -30, 0, 0, 0, 0, 0, 0, + "Aug 31st to Nov 30th is 2 months 30 days, not 3 months" + ); + } +} + +// Difference between end of longer month in one year to shorter month in +// later year +{ + const end = new Temporal.ZonedDateTime(104976000_000_000_000n /* = 1973-04-30T00Z */, "UTC"); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(31363200_000_000_000n /* = 1970-12-30T00Z */, "UTC").since(end, { largestUnit: "months" }), + 0, -28, 0, 0, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 28 months" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(31363200_000_000_000n /* = 1970-12-30T00Z */, "UTC").since(end, { largestUnit: "years" }), + -2, -4, 0, 0, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 2 years, 4 months" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(31449600_000_000_000n /* = 1970-12-31T00Z */, "UTC").since(end, { largestUnit: "months" }), + 0, -27, 0, -30, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 27 months, 30 days, not 28 months" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(31449600_000_000_000n /* = 1970-12-31T00Z */, "UTC").since(end, { largestUnit: "years" }), + -2, -3, 0, -30, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 2 years, 3 months, 30 days, not 2 years 4 months" + ); +} + +// Difference where months passes through a month that's the same length or +// shorter than either the start or end month +{ + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(2419200_000_000_000n /* = 1970-01-29T00Z */, "UTC").since(new Temporal.ZonedDateTime(7430400_000_000_000n /* = 1970-03-28T00Z */, "UTC"), { largestUnit: "months" }), + 0, -1, 0, -28, 0, 0, 0, 0, 0, 0, + "Jan 29th to Mar 28th is 1 month 28 days, not 58 days" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(2592000_000_000_000n /* = 1970-01-31T00Z */, "UTC").since(new Temporal.ZonedDateTime(44409600_000_000_000n /* = 1971-05-30T00Z */, "UTC"), { largestUnit: "years" }), + -1, -3, 0, -30, 0, 0, 0, 0, 0, 0, + "Jan 31st 1970 to May 30th 1971 is 1 year, 3 months, 30 days, not 1 year, 2 months, 60 days" + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getoffsetnanosecondsfor-maximum-forward-offset-shift.js new file mode 100644 index 0000000000..d71f6be08e --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getoffsetnanosecondsfor-maximum-forward-offset-shift.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.startofday +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants can be at most 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 0n + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + calls++; + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12 })]; + } +} + +const timeZone = new Shift24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +instance.startOfDay(); + +assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..82e86c4ee5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js @@ -0,0 +1,44 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.startofday +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 0n + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +assert.throws(RangeError, () => instance.startOfDay(), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getpossibleinstantsfor-maximum-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getpossibleinstantsfor-maximum-backward-offset-shift.js new file mode 100644 index 0000000000..f1342dfe2d --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getpossibleinstantsfor-maximum-backward-offset-shift.js @@ -0,0 +1,53 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.startofday +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + calls++; + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12 }), + utcInstant.add({ hours: 12 }) + ]; + } +} + +const timeZone = new Shift24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +instance.startOfDay(); + +assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getpossibleinstantsfor-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..06055c287e --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getpossibleinstantsfor-out-of-range-backward-offset-shift.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.startofday +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +assert.throws(RangeError, () => instance.startOfDay(), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..b01b28a4bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.until +description: An ISO 8601 string can be converted to a calendar ID in Calendar +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1970, monthCode: "M01", day: 1, timeZone, calendar }; + const result = instance.until(arg); + TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-year-zero.js index f0c915198e..f69f22d2b8 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-year-zero.js @@ -17,7 +17,8 @@ const invalidStrings = [ ]; const timeZone = new Temporal.TimeZone("UTC"); const instance = new Temporal.ZonedDateTime(0n, timeZone); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.until(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..bf1b4089f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-out-of-range-backward-offset-shift.js @@ -0,0 +1,50 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.until +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +assert.throws(RangeError, () => instance.until(arg), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..891307c99d --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-out-of-range-forward-offset-shift.js @@ -0,0 +1,45 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.until +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); +const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +assert.throws(RangeError, () => instance.until(arg), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..7226f0cb8c --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,26 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.until +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01T00:00[UTC][U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01T00:00[UTC][u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01T00:00[UTC][FOO=bar]", "invalid capitalized unrecognized key"], +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.until(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateadd-called-with-options-undefined.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateadd-called-with-options-undefined.js index 5710b9c2b4..14a26aa8ef 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateadd-called-with-options-undefined.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateadd-called-with-options-undefined.js @@ -14,27 +14,17 @@ features: [Temporal] const calendar = TemporalHelpers.calendarDateAddUndefinedOptions(); const timeZone = TemporalHelpers.oneShiftTimeZone(new Temporal.Instant(0n), 3600e9); const earlier = new Temporal.ZonedDateTime(0n, timeZone, calendar); - -// Basic difference with largestUnit larger than days. -// The call comes from this path: -// ZonedDateTime.until() -> DifferenceZonedDateTime -> AddZonedDateTime -> calendar.dateAdd() - -const later1 = new Temporal.ZonedDateTime(1_213_200_000_000_000n, timeZone, calendar); -earlier.until(later1, { largestUnit: "weeks" }); -assert.sameValue(calendar.dateAddCallCount, 1, "basic difference with largestUnit >days"); +const later = new Temporal.ZonedDateTime(1_213_200_000_000_000n, timeZone, calendar); // Difference with rounding, with smallestUnit a calendar unit. // The calls come from these paths: // ZonedDateTime.until() -> -// DifferenceZonedDateTime -> AddZonedDateTime -> calendar.dateAdd() // RoundDuration -> // MoveRelativeZonedDateTime -> AddZonedDateTime -> calendar.dateAdd() // MoveRelativeDate -> calendar.dateAdd() // BalanceDurationRelative -> MoveRelativeDate -> calendar.dateAdd() -calendar.dateAddCallCount = 0; - -earlier.until(later1, { smallestUnit: "weeks" }); -assert.sameValue(calendar.dateAddCallCount, 4, "rounding difference with calendar smallestUnit"); +earlier.until(later, { smallestUnit: "weeks" }); +assert.sameValue(calendar.dateAddCallCount, 3, "rounding difference with calendar smallestUnit"); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/differencezoneddatetime-inconsistent-custom-calendar.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/differencezoneddatetime-inconsistent-custom-calendar.js new file mode 100644 index 0000000000..7b77608492 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/differencezoneddatetime-inconsistent-custom-calendar.js @@ -0,0 +1,56 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.zoneddatetime.prototype.until +description: > + Throws a RangeError when custom calendar method returns inconsistent result +info: | + DifferenceZonedDateTime ( ... ) + 8. Repeat 3 times: + ... + g. If _sign_ = 0, or _timeSign_ = 0, or _sign_ = _timeSign_, then + ... + viii. Return ? CreateNormalizedDurationRecord(_dateDifference_.[[Years]], + _dateDifference_.[[Months]], _dateDifference_.[[Weeks]], + _dateDifference_.[[Days]], _norm_). + h. Set _dayCorrection_ to _dayCorrection_ + 1. + 9. NOTE: This step is only reached when custom calendar or time zone methods + return inconsistent values. + 10. Throw a *RangeError* exception. +features: [Temporal] +---*/ + +// Based partly on a test case by André Bargull + +const fiftyDays12Hours = 50n * 86400_000_000_000n + 12n * 3600_000_000_000n; + +{ + const tz = new (class extends Temporal.TimeZone { + getPossibleInstantsFor(dateTime) { + return super.getPossibleInstantsFor(dateTime.add({ days: 3 })); + } + })("UTC"); + + const zdt1 = new Temporal.ZonedDateTime(0n, tz); + const zdt2 = new Temporal.ZonedDateTime(fiftyDays12Hours, tz); + + assert.throws(RangeError, () => zdt1.until(zdt2, { largestUnit: "weeks" }), + "Calendar calculation where more than 2 days correction is needed should cause RangeError"); +} + +{ + const cal = new (class extends Temporal.Calendar { + dateUntil(one, two, options) { + return super.dateUntil(one, two, options).negated(); + } + })("iso8601"); + + const zdt1 = new Temporal.ZonedDateTime(0n, "UTC", cal); + const zdt2 = new Temporal.ZonedDateTime(fiftyDays12Hours, "UTC", cal); + + assert.throws(RangeError, () => zdt1.until(zdt2, { largestUnit: "weeks" }), + "Calendar calculation causing mixed-sign values should cause RangeError"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/dst-month-day-boundary.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/dst-month-day-boundary.js new file mode 100644 index 0000000000..73596e06c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/dst-month-day-boundary.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.until +description: > + Difference with the endpoint being the end of a skipped hour, chooses the + smaller of two possible durations +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Based on a test case by Adam Shaw + +const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); + +const d1 = new Temporal.ZonedDateTime(957258000_000_000_000n /* = 2000-05-02T02:00-07:00 */, timeZone); +const d2 = new Temporal.ZonedDateTime(954669600_000_000_000n /* = 2000-04-02T03:00-07:00 */, timeZone); +// NOTE: nonexistent hour just before d2 + +const result = d1.until(d2, { largestUnit: "months" }); + +TemporalHelpers.assertDuration( + result, 0, 0, 0, -29, -23, 0, 0, 0, 0, 0, + "Result should not balance up to months, but pick the smaller of two possible durations" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/dst-rounding-result.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/dst-rounding-result.js new file mode 100644 index 0000000000..e6faed63f3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/dst-rounding-result.js @@ -0,0 +1,48 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.zoneddatetime.prototype.until +description: > + Rounding the resulting duration takes the time zone's UTC offset shifts + into account +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Based on a test case by Adam Shaw + +const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); + +{ + // Month-only part of duration lands on skipped DST hour, should not cause + // disambiguation + const start = new Temporal.ZonedDateTime( + 950868000_000_000_000n /* = 2000-02-18T10Z */, + timeZone); /* = 2000-02-18T02-08 in local time */ + const end = new Temporal.ZonedDateTime( + 954709200_000_000_000n /* = 2000-04-02T21Z */, + timeZone); /* = 2000-04-02T14-07 in local time */ + + const duration = start.until(end, { largestUnit: "months" }); + TemporalHelpers.assertDuration(duration, 0, 1, 0, 15, 11, 0, 0, 0, 0, 0, + "1-month rounding window is shortened by DST"); +} + + +{ + // Month-only part of duration lands on skipped DST hour, should not cause + // disambiguation + const start = new Temporal.ZonedDateTime( + 951991200_000_000_000n /* = 2000-03-02T10Z */, + timeZone); /* = 2000-03-02T02-08 in local time */ + const end = new Temporal.ZonedDateTime( + 956005200_000_000_000n /* = 2000-04-17T21Z */, + timeZone); /* = 2000-04-17T14-07 in local time */ + + const duration = start.until(end, { largestUnit: "months" }); + TemporalHelpers.assertDuration(duration, 0, 1, 0, 15, 12, 0, 0, 0, 0, 0, + "1-month rounding window is not shortened by DST"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/find-intermediate-instant.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/find-intermediate-instant.js new file mode 100644 index 0000000000..9440f950a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/find-intermediate-instant.js @@ -0,0 +1,85 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.zoneddatetime.prototype.until +description: > + Up to 3 intermediate instants may be tried when calculating ZonedDateTime + difference +includes: [compareArray.js, temporalHelpers.js] +features: [BigInt, Temporal] +---*/ + +const calls = []; + +const springFallZone = TemporalHelpers.springForwardFallBackTimeZone(); +TemporalHelpers.observeMethod(calls, springFallZone, "getPossibleInstantsFor"); + +const dateLineZone = TemporalHelpers.crossDateLineTimeZone(); +TemporalHelpers.observeMethod(calls, dateLineZone, "getPossibleInstantsFor"); + +const zdt1 = new Temporal.ZonedDateTime(946722600_000_000_000n /* = 2000-01-01T02:30 local */, springFallZone); + +// Past -> future, without wall-clock overshoot +// Expects valid intermediate Instant WITHOUT day correction (computed once) +{ + const zdt2 = new Temporal.ZonedDateTime(949442400_000_000_000n /* = 2000-02-01T14:00 local */, springFallZone); + const result = zdt1.until(zdt2, { largestUnit: "years" }); + TemporalHelpers.assertDuration(result, 0, 1, 0, 0, 11, 30, 0, 0, 0, 0, "no wall-clock overshoot, no DST"); + assert.compareArray(calls, [ + "call getPossibleInstantsFor", // first intermediate in DifferenceZonedDateTime + ], "one intermediate should be tried"); +} + +calls.splice(0); // clear + +// Past -> future, WITH wall-clock overshoot +// Expects valid intermediate Instant with guaranteed 1-DAY correction (computed once) +{ + const zdt2 = new Temporal.ZonedDateTime(949395600_000_000_000n /* = 2000-02-01T01:00 local */, springFallZone); + const result = zdt1.until(zdt2, { largestUnit: "years" }); + TemporalHelpers.assertDuration(result, 0, 0, 0, 30, 22, 30, 0, 0, 0, 0, "wall-clock overshoot, no DST"); + assert.compareArray(calls, [ + "call getPossibleInstantsFor", // first intermediate in DifferenceZonedDateTime + ], "one intermediate should be tried"); +} + +calls.splice(0); // clear + +// Past -> future, WITH wall-clock overshoot +// Tries intermediate Instant with 1-DAY correction (first compute) +// Then, ANOTHER correction because updated intermediate Instant falls within spring DST gap, +// pushing it forward, causing wall-clock overshoot again +// (Not possible when going backwards) +{ + const zdt2 = new Temporal.ZonedDateTime(954669600_000_000_000n /* = 2000-04-02T02:00 local */, springFallZone); + const result = zdt1.until(zdt2, { largestUnit: "years" }); + TemporalHelpers.assertDuration(result, 0, 3, 0, 0, 23, 30, 0, 0, 0, 0, "wall-clock overshoot, small consiquential DST"); + assert.compareArray(calls, [ + "call getPossibleInstantsFor", // first intermediate in DifferenceZonedDateTime + "call getPossibleInstantsFor", // DisambiguatePossibleInstants on first intermediate + "call getPossibleInstantsFor", // second intermediate in DifferenceZonedDateTime + ], "two intermediates should be tried, with disambiguation"); +} + +calls.splice(0); // clear + +// Past -> future, WITH wall-clock overshoot +// Tries intermediate Instant with 1-DAY correction (first compute) +// Then, ANOTHER correction because updated intermediate Instant falls within dateline DST gap, +// pushing it forward, causing wall-clock overshoot again +// (Not possible when going backwards) +// (This test is just the same as the corresponding one in since(), but negative) +{ + const start = new Temporal.ZonedDateTime(1325102400_000_000_000n /* = 2011-12-28T10:00 local */, dateLineZone); + const end = new Temporal.ZonedDateTime(1325257200_000_000_000n /* = 2011-12-31T05:00 local */, dateLineZone); + const result = start.until(end, { largestUnit: "days" }); + TemporalHelpers.assertDuration(result, 0, 0, 0, 1, 19, 0, 0, 0, 0, 0, "wall-clock overshoot, big consiquential DST"); + assert.compareArray(calls, [ + "call getPossibleInstantsFor", // first intermediate in DifferenceZonedDateTime + "call getPossibleInstantsFor", // second intermediate in DifferenceZonedDateTime + "call getPossibleInstantsFor", // DisambiguatePossibleInstants on second intermediate + ], "two intermediates should be tried, with disambiguation"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/normalized-time-duration-to-days-loop-arbitrarily.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/normalized-time-duration-to-days-loop-arbitrarily.js index f057d733d9..77886a2042 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/normalized-time-duration-to-days-loop-arbitrarily.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/normalized-time-duration-to-days-loop-arbitrarily.js @@ -5,74 +5,42 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.until description: > - NormalizedTimeDurationToDays can loop arbitrarily up to max safe integer + NormalizedTimeDurationToDays should not be able to loop arbitrarily. info: | NormalizedTimeDurationToDays ( norm, zonedRelativeTo, timeZoneRec [ , precalculatedPlainDatetime ] ) ... - 21. Repeat, while done is false, - a. Let oneDayFarther be ? AddDaysToZonedDateTime(relativeResult.[[Instant]], - relativeResult.[[DateTime]], timeZoneRec, zonedRelativeTo.[[Calendar]], sign). - b. Set dayLengthNs to NormalizedTimeDurationFromEpochNanosecondsDifference(oneDayFarther.[[EpochNanoseconds]], - relativeResult.[[EpochNanoseconds]]). - c. Let oneDayLess be ? SubtractNormalizedTimeDuration(norm, dayLengthNs). - c. If NormalizedTimeDurationSign(oneDayLess) × sign ≥ 0, then - i. Set norm to oneDayLess. - ii. Set relativeResult to oneDayFarther. - iii. Set days to days + sign. - d. Else, - i. Set done to true. -includes: [temporalHelpers.js] + 22. If NormalizedTimeDurationSign(_oneDayLess_) × _sign_ ≥ 0, then + a. Set _norm_ to _oneDayLess_. + b. Set _relativeResult_ to _oneDayFarther_. + c. Set _days_ to _days_ + _sign_. + d. Set _oneDayFarther_ to ? AddDaysToZonedDateTime(_relativeResult_.[[Instant]], _relativeResult_.[[DateTime]], _timeZoneRec_, _zonedRelativeTo_.[[Calendar]], _sign_). + e. Set dayLengthNs to NormalizedTimeDurationFromEpochNanosecondsDifference(_oneDayFarther.[[EpochNanoseconds]], relativeResult.[[EpochNanoseconds]]). + f. If NormalizedTimeDurationSign(? SubtractNormalizedTimeDuration(_norm_, _dayLengthNs_)) × _sign_ ≥ 0, then + i. Throw a *RangeError* exception. features: [Temporal] ---*/ -const calls = []; const dayLengthNs = 86400000000000n; -const other = new Temporal.ZonedDateTime(dayLengthNs, "UTC", "iso8601"); - -function createRelativeTo(count) { - const dayInstant = new Temporal.Instant(dayLengthNs); - const substitutions = []; - const timeZone = new Temporal.TimeZone("UTC"); - // Return constant value for first _count_ calls - TemporalHelpers.substituteMethod( - timeZone, - "getPossibleInstantsFor", - substitutions - ); - substitutions.length = count; - let i = 0; - for (i = 0; i < substitutions.length; i++) { - // (this value) - substitutions[i] = [dayInstant]; +const dayInstant = new Temporal.Instant(dayLengthNs); +let calls = 0; +const timeZone = new class extends Temporal.TimeZone { + getPossibleInstantsFor() { + calls++; + return [dayInstant]; } - // Record calls in calls[] - TemporalHelpers.observeMethod(calls, timeZone, "getPossibleInstantsFor"); - return new Temporal.ZonedDateTime(0n, timeZone); -} - -let zdt = createRelativeTo(50); -calls.splice(0); // Reset calls list after ZonedDateTime construction -zdt.until(other, { - largestUnit: "day", -}); -assert.sameValue( - calls.length, - 50 + 1, - "Expected ZonedDateTime.until to call getPossibleInstantsFor correct number of times" -); +}("UTC"); -zdt = createRelativeTo(100); -calls.splice(0); // Reset calls list after previous loop + ZonedDateTime construction -zdt.until(other, { - largestUnit: "day", -}); -assert.sameValue( - calls.length, - 100 + 1, - "Expected ZonedDateTime.until to call getPossibleInstantsFor correct number of times" -); +const zdt = new Temporal.ZonedDateTime(0n, timeZone); +const other = new Temporal.ZonedDateTime(dayLengthNs * 2n, "UTC", "iso8601"); -zdt = createRelativeTo(105); -assert.throws(RangeError, () => zdt.until(other, { largestUnit: "day" }), "105 days > 2⁵³ ns"); +assert.throws(RangeError, () => zdt.until(other, { largestUnit: "day", smallestUnit: "second" }), "indefinite loop is prevented"); +assert.sameValue(calls, 4, "getPossibleInstantsFor is not called indefinitely"); + // Expected calls: + // DifferenceTemporalZonedDateTime -> + // DifferenceZonedDateTime -> GetInstantFor (1) + // NormalizedTimeDurationToDays -> + // AddDaysToZonedDateTime (2, step 12) + // AddDaysToZonedDateTime (3, step 15) + // AddDaysToZonedDateTime (4, step 18.d) reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/normalized-time-duration-to-days-range-errors.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/normalized-time-duration-to-days-range-errors.js index 178b1c981b..479dcf0b0c 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/normalized-time-duration-to-days-range-errors.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/normalized-time-duration-to-days-range-errors.js @@ -8,12 +8,12 @@ description: > RangeErrors. info: | NormalizedTimeDurationToDays ( norm, zonedRelativeTo, timeZoneRec [ , precalculatedPlainDateTime ] ) - 22. If days < 0 and sign = 1, throw a RangeError exception. - 23. If days > 0 and sign = -1, throw a RangeError exception. + 23. If days < 0 and sign = 1, throw a RangeError exception. + 24. If days > 0 and sign = -1, throw a RangeError exception. ... - 25. If NormalizedTimeDurationSign(_norm_) = 1 and sign = -1, throw a RangeError exception. + 26. If NormalizedTimeDurationSign(_norm_) = 1 and sign = -1, throw a RangeError exception. ... - 28. If dayLength ≥ 2⁵³, throw a RangeError exception. + 29. If dayLength ≥ 2⁵³, throw a RangeError exception. features: [Temporal, BigInt] includes: [temporalHelpers.js] ---*/ @@ -40,13 +40,16 @@ const dayNs = 86_400_000_000_000; const zeroZDT = new Temporal.ZonedDateTime(0n, "UTC"); const oneZDT = new Temporal.ZonedDateTime(1n, "UTC"); const epochInstant = new Temporal.Instant(0n); -const options = { largestUnit: "days" }; +const options = { largestUnit: "days", smallestUnit: "seconds", roundingMode: "expand" }; -// Step 22: days < 0 and sign = 1 +// Step 23: days < 0 and sign = 1 let start = new Temporal.ZonedDateTime( 0n, // Sets DifferenceZonedDateTime _ns1_ timeZoneSubstituteValues( - [[epochInstant]], // Returned in step 16, setting _relativeResult_ + [ + TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally in DifferenceZonedDateTime + [epochInstant], // Returned in step 16, setting _relativeResult_ + ], [ // Behave normally in 2 calls made prior to NormalizedTimeDurationToDays TemporalHelpers.SUBSTITUTE_SKIP, @@ -60,14 +63,18 @@ assert.throws(RangeError, () => start.until( oneZDT, // Sets DifferenceZonedDateTime _ns2_ options - ) + ), + "days < 0 and sign = 1" ); -// Step 23: days > 0 and sign = -1 +// Step 24: days > 0 and sign = -1 start = new Temporal.ZonedDateTime( 1n, // Sets DifferenceZonedDateTime _ns1_ timeZoneSubstituteValues( - [[epochInstant]], // Returned in step 16, setting _relativeResult_ + [ + TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally in DifferenceZonedDateTime + [epochInstant], // Returned in step 16, setting _relativeResult_ + ], [ // Behave normally in 2 calls made prior to NormalizedTimeDurationToDays TemporalHelpers.SUBSTITUTE_SKIP, @@ -81,14 +88,18 @@ assert.throws(RangeError, () => start.until( zeroZDT, // Sets DifferenceZonedDateTime _ns2_ options - ) + ), + "days > 0 and sign = -1" ); -// Step 25: nanoseconds > 0 and sign = -1 +// Step 26: nanoseconds > 0 and sign = -1 start = new Temporal.ZonedDateTime( 1n, // Sets DifferenceZonedDateTime _ns1_ timeZoneSubstituteValues( - [[new Temporal.Instant(-1n)]], // Returned in step 16, setting _relativeResult_ + [ + TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally in DifferenceZonedDateTime + [new Temporal.Instant(-2_000_000_000n)], // Returned in step 16, setting _relativeResult_ + ], [ // Behave normally in 2 calls made prior to NormalizedTimeDurationToDays TemporalHelpers.SUBSTITUTE_SKIP, @@ -102,16 +113,20 @@ assert.throws(RangeError, () => start.until( zeroZDT, // Sets DifferenceZonedDateTime _ns2_ options - ) + ), + "norm > 0 and sign = -1" ); -// Step 28: day length is an unsafe integer +// Step 29: day length is an unsafe integer start = new Temporal.ZonedDateTime( 0n, timeZoneSubstituteValues( - // Not called in step 16 because _days_ = 0 - // Returned in step 21.a, making _oneDayFarther_ 2^53 ns later than _relativeResult_ - [[new Temporal.Instant(2n ** 53n)]], + [ + TemporalHelpers.SUBSTITUTE_SKIP, // Behave normally in DifferenceZonedDateTime + // Not called in step 16 because _days_ = 0 + // Returned in step 19, making _oneDayFarther_ 2^53 ns later than _relativeResult_ + [new Temporal.Instant(2n ** 53n)], + ], [] ) ); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js index 6a233dc989..c88ecfd0d6 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js @@ -306,10 +306,6 @@ assert.compareArray(actual, [ // DifferenceZonedDateTime "call this.timeZone.getOffsetNanosecondsFor", "call this.timeZone.getOffsetNanosecondsFor", - // NanosecondsToDays - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - // NanosecondsToDays → AddDaysToZonedDateTime "call this.timeZone.getPossibleInstantsFor", ], "order of operations with identical wall-clock times and largestUnit a calendar unit"); actual.splice(0); // clear @@ -328,17 +324,8 @@ const expectedOpsForCalendarDifference = [ "call this.timeZone.getOffsetNanosecondsFor", // DifferenceZonedDateTime "call this.timeZone.getOffsetNanosecondsFor", - // DifferenceISODateTime - "call this.calendar.dateUntil", - // AddZonedDateTime - "call this.calendar.dateAdd", - "call this.timeZone.getPossibleInstantsFor", - // NanosecondsToDays - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - // NanosecondsToDays → AddDaysToZonedDateTime - "call this.timeZone.getPossibleInstantsFor", "call this.timeZone.getPossibleInstantsFor", + "call this.calendar.dateUntil", ]; const expectedOpsForCalendarRounding = [ diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/wrapping-at-end-of-month.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/wrapping-at-end-of-month.js new file mode 100644 index 0000000000..50b40393f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/until/wrapping-at-end-of-month.js @@ -0,0 +1,120 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.until +description: Tests balancing of days to months at end of month +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Difference between end of longer month to end of following shorter month +{ + const end = new Temporal.ZonedDateTime(5011200_000_000_000n /* = 1970-02-28T00Z */, "UTC"); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(2332800_000_000_000n /* = 1970-01-28T00Z */, "UTC").until(end, { largestUnit }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + "Jan 28th to Feb 28th is one month" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(2419200_000_000_000n /* = 1970-01-29T00Z */, "UTC").until(end, { largestUnit }), + 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, + "Jan 29th to Feb 28th is 30 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(2505600_000_000_000n /* = 1970-01-30T00Z */, "UTC").until(end, { largestUnit }), + 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, + "Jan 30th to Feb 28th is 29 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(2592000_000_000_000n /* = 1970-01-31T00Z */, "UTC").until(end, { largestUnit }), + 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, + "Jan 31st to Feb 28th is 28 days, not one month" + ); + } +} + +// Difference between end of leap-year January to end of leap-year February +{ + const end = new Temporal.ZonedDateTime(68169600_000_000_000n /* = 1972-02-29T00Z */, "UTC"); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(65491200_000_000_000n /* = 1972-01-29T00Z */, "UTC").until(end, { largestUnit }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + "Jan 29th to Feb 29th is one month" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(65577600_000_000_000n /* = 1972-01-30T00Z */, "UTC").until(end, { largestUnit }), + 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, + "Jan 30th to Feb 29th is 30 days, not one month" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(65664000_000_000_000n /* = 1972-01-31T00Z */, "UTC").until(end, { largestUnit }), + 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, + "Jan 31st to Feb 29th is 29 days, not one month" + ); + } +} + +// Difference between end of longer month to end of not-immediately-following +// shorter month +{ + const end = new Temporal.ZonedDateTime(28771200_000_000_000n /* = 1970-11-30T00Z */, "UTC"); + for (const largestUnit of ["years", "months"]) { + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(20822400_000_000_000n /* = 1970-08-30T00Z */, "UTC").until(end, { largestUnit }), + 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, + "Aug 30th to Nov 30th is 3 months" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(20908800_000_000_000n /* = 1970-08-31T00Z */, "UTC").until(end, { largestUnit }), + 0, 2, 0, 30, 0, 0, 0, 0, 0, 0, + "Aug 31st to Nov 30th is 2 months 30 days, not 3 months" + ); + } +} + +// Difference between end of longer month in one year to shorter month in +// later year +{ + const end = new Temporal.ZonedDateTime(104976000_000_000_000n /* = 1973-04-30T00Z */, "UTC"); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(31363200_000_000_000n /* = 1970-12-30T00Z */, "UTC").until(end, { largestUnit: "months" }), + 0, 28, 0, 0, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 28 months" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(31363200_000_000_000n /* = 1970-12-30T00Z */, "UTC").until(end, { largestUnit: "years" }), + 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 2 years, 4 months" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(31449600_000_000_000n /* = 1970-12-31T00Z */, "UTC").until(end, { largestUnit: "months" }), + 0, 27, 0, 30, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 27 months, 30 days, not 28 months" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(31449600_000_000_000n /* = 1970-12-31T00Z */, "UTC").until(end, { largestUnit: "years" }), + 2, 3, 0, 30, 0, 0, 0, 0, 0, 0, + "Dec 30th 1970 to Apr 30th 1973 is 2 years, 3 months, 30 days, not 2 years 4 months" + ); +} + +// Difference where months passes through a month that's the same length or +// shorter than either the start or end month +{ + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(2419200_000_000_000n /* = 1970-01-29T00Z */, "UTC").until(new Temporal.ZonedDateTime(7430400_000_000_000n /* = 1970-03-28T00Z */, "UTC"), { largestUnit: "months" }), + 0, 1, 0, 28, 0, 0, 0, 0, 0, 0, + "Jan 29th to Mar 28th is 1 month 28 days, not 58 days" + ); + TemporalHelpers.assertDuration( + new Temporal.ZonedDateTime(2592000_000_000_000n /* = 1970-01-31T00Z */, "UTC").until(new Temporal.ZonedDateTime(44409600_000_000_000n /* = 1971-05-30T00Z */, "UTC"), { largestUnit: "years" }), + 1, 3, 0, 30, 0, 0, 0, 0, 0, 0, + "Jan 31st 1970 to May 30th 1971 is 1 year, 3 months, 30 days, not 1 year, 2 months, 60 days" + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/custom-calendar-weekofyear.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/custom-calendar-weekofyear.js new file mode 100644 index 0000000000..43a7d2ba14 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/custom-calendar-weekofyear.js @@ -0,0 +1,27 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.weekofyear +description: > + Temporal.ZonedDateTime.prototype.weekOfYear returns undefined for all + custom calendars where weekOfYear() returns undefined. +features: [Temporal] +---*/ + +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + weekOfYear() { + return undefined; + } +} + +const calendar = new CustomCalendar(); +// Epoch Nanoseconds for new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); +const customCalendarDate = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar); +assert.sameValue(customCalendarDate.weekOfYear, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/validate-calendar-value.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/validate-calendar-value.js index 8b18332ce4..b2b83c1d41 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/validate-calendar-value.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/validate-calendar-value.js @@ -9,7 +9,6 @@ features: [Temporal] ---*/ const badResults = [ - [undefined, TypeError], [null, TypeError], [false, TypeError], [Infinity, RangeError], diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/with/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/with/getoffsetnanosecondsfor-maximum-forward-offset-shift.js new file mode 100644 index 0000000000..a1c2cec71d --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/with/getoffsetnanosecondsfor-maximum-forward-offset-shift.js @@ -0,0 +1,52 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.with +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants can be at most 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 0n; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + calls++; + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12 })]; + } +} + +const timeZone = new Shift24Hour(); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +for (const disambiguation of ["earlier", "later", "compatible"]) { + instance.with({ day: 1 }, { disambiguation }); + + assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); + calls = 0; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/with/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/with/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..a93ee7ff32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/with/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js @@ -0,0 +1,46 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.with +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 0n; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +for (const disambiguation of ["earlier", "later", "compatible"]) { + assert.throws(RangeError, () => instance.with({ day: 1 }, { disambiguation }), "RangeError should be thrown"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/with/getpossibleinstantsfor-maximum-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/with/getpossibleinstantsfor-maximum-backward-offset-shift.js new file mode 100644 index 0000000000..b053782926 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/with/getpossibleinstantsfor-maximum-backward-offset-shift.js @@ -0,0 +1,56 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.with +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + calls++; + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12 }), + utcInstant.add({ hours: 12 }) + ]; + } +} + +const timeZone = new Shift24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +for (const disambiguation of ["earlier", "later", "compatible"]) { + instance.with({ day: 1 }, { disambiguation }); + + assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); + calls = 0; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/with/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/with/getpossibleinstantsfor-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..7db6925321 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/with/getpossibleinstantsfor-out-of-range-backward-offset-shift.js @@ -0,0 +1,51 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.with +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +for (const disambiguation of ["earlier", "later", "compatible"]) { + assert.throws(RangeError, () => instance.with({ day: 1 }, { disambiguation }), "RangeError should be thrown"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-iso-string.js new file mode 100644 index 0000000000..834be0ebb6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-iso-string.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withcalendar +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", { + dateAdd() {}, + dateFromFields() {}, + dateUntil() {}, + day() {}, + dayOfWeek() {}, + dayOfYear() {}, + daysInMonth() {}, + daysInWeek() {}, + daysInYear() {}, + fields() {}, + id: "replace-me", + inLeapYear() {}, + mergeFields() {}, + month() {}, + monthCode() {}, + monthDayFromFields() {}, + monthsInYear() {}, + weekOfYear() {}, + year() {}, + yearMonthFromFields() {}, + yearOfWeek() {}, +}); + +for (const arg of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const result = instance.withCalendar(arg); + assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..a0b1fa2928 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withplaindate +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.withPlainDate(arg); + assert.sameValue(result.epochNanoseconds, 217_129_600_000_000_000n, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js index 3d7d95215e..52cefeffa3 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js @@ -17,7 +17,8 @@ const invalidStrings = [ ]; const timeZone = new Temporal.TimeZone("UTC"); const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.withPlainDate(arg), diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..c1f874813b --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,26 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withplaindate +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.withPlainDate(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getoffsetnanosecondsfor-maximum-forward-offset-shift.js new file mode 100644 index 0000000000..d595cb1952 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getoffsetnanosecondsfor-maximum-forward-offset-shift.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withplaindate +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants can be at most 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + calls++; + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12 })]; + } +} + +const timeZone = new Shift24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +instance.withPlainDate(new Temporal.PlainDate(1970, 1, 1)); + +assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..7af0ddc2d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js @@ -0,0 +1,44 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withplaindate +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +assert.throws(RangeError, () => instance.withPlainDate(new Temporal.PlainDate(1970, 1, 1)), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-maximum-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-maximum-backward-offset-shift.js new file mode 100644 index 0000000000..2ed4c8f1d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-maximum-backward-offset-shift.js @@ -0,0 +1,53 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withplaindate +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + calls++; + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12 }), + utcInstant.add({ hours: 12 }) + ]; + } +} + +const timeZone = new Shift24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +instance.withPlainDate(new Temporal.PlainDate(1970, 1, 1)); + +assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..b43bdba300 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-out-of-range-backward-offset-shift.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withplaindate +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +assert.throws(RangeError, () => instance.withPlainDate(new Temporal.PlainDate(1970, 1, 1)), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..d07df63e1e --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,32 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withplaintime +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["00:00[U-CA=iso8601]", "invalid capitalized key, time-only"], + ["T00:00[U-CA=iso8601]", "invalid capitalized key, time designator"], + ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], + ["00:00[u-CA=iso8601]", "invalid partially-capitalized key, time-only"], + ["T00:00[u-CA=iso8601]", "invalid partially-capitalized key, time designator"], + ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], + ["00:00[FOO=bar]", "invalid capitalized unrecognized key, time-only"], + ["T00:00[FOO=bar]", "invalid capitalized unrecognized key, time designator"], + ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.withPlainTime(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js new file mode 100644 index 0000000000..0bf0721c54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withplaintime +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants can be at most 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 0n + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + calls++; + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12 })]; + } +} + +const timeZone = new Shift24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +instance.withPlainTime(); + +assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js new file mode 100644 index 0000000000..8f2615faae --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js @@ -0,0 +1,44 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withplaintime +description: > + UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor + in DisambiguatePossibleInstants cannot be greater than 24 hours. +features: [Temporal] +info: | + DisambiguatePossibleInstants: + 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + _shiftEpochNs = 0n + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; + return 12 * 3600e9 + 1; + } + + getPossibleInstantsFor(plainDateTime) { + const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); + const { year, month, day } = plainDateTime; + + if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; + if (year === 1970 && month === 1 && day === 1) return []; + return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +assert.throws(RangeError, () => instance.withPlainTime(), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getpossibleinstantsfor-maximum-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getpossibleinstantsfor-maximum-backward-offset-shift.js new file mode 100644 index 0000000000..21dcd8b3ba --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getpossibleinstantsfor-maximum-backward-offset-shift.js @@ -0,0 +1,53 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withplaintime +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +let calls = 0; + +class Shift24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + calls++; + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12 }), + utcInstant.add({ hours: 12 }) + ]; + } +} + +const timeZone = new Shift24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +instance.withPlainTime(); + +assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js new file mode 100644 index 0000000000..f2856f0aea --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js @@ -0,0 +1,49 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withplaintime +description: > + UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. +features: [Temporal] +info: | + GetPossibleInstantsFor: + 5.b.i. Let _numResults_ be _list_'s length. + ii. If _numResults_ > 1, then + 1. Let _epochNs_ be a new empty List. + 2. For each value _instant_ in list, do + a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. + 3. Let _min_ be the least element of the List _epochNs_. + 4. Let _max_ be the greatest element of the List _epochNs_. + 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. +---*/ + +class ShiftLonger24Hour extends Temporal.TimeZone { + id = 'TestTimeZone'; + + constructor() { + super('UTC'); + } + + getOffsetNanosecondsFor(instant) { + return 0; + } + + getPossibleInstantsFor(plainDateTime) { + const utc = new Temporal.TimeZone("UTC"); + const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); + return [ + utcInstant.subtract({ hours: 12, nanoseconds: 1 }), + utcInstant.add({ hours: 12 }), + utcInstant, // add a third value in case the implementation doesn't sort + ]; + } +} + +const timeZone = new ShiftLonger24Hour(); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); +assert.throws(RangeError, () => instance.withPlainTime(), "RangeError should be thrown"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/custom-calendar-weekofyear.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/custom-calendar-weekofyear.js new file mode 100644 index 0000000000..331002f262 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/custom-calendar-weekofyear.js @@ -0,0 +1,27 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.yearofweek +description: > + Temporal.ZonedDateTime.prototype.yearOfWeek returns undefined for all + custom calendars where yearOfWeek() returns undefined. +features: [Temporal] +---*/ + +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + yearOfWeek() { + return undefined; + } +} + +const calendar = new CustomCalendar(); +// Epoch Nanoseconds for new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); +const customCalendarDate = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar); +assert.sameValue(customCalendarDate.yearOfWeek, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/validate-calendar-value.js b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/validate-calendar-value.js index 9bd447f9a1..9eb067c70b 100644 --- a/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/validate-calendar-value.js +++ b/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/validate-calendar-value.js @@ -9,7 +9,6 @@ features: [Temporal] ---*/ const badResults = [ - [undefined, TypeError], [Infinity, RangeError], [-Infinity, RangeError], [Symbol("foo"), TypeError], diff --git a/js/src/tests/test262/built-ins/Temporal/shell.js b/js/src/tests/test262/built-ins/Temporal/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/built-ins/Temporal/shell.js +++ b/js/src/tests/test262/built-ins/Temporal/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/built-ins/ThrowTypeError/length.js b/js/src/tests/test262/built-ins/ThrowTypeError/length.js index d30e3ec045..cc55b8f77b 100644 --- a/js/src/tests/test262/built-ins/ThrowTypeError/length.js +++ b/js/src/tests/test262/built-ins/ThrowTypeError/length.js @@ -18,10 +18,11 @@ var ThrowTypeError = Object.getOwnPropertyDescriptor(function() { return arguments; }(), "callee").get; -assert.sameValue(ThrowTypeError.length, 0); - -verifyNotEnumerable(ThrowTypeError, "length"); -verifyNotWritable(ThrowTypeError, "length"); -verifyNotConfigurable(ThrowTypeError, "length"); +verifyProperty(ThrowTypeError, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: false +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/Symbol.species/length.js b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/length.js index 8efd820740..1c0470e699 100644 --- a/js/src/tests/test262/built-ins/TypedArray/Symbol.species/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -25,10 +26,11 @@ features: [Symbol.species] var desc = Object.getOwnPropertyDescriptor(TypedArray, Symbol.species); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/Symbol.species/name.js b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/name.js index 8747ac6130..444d7c99cb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/Symbol.species/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -22,10 +23,11 @@ features: [Symbol.species] var desc = Object.getOwnPropertyDescriptor(TypedArray, Symbol.species); -assert.sameValue(desc.get.name, "get [Symbol.species]"); - -verifyNotEnumerable(desc.get, "name"); -verifyNotWritable(desc.get, "name"); -verifyConfigurable(desc.get, "name"); +verifyProperty(desc.get, "name", { + value: "get [Symbol.species]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/Symbol.species/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/prop-desc.js index 5a97e8f5e1..fd203d961c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/Symbol.species/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/Symbol.species/result.js b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/result.js index 3b79165925..11c1ca5ecb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/Symbol.species/result.js +++ b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/result.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/from/arylk-get-length-error.js b/js/src/tests/test262/built-ins/TypedArray/from/arylk-get-length-error.js index 705df14bf9..fb759d77dc 100644 --- a/js/src/tests/test262/built-ins/TypedArray/from/arylk-get-length-error.js +++ b/js/src/tests/test262/built-ins/TypedArray/from/arylk-get-length-error.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/from/arylk-to-length-error.js b/js/src/tests/test262/built-ins/TypedArray/from/arylk-to-length-error.js index e4ab814d5f..357362d82e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/from/arylk-to-length-error.js +++ b/js/src/tests/test262/built-ins/TypedArray/from/arylk-to-length-error.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/from/from-array-mapper-detaches-result.js b/js/src/tests/test262/built-ins/TypedArray/from/from-array-mapper-detaches-result.js new file mode 100644 index 0000000000..0af40c814e --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/from/from-array-mapper-detaches-result.js @@ -0,0 +1,39 @@ +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.from +description: > + If the mapper function detaches the result typed array, .from performs Set operation which ignores out-of-bounds indices. +info: | + %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 12. Repeat, while k < len, + ... + c. If mapping is true, then + i. Let mappedValue be ? Call(mapfn, thisArg, « kValue, 𝔽(k) »). + ... + e. Perform ? Set(targetObj, Pk, mappedValue, true). + ... +includes: [detachArrayBuffer.js] +features: [TypedArray] +---*/ + +let ab = new ArrayBuffer(3); +let target = new Int8Array(ab); +let values = [0, 1, 2]; + +let result = Int32Array.from.call(function() { + return target; +}, values, v => { + if (v === 1) { + $DETACHBUFFER(ab); + } + return v + 10; +}); + +assert.sameValue(result, target); +assert.sameValue(result.length, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/from/from-array-mapper-makes-result-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/from/from-array-mapper-makes-result-out-of-bounds.js new file mode 100644 index 0000000000..c3c541a2a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/from/from-array-mapper-makes-result-out-of-bounds.js @@ -0,0 +1,40 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.from +description: > + If the mapper function makes result typed array out-of-bounds, .from performs Set operation which ignores out-of-bounds indices. +info: | + %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 12. Repeat, while k < len, + ... + c. If mapping is true, then + i. Let mappedValue be ? Call(mapfn, thisArg, « kValue, 𝔽(k) »). + ... + e. Perform ? Set(targetObj, Pk, mappedValue, true). + ... +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let target = new Int8Array(rab); +let values = [0, 1, 2]; + +let result = Int32Array.from.call(function() { + return target; +}, values, v => { + if (v === 1) { + rab.resize(1); + } + return v + 10; +}); + +assert.sameValue(result, target); +assert.sameValue(result.length, 1); +assert.sameValue(result[0], 10); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/from/from-typedarray-into-itself-mapper-detaches-result.js b/js/src/tests/test262/built-ins/TypedArray/from/from-typedarray-into-itself-mapper-detaches-result.js new file mode 100644 index 0000000000..3ef68a8e8d --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/from/from-typedarray-into-itself-mapper-detaches-result.js @@ -0,0 +1,39 @@ +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.from +description: > + If the mapper function detaches the result typed array, .from performs Set operation which ignores out-of-bounds indices. +info: | + %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 12. Repeat, while k < len, + ... + c. If mapping is true, then + i. Let mappedValue be ? Call(mapfn, thisArg, « kValue, 𝔽(k) »). + ... + e. Perform ? Set(targetObj, Pk, mappedValue, true). + ... +includes: [detachArrayBuffer.js] +features: [TypedArray] +---*/ + +let ab = new ArrayBuffer(3); +let target = new Int8Array(ab); +target.set([0, 1, 2]); + +let result = Int32Array.from.call(function() { + return target; +}, target, v => { + if (v === 1) { + $DETACHBUFFER(ab); + } + return v + 10; +}); + +assert.sameValue(result, target); +assert.sameValue(result.length, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/from/from-typedarray-into-itself-mapper-makes-result-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/from/from-typedarray-into-itself-mapper-makes-result-out-of-bounds.js new file mode 100644 index 0000000000..d83cf5f5f6 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/from/from-typedarray-into-itself-mapper-makes-result-out-of-bounds.js @@ -0,0 +1,40 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.from +description: > + If the mapper function makes result typed array out-of-bounds, .from performs Set operation which ignores out-of-bounds indices. +info: | + %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 12. Repeat, while k < len, + ... + c. If mapping is true, then + i. Let mappedValue be ? Call(mapfn, thisArg, « kValue, 𝔽(k) »). + ... + e. Perform ? Set(targetObj, Pk, mappedValue, true). + ... +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let target = new Int8Array(rab); +target.set([0, 1, 2]); + +let result = Int32Array.from.call(function() { + return target; +}, target, v => { + if (v === 1) { + rab.resize(1); + } + return v + 10; +}); + +assert.sameValue(result, target); +assert.sameValue(result.length, 1); +assert.sameValue(result[0], 10); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/from/from-typedarray-mapper-detaches-result.js b/js/src/tests/test262/built-ins/TypedArray/from/from-typedarray-mapper-detaches-result.js new file mode 100644 index 0000000000..25b64bdde8 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/from/from-typedarray-mapper-detaches-result.js @@ -0,0 +1,39 @@ +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.from +description: > + If the mapper function detaches the result typed array, .from performs Set operation which ignores out-of-bounds indices. +info: | + %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 12. Repeat, while k < len, + ... + c. If mapping is true, then + i. Let mappedValue be ? Call(mapfn, thisArg, « kValue, 𝔽(k) »). + ... + e. Perform ? Set(targetObj, Pk, mappedValue, true). + ... +includes: [detachArrayBuffer.js] +features: [TypedArray] +---*/ + +let ab = new ArrayBuffer(3); +let target = new Int8Array(ab); +let values = new Int8Array([0, 1, 2]); + +let result = Int32Array.from.call(function() { + return target; +}, values, v => { + if (v === 1) { + $DETACHBUFFER(ab); + } + return v + 10; +}); + +assert.sameValue(result, target); +assert.sameValue(result.length, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/from/from-typedarray-mapper-makes-result-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/from/from-typedarray-mapper-makes-result-out-of-bounds.js new file mode 100644 index 0000000000..389155bfe9 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/from/from-typedarray-mapper-makes-result-out-of-bounds.js @@ -0,0 +1,40 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.from +description: > + If the mapper function makes result typed array out-of-bounds, .from performs Set operation which ignores out-of-bounds indices. +info: | + %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 12. Repeat, while k < len, + ... + c. If mapping is true, then + i. Let mappedValue be ? Call(mapfn, thisArg, « kValue, 𝔽(k) »). + ... + e. Perform ? Set(targetObj, Pk, mappedValue, true). + ... +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let target = new Int8Array(rab); +let values = new Int8Array([0, 1, 2]); + +let result = Int32Array.from.call(function() { + return target; +}, values, v => { + if (v === 1) { + rab.resize(1); + } + return v + 10; +}); + +assert.sameValue(result, target); +assert.sameValue(result.length, 1); +assert.sameValue(result[0], 10); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/from/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/from/invoked-as-func.js index 97ce6b2ff9..364a5d4a24 100644 --- a/js/src/tests/test262/built-ins/TypedArray/from/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/from/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/from/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/from/invoked-as-method.js index d2414e0923..9cafb59fdf 100644 --- a/js/src/tests/test262/built-ins/TypedArray/from/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/from/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/from/iter-access-error.js b/js/src/tests/test262/built-ins/TypedArray/from/iter-access-error.js index b37537d19e..5d37f8179c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/from/iter-access-error.js +++ b/js/src/tests/test262/built-ins/TypedArray/from/iter-access-error.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/from/iter-invoke-error.js b/js/src/tests/test262/built-ins/TypedArray/from/iter-invoke-error.js index de395eb2dc..99605d1254 100644 --- a/js/src/tests/test262/built-ins/TypedArray/from/iter-invoke-error.js +++ b/js/src/tests/test262/built-ins/TypedArray/from/iter-invoke-error.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/from/iter-next-error.js b/js/src/tests/test262/built-ins/TypedArray/from/iter-next-error.js index 7cbea13246..7783529181 100644 --- a/js/src/tests/test262/built-ins/TypedArray/from/iter-next-error.js +++ b/js/src/tests/test262/built-ins/TypedArray/from/iter-next-error.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/from/iter-next-value-error.js b/js/src/tests/test262/built-ins/TypedArray/from/iter-next-value-error.js index a1674c417b..3742e273ab 100644 --- a/js/src/tests/test262/built-ins/TypedArray/from/iter-next-value-error.js +++ b/js/src/tests/test262/built-ins/TypedArray/from/iter-next-value-error.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/from/iterated-array-changed-by-tonumber.js b/js/src/tests/test262/built-ins/TypedArray/from/iterated-array-changed-by-tonumber.js new file mode 100644 index 0000000000..a0d6099170 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/from/iterated-array-changed-by-tonumber.js @@ -0,0 +1,39 @@ +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.from +description: > + Modifications to input array after iteration are handled correctly. +info: | + %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 6. If usingIterator is not undefined, then + a. Let values be ? IteratorToList(? GetIteratorFromMethod(source, usingIterator)). + b. Let len be the number of elements in values. + ... + e. Repeat, while k < len, + ... + vi. Perform ? Set(targetObj, Pk, mappedValue, true). + ... +features: [TypedArray] +---*/ + +let values = [0, { + valueOf() { + // Removes all array elements. Caller must have saved all elements. + values.length = 0; + return 100; + } +}, 2]; + +// `from` called with array which uses the built-in array iterator. +let ta = Int32Array.from(values); + +assert.sameValue(ta.length, 3); +assert.sameValue(ta[0], 0); +assert.sameValue(ta[1], 100); +assert.sameValue(ta[2], 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/from/length.js b/js/src/tests/test262/built-ins/TypedArray/from/length.js index 6ec675f750..27d8ecb128 100644 --- a/js/src/tests/test262/built-ins/TypedArray/from/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/from/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -24,10 +25,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.from.length, 1); - -verifyNotEnumerable(TypedArray.from, "length"); -verifyNotWritable(TypedArray.from, "length"); -verifyConfigurable(TypedArray.from, "length"); +verifyProperty(TypedArray.from, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/from/mapfn-is-not-callable.js b/js/src/tests/test262/built-ins/TypedArray/from/mapfn-is-not-callable.js index ece0766bee..42fa25ef61 100644 --- a/js/src/tests/test262/built-ins/TypedArray/from/mapfn-is-not-callable.js +++ b/js/src/tests/test262/built-ins/TypedArray/from/mapfn-is-not-callable.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/from/name.js b/js/src/tests/test262/built-ins/TypedArray/from/name.js index 9fa98be4e7..888eecdb3f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/from/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/from/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.from.name, "from"); - -verifyNotEnumerable(TypedArray.from, "name"); -verifyNotWritable(TypedArray.from, "name"); -verifyConfigurable(TypedArray.from, "name"); +verifyProperty(TypedArray.from, "name", { + value: "from", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/from/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/from/not-a-constructor.js index 41a794dfca..72a0817679 100644 --- a/js/src/tests/test262/built-ins/TypedArray/from/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/from/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -25,7 +26,7 @@ assert.sameValue(isConstructor(TypedArray.from), false, 'isConstructor(TypedArra assert.throws(TypeError, () => { new TypedArray.from([]); -}, '`new TypedArray.from([])` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/from/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/from/prop-desc.js index 7dd61adf7d..bc9f0ca5ee 100644 --- a/js/src/tests/test262/built-ins/TypedArray/from/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/from/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/from/this-is-not-constructor.js b/js/src/tests/test262/built-ins/TypedArray/from/this-is-not-constructor.js index 7838753ba5..821152f3c1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/from/this-is-not-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/from/this-is-not-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/invoked.js b/js/src/tests/test262/built-ins/TypedArray/invoked.js index 3dca11ff4c..2af6656365 100644 --- a/js/src/tests/test262/built-ins/TypedArray/invoked.js +++ b/js/src/tests/test262/built-ins/TypedArray/invoked.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/length.js b/js/src/tests/test262/built-ins/TypedArray/length.js index 2f4e13aeff..e603641abe 100644 --- a/js/src/tests/test262/built-ins/TypedArray/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/name.js b/js/src/tests/test262/built-ins/TypedArray/name.js index ef6ccf58c1..a40ba68ba7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -18,10 +19,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.name, 'TypedArray'); - -verifyNotEnumerable(TypedArray, 'name'); -verifyNotWritable(TypedArray, 'name'); -verifyConfigurable(TypedArray, 'name'); +verifyProperty(TypedArray, "name", { + value: "TypedArray", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-func.js index 1f40a9659b..4e798e82e8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-method.js index 0b671ca852..9d24453218 100644 --- a/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/of/length.js b/js/src/tests/test262/built-ins/TypedArray/of/length.js index 9739cd5045..8ac2068bb3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/of/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/of/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -24,10 +25,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.of.length, 0); - -verifyNotEnumerable(TypedArray.of, "length"); -verifyNotWritable(TypedArray.of, "length"); -verifyConfigurable(TypedArray.of, "length"); +verifyProperty(TypedArray.of, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/of/name.js b/js/src/tests/test262/built-ins/TypedArray/of/name.js index c18c95cafe..1fbb1cc54e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/of/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/of/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.of.name, "of"); - -verifyNotEnumerable(TypedArray.of, "name"); -verifyNotWritable(TypedArray.of, "name"); -verifyConfigurable(TypedArray.of, "name"); +verifyProperty(TypedArray.of, "name", { + value: "of", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/of/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/of/not-a-constructor.js index 575bb492fb..ca84c190ed 100644 --- a/js/src/tests/test262/built-ins/TypedArray/of/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/of/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -25,7 +26,7 @@ assert.sameValue(isConstructor(TypedArray.of), false, 'isConstructor(TypedArray. assert.throws(TypeError, () => { new TypedArray.of(1, 2, 3, 4); -}, '`new TypedArray.of(1, 2, 3, 4)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/of/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/of/prop-desc.js index 86bad8552c..f940c5fb8c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/of/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/of/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/of/resized-with-out-of-bounds-and-in-bounds-indices.js b/js/src/tests/test262/built-ins/TypedArray/of/resized-with-out-of-bounds-and-in-bounds-indices.js new file mode 100644 index 0000000000..6e0ee8a25e --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/of/resized-with-out-of-bounds-and-in-bounds-indices.js @@ -0,0 +1,60 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.of +description: > + Performs Set operation which ignores out-of-bounds indices. +info: | + %TypedArray%.of ( ...items ) + + ... + 6. Repeat, while k < len, + ... + c. Perform ? Set(newObj, Pk, kValue, true). + ... + +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(3, {maxByteLength: 4}); +let ta = new Int8Array(rab); + +let one = { + valueOf() { + // Shrink buffer. Assignment to `ta[0]` should be ignored. + rab.resize(0); + return 1; + } +}; + +let two = { + valueOf() { + // Grow buffer. All following assignment should succeed. + rab.resize(4); + return 2; + } +}; + +// Typed array is correctly zero initialised. +assert.sameValue(ta.length, 3); +assert.sameValue(ta[0], 0); +assert.sameValue(ta[1], 0); +assert.sameValue(ta[2], 0); + +let result = Int8Array.of.call(function() { + return ta; +}, one, two, 3); + +// Correct result value. +assert.sameValue(result, ta); + +// Values are correctly set. +assert.sameValue(ta.length, 4); +assert.sameValue(ta[0], 0); +assert.sameValue(ta[1], 2); +assert.sameValue(ta[2], 3); +assert.sameValue(ta[3], 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/of/this-is-not-constructor.js b/js/src/tests/test262/built-ins/TypedArray/of/this-is-not-constructor.js index 606fba3255..047c7a24f0 100644 --- a/js/src/tests/test262/built-ins/TypedArray/of/this-is-not-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/of/this-is-not-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype.js b/js/src/tests/test262/built-ins/TypedArray/prototype.js index 95287ce179..a8cc57c472 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator.js index 1e125255c1..37f4b383d3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator/not-a-constructor.js index 2a894cabda..fb31d3f1bf 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8[Symbol.iterator](); -}, '`let u8 = new Uint8Array(1); new u8[Symbol.iterator]()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js index 246f30b499..05191eb113 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js @@ -25,10 +25,11 @@ features: [BigInt, Symbol.toStringTag] var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js index 3b77f82c2b..c553953baf 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js @@ -22,10 +22,11 @@ features: [BigInt, Symbol.toStringTag] var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag); -assert.sameValue(desc.get.name, "get [Symbol.toStringTag]"); - -verifyNotEnumerable(desc.get, "name"); -verifyNotWritable(desc.get, "name"); -verifyConfigurable(desc.get, "name"); +verifyProperty(desc.get, "name", { + value: "get [Symbol.toStringTag]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js index 2644bfebd4..53747b724f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/invoked-as-accessor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/invoked-as-accessor.js index 227ff392a1..0b3ffb30fc 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/invoked-as-accessor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/invoked-as-accessor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/invoked-as-func.js index f05d7656d6..af72124902 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/length.js index d47c20684b..e7e0117258 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -25,10 +26,11 @@ features: [Symbol.toStringTag] var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/name.js index 6de76bd40f..05141ff900 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -22,10 +23,11 @@ features: [Symbol.toStringTag] var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag); -assert.sameValue(desc.get.name, "get [Symbol.toStringTag]"); - -verifyNotEnumerable(desc.get, "name"); -verifyNotWritable(desc.get, "name"); -verifyConfigurable(desc.get, "name"); +verifyProperty(desc.get, "name", { + value: "get [Symbol.toStringTag]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/prop-desc.js index 7fda276f58..ad6754e5cf 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js index 4cc973019c..5c09a7f9c5 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js index 06450f6030..2cc5fd385c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js index 460564f162..4875b31c33 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-argument-tointeger.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-argument-tointeger.js index 0177ff8308..6d876f3ec3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-argument-tointeger.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-argument-tointeger.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js index e3f65c143d..2f6c5b24fe 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -24,7 +25,7 @@ testWithTypedArrayConstructors(TA => { assert.throws(TypeError, () => { a.at(Symbol()); - }, '`a.at(Symbol())` throws TypeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js index 4d604500bb..f8eb8dd7fa 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/length.js index acd90fd31c..29aa7993b7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/at/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -18,13 +19,11 @@ assert.sameValue( 'The value of `typeof TypedArray.prototype.at` is "function"' ); -assert.sameValue( - TypedArray.prototype.at.length, 1, - 'The value of TypedArray.prototype.at.length is 1' -); - -verifyNotEnumerable(TypedArray.prototype.at, 'length'); -verifyNotWritable(TypedArray.prototype.at, 'length'); -verifyConfigurable(TypedArray.prototype.at, 'length'); +verifyProperty(TypedArray.prototype.at, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/name.js index fd4fcf2324..436c47a595 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/at/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/prop-desc.js index 946b185db0..dada242916 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/at/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js index 1613acdcce..59cd73cd26 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/return-abrupt-from-this.js index aaf89b12ef..563a419ad1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/at/return-abrupt-from-this.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/return-abrupt-from-this.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -21,22 +22,22 @@ assert.sameValue( assert.throws(TypeError, () => { TypedArray.prototype.at.call(undefined); -}, '`TypedArray.prototype.at.call(undefined)` throws TypeError'); +}); assert.throws(TypeError, () => { TypedArray.prototype.at.call(null); -}, '`TypedArray.prototype.at.call(null)` throws TypeError'); +}); testWithTypedArrayConstructors(TA => { assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"'); assert.throws(TypeError, () => { TA.prototype.at.call(undefined); - }, '`TA.prototype.at.call(undefined)` throws TypeError'); + }); assert.throws(TypeError, () => { TA.prototype.at.call(null); - }, '`TA.prototype.at.call(null)` throws TypeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-item-relative-index.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-item-relative-index.js index ff4d81fc04..c615b657da 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-item-relative-index.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-item-relative-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-item.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-item.js index 77ac1a0317..615c69c4b8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-item.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-item.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js index c4eafb1e10..7b0ddba071 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js index 8a954e3971..af9af6f6f5 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/detached-buffer.js index 37d07fc49b..2d3da6c56d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-accessor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-accessor.js index d1ce4b348a..4d02a18818 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-accessor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-accessor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-func.js index 4b47043775..14d8be3c48 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/length.js index 5d0450e8f0..a343b2d947 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -25,10 +26,11 @@ features: [TypedArray] var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer"); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/name.js index f0464af9dc..af4c7cc517 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -22,10 +23,11 @@ features: [TypedArray] var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer"); -assert.sameValue(desc.get.name, "get buffer"); - -verifyNotEnumerable(desc.get, "name"); -verifyNotWritable(desc.get, "name"); -verifyConfigurable(desc.get, "name"); +verifyProperty(desc.get, "name", { + value: "get buffer", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/prop-desc.js index 70f7c8973f..3d1d6b63ad 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/return-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/return-buffer.js index aa17d649bf..c9ff2122a9 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/return-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/return-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js index 69844e2da1..4f57e51995 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-inherits-typedarray.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-inherits-typedarray.js index 27d44fee16..82b823a8db 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-inherits-typedarray.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-inherits-typedarray.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Google. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-is-not-object.js index 6f23eb7253..670fcbba4f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/detached-buffer.js index 205495e17c..9f69a6a2a2 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/invoked-as-accessor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/invoked-as-accessor.js index 6f61359335..aed9dcd57b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/invoked-as-accessor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/invoked-as-accessor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/invoked-as-func.js index 2564aef2f1..ec048f95d6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/length.js index c8d44217b9..665001a4e4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -25,10 +26,11 @@ features: [TypedArray] var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength"); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/name.js index b6da9f6c41..c004b2d570 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -22,10 +23,11 @@ features: [TypedArray] var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength"); -assert.sameValue(desc.get.name, "get byteLength"); - -verifyNotEnumerable(desc.get, "name"); -verifyNotWritable(desc.get, "name"); -verifyConfigurable(desc.get, "name"); +verifyProperty(desc.get, "name", { + value: "get byteLength", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/prop-desc.js index cb1a455857..ebe22609dd 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js index eec8cf0b14..3ac27e0682 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js index 5bef61d780..81ab5c4fb4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/return-bytelength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/return-bytelength.js index a344aa1d4f..7c47369993 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/return-bytelength.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/return-bytelength.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js index 212bd2b016..26c935b03f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/this-is-not-object.js index 84a1e60675..0ed69a16db 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/detached-buffer.js index e831fd0232..2fcdf445a8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/invoked-as-accessor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/invoked-as-accessor.js index 7ebe5f7ff2..20894b2b5f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/invoked-as-accessor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/invoked-as-accessor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/invoked-as-func.js index e7ff71bfef..49ca72256a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/length.js index f8e16555cb..a539d8f4f7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -25,10 +26,11 @@ features: [TypedArray] var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset"); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/name.js index 4a2e7d3ea3..7c3b3e2c87 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -22,10 +23,11 @@ features: [TypedArray] var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset"); -assert.sameValue(desc.get.name, "get byteOffset"); - -verifyNotEnumerable(desc.get, "name"); -verifyNotWritable(desc.get, "name"); -verifyConfigurable(desc.get, "name"); +verifyProperty(desc.get, "name", { + value: "get byteOffset", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/prop-desc.js index 8d6f554f4a..efe5371932 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js index 7aa66e07e5..6a43427556 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js index 5bbfb4e5b7..c01adaf4c0 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/return-byteoffset.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/return-byteoffset.js index 889aef45b5..de9ea26f85 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/return-byteoffset.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/return-byteoffset.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js index 4388d3d760..8fc44140ca 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/this-is-not-object.js index da5c78ed28..a2cd9b964e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/constructor.js index d41ffbfa41..fa10f9aa9f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/bit-precision.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/bit-precision.js index e72c355cb9..9a606f8609 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/bit-precision.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/bit-precision.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/byteoffset.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/byteoffset.js index ec9f014d04..927aa049d4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/byteoffset.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/byteoffset.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Chengzhong Wu. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js index 2b687ed165..17fb256515 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2019 Google. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js index 484f388021..3505f5e46d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2019 Google. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end.js index 01a44699d5..252941dc59 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js index 559d3a18df..81bca9bdfd 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2019 Google. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-start.js index 9eb1399586..dbbe1eca2b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-start.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-start.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-target.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-target.js index cfe5773f8f..22f0a180da 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-target.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-target.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/detached-buffer.js index 78e7bbda66..48f65c7244 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js index d5cc8f993d..70e43bb49a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/invoked-as-func.js index 61da74b61a..14d0fd743b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/invoked-as-method.js index 1c7783022f..abdc42c3e7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/length.js index f7652c91da..e52c164dcf 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.copyWithin.length, 2); - -verifyNotEnumerable(TypedArray.prototype.copyWithin, "length"); -verifyNotWritable(TypedArray.prototype.copyWithin, "length"); -verifyConfigurable(TypedArray.prototype.copyWithin, "length"); +verifyProperty(TypedArray.prototype.copyWithin, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/name.js index 7a888ea988..12e395b7ec 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.copyWithin.name, "copyWithin"); - -verifyNotEnumerable(TypedArray.prototype.copyWithin, "name"); -verifyNotWritable(TypedArray.prototype.copyWithin, "name"); -verifyConfigurable(TypedArray.prototype.copyWithin, "name"); +verifyProperty(TypedArray.prototype.copyWithin, "name", { + value: "copyWithin", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-end.js index 51fdfe1ab0..2027336179 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-end.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-end.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js index 97ae46c850..4393bdde66 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js index 31cfc40993..1d53604a5f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js index ac9c07bf31..651a0761d1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-start.js index 21c18b503e..feb6d8b9ce 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-start.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-start.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-target.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-target.js index b8fc48835a..288f507766 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-target.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-target.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js index 569b7d95b4..1af316d086 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js index d2b7e87fbc..edaa63bce5 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js index d0d152e3d2..ddf884f514 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js index 62a6bfcd4a..fcd2962426 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/not-a-constructor.js index 34042bfc79..96ab695c1f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.copyWithin(); -}, '`let u8 = new Uint8Array(1); new u8.copyWithin()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/prop-desc.js index 96da143cac..31ae3e64c6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js index 09d60ac7d1..6adcb9f266 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js index 5d7ef05e4e..12066c7c01 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js index 4a5455bf26..a46ea66ef5 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js index 6a0843ae3f..d87c5dcb9c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js index a1148053a7..85fc5f07ee 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js index 0e9c56d1a2..06c396b8a8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js index 4335158b50..f29e67a2f4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-this.js index 2ff0381574..b339b2ee48 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-this.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-this.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/this-is-not-object.js index 7f19b0b3ef..bc8457b1c7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js index 9bd0b0458d..358643d1a3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/undefined-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/undefined-end.js index e4e7072486..4d04dd440e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/undefined-end.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/undefined-end.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/detached-buffer.js index 4a644f910c..b3e18e6f6f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/invoked-as-func.js index 1e5894ad29..6f3526bd98 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/invoked-as-method.js index 17ce58a45c..9fb1f3de90 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/iter-prototype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/iter-prototype.js index 7637d66454..89f60b422f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/iter-prototype.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/iter-prototype.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/length.js index f7c54bd2a0..0d7d3e87c7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.entries.length, 0); - -verifyNotEnumerable(TypedArray.prototype.entries, "length"); -verifyNotWritable(TypedArray.prototype.entries, "length"); -verifyConfigurable(TypedArray.prototype.entries, "length"); +verifyProperty(TypedArray.prototype.entries, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/name.js index 4947bc59fa..2e84afb33a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.entries.name, "entries"); - -verifyNotEnumerable(TypedArray.prototype.entries, "name"); -verifyNotWritable(TypedArray.prototype.entries, "name"); -verifyConfigurable(TypedArray.prototype.entries, "name"); +verifyProperty(TypedArray.prototype.entries, "name", { + value: "entries", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/not-a-constructor.js index 8b28d47a0f..c7b6d4c120 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.entries(); -}, '`let u8 = new Uint8Array(1); new u8.entries()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/prop-desc.js index ce4a744117..352e2ebf53 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js index 7b4f90f25a..ab788c1ac8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/return-itor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/return-itor.js index 16923a967c..e1bb6478f2 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/return-itor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/return-itor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/this-is-not-object.js index 58afdee779..8943ba9f63 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js index f0574cd6b2..5d3ba24265 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js index 643e3d9ab1..bf2f2581f1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js index 3db2e4efb3..f030f60ac3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js index c31447279d..855d890f50 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js index b9f512de47..e7f3019b27 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-callable-throws.js index a3a9538f6a..5f8b86346b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-callable-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-callable-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js index 5218382720..5ee88ee3a5 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-resize.js index 97dc191eaf..d141515703 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-resize.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-resize.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js index 8f6678cf55..102e2b0752 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-returns-abrupt.js index 4b7474124c..81222a5a2e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-returns-abrupt.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-returns-abrupt.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js index b9d28709b8..477f776630 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-this.js index 0619270eaf..e5f184182e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-this.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-this.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/detached-buffer.js index 22e87b85f5..39d5c603c9 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js index ec9c9ae8ef..3a173694db 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-func.js index c62503b63e..a9225b5fec 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-method.js index f7e77e539b..f596f4c44d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/length.js index af76735482..140327c4c2 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.every.length, 1); - -verifyNotEnumerable(TypedArray.prototype.every, "length"); -verifyNotWritable(TypedArray.prototype.every, "length"); -verifyConfigurable(TypedArray.prototype.every, "length"); +verifyProperty(TypedArray.prototype.every, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/name.js index 53cae5735e..73531de5e2 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.every.name, "every"); - -verifyNotEnumerable(TypedArray.prototype.every, "name"); -verifyNotWritable(TypedArray.prototype.every, "name"); -verifyConfigurable(TypedArray.prototype.every, "name"); +verifyProperty(TypedArray.prototype.every, "name", { + value: "every", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/not-a-constructor.js index 16bffa2af1..e84209e404 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.every(() => {}); -}, '`let u8 = new Uint8Array(1); new u8.every(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/prop-desc.js index f4d99d733a..eff1286ae9 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js index e9215ead91..460e0dba54 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js index 437bfd2b3d..0fdd31d60b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js index b75a13bb27..19612096fd 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-object.js index 9086272c65..fc002d4370 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-typedarray-instance.js index 5d73f3d3d0..626bd565f2 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/values-are-not-cached.js index 6b64c3fb8d..07a714edfd 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/every/values-are-not-cached.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/values-are-not-cached.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/absent-indices-computed-from-initial-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/absent-indices-computed-from-initial-length.js new file mode 100644 index 0000000000..e2ae779081 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/absent-indices-computed-from-initial-length.js @@ -0,0 +1,54 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Absent start and end parameters are computed from initial length. +info: | + %TypedArray%.prototype.fill ( value [ , start [ , end ] ] ) + + ... + 2. Let taRecord be ? ValidateTypedArray(O, seq-cst). + 3. Let len be TypedArrayLength(taRecord). + ... + 5. Otherwise, set value to ? ToNumber(value). + 6. Let relativeStart be ? ToIntegerOrInfinity(start). + ... + 9. Else, let startIndex be min(relativeStart, len). + 10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end). + ... + 13. Else, let endIndex be min(relativeEnd, len). + ... + +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(1, {maxByteLength: 4}); +let ta = new Int8Array(rab); + +let value = { + valueOf() { + // Set buffer to maximum byte length. + rab.resize(4); + + // Return the fill value. + return 123; + } +}; + +// Ensure typed array is correctly initialised. +assert.sameValue(ta.length, 1); +assert.sameValue(ta[0], 0); + +ta.fill(value); + +// Ensure typed array has correct length and only the first element was filled. +assert.sameValue(ta.length, 4); +assert.sameValue(ta[0], 123); +assert.sameValue(ta[1], 0); +assert.sameValue(ta[2], 0); +assert.sameValue(ta[3], 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-end-detach.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-end-detach.js index ccaa1ae6bd..44881f8a7e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-end-detach.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-end-detach.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Google. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-indexes.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-indexes.js index f2f78c3d39..43225f1632 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-indexes.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-indexes.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-start-detach.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-start-detach.js index 63656210b1..891c1e1c05 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-start-detach.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-start-detach.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Google. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-value-detach.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-value-detach.js index cdfa9efd88..b7bc5c54e2 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-value-detach.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-value-detach.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Google. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/detached-buffer.js index e81231bc64..c43330e575 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-once.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-once.js index 0abceac140..1a9c45bfa3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-once.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-once.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js index 0990868026..2263805084 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations.js index c23bfe9b2b..78325d980f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js index 7f8d6dd51f..802022c54b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-non-numeric.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-non-numeric.js index 371f9bde5f..70b83203ce 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-non-numeric.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-non-numeric.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-relative-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-relative-end.js index 086bf5d1b9..f324c228a7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-relative-end.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-relative-end.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-relative-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-relative-start.js index d418285a8e..af824a5dcb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-relative-start.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-relative-start.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-symbol-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-symbol-throws.js index 48bbe9c94e..08b9ee6ae8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-symbol-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-symbol-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values.js index a3a4bad901..c9315ee3e5 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/get-length-ignores-length-prop.js index bdd67a6212..085264a17f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/get-length-ignores-length-prop.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/get-length-ignores-length-prop.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/invoked-as-func.js index 10b81cbf80..7845158253 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/invoked-as-method.js index 2293f0644a..1ab0241f6d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/length.js index 2106e754bc..7427e6459a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.fill.length, 1); - -verifyNotEnumerable(TypedArray.prototype.fill, "length"); -verifyNotWritable(TypedArray.prototype.fill, "length"); -verifyConfigurable(TypedArray.prototype.fill, "length"); +verifyProperty(TypedArray.prototype.fill, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/name.js index c1e6729cee..5fe1511722 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.fill.name, "fill"); - -verifyNotEnumerable(TypedArray.prototype.fill, "name"); -verifyNotWritable(TypedArray.prototype.fill, "name"); -verifyConfigurable(TypedArray.prototype.fill, "name"); +verifyProperty(TypedArray.prototype.fill, "name", { + value: "fill", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/not-a-constructor.js index 984f6435ce..ebc79348f6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.fill(); -}, '`let u8 = new Uint8Array(1); new u8.fill()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/prop-desc.js index b9de7e83b7..91e78b8b2a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js index 0c77c38dcd..54a911522f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-end.js index aa95620a25..506a1fdf71 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-end.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-end.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-set-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-set-value.js index 90d3c469ac..dd3266124a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-set-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-set-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js index 2a94acc7e4..6b2ab793e0 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-start.js index e7016c9159..afe1580f6b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-start.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-start.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js index 2f1fec95a1..709a6a6fc4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-this.js index afba1718ac..aa940228fc 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-this.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-this.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/this-is-not-object.js index 17d8f004c5..5b5fe09212 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js index 4568ee60c1..cbaeac38ea 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/arraylength-internal.js index 33c21ff6f6..c4af66e07b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/arraylength-internal.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/arraylength-internal.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js index 35859300b2..41d142d699 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js index 4b64fc8fe4..afb437336c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js index 1d4cdffd48..e0bffe0f09 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-called-before-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-called-before-species.js index e4294991a3..5bd94f2290 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-called-before-species.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-called-before-species.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-detachbuffer.js index 27ea1c0524..d3e06e1464 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-detachbuffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-detachbuffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js index 0c88c6a18b..cc343e93ba 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js index e14ad06554..96aa2376ec 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js index b9de4395ac..e3c22bf7f7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-resize.js index c11fbfabd6..5bcf83822e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-resize.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-resize.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js index 6dfefa332e..da8f248ff8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js index 8b40373c4a..ef53548249 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js index 4f42d5a7f2..115ec2c23a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-this.js index 500140145c..8a9b7f80dd 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-this.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-this.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/detached-buffer.js index 56763ff852..f41c66fdd6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/invoked-as-func.js index 6b2b117b87..ff10f2e89a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/invoked-as-method.js index e05b086e7e..bf96655c59 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/length.js index 43eb0a71d7..e24910e251 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.filter.length, 1); - -verifyNotEnumerable(TypedArray.prototype.filter, "length"); -verifyNotWritable(TypedArray.prototype.filter, "length"); -verifyConfigurable(TypedArray.prototype.filter, "length"); +verifyProperty(TypedArray.prototype.filter, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/name.js index 517b0a9b17..db0d552c0f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.filter.name, "filter"); - -verifyNotEnumerable(TypedArray.prototype.filter, "name"); -verifyNotWritable(TypedArray.prototype.filter, "name"); -verifyConfigurable(TypedArray.prototype.filter, "name"); +verifyProperty(TypedArray.prototype.filter, "name", { + value: "filter", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/not-a-constructor.js index 403a52833e..b88ca7fd3a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.filter(() => {}); -}, '`let u8 = new Uint8Array(1); new u8.filter(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/prop-desc.js index 4fd22727f2..428194e07c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-does-not-share-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-does-not-share-buffer.js index f9c95146bb..e39b204533 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-does-not-share-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-does-not-share-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js index 333865b7f9..991f488edf 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js index ebdc9cd740..bb5da95a23 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js index fea18d1f0d..9a46dae8ff 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-destination-resizable.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-destination-resizable.js index 65c4d3db3e..74954ac780 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-destination-resizable.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-destination-resizable.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2023 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js index d3ff3fa259..645b1a2f59 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js index 264a90ef1e..5e79c2d6aa 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js index bf3e736c60..6d0195c146 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor.js index df73eb95af..315bddaae5 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js index 2c3ca7cce1..5500c0a55a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js index 233bab0335..7859b12810 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index 1408f79470..8203b94e93 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2023 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js index e95a16d1af..5f3bb10c55 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js index 7b2ef2a03a..dda264b286 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js index f0bb676bbd..f11de582c7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js index 795267c2a3..29f4412124 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js index 2a8a77a84e..168c101383 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js index c7be1baf0b..a0f4aca8e3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js index eceb6c5440..8f03a32f10 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species.js index e9139c9c20..e65b0809dc 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/this-is-not-object.js index 53275207fd..0f8bee7e41 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js index e223f362dc..29ec2b83cf 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/values-are-not-cached.js index e9f070db01..b62ed2f880 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/values-are-not-cached.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/values-are-not-cached.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/values-are-set.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/values-are-set.js index f819a8fd83..bcad70a7f1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/values-are-set.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/values-are-set.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/callbackfn-resize.js index faf3e09ace..8aed7fb8db 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/callbackfn-resize.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/callbackfn-resize.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/detached-buffer.js index 5de4a56041..f5039a14fe 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/get-length-ignores-length-prop.js index ff41a27af9..5afd88bb6a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/get-length-ignores-length-prop.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/get-length-ignores-length-prop.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/invoked-as-func.js index e63cc49e07..1cb40629d8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/invoked-as-method.js index a4d8b598ba..472f26ba99 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/length.js index 1583fe26d2..dc9eaeb1c1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.find.length, 1); - -verifyNotEnumerable(TypedArray.prototype.find, "length"); -verifyNotWritable(TypedArray.prototype.find, "length"); -verifyConfigurable(TypedArray.prototype.find, "length"); +verifyProperty(TypedArray.prototype.find, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/name.js index 1d1f09f6b8..e9e781cc0e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.find.name, "find"); - -verifyNotEnumerable(TypedArray.prototype.find, "name"); -verifyNotWritable(TypedArray.prototype.find, "name"); -verifyConfigurable(TypedArray.prototype.find, "name"); +verifyProperty(TypedArray.prototype.find, "name", { + value: "find", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/not-a-constructor.js index c7453c01f2..222f8ee1e4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.find(() => {}); -}, '`let u8 = new Uint8Array(1); new u8.find(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-changes-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-changes-value.js index 7dcaccf39b..8fe7135dbb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-changes-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-changes-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-parameters.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-parameters.js index 3df875dc37..4b9b7c6181 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-parameters.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-parameters.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-this-non-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-this-non-strict.js index b96f0ee394..f0855b64a4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-this-non-strict.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-this-non-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-this-strict-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-this-strict-strict.js index 207b73208c..23f3c2222e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-this-strict-strict.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-this-strict-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) 'use strict'; // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-is-not-callable-throws.js index 40f7c959dd..e1cef73142 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-is-not-callable-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-is-not-callable-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-may-detach-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-may-detach-buffer.js index ca16ed882d..646c5b49fb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-may-detach-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-may-detach-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js index 7ea189e4b1..35ff0b381e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/prop-desc.js index ed0168a1cd..26844b760f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js index 2215239c21..ac2232d5a3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js index 3ec89c8902..d9f728cfa1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js index f5cfd69ff7..6701a42d00 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js index bbfa0928e9..c00e18b93c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/this-is-not-object.js index 9a6479ee49..5df0c8a1b2 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/this-is-not-typedarray-instance.js index cdec6e01ad..5cf1abef6f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/find/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/callbackfn-resize.js index 6b820315b9..58e1de8613 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/callbackfn-resize.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/callbackfn-resize.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/detached-buffer.js index b936c3dc74..532c6f98c0 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js index 19f41d6844..b25f4f1cc9 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/invoked-as-func.js index 4d1c3dbcaf..580e734514 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/invoked-as-method.js index e787cd2dfc..1074567ec1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/length.js index 47fd253eef..469cb12f45 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.findIndex.length, 1); - -verifyNotEnumerable(TypedArray.prototype.findIndex, "length"); -verifyNotWritable(TypedArray.prototype.findIndex, "length"); -verifyConfigurable(TypedArray.prototype.findIndex, "length"); +verifyProperty(TypedArray.prototype.findIndex, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/name.js index efe006ee61..9449c89d33 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.findIndex.name, "findIndex"); - -verifyNotEnumerable(TypedArray.prototype.findIndex, "name"); -verifyNotWritable(TypedArray.prototype.findIndex, "name"); -verifyConfigurable(TypedArray.prototype.findIndex, "name"); +verifyProperty(TypedArray.prototype.findIndex, "name", { + value: "findIndex", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/not-a-constructor.js index c41db60aef..d76e1fbebb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.findIndex(() => {}); -}, '`let u8 = new Uint8Array(1); new u8.findIndex(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-changes-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-changes-value.js index 8ee1fcccae..e4852f2ff6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-changes-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-changes-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-parameters.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-parameters.js index 86ec93c907..db366042e7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-parameters.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-parameters.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js index db41c2cae1..44136d1a82 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-this-strict-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-this-strict-strict.js index d13f4c3bcf..76fe16e62e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-this-strict-strict.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-this-strict-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) 'use strict'; // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js index cc43dfd920..8dbeb26dc8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js index a86b1b06b0..a87daf661a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js index 5ad0de0f26..19c8af911b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/prop-desc.js index 26f01cd00a..2898dfb805 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js index abb7c66056..55f53cc8da 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js index d41faea12a..d8e7dd35b7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js index c0c0a8a07b..6f15afb6b1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js index e17e63a44b..d2667bae6f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/this-is-not-object.js index 5297a42273..0901b90e10 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js index 60b87b1561..afbe2d98df 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/callbackfn-resize.js index 1e30c04bfd..4e3a422ff2 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/callbackfn-resize.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/callbackfn-resize.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/detached-buffer.js index 4aa8408d8b..50578225db 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js index 2914416949..9a961f226e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/invoked-as-func.js index ccfb329e0b..07cced9ad6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/invoked-as-method.js index cb1bc32592..4878a90b0a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/length.js index 0513865dd8..37c04d2a86 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/name.js index 4ed9497836..b3d95cfe83 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/not-a-constructor.js index 0aa9fd189c..525852aa6a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.findLast(() => {}); -}, '`let u8 = new Uint8Array(1); new u8.findLast(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-changes-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-changes-value.js index fa6d96cb83..ee31cec69d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-changes-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-changes-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-parameters.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-parameters.js index b31a93f459..88f9cbe7a2 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-parameters.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-parameters.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js index b35b25e9f2..c573a47072 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-this-strict-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-this-strict-strict.js index 6c9b6936bf..5477085dbe 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-this-strict-strict.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-this-strict-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) 'use strict'; // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js index 4e46f36162..c985b86afb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js index 51cc7dad9a..d11ad4f14b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js index ffe6e0a944..a9319ec4b2 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/prop-desc.js index bc0ad32e75..3f4098b8a7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js index b18ead0dc0..6b76c97118 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js index 5b1641f81d..406ac6ef97 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js index 842492b522..90c8e943d1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js index 313915e115..748670de1e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/this-is-not-object.js index 8e3cd5e0fb..a0416e1bad 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js index d86c6593a8..38f21ba53d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/callbackfn-resize.js index 49814daf75..cd34b58f24 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/callbackfn-resize.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/callbackfn-resize.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/detached-buffer.js index 953b277879..c17b5a6000 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js index 389ec09afa..cfa812a0b8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/invoked-as-func.js index bec6bb9b56..b5c7345b50 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/invoked-as-method.js index 89ee3f90f7..71cb3de75d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/length.js index 9586c335a5..f6dce29629 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/name.js index 87e4639963..6df3d55193 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/not-a-constructor.js index ec57906ae8..3f08ec6126 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.findLastIndex(() => {}); -}, '`let u8 = new Uint8Array(1); new u8.findLastIndex(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js index d288354edd..881ebec44a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js index 6fd62813ea..03dc1a3e42 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js index 3c82732709..2c89afded1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-strict-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-strict-strict.js index db22a84372..842a570cfb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-strict-strict.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-strict-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) 'use strict'; // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js index 3785ecdac2..9b580e2b45 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js index 9edb72ff2f..7bc92ad6f3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js index 857a521897..28ad969074 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/prop-desc.js index 344ab98b2f..37fa0ce855 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js index e615464938..7c2bf989ab 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js index 52ab6a5cd6..4594f837d8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js index c81fb38cdf..11a2870293 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js index e535075e9b..7735ae6f4f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/this-is-not-object.js index 1dbfc3115f..c6347d6170 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js index cc92b40bec..1b11832d93 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Microsoft. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/arraylength-internal.js index c7e0f770e7..986422ac80 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/arraylength-internal.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/arraylength-internal.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js index eb007e15bb..bd12688aeb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js index adfda0ac0b..90ebff38fd 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js index ce1e7515af..14f490f168 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js index b831382b20..da435af8c7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js index 011ae6dcbe..6fad187137 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js index cdd228a7fa..32707e0f19 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-resize.js index 6a5ba40878..f8e852ac0c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-resize.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-resize.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js index 1d5493d02e..5bd383e578 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js index a8c3a758e9..507fec380c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js index 414ae3d1e6..6cec273bc3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-this.js index 0715e8db66..0cecf426f1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-this.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-this.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/detached-buffer.js index e35a41d5e4..e0a93ccb87 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/invoked-as-func.js index d4846aefc6..d8f645a070 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/invoked-as-method.js index dad90f6f41..9995d92863 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/length.js index b31c55e2de..32b2dffce3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.forEach.length, 1); - -verifyNotEnumerable(TypedArray.prototype.forEach, "length"); -verifyNotWritable(TypedArray.prototype.forEach, "length"); -verifyConfigurable(TypedArray.prototype.forEach, "length"); +verifyProperty(TypedArray.prototype.forEach, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/name.js index 0f492bcbaf..20979d6f67 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.forEach.name, "forEach"); - -verifyNotEnumerable(TypedArray.prototype.forEach, "name"); -verifyNotWritable(TypedArray.prototype.forEach, "name"); -verifyConfigurable(TypedArray.prototype.forEach, "name"); +verifyProperty(TypedArray.prototype.forEach, "name", { + value: "forEach", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/not-a-constructor.js index e966540f48..3e30858a12 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.forEach(() => {}); -}, '`let u8 = new Uint8Array(1); new u8.forEach(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/prop-desc.js index 611f1508a6..1d5efd77ef 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js index 00dc492e14..015aad4762 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/returns-undefined.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/returns-undefined.js index 37a0c81076..88b5c588c5 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/returns-undefined.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/returns-undefined.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/this-is-not-object.js index 8a228dc6c3..999764f3bf 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js index 34677e33e4..1f0c972ea3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/values-are-not-cached.js index 9b1fe0706a..74f5b08f44 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/values-are-not-cached.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/values-are-not-cached.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js index 493f0bc00d..8c707f19f8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js index 43ba9f0629..fbedbc0525 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer.js index 3d8dff1368..d9e1217a7d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js index 4298fc7c08..9f440d7d78 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-infinity.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-infinity.js index d067193aaa..4ba0bb426c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-infinity.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-infinity.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-minus-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-minus-zero.js index 0bb301447f..149ee34f0b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-minus-zero.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-minus-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js index b7a1f870a0..48743ce951 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/index-compared-against-initial-length-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/index-compared-against-initial-length-out-of-bounds.js new file mode 100644 index 0000000000..a589430e35 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/index-compared-against-initial-length-out-of-bounds.js @@ -0,0 +1,54 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.includes +description: > + Index is compared against the initial length when typed array is made out-of-bounds. +info: | + %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 2. Let taRecord be ? ValidateTypedArray(O, seq-cst). + 3. Let len be TypedArrayLength(taRecord). + ... + 5. Let n be ? ToIntegerOrInfinity(fromIndex). + ... + 9. If n ≥ 0, then + a. Let k be n. + ... + 11. Repeat, while k < len, + ... + +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(4, {maxByteLength: 20}); + +// Uses byteOffset to make typed array out-of-bounds when shrinking size to zero. +let byteOffset = 1; + +let ta = new Int8Array(rab, byteOffset); + +let index = { + valueOf() { + // Shrink buffer to zero. + rab.resize(0); + + // Index is larger than the initial length. + return 10; + } +}; + +// Typed array is in-bounds. +assert.sameValue(ta.length, 3); + +let result = ta.includes(undefined, index); + +// Typed array is out-of-bounds. +assert.sameValue(ta.length, 0); + +assert.sameValue(result, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/index-compared-against-initial-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/index-compared-against-initial-length.js new file mode 100644 index 0000000000..572381275e --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/index-compared-against-initial-length.js @@ -0,0 +1,50 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.includes +description: > + Index is compared against the initial length. +info: | + %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 2. Let taRecord be ? ValidateTypedArray(O, seq-cst). + 3. Let len be TypedArrayLength(taRecord). + ... + 5. Let n be ? ToIntegerOrInfinity(fromIndex). + ... + 9. If n ≥ 0, then + a. Let k be n. + ... + 11. Repeat, while k < len, + ... + +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(4, {maxByteLength: 20}); +let ta = new Int8Array(rab); + +let index = { + valueOf() { + // Shrink buffer to zero. + rab.resize(0); + + // Index is larger than the initial length. + return 10; + } +}; + +// Auto-length is correctly tracked. +assert.sameValue(ta.length, 4); + +let result = ta.includes(undefined, index); + +// Auto-length is correctly set to zero. +assert.sameValue(ta.length, 0); + +assert.sameValue(result, false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/invoked-as-func.js index d90cc7b111..bd792357bb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/invoked-as-method.js index 0d138bfa6c..892a20eae3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/length-zero-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/length-zero-returns-false.js index ab59a078d7..505b41f60b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/length-zero-returns-false.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/length-zero-returns-false.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/length.js index 33e7547d6c..bf18d9a8b9 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.includes.length, 1); - -verifyNotEnumerable(TypedArray.prototype.includes, "length"); -verifyNotWritable(TypedArray.prototype.includes, "length"); -verifyConfigurable(TypedArray.prototype.includes, "length"); +verifyProperty(TypedArray.prototype.includes, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/name.js index a76942e846..4876464dc4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.includes.name, "includes"); - -verifyNotEnumerable(TypedArray.prototype.includes, "name"); -verifyNotWritable(TypedArray.prototype.includes, "name"); -verifyConfigurable(TypedArray.prototype.includes, "name"); +verifyProperty(TypedArray.prototype.includes, "name", { + value: "includes", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/not-a-constructor.js index 726d7ec28f..7793b8f45c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.includes(1); -}, '`let u8 = new Uint8Array(1); new u8.includes(1)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/prop-desc.js index 3931bd6be2..7435acc534 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js index 13200e4c27..f495195719 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js index 495c48b1a1..2ae78b4366 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js index ee5c08f7df..aeff01f614 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/samevaluezero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/samevaluezero.js index a7bfc4042d..cde21311ba 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/samevaluezero.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/samevaluezero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/search-found-returns-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/search-found-returns-true.js index 7d2cf925b7..fcaa097e9c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/search-found-returns-true.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/search-found-returns-true.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/search-not-found-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/search-not-found-returns-false.js index f647deebf9..16111c4ea2 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/search-not-found-returns-false.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/search-not-found-returns-false.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/searchelement-not-integer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/searchelement-not-integer.js index 22d65b5c0b..8288c44960 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/searchelement-not-integer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/searchelement-not-integer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Google. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/this-is-not-object.js index ffaadb48fc..c58b4656d6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js index 3a7d86dcd3..7c5085f9d9 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/tointeger-fromindex.js index ad25ab47d7..56987497c9 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/tointeger-fromindex.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/tointeger-fromindex.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js index 7081b55ed5..647bd47a30 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js index 8fff2cbb75..00a9ba2b2e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer.js index 60c374ad87..eedd365925 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js index de345d49a2..ed92338e66 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-infinity.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-infinity.js index 1f75f72769..2c6aba95ee 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-infinity.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-infinity.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js index 6bd0d4b447..33235375c3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js index 04738cec2b..763b6d6497 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-func.js index 84ca275587..d66918e7d5 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-method.js index a0617fd2a2..39b73471d1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js index 37163cf2aa..09d1d8ec3e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length.js index 5c866bebad..3f848204d7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.indexOf.length, 1); - -verifyNotEnumerable(TypedArray.prototype.indexOf, "length"); -verifyNotWritable(TypedArray.prototype.indexOf, "length"); -verifyConfigurable(TypedArray.prototype.indexOf, "length"); +verifyProperty(TypedArray.prototype.indexOf, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/name.js index 54aea8a605..749cd046ba 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.indexOf.name, "indexOf"); - -verifyNotEnumerable(TypedArray.prototype.indexOf, "name"); -verifyNotWritable(TypedArray.prototype.indexOf, "name"); -verifyConfigurable(TypedArray.prototype.indexOf, "name"); +verifyProperty(TypedArray.prototype.indexOf, "name", { + value: "indexOf", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/no-arg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/no-arg.js index 57015f26c9..6854532e9a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/no-arg.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/no-arg.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Alexey Shvayka. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/not-a-constructor.js index 7ada33c348..ae692b54b7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.indexOf(); -}, '`let u8 = new Uint8Array(1); new u8.indexOf()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/prop-desc.js index be05ced431..3af758de03 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js index b77a1e11c1..295844058c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js index 21820e40ae..6f2de66f84 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js index 7789414bdc..9fdb0a8b81 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-found-returns-index.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-found-returns-index.js index 810caadd88..a9bcd5a195 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-found-returns-index.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-found-returns-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js index e270f87c37..c313b3baf0 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/strict-comparison.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/strict-comparison.js index 64e9e774e5..ee0e29633f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/strict-comparison.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/strict-comparison.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-object.js index 9bb19be858..845f485645 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js index 22fff52e60..33016599cf 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/tointeger-fromindex.js index 07f6808fdc..11b3a82c80 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/tointeger-fromindex.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/tointeger-fromindex.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js index 319f85e9c2..87bf1f9d1d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js index 02235e1b35..1a8fb0cd45 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js index 660c1e497d..2f58359eb8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/detached-buffer.js index a78b14a226..8f622b9ed0 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/empty-instance-empty-string.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/empty-instance-empty-string.js index 54e40f5194..4f313db82f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/empty-instance-empty-string.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/empty-instance-empty-string.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js index 95b4bac090..f1e537bed4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/invoked-as-func.js index 035a040719..4c94418800 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/invoked-as-method.js index d57a9cd0b3..71ccf3d9b0 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/length.js index 2ba19e6f94..e9c10e5e8d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.join.length, 1); - -verifyNotEnumerable(TypedArray.prototype.join, "length"); -verifyNotWritable(TypedArray.prototype.join, "length"); -verifyConfigurable(TypedArray.prototype.join, "length"); +verifyProperty(TypedArray.prototype.join, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/name.js index df6cec6248..b2ac1d73a3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.join.name, "join"); - -verifyNotEnumerable(TypedArray.prototype.join, "name"); -verifyNotWritable(TypedArray.prototype.join, "name"); -verifyConfigurable(TypedArray.prototype.join, "name"); +verifyProperty(TypedArray.prototype.join, "name", { + value: "join", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/not-a-constructor.js index 7ab017fbf1..338879aeb8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.join(); -}, '`let u8 = new Uint8Array(1); new u8.join()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/prop-desc.js index c42df0790b..16e0808b53 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js index 9a21ff741a..8582f05ca6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-value.js index 082e482b9f..1e8030a9a3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js index ce5ad17b4b..76994aadad 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-separator.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-separator.js index a530a4714b..2c3a345c96 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-separator.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-separator.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js index 45fe1e5e23..e93b479442 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/separator-tostring-once-after-resized.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/separator-tostring-once-after-resized.js new file mode 100644 index 0000000000..fdae9040c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/separator-tostring-once-after-resized.js @@ -0,0 +1,42 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.join +description: > + ToString is called once when the array is resized. +info: | + %TypedArray%.prototype.join ( separator ) + + ... + 2. Let taRecord be ? ValidateTypedArray(O, seq-cst). + 3. Let len be TypedArrayLength(taRecord). + ... + 5. Else, let sep be ? ToString(separator). + ... + +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let ta = new Int8Array(rab); + +let callCount = 0; + +let index = { + toString() { + callCount++; + rab.resize(0); + return "-"; + } +}; + +assert.sameValue(callCount, 0); + +let r = ta.join(index); + +assert.sameValue(callCount, 1); +assert.sameValue(r, "--"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/this-is-not-object.js index ff4ef67fd1..10bae4ba82 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/this-is-not-typedarray-instance.js index 926c39a97e..16925a33a1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/join/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/detached-buffer.js index 3221123031..a34f87dbbb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/invoked-as-func.js index 130d3c9220..51d4b6973b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/invoked-as-method.js index 15ac944e05..f196c54dd8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/iter-prototype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/iter-prototype.js index 427367bb4e..12c3177602 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/iter-prototype.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/iter-prototype.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/length.js index 73abbf3fb9..ad16aab4d0 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.keys.length, 0); - -verifyNotEnumerable(TypedArray.prototype.keys, "length"); -verifyNotWritable(TypedArray.prototype.keys, "length"); -verifyConfigurable(TypedArray.prototype.keys, "length"); +verifyProperty(TypedArray.prototype.keys, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/name.js index f0f097382f..3a281d9db9 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.keys.name, "keys"); - -verifyNotEnumerable(TypedArray.prototype.keys, "name"); -verifyNotWritable(TypedArray.prototype.keys, "name"); -verifyConfigurable(TypedArray.prototype.keys, "name"); +verifyProperty(TypedArray.prototype.keys, "name", { + value: "keys", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/not-a-constructor.js index a5475acf51..bd739ca6dc 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.keys(); -}, '`let u8 = new Uint8Array(1); new u8.keys()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/prop-desc.js index 8e2f483c11..b64107a7c2 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js index e0fc4129ce..eb46c02f35 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/return-itor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/return-itor.js index 5f06a7de97..90a0fbf336 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/return-itor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/return-itor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/this-is-not-object.js index 57d767940d..71109097e5 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js index d2c1ecfea8..0027859d57 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js index d950512ac3..aa833e701e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js index 6d4460d294..36c1764fe6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer.js index 65a6620143..d5232d412f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js index 0ed0db309b..8b6e3e206e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js index 8a7658c44c..cb2fc1f2de 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js index 3c20d9e937..ffa887b18c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/invoked-as-func.js index d5808cc179..d28669e60d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/invoked-as-method.js index a79f2a2de6..f3affc27aa 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js index 722e7cb618..f2573e9b66 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/length.js index 4361948ea9..019317f291 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.lastIndexOf.length, 1); - -verifyNotEnumerable(TypedArray.prototype.lastIndexOf, "length"); -verifyNotWritable(TypedArray.prototype.lastIndexOf, "length"); -verifyConfigurable(TypedArray.prototype.lastIndexOf, "length"); +verifyProperty(TypedArray.prototype.lastIndexOf, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/name.js index 392c531592..1b84c2d33f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.lastIndexOf.name, "lastIndexOf"); - -verifyNotEnumerable(TypedArray.prototype.lastIndexOf, "name"); -verifyNotWritable(TypedArray.prototype.lastIndexOf, "name"); -verifyConfigurable(TypedArray.prototype.lastIndexOf, "name"); +verifyProperty(TypedArray.prototype.lastIndexOf, "name", { + value: "lastIndexOf", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/no-arg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/no-arg.js index 850f393c60..89ca5f75f7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/no-arg.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/no-arg.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Alexey Shvayka. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/not-a-constructor.js index 7bd22e16b3..2329b45b8d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.lastIndexOf(); -}, '`let u8 = new Uint8Array(1); new u8.lastIndexOf()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/prop-desc.js index 50422e3001..9ed38b05aa 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js index 61d9dcefdf..859dc2981d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js index f5a7b107dc..6dfe282e21 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js index 621460a5b8..fc36d939eb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js index 439473494a..8af41744d3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js index ea611e2f89..83e504d26b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/strict-comparison.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/strict-comparison.js index 09c3da772d..03ea78e35e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/strict-comparison.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/strict-comparison.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-object.js index b393b8925d..e508e4fba8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js index 2972430535..388bf428c8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js index 77465b511e..12e178db84 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/detached-buffer.js index 4f34f05a30..96ce2563bf 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/length/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/invoked-as-accessor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/invoked-as-accessor.js index b1856a3872..32b4307676 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/length/invoked-as-accessor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/invoked-as-accessor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/invoked-as-func.js index 73bfed75a1..317a2e4b73 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/length/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/length.js index bb6d86ba78..63afefa088 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/length/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -25,10 +26,11 @@ features: [TypedArray] var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "length"); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/name.js index d5ff3cfc37..cd3d1281fb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/length/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -22,10 +23,11 @@ features: [TypedArray] var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "length"); -assert.sameValue(desc.get.name, "get length"); - -verifyNotEnumerable(desc.get, "name"); -verifyNotWritable(desc.get, "name"); -verifyConfigurable(desc.get, "name"); +verifyProperty(desc.get, "name", { + value: "get length", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/prop-desc.js index 4dd62e29bc..c45dcf4172 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/length/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/resizable-array-buffer-auto.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/resizable-array-buffer-auto.js index 0e84da9467..ac17074953 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/length/resizable-array-buffer-auto.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/resizable-array-buffer-auto.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/resizable-array-buffer-fixed.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/resizable-array-buffer-fixed.js index 0616f26dc2..187bd6e513 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/length/resizable-array-buffer-fixed.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/resizable-array-buffer-fixed.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/return-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/return-length.js index 56c987fdf3..e6961f900f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/length/return-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/return-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js index 25effb5786..3d827d6049 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/this-is-not-object.js index 56d3e96207..16d5f7aa93 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/length/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/arraylength-internal.js index 4d50955331..7f9b40163b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/arraylength-internal.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/arraylength-internal.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js index dd2f599d91..44cb4d6364 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js index 14e593c926..bb9d1c483d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-detachbuffer.js index cead041854..68b24a4831 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-detachbuffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-detachbuffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-is-not-callable.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-is-not-callable.js index c6ca42907e..8fb62b1259 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-is-not-callable.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-is-not-callable.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js index 4bbceeac78..2b12c19f6a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js index d2c14b4635..eebbbae64e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-resize.js index ff96ec113c..cbcb364ef7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-resize.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-resize.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js index 8627c187a3..3d0cd4f646 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js index a386d40389..d4d8072aa7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js index 228d5fca0b..530ef6efff 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-returns-abrupt.js index 1849feee03..d455284ad0 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-returns-abrupt.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-returns-abrupt.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js index 3367d09ed7..4d1ea405ba 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-this.js index f32ca0efa0..1494a6573f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-this.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-this.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/detached-buffer.js index 91ae25122b..c74d339bdd 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/invoked-as-func.js index 390cc0f907..443d9589b8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/invoked-as-method.js index 412ec13842..0079e106eb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/length.js index 005f678a2a..79ebbbd7bf 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.map.length, 1); - -verifyNotEnumerable(TypedArray.prototype.map, "length"); -verifyNotWritable(TypedArray.prototype.map, "length"); -verifyConfigurable(TypedArray.prototype.map, "length"); +verifyProperty(TypedArray.prototype.map, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/name.js index 318e83fc91..8a18b0cefb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.map.name, "map"); - -verifyNotEnumerable(TypedArray.prototype.map, "name"); -verifyNotWritable(TypedArray.prototype.map, "name"); -verifyConfigurable(TypedArray.prototype.map, "name"); +verifyProperty(TypedArray.prototype.map, "name", { + value: "map", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/not-a-constructor.js index c4f000f14d..9898a6edc0 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.map(() => {}); -}, '`let u8 = new Uint8Array(1); new u8.map(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/prop-desc.js index 4aff20321f..55f46ae5ab 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js index 4fbbd4c34d..fecf11cd89 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js index 22f12111a8..ded4b2ef29 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js index 95607e6bf6..9ab4c3185e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js index caf14ee0e7..ec6eafc32b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js index 781e95ed79..95e2d0a683 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-destination-resizable.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-destination-resizable.js index 62758220ae..0b9ea40c5e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-destination-resizable.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-destination-resizable.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2023 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js index 8cb024e74f..1477a37a30 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Peter Wong. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js index 69461a29bc..dd09bca26d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Peter Wong. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js index 5f2498a20b..ccc9bf307e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Peter Wong. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor.js index 867e80d95e..2b77c8d909 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Peter Wong. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js index e13dc1fa89..2bc8ec6347 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Peter Wong. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js index 31f2b4e2c1..ffb37ec15c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Peter Wong. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index 104d2cd93e..055bd3e256 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2023 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js index cfee782837..b9309ac581 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Peter Wong. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js index adaf755194..51c6aa21ed 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Peter Wong. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js index 5891ee6291..40f27793f3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Peter Wong. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js index cc914eb35c..87ca2491a3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Peter Wong. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js index cc5cd4a718..c35d7d8fd7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Peter Wong. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js index 7c2d50f58a..0ae7c9fd94 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Peter Wong. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js index 1f69a5f099..f32d898d15 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Peter Wong. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species.js index ebb6be8c28..5bf51e9f75 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Peter Wong. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/this-is-not-object.js index 5ffe12583d..ebebab845e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/this-is-not-typedarray-instance.js index 214354fa23..0ee9b0ff3e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/values-are-not-cached.js index b65af8329f..48b39cd1ff 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/map/values-are-not-cached.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/values-are-not-cached.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js index c94056f7af..e713712489 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js index da27455283..5d8e0b2e41 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js index a9e4cc7cdc..cb9bf6842f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js index b604544757..ae65c9a34d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js index d7dca0aa6b..93a1af9249 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js index 775ccc995b..3b7d848711 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-resize.js index e304b7bb12..30ef850ece 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-resize.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-resize.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js index 6c08f0cb18..b8f2490d8e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js index 5999871cca..a020b0b3f8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js index 8fd43bad16..8e473eca13 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-this.js index 9bec756c34..166db799d9 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-this.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-this.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/detached-buffer.js index 77ef5a447f..dd8cc05ab7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js index 49863aad95..dfc19e1064 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js index 9924f89ae2..0298b7eff2 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js index 301955fc2d..d05a0b7730 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/invoked-as-func.js index fd0a92b827..f135afe2eb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/invoked-as-method.js index cb355bdbbc..3f2cd1af74 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/length.js index 8c3e198e11..01c44e5d2c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.reduce.length, 1); - -verifyNotEnumerable(TypedArray.prototype.reduce, "length"); -verifyNotWritable(TypedArray.prototype.reduce, "length"); -verifyConfigurable(TypedArray.prototype.reduce, "length"); +verifyProperty(TypedArray.prototype.reduce, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/name.js index 0daed85804..a013352ef3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.reduce.name, "reduce"); - -verifyNotEnumerable(TypedArray.prototype.reduce, "name"); -verifyNotWritable(TypedArray.prototype.reduce, "name"); -verifyConfigurable(TypedArray.prototype.reduce, "name"); +verifyProperty(TypedArray.prototype.reduce, "name", { + value: "reduce", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/not-a-constructor.js index 4cc53d856d..d71c7f7004 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.reduce(() => {}, []); -}, '`let u8 = new Uint8Array(1); new u8.reduce(() => {}, [])` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/prop-desc.js index ace3661a03..174516fcf3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js index 12b86326a6..2723495a89 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/result-of-any-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/result-of-any-type.js index 2950251b61..45e746818e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/result-of-any-type.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/result-of-any-type.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js index a2d9eaf1f8..7e58dcdfbb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js index 2b591cfd84..370ef10b0d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/this-is-not-object.js index baee34b2c7..2506ecabe1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js index a1d606915e..031c1f816a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/values-are-not-cached.js index dcc9f8567a..ba8339edb0 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/values-are-not-cached.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/values-are-not-cached.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js index 4d4bc07f7b..43b869e144 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js index 980cac7ae0..542442f7a7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js index 48cc0be33c..90423d0a1e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js index 8de1268a44..0272f021ae 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js index dcf8d628e8..b297cfa77e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js index cd881b9b72..939b4b9105 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-resize.js index 74ae23ee61..c8fe0f62c5 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-resize.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-resize.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js index 7a9e8244d3..e42b59cba7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js index e37d426ce8..aac2d110ef 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js index 3381fc34e1..21838fbb41 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-this.js index bc62313fbe..c7a659a020 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-this.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-this.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/detached-buffer.js index 703125d148..345c1ffdd1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js index eb3a4f12bb..119f4bb7ce 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js index e65a06ee40..09c3134bb1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js index 63d2ba2c75..16fde19f30 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/invoked-as-func.js index 0dd4b313ee..407d5f5118 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/invoked-as-method.js index 74f48b50d6..a057b7eec5 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/length.js index 075fdf1d6a..cacb72bec9 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.reduceRight.length, 1); - -verifyNotEnumerable(TypedArray.prototype.reduceRight, "length"); -verifyNotWritable(TypedArray.prototype.reduceRight, "length"); -verifyConfigurable(TypedArray.prototype.reduceRight, "length"); +verifyProperty(TypedArray.prototype.reduceRight, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/name.js index 46b5b553bc..b63e7b5623 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.reduceRight.name, "reduceRight"); - -verifyNotEnumerable(TypedArray.prototype.reduceRight, "name"); -verifyNotWritable(TypedArray.prototype.reduceRight, "name"); -verifyConfigurable(TypedArray.prototype.reduceRight, "name"); +verifyProperty(TypedArray.prototype.reduceRight, "name", { + value: "reduceRight", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/not-a-constructor.js index a208f6e644..6437833a36 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.reduceRight(() => {}, []); -}, '`let u8 = new Uint8Array(1); new u8.reduceRight(() => {}, [])` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/prop-desc.js index b3e98bf99d..97c1ac450d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js index cdac8406de..ef58f68bcb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/result-of-any-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/result-of-any-type.js index 24e3da9059..fca21923f1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/result-of-any-type.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/result-of-any-type.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js index 0a842133bf..39c9ed455e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js index ec61d34c4d..ba275a1e6a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/this-is-not-object.js index 64730d4df4..e8f2b9fd96 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js index f55fd60dc2..3d6778c0e9 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/values-are-not-cached.js index 55afeef5d1..fc6c5b53da 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/values-are-not-cached.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/values-are-not-cached.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/detached-buffer.js index 896082d81c..46650fc6e8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js index 5cead93847..908e458beb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/invoked-as-func.js index 370572c694..ede66061bc 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/invoked-as-method.js index 90f2791edd..33749b4ebe 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/length.js index b0387a8bc5..d223455250 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.reverse.length, 0); - -verifyNotEnumerable(TypedArray.prototype.reverse, "length"); -verifyNotWritable(TypedArray.prototype.reverse, "length"); -verifyConfigurable(TypedArray.prototype.reverse, "length"); +verifyProperty(TypedArray.prototype.reverse, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/name.js index 0d39739566..25397ad00e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.reverse.name, "reverse"); - -verifyNotEnumerable(TypedArray.prototype.reverse, "name"); -verifyNotWritable(TypedArray.prototype.reverse, "name"); -verifyConfigurable(TypedArray.prototype.reverse, "name"); +verifyProperty(TypedArray.prototype.reverse, "name", { + value: "reverse", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/not-a-constructor.js index 0a0bd3b968..0d05171789 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.reverse(); -}, '`let u8 = new Uint8Array(1); new u8.reverse()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js index 3d04d8a0ac..73b64497ab 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/prop-desc.js index caba22fd33..a15e3f18b1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js index 5b9396d94a..3e8fa96124 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/returns-original-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/returns-original-object.js index 732dd0d193..fd7674a414 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/returns-original-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/returns-original-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/reverts.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/reverts.js index 8f476a8201..3cd9a7701e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/reverts.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/reverts.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/this-is-not-object.js index aed6161e54..c2d3e3c605 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js index f5e662b567..fbdabdab08 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js index 9250e0d7fc..6ce4b45e62 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Valerie Young. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js index a181191cc9..27a1447599 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-offset-tointeger.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-offset-tointeger.js index dbf9ca1d3f..0f2dcdbeee 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-offset-tointeger.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-offset-tointeger.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-primitive-toobject.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-primitive-toobject.js index ed577e2012..5df469270f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-primitive-toobject.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-primitive-toobject.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Alexey Shvayka. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js index cfbf10dbea..dbc0539d0c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js index bec35b327b..9eff93eea3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js index 07c226e5b7..a7007a5bbc 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js index c046c5c12d..7254363942 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js index ef71d78dd0..1eb3aa9faf 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js index 79a87c36b3..c72e58a113 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js index ae70c2693e..1c305d6207 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js index a2afd09f7e..d827b90c2a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js index f479186b51..e8fa063ae4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-set-values-in-order.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-set-values-in-order.js index e74106d4c7..47cd8200d6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-set-values-in-order.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-set-values-in-order.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-set-values.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-set-values.js index 4a5c4acb8a..4e45f5fae6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-set-values.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-set-values.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js index fe4bef4fe0..470feb0023 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js index 135588343b..a6f0960989 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js index b2440a89db..77c0db808f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js index 8992c3eb34..6f9fad2406 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js index e67af3acb5..7b6f4b26e4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2022 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js index 8cf8a6ffb2..f50a44cad7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js index aaf0b2ef01..65aa725309 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/bit-precision.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/bit-precision.js index dd56f5e98a..4a9f581845 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/bit-precision.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/bit-precision.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/invoked-as-func.js index 3201477ce0..becdb75f8f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/invoked-as-method.js index 9636b4a1de..934436b77e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/length.js index 83ece00244..63ec5e80f3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.set.length, 1); - -verifyNotEnumerable(TypedArray.prototype.set, "length"); -verifyNotWritable(TypedArray.prototype.set, "length"); -verifyConfigurable(TypedArray.prototype.set, "length"); +verifyProperty(TypedArray.prototype.set, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/name.js index cdaf0d8382..d5ba537807 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.set.name, "set"); - -verifyNotEnumerable(TypedArray.prototype.set, "name"); -verifyNotWritable(TypedArray.prototype.set, "name"); -verifyConfigurable(TypedArray.prototype.set, "name"); +verifyProperty(TypedArray.prototype.set, "name", { + value: "set", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/not-a-constructor.js index 818ea73dbd..2c4c819538 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.set([0], 0); -}, '`let u8 = new Uint8Array(1); new u8.set([0], 0)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/prop-desc.js index 6c78673324..45a356c6ad 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/src-typedarray-big-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/src-typedarray-big-throws.js index bd388c9953..b445b7954b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/src-typedarray-big-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/src-typedarray-big-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Valerie Young. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/this-is-not-object.js index d8b62e11a2..bbdd923131 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/this-is-not-typedarray-instance.js index fdac8e08cd..a5a3282935 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js index 26a9ef1064..5a6d22b17a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js index e4c73580bb..c88e6a9ba2 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js index 5672695847..7d78c38e6d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js index a5f8f15186..75eecdf7cc 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js index b2eb05f8af..4a9af6f239 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js index 8b6f0655ea..71bd008f89 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js index 3e289e32ae..d4999b33ef 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js index 75dca6862e..9c90262437 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js index c7e109ba8d..84d8517305 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js index 1990f48b7d..91512af5d1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js index d5af3ec6ec..69d0ee1866 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js index c50f9a9606..d671a99b94 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js index 40cf0eecb5..606fce0b2d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js index 25a20358b0..ffda7dd684 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js index 29e8a8ca3a..16b8d2dfd6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js index 0d9d251568..aee12428ad 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js index 4a4af2c71d..9c10fb34f9 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js index a43d522c01..64dd408966 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js index ae3ef5b834..e198167d2f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js index 9e852856ec..30e36763e6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js index bb7cbe0ad2..29f6975cfa 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js index 521772dfff..dcbb6d2802 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/arraylength-internal.js index 6a7431fdd4..3e840736bd 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/arraylength-internal.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/arraylength-internal.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/bit-precision.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/bit-precision.js index e68a251a91..69b7388c13 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/bit-precision.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/bit-precision.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js index 98e67832dd..23a88fe065 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js index cff4bdfe80..760d806878 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-get-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-get-ctor.js index def685a2d6..82816b136e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-get-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-get-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js index bc4ddecd6e..299eecc959 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js index df223edad8..1c40898844 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js index d6e018010a..a1d1dad8f5 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer.js index f89105dfce..909bb02529 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/infinity.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/infinity.js index 4d4e53a76f..0bfa40656b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/infinity.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/infinity.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/invoked-as-func.js index c41db512d4..1f62b2ba24 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/invoked-as-method.js index abbf41b1bb..538b2c7917 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/length.js index b4dc6292c2..90f5209830 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.slice.length, 2); - -verifyNotEnumerable(TypedArray.prototype.slice, "length"); -verifyNotWritable(TypedArray.prototype.slice, "length"); -verifyConfigurable(TypedArray.prototype.slice, "length"); +verifyProperty(TypedArray.prototype.slice, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/minus-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/minus-zero.js index cec3ea1260..206449af2a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/minus-zero.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/minus-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/name.js index 0065064c4f..1378804fb3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.slice.name, "slice"); - -verifyNotEnumerable(TypedArray.prototype.slice, "name"); -verifyNotWritable(TypedArray.prototype.slice, "name"); -verifyConfigurable(TypedArray.prototype.slice, "name"); +verifyProperty(TypedArray.prototype.slice, "name", { + value: "slice", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/not-a-constructor.js index c22277eea3..6b9bdc917e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.slice(); -}, '`let u8 = new Uint8Array(1); new u8.slice()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/prop-desc.js index 7866448d95..8e43962613 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js index ca5360e87e..8d3f888705 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-different-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-different-length.js index 21507d93fd..8a8ccbd0c1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-different-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-different-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-empty-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-empty-length.js index 2b0610a11e..e88fbe122c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-empty-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-empty-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-same-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-same-length.js index 2d9cb4ac26..42580f4acd 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-same-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-same-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js index 2d73a65949..39e89edaff 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-end.js index a0c21bf198..97e953b951 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-end.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-end.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js index 5e87198742..796d4c7ebc 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-start.js index 5c9aa7c2d4..b0ae21e426 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-start.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-start.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js index 84d4e25bcf..7f3d216b3d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js index f9ad9584bd..24fd3ff83a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-destination-resizable.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-destination-resizable.js index 8b2674b9f8..9e44870815 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-destination-resizable.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-destination-resizable.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2023 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js index dcf690fb8f..c673ed7021 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js index 66551be445..04c1f7dbca 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js index 6bb0dec7be..a4e5da18bd 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor.js index 91abb251a5..a750ade08e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js index c5e87d9908..34b90cd52e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js index ec10f87cec..80a961a3f4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index f76bc4dbad..dc235605f3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2023 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js index c8544e8c00..627482dc82 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js index 8b8f45205c..604bd75b30 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js index fb5bf37410..cecd96365d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js index 840a42a507..98d9d5082c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js index 653a5aa24a..5b8c3c6097 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js index c7a8bba242..f98827b433 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js index b50e582639..d80df4a0e1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species.js index 0fd855cefd..1377135990 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/this-is-not-object.js index f47390fd8a..effe081914 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js index 8844744c09..c9a146572f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/tointeger-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/tointeger-end.js index ef3e1975d8..3651207b73 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/tointeger-end.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/tointeger-end.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/tointeger-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/tointeger-start.js index 3ebf4087aa..4e82a93114 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/tointeger-start.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/tointeger-start.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js index d33d176b86..cede559699 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js index ee882504fa..323daa434d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-detachbuffer.js index 101a1b8f27..fc2c84a8cd 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-detachbuffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-detachbuffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js index 2b72c24ac2..4db26c7f35 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-not-callable-throws.js index 550476faf9..566d7502a8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-not-callable-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-not-callable-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js index 912e8bb1de..a00f82b7e4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-resize.js index 1affd3f4b2..d678030267 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-resize.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-resize.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js index 3b63658139..a76efd1366 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-returns-abrupt.js index 5aea9d38df..8034e83b10 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-returns-abrupt.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-returns-abrupt.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js index 74935314b5..80dfca903b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-this.js index fa1d572adb..028ce99f2b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-this.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-this.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/detached-buffer.js index 45765bd6d2..a582eb2d28 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js index 28f970779f..d81174babf 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/invoked-as-func.js index 9041ac22aa..1cc7d9ab46 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/invoked-as-method.js index ae1b089198..b5ad9a2ead 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/length.js index c610a9f8a8..c80d6bb556 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.some.length, 1); - -verifyNotEnumerable(TypedArray.prototype.some, "length"); -verifyNotWritable(TypedArray.prototype.some, "length"); -verifyConfigurable(TypedArray.prototype.some, "length"); +verifyProperty(TypedArray.prototype.some, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/name.js index 93e47d5de1..e1b549dcca 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.some.name, "some"); - -verifyNotEnumerable(TypedArray.prototype.some, "name"); -verifyNotWritable(TypedArray.prototype.some, "name"); -verifyConfigurable(TypedArray.prototype.some, "name"); +verifyProperty(TypedArray.prototype.some, "name", { + value: "some", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/not-a-constructor.js index 99efaa7776..1834bf0554 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.some(() => {}); -}, '`let u8 = new Uint8Array(1); new u8.some(() => {})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/prop-desc.js index 41d68a78bc..4211e0adfe 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js index e18d7020e8..9da1d57834 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js index 1cd998f2b5..bb5bad5965 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js index 7a8c8100b2..0927c497db 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/this-is-not-object.js index 408ac5ff28..6e5c7b5eb4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/this-is-not-typedarray-instance.js index 08b3c3b6ed..640b38b504 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/values-are-not-cached.js index 068ba9f1a1..23551a549b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/some/values-are-not-cached.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/values-are-not-cached.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/arraylength-internal.js index b11284fb67..bedc736b95 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/arraylength-internal.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/arraylength-internal.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-call-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-call-throws.js index 4ec5160af3..abd5025428 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-call-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-call-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-calls.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-calls.js index 53c60777d9..9d79cd1891 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-calls.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-calls.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-is-undefined.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-is-undefined.js index f63e734f2d..029528b6db 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-is-undefined.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-is-undefined.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js index 8bbdd3bce0..cc87ace424 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2017 Jordan Harband. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/detached-buffer.js index cb25eab0dd..2ff62a3bdf 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/invoked-as-func.js index 582fe56c42..ca07ff6784 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/invoked-as-method.js index 50f84f46dd..7f13209cbd 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/length.js index bb8480eaa4..51b5c0b1dc 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.sort.length, 1); - -verifyNotEnumerable(TypedArray.prototype.sort, "length"); -verifyNotWritable(TypedArray.prototype.sort, "length"); -verifyConfigurable(TypedArray.prototype.sort, "length"); +verifyProperty(TypedArray.prototype.sort, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/name.js index 347586ddce..c1d68121d9 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.sort.name, "sort"); - -verifyNotEnumerable(TypedArray.prototype.sort, "name"); -verifyNotWritable(TypedArray.prototype.sort, "name"); -verifyConfigurable(TypedArray.prototype.sort, "name"); +verifyProperty(TypedArray.prototype.sort, "name", { + value: "sort", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/not-a-constructor.js index 4814d4a7df..fb5196097a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.sort(); -}, '`let u8 = new Uint8Array(1); new u8.sort()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/prop-desc.js index 8d0d2d273b..80c539ac16 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js index acd949c90d..89615c6722 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/return-same-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/return-same-instance.js index ad1283c0f5..108d166c19 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/return-same-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/return-same-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sort-tonumber.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sort-tonumber.js index dcc99bc87c..b24bfc96e4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sort-tonumber.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sort-tonumber.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js index 82c8d16ad2..53b60393cc 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sorted-values-nan.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sorted-values-nan.js index 2a6ff72aab..a74c18e592 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sorted-values-nan.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sorted-values-nan.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sorted-values.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sorted-values.js index 459c40a13d..4303d47897 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sorted-values.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sorted-values.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/stability.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/stability.js index 3a904f9f02..5c000d3953 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/stability.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/stability.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2019 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/this-is-not-object.js index 0331551ca8..f0e7be7a9a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js index 8dfac62ce6..26c7513eca 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/detached-buffer.js index c65f6efff6..1d2dc2c484 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/infinity.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/infinity.js index 283689ecea..1bef2b4196 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/infinity.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/infinity.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/invoked-as-func.js index 7bd0688838..bb5d1c4ed7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/invoked-as-method.js index c5c39eb9e3..9496616c45 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/length.js index 7c29e2ff6b..dc5fe0bcfc 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.subarray.length, 2); - -verifyNotEnumerable(TypedArray.prototype.subarray, "length"); -verifyNotWritable(TypedArray.prototype.subarray, "length"); -verifyConfigurable(TypedArray.prototype.subarray, "length"); +verifyProperty(TypedArray.prototype.subarray, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/minus-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/minus-zero.js index 8c77ef6dd2..444d9a204d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/minus-zero.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/minus-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/name.js index 890fd6c7ce..d68577f8c7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.subarray.name, "subarray"); - -verifyNotEnumerable(TypedArray.prototype.subarray, "name"); -verifyNotWritable(TypedArray.prototype.subarray, "name"); -verifyConfigurable(TypedArray.prototype.subarray, "name"); +verifyProperty(TypedArray.prototype.subarray, "name", { + value: "subarray", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/not-a-constructor.js index 1714a12b2a..db549cbc9d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.subarray(); -}, '`let u8 = new Uint8Array(1); new u8.subarray()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/prop-desc.js index e21769abed..b774846318 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-byteOffset-from-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-byteOffset-from-out-of-bounds.js new file mode 100644 index 0000000000..f7d1214d8f --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-byteOffset-from-out-of-bounds.js @@ -0,0 +1,52 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Result has the correct byteOffset when input is initially out-of-bounds. +info: | + %TypedArray%.prototype.subarray ( start, end ) + + ... + 13. Let srcByteOffset be O.[[ByteOffset]]. + 14. Let beginByteOffset be srcByteOffset + (startIndex × elementSize). + 15. If O.[[ArrayLength]] is auto and end is undefined, then + a. Let argumentsList be « buffer, 𝔽(beginByteOffset) ». + 16. + ... + e. Let newLength be max(endIndex - startIndex, 0). + f. Let argumentsList be « buffer, 𝔽(beginByteOffset), 𝔽(newLength) ». + 17. Return ? TypedArraySpeciesCreate(O, argumentsList). +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(10, {maxByteLength: 10}); + +let autoLength = new Int8Array(rab, 4); +let withLength = new Int8Array(rab, 4, 2); + +let start = { + valueOf() { + // Make |autoLength| and |withLength| in-bounds again. + rab.resize(10); + return 1; + } +}; + +// Make |autoLength| out-of-bounds. +rab.resize(0); + +let resultAutoLength = autoLength.subarray(start); +assert.sameValue(resultAutoLength.byteOffset, 4); +assert.sameValue(resultAutoLength.length, 6); + +// Make |withLength| out-of-bounds. +rab.resize(0); + +let resultWithLength = withLength.subarray(start); +assert.sameValue(resultWithLength.byteOffset, 4); +assert.sameValue(resultWithLength.length, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js index 6bd16f4c9b..dff7641edd 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js index 48d9a3b490..ea68f2309d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js index 223703aaa4..8596786801 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-different-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-different-length.js index 3445ae36be..d16251bd26 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-different-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-different-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-empty-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-empty-length.js index 204effe618..d26583ee0a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-empty-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-empty-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-same-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-same-length.js index 614ad244ed..520adfc6b9 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-same-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-same-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js index 650627c289..4644cf09d6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin.js index 9f8f28630b..6ad924f229 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js index 0e64f4ed39..d90ab8a2ef 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end.js index 3ab6a1c68c..f53845eebc 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js index c141c84747..832141e2bd 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js index b09d8759c5..771d7a1f9f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js index 7b96f3041c..f64303eeb8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor.js index a14d069528..07f5995040 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js index 7e40dbe686..1a4e4e5f72 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js index 1590a0c45b..77dc50a3bf 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js index f86ed913db..7193e2ef82 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js index 5e3d0d7be7..9a93ebc9e9 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js index 46e69712ee..6d490ad24e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js index 01411d313c..1d756ebe46 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js index cb21cd8f3c..97994233bb 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species.js index 26bae75f03..295e2f51ca 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/this-is-not-object.js index e8aca60f7b..0a314533e8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js index da35e935f1..698b07da72 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/tointeger-begin.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/tointeger-begin.js index de48a3d1a6..445a7daa7c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/tointeger-begin.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/tointeger-begin.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/tointeger-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/tointeger-end.js index a45c5258da..31c6d2d04a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/tointeger-end.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/tointeger-end.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js index 7cbb2cb39a..e8ad0a1010 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js index 585035169e..5075e32d17 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js index 379470d105..3e8a0aee6c 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/detached-buffer.js index df5d1a5a8c..bfb1552154 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js index fb9690e4eb..08321c7ebd 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js index 910b72a391..1e8ac66692 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/invoked-as-func.js index 50b138d41b..aa91b99950 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/invoked-as-method.js index da9ce62df8..27cad0672f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/length.js index fcd30d3ec8..1769ea0b70 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.toLocaleString.length, 0); - -verifyNotEnumerable(TypedArray.prototype.toLocaleString, "length"); -verifyNotWritable(TypedArray.prototype.toLocaleString, "length"); -verifyConfigurable(TypedArray.prototype.toLocaleString, "length"); +verifyProperty(TypedArray.prototype.toLocaleString, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/name.js index b793dd388b..fcace09fbe 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.toLocaleString.name, "toLocaleString"); - -verifyNotEnumerable(TypedArray.prototype.toLocaleString, "name"); -verifyNotWritable(TypedArray.prototype.toLocaleString, "name"); -verifyConfigurable(TypedArray.prototype.toLocaleString, "name"); +verifyProperty(TypedArray.prototype.toLocaleString, "name", { + value: "toLocaleString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/not-a-constructor.js index 3366ceacde..43f6f01e8e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.toLocaleString(); -}, '`let u8 = new Uint8Array(1); new u8.toLocaleString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/prop-desc.js index e4d7516476..b2047d7b2d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js index 9114df1a13..5be853baa4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js index 05095bd645..73ff05af24 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js index 690e9c32e6..26091b52ca 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js index f46d410a13..2c53e6a04d 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js index 7b3f2d68ba..3cc0c245a6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js index acc8eca436..325707fec0 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js index bb1e1efc42..0fcab21960 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-result.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-result.js index 60cd013f90..e597817d5e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-result.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-result.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/this-is-not-object.js index 2c471f761e..2c7b869124 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js index b3c33fc0c2..4393449b20 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/ignores-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/ignores-species.js index 9534b8b924..050df4a650 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/ignores-species.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/ignores-species.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/immutable.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/immutable.js index 929f4fb310..195388b573 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/immutable.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/immutable.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js index 15b32a1d70..49d11c8176 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/length.js index 07c690084a..7619516c27 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/name.js index 803d016bf2..2593288cca 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js index f3fd60c4f6..e79f58dc33 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js index 96220d36bd..1d424d39b6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { new TypedArray.prototype.toReversed(); -}, '`new TypedArray.prototype.toReversed()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js index 119df147a5..5122e2a068 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js index 1ff4bbfe9c..836a621e4a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js index 61894ca9fe..32a6636ca3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/ignores-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/ignores-species.js index bdd4fa92e8..d46211ef26 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/ignores-species.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/ignores-species.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/immutable.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/immutable.js index 7fb76e65f5..560ce2f6f1 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/immutable.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/immutable.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js index 977e74b9c5..2bf10fd5a8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/length.js index 20e9f3d35b..aa5b3370ee 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/name.js index 644f27593f..b0f701e4c5 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js index 54588af0d5..c9b3ce78f2 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js index be40246fa1..a8ae472d34 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { new TypedArray.prototype.toSorted(); -}, '`new TypedArray.prototype.toSorted()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js index 47cdf3627a..78e4ef4558 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toString.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toString.js index 5b19a806fc..162aa90e50 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toString.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toString.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toString/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/detached-buffer.js index 427bf7fcf6..b63f504117 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toString/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/not-a-constructor.js index 745ac903df..f7c2008fd0 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/toString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.toString(); -}, '`let u8 = new Uint8Array(1); new u8.toString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/detached-buffer.js index 732b108995..765b75eb7e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/values/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/invoked-as-func.js index 6baf62480c..397d109a75 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/values/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/invoked-as-method.js index 9b2e7689f7..29dbcaf63b 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/values/invoked-as-method.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/invoked-as-method.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/iter-prototype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/iter-prototype.js index 2ebe86343d..93a4e31383 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/values/iter-prototype.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/iter-prototype.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/length.js index 11e022a134..a3a03837b3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/values/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -23,10 +24,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.values.length, 0); - -verifyNotEnumerable(TypedArray.prototype.values, "length"); -verifyNotWritable(TypedArray.prototype.values, "length"); -verifyConfigurable(TypedArray.prototype.values, "length"); +verifyProperty(TypedArray.prototype.values, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/make-in-bounds-after-exhausted.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/make-in-bounds-after-exhausted.js new file mode 100644 index 0000000000..c567885f18 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/make-in-bounds-after-exhausted.js @@ -0,0 +1,58 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.values +description: > + Iterator is still exhausted when typedarray is changed to in-bounds. +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let ta = new Int8Array(rab); + +// Ensure the TypedArray is correctly initialised. +assert.sameValue(ta.length, 3); +assert.sameValue(ta.byteOffset, 0); + +ta[0] = 11; +ta[1] = 22; +ta[2] = 33; + +let it = ta.values(); +let r; + +// Fetch the first value. +r = it.next(); +assert.sameValue(r.done, false); +assert.sameValue(r.value, 11); + +// Resize buffer to zero. +rab.resize(0); + +// TypedArray is now out-of-bounds. +assert.sameValue(ta.length, 0); +assert.sameValue(ta.byteOffset, 0); + +// Resize buffer to zero. +rab.resize(0); + +// Attempt to fetch the next value. This exhausts the iterator. +r = it.next(); +assert.sameValue(r.done, true); +assert.sameValue(r.value, undefined); + +// Resize buffer so the typed array is again in-bounds. +rab.resize(5); + +// TypedArray is now in-bounds. +assert.sameValue(ta.length, 5); +assert.sameValue(ta.byteOffset, 0); + +// Attempt to fetch another value from an already exhausted iterator. +r = it.next(); +assert.sameValue(r.done, true); +assert.sameValue(r.value, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js new file mode 100644 index 0000000000..8baa1c0920 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js @@ -0,0 +1,52 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.values +description: > + Calling next on an out-of-bounds typedarray throws no error when iterator exhausted. +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let ta = new Int8Array(rab, 1); + +// Ensure the TypedArray is correctly initialised. +assert.sameValue(ta.length, 2); +assert.sameValue(ta.byteOffset, 1); + +ta[0] = 11; +ta[1] = 22; + +let it = ta.values(); +let r; + +// Fetch the first value. +r = it.next(); +assert.sameValue(r.done, false); +assert.sameValue(r.value, 11); + +// Fetch the second value. +r = it.next(); +assert.sameValue(r.done, false); +assert.sameValue(r.value, 22); + +// Iterator is now exhausted. +r = it.next(); +assert.sameValue(r.done, true); +assert.sameValue(r.value, undefined); + +// Resize buffer to zero. +rab.resize(0); + +// TypedArray is now out-of-bounds. +assert.sameValue(ta.length, 0); +assert.sameValue(ta.byteOffset, 0); + +// Calling next doesn't throw an error. +r = it.next(); +assert.sameValue(r.done, true); +assert.sameValue(r.value, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/name.js index eacaf7f45e..9db35f6120 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/values/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -20,10 +21,11 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray] ---*/ -assert.sameValue(TypedArray.prototype.values.name, "values"); - -verifyNotEnumerable(TypedArray.prototype.values, "name"); -verifyNotWritable(TypedArray.prototype.values, "name"); -verifyConfigurable(TypedArray.prototype.values, "name"); +verifyProperty(TypedArray.prototype.values, "name", { + value: "values", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/not-a-constructor.js index 21b26b428f..ba8595192e 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/values/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -29,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let u8 = new Uint8Array(1); new u8.values(); -}, '`let u8 = new Uint8Array(1); new u8.values()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/prop-desc.js index 3317588756..2d54e08a81 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/values/prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js index 1049477287..07dccc377a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/return-itor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/return-itor.js index 5ebdfa17d5..a75bd6003f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/values/return-itor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/return-itor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/this-is-not-object.js index 0169af4e91..bd057bf9e2 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/values/this-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/this-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/this-is-not-typedarray-instance.js index 7afa67e4a5..57e7ba66b8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/values/this-is-not-typedarray-instance.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/this-is-not-typedarray-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/early-type-coercion.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/early-type-coercion.js index bf38eb2556..c08f33a890 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/early-type-coercion.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/early-type-coercion.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/ignores-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/ignores-species.js index 044707a6f0..46cfb0d9f4 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/ignores-species.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/ignores-species.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/immutable.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/immutable.js index 0b46dfd28a..61c10de916 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/immutable.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/immutable.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js index c96c2e2005..2e5e069a0f 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-casted-to-number.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-casted-to-number.js index 19e0a1625d..7d28553524 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-casted-to-number.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-casted-to-number.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-negative.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-negative.js index 640a49736c..a8335d2bd7 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-negative.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-negative.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js index f5481fff1e..2ebb4e5fe6 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-validated-against-current-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-validated-against-current-length.js new file mode 100644 index 0000000000..db6c1b534e --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-validated-against-current-length.js @@ -0,0 +1,61 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + The index is validated against the current length. +info: | + %TypedArray%.prototype.with ( index, value ) + + 1. Let O be the this value. + 2. Let taRecord be ? ValidateTypedArray(O, SEQ-CST). + 3. Let len be TypedArrayLength(taRecord). + ... + 8. Else, let numericValue be ? ToNumber(value). + ... + 10. Let A be ? TypedArrayCreateSameType(O, « 𝔽(len) »). + ... + 13. Return A. + +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(2, {maxByteLength: 5}); +let ta = new Int8Array(rab); + +ta[0] = 11; +ta[1] = 22; + +// Ensure typed array is correctly initialised. +assert.sameValue(ta.length, 2); +assert.sameValue(ta[0], 11); +assert.sameValue(ta[1], 22); + +// Index is initially out-of-bounds. +let index = 4; + +let value = { + valueOf() { + rab.resize(5); + return 123; + } +}; + +let result = ta.with(index, value); + +// Typed array has been resized. +assert.sameValue(ta.length, 5); +assert.sameValue(ta[0], 11); +assert.sameValue(ta[1], 22); +assert.sameValue(ta[2], 0); +assert.sameValue(ta[3], 0); +assert.sameValue(ta[4], 0); + +// Result is correctly initialised. +assert.sameValue(result.length, 2); +assert.sameValue(result[0], 11); +assert.sameValue(result[1], 22); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/length-property-ignored.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/length-property-ignored.js index 1a81148015..4d3040bb42 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/length-property-ignored.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/length-property-ignored.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/length.js index 3fddf24a14..7cbad184b5 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/length.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/name.js index 095d7161a9..f99f833bf8 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/name.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/name.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js index 8d8c1368a8..d024db6aa0 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/not-a-constructor.js index 09f4c4b144..d498709d0a 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/not-a-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/this-value-invalid.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/this-value-invalid.js index 92bb51bb46..bc27053107 100644 --- a/js/src/tests/test262/built-ins/TypedArray/prototype/with/this-value-invalid.js +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/this-value-invalid.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArray/shell.js b/js/src/tests/test262/built-ins/TypedArray/shell.js index c32f046213..c888512cb3 100644 --- a/js/src/tests/test262/built-ins/TypedArray/shell.js +++ b/js/src/tests/test262/built-ins/TypedArray/shell.js @@ -53,7 +53,22 @@ var byteConversionValues = { -4294967296, // - ( 2 ** 32 ) Infinity, -Infinity, - 0 + 0, + 2049, // an integer which rounds down under ties-to-even when cast to float16 + 2051, // an integer which rounds up under ties-to-even when cast to float16 + 0.00006103515625, // smallest normal float16 + 0.00006097555160522461, // largest subnormal float16 + 5.960464477539063e-8, // smallest float16 + 2.9802322387695312e-8, // largest double which rounds to 0 when cast to float16 + 2.980232238769532e-8, // smallest double which does not round to 0 when cast to float16 + 8.940696716308594e-8, // a double which rounds up to a subnormal under ties-to-even when cast to float16 + 1.4901161193847656e-7, // a double which rounds down to a subnormal under ties-to-even when cast to float16 + 1.490116119384766e-7, // the next double above the one on the previous line one + 65504, // max finite float16 + 65520, // smallest double which rounds to infinity when cast to float16 + 65519.99999999999, // largest double which does not round to infinity when cast to float16 + 0.000061005353927612305, // smallest double which rounds to a non-subnormal when cast to float16 + 0.0000610053539276123 // largest double which rounds to a subnormal when cast to float16 ], expected: { @@ -98,7 +113,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 1, // 2049 + 3, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + -32, // 65504 + -16, // 65520 + -17, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint8: [ 127, // 127 @@ -141,7 +171,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 1, // 2049 + 3, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 224, // 65504 + 240, // 65520 + 239, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint8Clamped: [ 127, // 127 @@ -184,7 +229,22 @@ var byteConversionValues = { 0, // -4294967296 255, // Infinity 0, // -Infinity - 0 + 0, // 0 + 255, // 2049 + 255, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 255, // 65504 + 255, // 65520 + 255, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Int16: [ 127, // 127 @@ -227,7 +287,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + -32, // 65504 + -16, // 65520 + -17, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint16: [ 127, // 127 @@ -270,7 +345,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Int32: [ 127, // 127 @@ -313,7 +403,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint32: [ 127, // 127 @@ -356,93 +461,138 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Float16: [ - 127, // 127 - 128, // 128 - 32768, // 32767 - 32768, // 32768 - Infinity, // 2147483647 - Infinity, // 2147483648 - 255, // 255 - 256, // 256 - Infinity, // 65535 - Infinity, // 65536 - Infinity, // 4294967295 - Infinity, // 4294967296 - Infinity, // 9007199254740991 - Infinity, // 9007199254740992 - 1.099609375, // 1.1 - 0.0999755859375, // 0.1 - 0.5, // 0.5 - 0.5, // 0.50000001, - 0.60009765625, // 0.6 - 0.7001953125, // 0.7 - NaN, // undefined - -1, // -1 - -0, // -0 - -0.0999755859375, // -0.1 - -1.099609375, // -1.1 - NaN, // NaN - -127, // -127 - -128, // -128 - -32768, // -32767 - -32768, // -32768 - -Infinity, // -2147483647 - -Infinity, // -2147483648 - -255, // -255 - -256, // -256 - -Infinity, // -65535 - -Infinity, // -65536 - -Infinity, // -4294967295 - -Infinity, // -4294967296 - Infinity, // Infinity - -Infinity, // -Infinity - 0 + 127, // 127 + 128, // 128 + 32768, // 32767 + 32768, // 32768 + Infinity, // 2147483647 + Infinity, // 2147483648 + 255, // 255 + 256, // 256 + Infinity, // 65535 + Infinity, // 65536 + Infinity, // 4294967295 + Infinity, // 4294967296 + Infinity, // 9007199254740991 + Infinity, // 9007199254740992 + 1.099609375, // 1.1 + 0.0999755859375, // 0.1 + 0.5, // 0.5 + 0.5, // 0.50000001, + 0.60009765625, // 0.6 + 0.7001953125, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.0999755859375, // -0.1 + -1.099609375, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32768, // -32767 + -32768, // -32768 + -Infinity, // -2147483647 + -Infinity, // -2147483648 + -255, // -255 + -256, // -256 + -Infinity, // -65535 + -Infinity, // -65536 + -Infinity, // -4294967295 + -Infinity, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0, // 0 + 2048, // 2049 + 2052, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 5.960464477539063e-8, // 2.980232238769532e-8 + 1.1920928955078125e-7, // 8.940696716308594e-8 + 1.1920928955078125e-7, // 1.4901161193847656e-7 + 1.7881393432617188e-7, // 1.490116119384766e-7 + 65504, // 65504 + Infinity, // 65520 + 65504, // 65519.99999999999 + 0.00006103515625, // 0.000061005353927612305 + 0.00006097555160522461 // 0.0000610053539276123 ], Float32: [ - 127, // 127 - 128, // 128 - 32767, // 32767 - 32768, // 32768 - 2147483648, // 2147483647 - 2147483648, // 2147483648 - 255, // 255 - 256, // 256 - 65535, // 65535 - 65536, // 65536 - 4294967296, // 4294967295 - 4294967296, // 4294967296 - 9007199254740992, // 9007199254740991 - 9007199254740992, // 9007199254740992 - 1.100000023841858, // 1.1 - 0.10000000149011612, // 0.1 - 0.5, // 0.5 - 0.5, // 0.50000001, - 0.6000000238418579, // 0.6 - 0.699999988079071, // 0.7 - NaN, // undefined - -1, // -1 - -0, // -0 - -0.10000000149011612, // -0.1 - -1.100000023841858, // -1.1 - NaN, // NaN - -127, // -127 - -128, // -128 - -32767, // -32767 - -32768, // -32768 - -2147483648, // -2147483647 - -2147483648, // -2147483648 - -255, // -255 - -256, // -256 - -65535, // -65535 - -65536, // -65536 - -4294967296, // -4294967295 - -4294967296, // -4294967296 - Infinity, // Infinity - -Infinity, // -Infinity - 0 + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483648, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967296, // 4294967295 + 4294967296, // 4294967296 + 9007199254740992, // 9007199254740991 + 9007199254740992, // 9007199254740992 + 1.100000023841858, // 1.1 + 0.10000000149011612, // 0.1 + 0.5, // 0.5 + 0.5, // 0.50000001, + 0.6000000238418579, // 0.6 + 0.699999988079071, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.10000000149011612, // -0.1 + -1.100000023841858, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483648, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + -4294967296, // -4294967295 + -4294967296, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 2.9802322387695312e-8, // 2.9802322387695312e-8 + 2.9802322387695312e-8, // 2.980232238769532e-8 + 8.940696716308594e-8, // 8.940696716308594e-8 + 1.4901161193847656e-7, // 1.4901161193847656e-7 + 1.4901161193847656e-7, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65520, // 65519.99999999999 + 0.000061005353927612305, // 0.000061005353927612305 + 0.000061005353927612305 // 0.0000610053539276123 ], Float64: [ 127, // 127 @@ -485,7 +635,22 @@ var byteConversionValues = { -4294967296, // -4294967296 Infinity, // Infinity -Infinity, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 2.9802322387695312e-8, // 2.9802322387695312e-8 + 2.980232238769532e-8, // 2.980232238769532e-8 + 8.940696716308594e-8, // 8.940696716308594e-8 + 1.4901161193847656e-7, // 1.4901161193847656e-7 + 1.490116119384766e-7, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519.99999999999, // 65519.99999999999 + 0.000061005353927612305, // 0.000061005353927612305 + 0.0000610053539276123 // 0.0000610053539276123 ] } }; diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/BigInt64Array/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/BigInt64Array/proto.js index 23e5d1da1d..bb97de324e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/BigInt64Array/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/BigInt64Array/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2017 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/BigInt64Array/prototype/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/BigInt64Array/prototype/proto.js index 460aaca932..a71ac041ff 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/BigInt64Array/prototype/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/BigInt64Array/prototype/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2017 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/BigUint64Array/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/BigUint64Array/proto.js index 6af1546744..c33a1ca001 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/BigUint64Array/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/BigUint64Array/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2017 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/BigUint64Array/prototype/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/BigUint64Array/prototype/proto.js index b114d3ae20..1f5db62f59 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/BigUint64Array/prototype/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/BigUint64Array/prototype/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2017 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Float32Array/name.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Float32Array/name.js index e7e141d975..f0b4aba701 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Float32Array/name.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Float32Array/name.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] features: [TypedArray] ---*/ -assert.sameValue(Float32Array.name, "Float32Array"); - -verifyNotEnumerable(Float32Array, "name"); -verifyNotWritable(Float32Array, "name"); -verifyConfigurable(Float32Array, "name"); +verifyProperty(Float32Array, "name", { + value: "Float32Array", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Float32Array/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Float32Array/proto.js index 82f214ed30..b185a9ff4f 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Float32Array/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Float32Array/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Float32Array/prototype/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Float32Array/prototype/proto.js index 1db64d3074..1be010e387 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Float32Array/prototype/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Float32Array/prototype/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Float64Array/name.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Float64Array/name.js index e9e559c9ee..64954bfcba 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Float64Array/name.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Float64Array/name.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] features: [TypedArray] ---*/ -assert.sameValue(Float64Array.name, "Float64Array"); - -verifyNotEnumerable(Float64Array, "name"); -verifyNotWritable(Float64Array, "name"); -verifyConfigurable(Float64Array, "name"); +verifyProperty(Float64Array, "name", { + value: "Float64Array", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Float64Array/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Float64Array/proto.js index 1f9a6dbdb0..a302c596b7 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Float64Array/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Float64Array/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Float64Array/prototype/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Float64Array/prototype/proto.js index ec35277dbd..b5a34cc786 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Float64Array/prototype/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Float64Array/prototype/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int16Array/name.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int16Array/name.js index 188718a488..d7e0bff6ab 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int16Array/name.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int16Array/name.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] features: [TypedArray] ---*/ -assert.sameValue(Int16Array.name, "Int16Array"); - -verifyNotEnumerable(Int16Array, "name"); -verifyNotWritable(Int16Array, "name"); -verifyConfigurable(Int16Array, "name"); +verifyProperty(Int16Array, "name", { + value: "Int16Array", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int16Array/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int16Array/proto.js index cd1a83901c..8cf0d45b6a 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int16Array/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int16Array/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int16Array/prototype/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int16Array/prototype/proto.js index 99a478232b..6e7dbe73b1 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int16Array/prototype/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int16Array/prototype/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int32Array/name.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int32Array/name.js index d7e639093b..d7e0e2c51f 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int32Array/name.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int32Array/name.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] features: [TypedArray] ---*/ -assert.sameValue(Int32Array.name, "Int32Array"); - -verifyNotEnumerable(Int32Array, "name"); -verifyNotWritable(Int32Array, "name"); -verifyConfigurable(Int32Array, "name"); +verifyProperty(Int32Array, "name", { + value: "Int32Array", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int32Array/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int32Array/proto.js index 24f99cf935..cc08cfceec 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int32Array/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int32Array/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int32Array/prototype/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int32Array/prototype/proto.js index cdec27c587..e5a1ade7b1 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int32Array/prototype/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int32Array/prototype/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int8Array/name.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int8Array/name.js index e4a12de7e7..3f0ea41b60 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int8Array/name.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int8Array/name.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] features: [TypedArray] ---*/ -assert.sameValue(Int8Array.name, "Int8Array"); - -verifyNotEnumerable(Int8Array, "name"); -verifyNotWritable(Int8Array, "name"); -verifyConfigurable(Int8Array, "name"); +verifyProperty(Int8Array, "name", { + value: "Int8Array", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int8Array/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int8Array/proto.js index 615d4f90ad..20272d5a78 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int8Array/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int8Array/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int8Array/prototype/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int8Array/prototype/proto.js index 6886e56cff..726f786a9e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Int8Array/prototype/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Int8Array/prototype/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint16Array/name.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint16Array/name.js index 35e59e9927..2614815c6b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint16Array/name.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint16Array/name.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] features: [TypedArray] ---*/ -assert.sameValue(Uint16Array.name, "Uint16Array"); - -verifyNotEnumerable(Uint16Array, "name"); -verifyNotWritable(Uint16Array, "name"); -verifyConfigurable(Uint16Array, "name"); +verifyProperty(Uint16Array, "name", { + value: "Uint16Array", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint16Array/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint16Array/proto.js index 1926d6eefe..58e501192e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint16Array/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint16Array/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint16Array/prototype/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint16Array/prototype/proto.js index b28264d2f9..76ce25bdc1 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint16Array/prototype/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint16Array/prototype/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/name.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/name.js index 231782fbf9..6cedd9b2ec 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/name.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/name.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] features: [TypedArray] ---*/ -assert.sameValue(Uint32Array.name, "Uint32Array"); - -verifyNotEnumerable(Uint32Array, "name"); -verifyNotWritable(Uint32Array, "name"); -verifyConfigurable(Uint32Array, "name"); +verifyProperty(Uint32Array, "name", { + value: "Uint32Array", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/proto.js index 23afd396b5..ac377e7086 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/proto.js index db175cdf0f..b41b44fde5 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint32Array/prototype/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8Array/name.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8Array/name.js index c3b17bdc55..7a40029267 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8Array/name.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8Array/name.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] features: [TypedArray] ---*/ -assert.sameValue(Uint8Array.name, "Uint8Array"); - -verifyNotEnumerable(Uint8Array, "name"); -verifyNotWritable(Uint8Array, "name"); -verifyConfigurable(Uint8Array, "name"); +verifyProperty(Uint8Array, "name", { + value: "Uint8Array", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8Array/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8Array/proto.js index 4549c9c5c4..2fa2b3f5f3 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8Array/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8Array/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8Array/prototype/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8Array/prototype/proto.js index 780a41c80d..8e48ff4a01 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8Array/prototype/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8Array/prototype/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8ClampedArray/name.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8ClampedArray/name.js index 263014c653..0b1f205c7f 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8ClampedArray/name.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8ClampedArray/name.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] features: [TypedArray] ---*/ -assert.sameValue(Uint8ClampedArray.name, "Uint8ClampedArray"); - -verifyNotEnumerable(Uint8ClampedArray, "name"); -verifyNotWritable(Uint8ClampedArray, "name"); -verifyConfigurable(Uint8ClampedArray, "name"); +verifyProperty(Uint8ClampedArray, "name", { + value: "Uint8ClampedArray", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8ClampedArray/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8ClampedArray/proto.js index 42cf2b2121..fb48296cd9 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8ClampedArray/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8ClampedArray/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8ClampedArray/prototype/proto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8ClampedArray/prototype/proto.js index 59620ea596..f5e2492076 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8ClampedArray/prototype/proto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/Uint8ClampedArray/prototype/proto.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/src-typedarray-not-big-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/src-typedarray-not-big-throws.js index 385307c130..dcd8377ccb 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/src-typedarray-not-big-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/src-typedarray-not-big-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Valerie Young. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size-sab.js index 6cd11a7883..09b261fbc4 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size.js index 0b1f59d0b1..0b66e1a912 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-negative-throws-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-negative-throws-sab.js index 70d62315c1..7054786da3 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-negative-throws-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-negative-throws-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-negative-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-negative-throws.js index 996976385e..5c93556f2f 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-negative-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-negative-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-negative-zero-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-negative-zero-sab.js index ecb8b39000..80b41bd1c2 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-negative-zero-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-negative-zero-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-negative-zero.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-negative-zero.js index cd8b786ccc..d38df17c8b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-negative-zero.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-negative-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2015 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-symbol-throws-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-symbol-throws-sab.js index b7a509cb98..25db8b4745 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-symbol-throws-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-symbol-throws-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-symbol-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-symbol-throws.js index 9423fc4d6c..9aaea65abe 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-symbol-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-symbol-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size-sab.js index 148be420dd..78dfd2e06f 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size.js index bd3005f74a..6fd2303d25 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-to-number-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-to-number-detachbuffer.js index 627c8778ad..6c581a55d7 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-to-number-detachbuffer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-to-number-detachbuffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-to-number-throws-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-to-number-throws-sab.js index 5b3ec7591d..2a1a9e41f3 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-to-number-throws-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-to-number-throws-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-to-number-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-to-number-throws.js index 47ff7ea095..2414b5cdd1 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-to-number-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-to-number-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/custom-proto-access-throws-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/custom-proto-access-throws-sab.js index bccf102235..9976158eb7 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/custom-proto-access-throws-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/custom-proto-access-throws-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/custom-proto-access-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/custom-proto-access-throws.js index 3f43b72932..0c55f1b7d6 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/custom-proto-access-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/custom-proto-access-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-length-and-offset-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-length-and-offset-sab.js index 56ecd2f44a..082d63a8a4 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-length-and-offset-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-length-and-offset-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-length-and-offset.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-length-and-offset.js index 80e815cf61..6c795df976 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-length-and-offset.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-length-and-offset.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-length-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-length-sab.js index a729a9a231..259d3d9320 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-length-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-length-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-length.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-length.js index 52abb61850..9845a827ce 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-length.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-negative-length-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-negative-length-sab.js index 3e7a33df8a..98cd8597bc 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-negative-length-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-negative-length-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-negative-length.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-negative-length.js index f795adabeb..2c00b69737 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-negative-length.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-negative-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-offset-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-offset-sab.js index 3ad0730ddb..4d5879643f 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-offset-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-offset-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-offset.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-offset.js index 1c416c4a45..fa73963e38 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-offset.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-offset.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/detachedbuffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/detachedbuffer.js index 15f2abe5e3..33f45327c3 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/detachedbuffer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/detachedbuffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-length-throws-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-length-throws-sab.js index ee0b54e943..71d193af6c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-length-throws-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-length-throws-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-length-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-length-throws.js index ab5836e944..63801af8b7 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-length-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-length-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-offset-throws-resizable-ab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-offset-throws-resizable-ab.js index 0095a54485..45dd413421 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-offset-throws-resizable-ab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-offset-throws-resizable-ab.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-offset-throws-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-offset-throws-sab.js index bba14855bf..28c58e063e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-offset-throws-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-offset-throws-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-offset-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-offset-throws.js index 17d39e4ea5..f66d7a400e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-offset-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/excessive-offset-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/invoked-with-undefined-newtarget-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/invoked-with-undefined-newtarget-sab.js index d08a6e8f7f..8916c2ac5e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/invoked-with-undefined-newtarget-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/invoked-with-undefined-newtarget-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/invoked-with-undefined-newtarget.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/invoked-with-undefined-newtarget.js index 7b8abeb3aa..6a897453d3 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/invoked-with-undefined-newtarget.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/invoked-with-undefined-newtarget.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/is-referenced-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/is-referenced-sab.js index a7c268a073..637f0a751e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/is-referenced-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/is-referenced-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/is-referenced.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/is-referenced.js index 9a7ad5ac4e..40d91ef9a6 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/is-referenced.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/is-referenced.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-access-throws-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-access-throws-sab.js index e22085c72a..979c422f45 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-access-throws-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-access-throws-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-access-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-access-throws.js index c05d709abc..a20dbfd51d 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-access-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-access-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-is-symbol-throws-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-is-symbol-throws-sab.js index 61cc16a0cb..8f62bbece4 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-is-symbol-throws-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-is-symbol-throws-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-is-symbol-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-is-symbol-throws.js index f04940f4ee..6bf3208e91 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-is-symbol-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-is-symbol-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-to-number-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-to-number-detachbuffer.js index 47ff17be0e..d9d01af299 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-to-number-detachbuffer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/length-to-number-detachbuffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/new-instance-extensibility-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/new-instance-extensibility-sab.js index be15fb3873..3fee45674a 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/new-instance-extensibility-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/new-instance-extensibility-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/new-instance-extensibility.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/new-instance-extensibility.js index 14be0cdec5..3bf4b39094 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/new-instance-extensibility.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/new-instance-extensibility.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/proto-from-ctor-realm-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/proto-from-ctor-realm-sab.js index 1da9bed6a2..228d90d808 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/proto-from-ctor-realm-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/proto-from-ctor-realm-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/proto-from-ctor-realm.js index 300629cadc..a0a8b5b575 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/proto-from-ctor-realm.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/proto-from-ctor-realm.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/returns-new-instance-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/returns-new-instance-sab.js index 17ea189089..feb96f9cd8 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/returns-new-instance-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/returns-new-instance-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/returns-new-instance.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/returns-new-instance.js index 46bb08e0ec..4e0e9542d8 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/returns-new-instance.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/returns-new-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/toindex-bytelength-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/toindex-bytelength-sab.js index f95a6366a1..c1d20fe6be 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/toindex-bytelength-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/toindex-bytelength-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/toindex-bytelength.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/toindex-bytelength.js index 062330df84..3f7ee16dcd 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/toindex-bytelength.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/toindex-bytelength.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/toindex-byteoffset-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/toindex-byteoffset-sab.js index 8ba2f41b9c..18bac82b01 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/toindex-byteoffset-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/toindex-byteoffset-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/toindex-byteoffset.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/toindex-byteoffset.js index 66a3629446..b8aa9340c2 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/toindex-byteoffset.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/toindex-byteoffset.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/typedarray-backed-by-sharedarraybuffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/typedarray-backed-by-sharedarraybuffer.js index 2ba3df217a..8fe01c563b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/typedarray-backed-by-sharedarraybuffer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/typedarray-backed-by-sharedarraybuffer.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/use-custom-proto-if-object-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/use-custom-proto-if-object-sab.js index 1b67197f02..bf6947d70c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/use-custom-proto-if-object-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/use-custom-proto-if-object-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/use-custom-proto-if-object.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/use-custom-proto-if-object.js index aad34833ca..3b0977c01c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/use-custom-proto-if-object.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/use-custom-proto-if-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/use-default-proto-if-custom-proto-is-not-object-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/use-default-proto-if-custom-proto-is-not-object-sab.js index 21086e7a26..1099370d8e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/use-default-proto-if-custom-proto-is-not-object-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/use-default-proto-if-custom-proto-is-not-object-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/use-default-proto-if-custom-proto-is-not-object.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/use-default-proto-if-custom-proto-is-not-object.js index dfef9bdf32..8e35ba0b33 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/use-default-proto-if-custom-proto-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/buffer-arg/use-default-proto-if-custom-proto-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/custom-proto-access-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/custom-proto-access-throws.js index d8808efd52..2742751a62 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/custom-proto-access-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/custom-proto-access-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/init-zeros.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/init-zeros.js index 60f2e09349..d99515e9ad 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/init-zeros.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/init-zeros.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/is-infinity-throws-rangeerror.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/is-infinity-throws-rangeerror.js index e2eee55c64..02d9bf50d9 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/is-infinity-throws-rangeerror.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/is-infinity-throws-rangeerror.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/is-negative-integer-throws-rangeerror.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/is-negative-integer-throws-rangeerror.js index b633202456..bdaec2dada 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/is-negative-integer-throws-rangeerror.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/is-negative-integer-throws-rangeerror.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/is-symbol-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/is-symbol-throws.js index a383eb453c..72f961ba9d 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/is-symbol-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/is-symbol-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/new-instance-extensibility.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/new-instance-extensibility.js index 28a76944ff..86616927c7 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/new-instance-extensibility.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/new-instance-extensibility.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/proto-from-ctor-realm.js index 02f39b12e5..da803e4c53 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/proto-from-ctor-realm.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/proto-from-ctor-realm.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/returns-object.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/returns-object.js index 25f90a4a1d..63313cb769 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/returns-object.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/returns-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/toindex-length.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/toindex-length.js index d84897dfa8..78469b68f1 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/toindex-length.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/toindex-length.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/undefined-newtarget-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/undefined-newtarget-throws.js index 8c43e87b2d..d9cd7cdb15 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/undefined-newtarget-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/undefined-newtarget-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/use-custom-proto-if-object.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/use-custom-proto-if-object.js index 59f7b7f0f0..affc9cb34e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/use-custom-proto-if-object.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/use-custom-proto-if-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/use-default-proto-if-custom-proto-is-not-object.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/use-default-proto-if-custom-proto-is-not-object.js index 6617e5c899..0e14a91595 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/use-default-proto-if-custom-proto-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/length-arg/use-default-proto-if-custom-proto-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/custom-proto-access-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/custom-proto-access-throws.js index 5c3a24bd54..10f576962c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/custom-proto-access-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/custom-proto-access-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/new-instance-extensibility.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/new-instance-extensibility.js index e72a6b7e38..555eb2d95b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/new-instance-extensibility.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/new-instance-extensibility.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/proto-from-ctor-realm.js index 533d41736f..f5ff2b376a 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/proto-from-ctor-realm.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/proto-from-ctor-realm.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/returns-object.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/returns-object.js index 2538dbc5f8..3bc999eb6c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/returns-object.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/returns-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/undefined-newtarget-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/undefined-newtarget-throws.js index f238450d16..95384239c9 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/undefined-newtarget-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/undefined-newtarget-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/use-custom-proto-if-object.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/use-custom-proto-if-object.js index 420e56e088..1a6627f2fa 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/use-custom-proto-if-object.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/use-custom-proto-if-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/use-default-proto-if-custom-proto-is-not-object.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/use-default-proto-if-custom-proto-is-not-object.js index ca9f018f0d..f13ec9f692 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/use-default-proto-if-custom-proto-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/no-args/use-default-proto-if-custom-proto-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/as-array-returns.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/as-array-returns.js index abbc8b5979..11303c95be 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/as-array-returns.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/as-array-returns.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/as-generator-iterable-returns.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/as-generator-iterable-returns.js index a86d9ef1a5..5d6a865645 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/as-generator-iterable-returns.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/as-generator-iterable-returns.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/conversion-operation-consistent-nan.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/conversion-operation-consistent-nan.js index f71f68003f..f3103232ca 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/conversion-operation-consistent-nan.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/conversion-operation-consistent-nan.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/conversion-operation.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/conversion-operation.js index b8c41f1de1..168036bf59 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/conversion-operation.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/conversion-operation.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/custom-proto-access-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/custom-proto-access-throws.js index c34af4e31b..71b04f1f03 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/custom-proto-access-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/custom-proto-access-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterated-array-changed-by-tonumber.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterated-array-changed-by-tonumber.js new file mode 100644 index 0000000000..6251655196 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterated-array-changed-by-tonumber.js @@ -0,0 +1,46 @@ +// |reftest| shell-option(--enable-float16array) +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray +description: > + Modifications to input array after iteration are handled correctly. +info: | + TypedArray ( ...args ) + + ... + 6. Else, + ... + b. If firstArgument is an Object, then + ... + iv. Else, + ... + 2. Let usingIterator be ? GetMethod(firstArgument, @@iterator). + 3. If usingIterator is not undefined, then + a. Let values be ? IteratorToList(? GetIteratorFromMethod(firstArgument, usingIterator)). + b. Perform ? InitializeTypedArrayFromList(O, values). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TypedArray) { + let values = [0, { + valueOf() { + // Removes all array elements. Caller must have saved all elements. + values.length = 0; + return 100; + } + }, 2]; + + // Constructor called with array which uses the built-in array iterator. + var ta = new TypedArray(values); + + assert.sameValue(ta.length, 3); + assert.sameValue(ta[0], 0); + assert.sameValue(ta[1], 100); + assert.sameValue(ta[2], 2); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterated-array-with-modified-array-iterator.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterated-array-with-modified-array-iterator.js new file mode 100644 index 0000000000..fe1f672adb --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterated-array-with-modified-array-iterator.js @@ -0,0 +1,52 @@ +// |reftest| shell-option(--enable-float16array) +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray +description: > + Modifications to input array after iteration are handled correctly. +info: | + TypedArray ( ...args ) + + ... + 6. Else, + ... + b. If firstArgument is an Object, then + ... + iv. Else, + ... + 2. Let usingIterator be ? GetMethod(firstArgument, @@iterator). + 3. If usingIterator is not undefined, then + a. Let values be ? IteratorToList(? GetIteratorFromMethod(firstArgument, usingIterator)). + b. Perform ? InitializeTypedArrayFromList(O, values). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +let ArrayIteratorPrototype = Object.getPrototypeOf([].values()); +let values; + +// Modify the built-in ArrayIteratorPrototype `next` method. +ArrayIteratorPrototype.next = function() { + let done = values.length === 0; + let value = values.pop(); + return {value, done}; +}; + +testWithTypedArrayConstructors(function(TypedArray) { + // Reset `values` array. + values = [1, 2, 3, 4]; + + // Constructor called with array which uses the modified array iterator. + var ta = new TypedArray([0]); + + assert.sameValue(ta.length, 4); + assert.sameValue(ta[0], 4); + assert.sameValue(ta[1], 3); + assert.sameValue(ta[2], 2); + assert.sameValue(ta[3], 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterating-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterating-throws.js index 7867b4a3a1..4327297746 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterating-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterating-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-is-null-as-array-like.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-is-null-as-array-like.js index de906f06b4..b1854e4dbe 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-is-null-as-array-like.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-is-null-as-array-like.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Alexey Shvayka. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-not-callable-throws.js index 500437a3ed..d3d9f7c608 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-not-callable-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-not-callable-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-throws.js index 9b9c57a11b..4dcb325608 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/iterator-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/length-excessive-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/length-excessive-throws.js index 1d681cfe61..5a18692653 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/length-excessive-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/length-excessive-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/length-is-symbol-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/length-is-symbol-throws.js index 1e2f7e23c9..667cbd3184 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/length-is-symbol-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/length-is-symbol-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/length-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/length-throws.js index 8dccea8901..c9bb5b8de6 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/length-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/length-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/new-instance-extensibility.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/new-instance-extensibility.js index 25345c0979..8508b38961 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/new-instance-extensibility.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/new-instance-extensibility.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/proto-from-ctor-realm.js index 213fbfbdd8..8c7a15f89b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/proto-from-ctor-realm.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/proto-from-ctor-realm.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/returns.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/returns.js index 7b795eed85..cd210c0166 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/returns.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/returns.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/shell.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/shell.js index 4d14a8634d..665ef0a961 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/shell.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/shell.js @@ -53,7 +53,22 @@ var byteConversionValues = { -4294967296, // - ( 2 ** 32 ) Infinity, -Infinity, - 0 + 0, + 2049, // an integer which rounds down under ties-to-even when cast to float16 + 2051, // an integer which rounds up under ties-to-even when cast to float16 + 0.00006103515625, // smallest normal float16 + 0.00006097555160522461, // largest subnormal float16 + 5.960464477539063e-8, // smallest float16 + 2.9802322387695312e-8, // largest double which rounds to 0 when cast to float16 + 2.980232238769532e-8, // smallest double which does not round to 0 when cast to float16 + 8.940696716308594e-8, // a double which rounds up to a subnormal under ties-to-even when cast to float16 + 1.4901161193847656e-7, // a double which rounds down to a subnormal under ties-to-even when cast to float16 + 1.490116119384766e-7, // the next double above the one on the previous line one + 65504, // max finite float16 + 65520, // smallest double which rounds to infinity when cast to float16 + 65519.99999999999, // largest double which does not round to infinity when cast to float16 + 0.000061005353927612305, // smallest double which rounds to a non-subnormal when cast to float16 + 0.0000610053539276123 // largest double which rounds to a subnormal when cast to float16 ], expected: { @@ -98,7 +113,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 1, // 2049 + 3, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + -32, // 65504 + -16, // 65520 + -17, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint8: [ 127, // 127 @@ -141,7 +171,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 1, // 2049 + 3, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 224, // 65504 + 240, // 65520 + 239, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint8Clamped: [ 127, // 127 @@ -184,7 +229,22 @@ var byteConversionValues = { 0, // -4294967296 255, // Infinity 0, // -Infinity - 0 + 0, // 0 + 255, // 2049 + 255, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 255, // 65504 + 255, // 65520 + 255, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Int16: [ 127, // 127 @@ -227,7 +287,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + -32, // 65504 + -16, // 65520 + -17, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint16: [ 127, // 127 @@ -270,7 +345,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Int32: [ 127, // 127 @@ -313,7 +403,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint32: [ 127, // 127 @@ -356,93 +461,138 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Float16: [ - 127, // 127 - 128, // 128 - 32768, // 32767 - 32768, // 32768 - Infinity, // 2147483647 - Infinity, // 2147483648 - 255, // 255 - 256, // 256 - Infinity, // 65535 - Infinity, // 65536 - Infinity, // 4294967295 - Infinity, // 4294967296 - Infinity, // 9007199254740991 - Infinity, // 9007199254740992 - 1.099609375, // 1.1 - 0.0999755859375, // 0.1 - 0.5, // 0.5 - 0.5, // 0.50000001, - 0.60009765625, // 0.6 - 0.7001953125, // 0.7 - NaN, // undefined - -1, // -1 - -0, // -0 - -0.0999755859375, // -0.1 - -1.099609375, // -1.1 - NaN, // NaN - -127, // -127 - -128, // -128 - -32768, // -32767 - -32768, // -32768 - -Infinity, // -2147483647 - -Infinity, // -2147483648 - -255, // -255 - -256, // -256 - -Infinity, // -65535 - -Infinity, // -65536 - -Infinity, // -4294967295 - -Infinity, // -4294967296 - Infinity, // Infinity - -Infinity, // -Infinity - 0 + 127, // 127 + 128, // 128 + 32768, // 32767 + 32768, // 32768 + Infinity, // 2147483647 + Infinity, // 2147483648 + 255, // 255 + 256, // 256 + Infinity, // 65535 + Infinity, // 65536 + Infinity, // 4294967295 + Infinity, // 4294967296 + Infinity, // 9007199254740991 + Infinity, // 9007199254740992 + 1.099609375, // 1.1 + 0.0999755859375, // 0.1 + 0.5, // 0.5 + 0.5, // 0.50000001, + 0.60009765625, // 0.6 + 0.7001953125, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.0999755859375, // -0.1 + -1.099609375, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32768, // -32767 + -32768, // -32768 + -Infinity, // -2147483647 + -Infinity, // -2147483648 + -255, // -255 + -256, // -256 + -Infinity, // -65535 + -Infinity, // -65536 + -Infinity, // -4294967295 + -Infinity, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0, // 0 + 2048, // 2049 + 2052, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 5.960464477539063e-8, // 2.980232238769532e-8 + 1.1920928955078125e-7, // 8.940696716308594e-8 + 1.1920928955078125e-7, // 1.4901161193847656e-7 + 1.7881393432617188e-7, // 1.490116119384766e-7 + 65504, // 65504 + Infinity, // 65520 + 65504, // 65519.99999999999 + 0.00006103515625, // 0.000061005353927612305 + 0.00006097555160522461 // 0.0000610053539276123 ], Float32: [ - 127, // 127 - 128, // 128 - 32767, // 32767 - 32768, // 32768 - 2147483648, // 2147483647 - 2147483648, // 2147483648 - 255, // 255 - 256, // 256 - 65535, // 65535 - 65536, // 65536 - 4294967296, // 4294967295 - 4294967296, // 4294967296 - 9007199254740992, // 9007199254740991 - 9007199254740992, // 9007199254740992 - 1.100000023841858, // 1.1 - 0.10000000149011612, // 0.1 - 0.5, // 0.5 - 0.5, // 0.50000001, - 0.6000000238418579, // 0.6 - 0.699999988079071, // 0.7 - NaN, // undefined - -1, // -1 - -0, // -0 - -0.10000000149011612, // -0.1 - -1.100000023841858, // -1.1 - NaN, // NaN - -127, // -127 - -128, // -128 - -32767, // -32767 - -32768, // -32768 - -2147483648, // -2147483647 - -2147483648, // -2147483648 - -255, // -255 - -256, // -256 - -65535, // -65535 - -65536, // -65536 - -4294967296, // -4294967295 - -4294967296, // -4294967296 - Infinity, // Infinity - -Infinity, // -Infinity - 0 + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483648, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967296, // 4294967295 + 4294967296, // 4294967296 + 9007199254740992, // 9007199254740991 + 9007199254740992, // 9007199254740992 + 1.100000023841858, // 1.1 + 0.10000000149011612, // 0.1 + 0.5, // 0.5 + 0.5, // 0.50000001, + 0.6000000238418579, // 0.6 + 0.699999988079071, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.10000000149011612, // -0.1 + -1.100000023841858, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483648, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + -4294967296, // -4294967295 + -4294967296, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 2.9802322387695312e-8, // 2.9802322387695312e-8 + 2.9802322387695312e-8, // 2.980232238769532e-8 + 8.940696716308594e-8, // 8.940696716308594e-8 + 1.4901161193847656e-7, // 1.4901161193847656e-7 + 1.4901161193847656e-7, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65520, // 65519.99999999999 + 0.000061005353927612305, // 0.000061005353927612305 + 0.000061005353927612305 // 0.0000610053539276123 ], Float64: [ 127, // 127 @@ -485,7 +635,22 @@ var byteConversionValues = { -4294967296, // -4294967296 Infinity, // Infinity -Infinity, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 2.9802322387695312e-8, // 2.9802322387695312e-8 + 2.980232238769532e-8, // 2.980232238769532e-8 + 8.940696716308594e-8, // 8.940696716308594e-8 + 1.4901161193847656e-7, // 1.4901161193847656e-7 + 1.490116119384766e-7, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519.99999999999, // 65519.99999999999 + 0.000061005353927612305, // 0.000061005353927612305 + 0.0000610053539276123 // 0.0000610053539276123 ] } }; diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-from-property.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-from-property.js index 574b628f9e..364db4a15b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-from-property.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-from-property.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-to-primitive-typeerror.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-to-primitive-typeerror.js index 1e0cba0b5a..ea5d804b38 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-to-primitive-typeerror.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-to-primitive-typeerror.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-to-primitive.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-to-primitive.js index b70a039911..79e87b69e1 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-to-primitive.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-to-primitive.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-tostring.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-tostring.js index 9940e1e608..4b2bbe8b8e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-tostring.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-tostring.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-valueof-typeerror.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-valueof-typeerror.js index 746e244537..118bed7af1 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-valueof-typeerror.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-valueof-typeerror.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-valueof.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-valueof.js index 7bb03318c0..96acc357f5 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-valueof.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-obj-valueof.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-property.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-property.js index 0e5f93d30a..ff5a754804 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-property.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-property.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-symbol-property.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-symbol-property.js index f30ef12f5c..3a7d48165c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-symbol-property.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/throws-setting-symbol-property.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/undefined-newtarget-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/undefined-newtarget-throws.js index b5b6b00fa1..a93f077fd1 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/undefined-newtarget-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/undefined-newtarget-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/use-custom-proto-if-object.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/use-custom-proto-if-object.js index 996f9d659a..8d766e8b21 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/use-custom-proto-if-object.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/use-custom-proto-if-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/use-default-proto-if-custom-proto-is-not-object.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/use-default-proto-if-custom-proto-is-not-object.js index 7ae957d8a1..8a0afbb04e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/use-default-proto-if-custom-proto-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/object-arg/use-default-proto-if-custom-proto-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/custom-proto-access-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/custom-proto-access-throws.js index 9668bd269b..a2c8c95545 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/custom-proto-access-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/custom-proto-access-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/new-instance-extensibility.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/new-instance-extensibility.js index 59d5efba90..789160306e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/new-instance-extensibility.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/new-instance-extensibility.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-returns-new-typedarray.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-returns-new-typedarray.js index 8f6d0f51fe..916b476121 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-returns-new-typedarray.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/other-ctor-returns-new-typedarray.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/proto-from-ctor-realm.js index d7aae2b83f..ec99dc3bc4 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/proto-from-ctor-realm.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/proto-from-ctor-realm.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/returns-new-instance.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/returns-new-instance.js index b59e86f5a2..286eb9e91c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/returns-new-instance.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/returns-new-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-null.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-null.js index 2dc3b4bd0a..b20e77b00c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-null.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-null.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-undefined.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-undefined.js index 53904f8aa1..48a27ae56b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-undefined.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-buffer-ctor-species-undefined.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-returns-new-cloned-typedarray.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-returns-new-cloned-typedarray.js index 95d273cff2..f69be105c1 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-returns-new-cloned-typedarray.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/same-ctor-returns-new-cloned-typedarray.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/src-typedarray-big-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/src-typedarray-big-throws.js index d7aaead773..76a38e1cb7 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/src-typedarray-big-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/src-typedarray-big-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Valerie Young. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/undefined-newtarget-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/undefined-newtarget-throws.js index 4ea662775e..821fc3d229 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/undefined-newtarget-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/undefined-newtarget-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/use-custom-proto-if-object.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/use-custom-proto-if-object.js index c52ac6df1a..0d08f50b3a 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/use-custom-proto-if-object.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/use-custom-proto-if-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/use-default-proto-if-custom-proto-is-not-object.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/use-default-proto-if-custom-proto-is-not-object.js index e82396a021..d4525a4cfc 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/use-default-proto-if-custom-proto-is-not-object.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors/typedarray-arg/use-default-proto-if-custom-proto-is-not-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/arylk-get-length-error.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/arylk-get-length-error.js index a81e83852d..a7f33ebd2b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/arylk-get-length-error.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/arylk-get-length-error.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/arylk-to-length-error.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/arylk-to-length-error.js index 55eb5749ca..9ec5f7bf9f 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/arylk-to-length-error.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/arylk-to-length-error.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/custom-ctor-does-not-instantiate-ta-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/custom-ctor-does-not-instantiate-ta-throws.js index c7e4907e32..fe0b87efe4 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/custom-ctor-does-not-instantiate-ta-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/custom-ctor-does-not-instantiate-ta-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/custom-ctor-returns-other-instance.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/custom-ctor-returns-other-instance.js index 9083ca3c08..6bf9ac83e6 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/custom-ctor-returns-other-instance.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/custom-ctor-returns-other-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/custom-ctor-returns-smaller-instance-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/custom-ctor-returns-smaller-instance-throws.js index 044910acbf..8f005b5952 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/custom-ctor-returns-smaller-instance-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/custom-ctor-returns-smaller-instance-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/custom-ctor.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/custom-ctor.js index 292093d14d..93b40fef68 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/custom-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/custom-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/inherited.js index 9577e35aab..6fc0819fbf 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/invoked-as-func.js index b5dd5512cb..b48ab58a6b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/iter-access-error.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/iter-access-error.js index e5c3737c29..7feacdadb3 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/iter-access-error.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/iter-access-error.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/iter-invoke-error.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/iter-invoke-error.js index 5ff5bcc32e..65fb7f7d6c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/iter-invoke-error.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/iter-invoke-error.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/iter-next-error.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/iter-next-error.js index 709c8026f5..ce3a3aa168 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/iter-next-error.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/iter-next-error.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/iter-next-value-error.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/iter-next-value-error.js index 221433130d..e9aac7e83b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/iter-next-value-error.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/iter-next-value-error.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-abrupt-completion.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-abrupt-completion.js index 9d32ab9524..a0eaa7d336 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-abrupt-completion.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-abrupt-completion.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-arguments.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-arguments.js index 28b04f06da..4b95b05712 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-arguments.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-arguments.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-is-not-callable.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-is-not-callable.js index f5b9b7865b..4b31776f2e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-is-not-callable.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-is-not-callable.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-this-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-this-with-thisarg.js index 4be11060b8..3f7088954d 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-this-with-thisarg.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-this-with-thisarg.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-this-without-thisarg-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-this-without-thisarg-non-strict.js index b6ff0005da..a912a83f74 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-this-without-thisarg-non-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-this-without-thisarg-non-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-this-without-thisarg-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-this-without-thisarg-strict-strict.js index 8a136b75bc..c66bf386cc 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-this-without-thisarg-strict-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/mapfn-this-without-thisarg-strict-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) 'use strict'; // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/nan-conversion.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/nan-conversion.js index a35febc000..83877e2fc3 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/nan-conversion.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/nan-conversion.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-empty.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-empty.js index 0a276b5b58..f49d3c29d0 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-empty.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-empty.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-from-ordinary-object.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-from-ordinary-object.js index 6e0d9f4127..0b820af684 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-from-ordinary-object.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-from-ordinary-object.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-from-sparse-array.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-from-sparse-array.js index 85c9bbb5f7..c0f70dc85e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-from-sparse-array.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-from-sparse-array.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-from-zero.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-from-zero.js index 76eebadd49..bcd89444d3 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-from-zero.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-from-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-using-custom-ctor.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-using-custom-ctor.js index 375458c109..27b437b774 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-using-custom-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-using-custom-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-with-mapfn.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-with-mapfn.js index 9a17d2db77..cee2af2ef1 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-with-mapfn.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-with-mapfn.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-without-mapfn.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-without-mapfn.js index f5aa405987..0e5f72a612 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-without-mapfn.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/new-instance-without-mapfn.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/property-abrupt-completion.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/property-abrupt-completion.js index 20b1934e03..7de60a6aa5 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/property-abrupt-completion.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/property-abrupt-completion.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/set-value-abrupt-completion.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/set-value-abrupt-completion.js index e94d807876..2b1672ff7a 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/set-value-abrupt-completion.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/set-value-abrupt-completion.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/source-value-is-symbol-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/source-value-is-symbol-throws.js index e5a1ff264b..7ebc4e1f4f 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/source-value-is-symbol-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/source-value-is-symbol-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/this-is-not-constructor.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/this-is-not-constructor.js index 3369baef9b..48cd44966f 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/this-is-not-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/this-is-not-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation-consistent-nan.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation-consistent-nan.js index 12b8eb5042..8dd6bc7322 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation-consistent-nan.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation-consistent-nan.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation.js index 9cb1a271c1..6e9d0773bd 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/desc-value-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/desc-value-throws.js index 987400e098..4c5588e49d 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/desc-value-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/desc-value-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer-throws-realm.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer-throws-realm.js index e0bc4aa960..4febd9feb5 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer-throws-realm.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer-throws-realm.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer-throws.js index 0508818e9d..d07aca032c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Alexey Shvayka. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer.js index 5bca5e6893..72061fea46 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-greater-than-last-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-greater-than-last-index.js index ad49623d94..735f0c9679 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-greater-than-last-index.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-greater-than-last-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-lower-than-zero.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-lower-than-zero.js index bafcc4e84f..21da5c2480 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-lower-than-zero.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-lower-than-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-minus-zero.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-minus-zero.js index 970eb231eb..a74d68df05 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-minus-zero.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-minus-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-canonical-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-canonical-index.js index c667f7ac46..5fa7ed880b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-canonical-index.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-canonical-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-integer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-integer.js index 7b1c6c9206..dc2f823b01 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-integer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-integer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-numeric-index-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-numeric-index-throws.js index 5dbb162ef3..429f686806 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-numeric-index-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-numeric-index-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Alexey Shvayka. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-numeric-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-numeric-index.js index 33b460ede6..b26ebb94db 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-numeric-index.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-not-numeric-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-accessor-desc-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-accessor-desc-throws.js index c794dd233d..4cf7805455 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-accessor-desc-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-accessor-desc-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Alexey Shvayka. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-accessor-desc.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-accessor-desc.js index b382b1fcea..a27e8989cd 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-accessor-desc.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-accessor-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-configurable.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-configurable.js index 3e6defb841..1197dfa091 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-configurable.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-configurable.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-configurable-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-configurable-throws.js index 12c0ea92de..d3f9ccc4a8 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-configurable-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-configurable-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Alexey Shvayka. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-enumerable-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-enumerable-throws.js index 3e09508c43..7fd184108c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-enumerable-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-enumerable-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Alexey Shvayka. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-enumerable.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-enumerable.js index 1c8ab48205..08ebd8cbb1 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-enumerable.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-enumerable.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-writable-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-writable-throws.js index 99c5579ee8..4322532753 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-writable-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-writable-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2021 Alexey Shvayka. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-writable.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-writable.js index 25d78bf869..e5d105b810 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-writable.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex-desc-not-writable.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex.js index 0b45de3189..0ae1ae372c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-numericindex.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-symbol.js index 867f69e9d3..da9dfc1b73 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/key-is-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/non-extensible-new-key.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/non-extensible-new-key.js index 51a824d248..3fa85523aa 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/non-extensible-new-key.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/non-extensible-new-key.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/non-extensible-redefine-key.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/non-extensible-redefine-key.js index 00e67d6fd6..7831b2d803 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/non-extensible-redefine-key.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/non-extensible-redefine-key.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/set-value.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/set-value.js index 2b81f9777f..063055b318 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/set-value.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/set-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/shell.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/shell.js index c32f046213..c888512cb3 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/shell.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/shell.js @@ -53,7 +53,22 @@ var byteConversionValues = { -4294967296, // - ( 2 ** 32 ) Infinity, -Infinity, - 0 + 0, + 2049, // an integer which rounds down under ties-to-even when cast to float16 + 2051, // an integer which rounds up under ties-to-even when cast to float16 + 0.00006103515625, // smallest normal float16 + 0.00006097555160522461, // largest subnormal float16 + 5.960464477539063e-8, // smallest float16 + 2.9802322387695312e-8, // largest double which rounds to 0 when cast to float16 + 2.980232238769532e-8, // smallest double which does not round to 0 when cast to float16 + 8.940696716308594e-8, // a double which rounds up to a subnormal under ties-to-even when cast to float16 + 1.4901161193847656e-7, // a double which rounds down to a subnormal under ties-to-even when cast to float16 + 1.490116119384766e-7, // the next double above the one on the previous line one + 65504, // max finite float16 + 65520, // smallest double which rounds to infinity when cast to float16 + 65519.99999999999, // largest double which does not round to infinity when cast to float16 + 0.000061005353927612305, // smallest double which rounds to a non-subnormal when cast to float16 + 0.0000610053539276123 // largest double which rounds to a subnormal when cast to float16 ], expected: { @@ -98,7 +113,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 1, // 2049 + 3, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + -32, // 65504 + -16, // 65520 + -17, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint8: [ 127, // 127 @@ -141,7 +171,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 1, // 2049 + 3, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 224, // 65504 + 240, // 65520 + 239, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint8Clamped: [ 127, // 127 @@ -184,7 +229,22 @@ var byteConversionValues = { 0, // -4294967296 255, // Infinity 0, // -Infinity - 0 + 0, // 0 + 255, // 2049 + 255, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 255, // 65504 + 255, // 65520 + 255, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Int16: [ 127, // 127 @@ -227,7 +287,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + -32, // 65504 + -16, // 65520 + -17, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint16: [ 127, // 127 @@ -270,7 +345,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Int32: [ 127, // 127 @@ -313,7 +403,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint32: [ 127, // 127 @@ -356,93 +461,138 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Float16: [ - 127, // 127 - 128, // 128 - 32768, // 32767 - 32768, // 32768 - Infinity, // 2147483647 - Infinity, // 2147483648 - 255, // 255 - 256, // 256 - Infinity, // 65535 - Infinity, // 65536 - Infinity, // 4294967295 - Infinity, // 4294967296 - Infinity, // 9007199254740991 - Infinity, // 9007199254740992 - 1.099609375, // 1.1 - 0.0999755859375, // 0.1 - 0.5, // 0.5 - 0.5, // 0.50000001, - 0.60009765625, // 0.6 - 0.7001953125, // 0.7 - NaN, // undefined - -1, // -1 - -0, // -0 - -0.0999755859375, // -0.1 - -1.099609375, // -1.1 - NaN, // NaN - -127, // -127 - -128, // -128 - -32768, // -32767 - -32768, // -32768 - -Infinity, // -2147483647 - -Infinity, // -2147483648 - -255, // -255 - -256, // -256 - -Infinity, // -65535 - -Infinity, // -65536 - -Infinity, // -4294967295 - -Infinity, // -4294967296 - Infinity, // Infinity - -Infinity, // -Infinity - 0 + 127, // 127 + 128, // 128 + 32768, // 32767 + 32768, // 32768 + Infinity, // 2147483647 + Infinity, // 2147483648 + 255, // 255 + 256, // 256 + Infinity, // 65535 + Infinity, // 65536 + Infinity, // 4294967295 + Infinity, // 4294967296 + Infinity, // 9007199254740991 + Infinity, // 9007199254740992 + 1.099609375, // 1.1 + 0.0999755859375, // 0.1 + 0.5, // 0.5 + 0.5, // 0.50000001, + 0.60009765625, // 0.6 + 0.7001953125, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.0999755859375, // -0.1 + -1.099609375, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32768, // -32767 + -32768, // -32768 + -Infinity, // -2147483647 + -Infinity, // -2147483648 + -255, // -255 + -256, // -256 + -Infinity, // -65535 + -Infinity, // -65536 + -Infinity, // -4294967295 + -Infinity, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0, // 0 + 2048, // 2049 + 2052, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 5.960464477539063e-8, // 2.980232238769532e-8 + 1.1920928955078125e-7, // 8.940696716308594e-8 + 1.1920928955078125e-7, // 1.4901161193847656e-7 + 1.7881393432617188e-7, // 1.490116119384766e-7 + 65504, // 65504 + Infinity, // 65520 + 65504, // 65519.99999999999 + 0.00006103515625, // 0.000061005353927612305 + 0.00006097555160522461 // 0.0000610053539276123 ], Float32: [ - 127, // 127 - 128, // 128 - 32767, // 32767 - 32768, // 32768 - 2147483648, // 2147483647 - 2147483648, // 2147483648 - 255, // 255 - 256, // 256 - 65535, // 65535 - 65536, // 65536 - 4294967296, // 4294967295 - 4294967296, // 4294967296 - 9007199254740992, // 9007199254740991 - 9007199254740992, // 9007199254740992 - 1.100000023841858, // 1.1 - 0.10000000149011612, // 0.1 - 0.5, // 0.5 - 0.5, // 0.50000001, - 0.6000000238418579, // 0.6 - 0.699999988079071, // 0.7 - NaN, // undefined - -1, // -1 - -0, // -0 - -0.10000000149011612, // -0.1 - -1.100000023841858, // -1.1 - NaN, // NaN - -127, // -127 - -128, // -128 - -32767, // -32767 - -32768, // -32768 - -2147483648, // -2147483647 - -2147483648, // -2147483648 - -255, // -255 - -256, // -256 - -65535, // -65535 - -65536, // -65536 - -4294967296, // -4294967295 - -4294967296, // -4294967296 - Infinity, // Infinity - -Infinity, // -Infinity - 0 + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483648, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967296, // 4294967295 + 4294967296, // 4294967296 + 9007199254740992, // 9007199254740991 + 9007199254740992, // 9007199254740992 + 1.100000023841858, // 1.1 + 0.10000000149011612, // 0.1 + 0.5, // 0.5 + 0.5, // 0.50000001, + 0.6000000238418579, // 0.6 + 0.699999988079071, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.10000000149011612, // -0.1 + -1.100000023841858, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483648, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + -4294967296, // -4294967295 + -4294967296, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 2.9802322387695312e-8, // 2.9802322387695312e-8 + 2.9802322387695312e-8, // 2.980232238769532e-8 + 8.940696716308594e-8, // 8.940696716308594e-8 + 1.4901161193847656e-7, // 1.4901161193847656e-7 + 1.4901161193847656e-7, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65520, // 65519.99999999999 + 0.000061005353927612305, // 0.000061005353927612305 + 0.000061005353927612305 // 0.0000610053539276123 ], Float64: [ 127, // 127 @@ -485,7 +635,22 @@ var byteConversionValues = { -4294967296, // -4294967296 Infinity, // Infinity -Infinity, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 2.9802322387695312e-8, // 2.9802322387695312e-8 + 2.980232238769532e-8, // 2.980232238769532e-8 + 8.940696716308594e-8, // 8.940696716308594e-8 + 1.4901161193847656e-7, // 1.4901161193847656e-7 + 1.490116119384766e-7, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519.99999999999, // 65519.99999999999 + 0.000061005353927612305, // 0.000061005353927612305 + 0.0000610053539276123 // 0.0000610053539276123 ] } }; diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/this-is-not-extensible.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/this-is-not-extensible.js index 466959ed64..5a6ae195bf 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/this-is-not-extensible.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/this-is-not-extensible.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/tonumber-value-detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/tonumber-value-detached-buffer.js index 62b51f8945..a4f5eac988 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/tonumber-value-detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/tonumber-value-detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-key-is-symbol.js index ed0dddfd7b..8d72613876 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-key-is-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-key-is-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-realm.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-realm.js index 05cc9e7246..6baca7b13b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-realm.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-realm.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-ab-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-ab-strict-strict.js index b54d66cca8..61bd2918d0 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-ab-strict-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-ab-strict-strict.js @@ -40,16 +40,16 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(TypeError, () => { delete sample["0"]; - }, '`delete sample["0"]` throws TypeError'); + }); assert.throws(TypeError, () => { delete sample["1"]; - }, '`delete sample["1"]` throws TypeError'); + }); assert.throws(TypeError, () => { delete sample[0]; - }, '`delete sample[0]` throws TypeError'); + }); assert.throws(TypeError, () => { delete sample[0]; - }, '`delete sample[0]` throws TypeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-sab-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-sab-non-strict.js index 0f63640193..7b591a085e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-sab-non-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-sab-non-strict.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-sab-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-sab-strict-strict.js index 6677f96548..cd3aaaa64e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-sab-strict-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-sab-strict-strict.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally 'use strict'; // Copyright (C) 2020 Rick Waldron. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-canonical-index-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-canonical-index-strict-strict.js index 4435c4ac17..52a1d0c371 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-canonical-index-strict-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-canonical-index-strict-strict.js @@ -60,7 +60,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(TypeError, () => { delete sample[key]; - }, '`delete sample[key]` throws TypeError'); + }); delete TypedArray.prototype[key]; }); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-minus-zero-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-minus-zero-strict-strict.js index c0e42e745e..4225c3761e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-minus-zero-strict-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-minus-zero-strict-strict.js @@ -43,7 +43,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.sameValue(delete sample["-0"], true, 'The value of `delete sample["-0"]` is true'); assert.throws(TypeError, () => { delete sample[-0]; - }, '`delete sample[-0]` throws TypeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-numeric-index-get-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-numeric-index-get-throws.js index 2cd35158c4..ba58f7e2bb 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-numeric-index-get-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-numeric-index-get-throws.js @@ -34,7 +34,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(Test262Error, () => { sample.foo; - }, '`sample.foo` throws Test262Error'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-numeric-index-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-numeric-index-strict-strict.js index 2a9f7171e9..69f1052a0f 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-numeric-index-strict-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-numeric-index-strict-strict.js @@ -42,7 +42,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(TypeError, () => { delete sample.bar; - }, '`delete sample.bar` throws TypeError'); + }); assert.sameValue(delete sample.baz, true, 'The value of `delete sample.baz` is true'); }); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-out-of-bounds-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-out-of-bounds-strict-strict.js index 8d67ba003f..d5b4a54f9b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-out-of-bounds-strict-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-out-of-bounds-strict-strict.js @@ -44,11 +44,11 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(TypeError, () => { delete sample["0"]; - }, '`delete sample["0"]` throws TypeError'); + }); assert.throws(TypeError, () => { delete sample[0]; - }, '`delete sample[0]` throws TypeError'); + }); assert.sameValue(delete sample["1"], true, 'The value of `delete sample["1"]` is true'); assert.sameValue(delete sample[1], true, 'The value of `delete sample[1]` is true'); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-key-is-not-numeric-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-key-is-not-numeric-index.js index f204b58813..c54c35d46d 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-key-is-not-numeric-index.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-key-is-not-numeric-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-key-is-symbol.js index ed0dddfd7b..8d72613876 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-key-is-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-key-is-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-realm.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-realm.js index 05cc9e7246..6baca7b13b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-realm.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-realm.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer.js index d55e8b15ee..f79153c5b1 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-ab-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-ab-non-strict.js index ac273ff0a6..3d019ff1f6 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-ab-non-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-ab-non-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-ab-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-ab-strict-strict.js index 5ac3219bba..63f2adc265 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-ab-strict-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-ab-strict-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) 'use strict'; // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -40,16 +41,16 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(TypeError, () => { delete sample["0"]; - }, '`delete sample["0"]` throws TypeError'); + }); assert.throws(TypeError, () => { delete sample["1"]; - }, '`delete sample["1"]` throws TypeError'); + }); assert.throws(TypeError, () => { delete sample[0]; - }, '`delete sample[0]` throws TypeError'); + }); assert.throws(TypeError, () => { delete sample[0]; - }, '`delete sample[0]` throws TypeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-sab-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-sab-non-strict.js index 0f63640193..7b591a085e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-sab-non-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-sab-non-strict.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2020 Rick Waldron. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-sab-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-sab-strict-strict.js index 6677f96548..cd3aaaa64e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-sab-strict-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-sab-strict-strict.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally 'use strict'; // Copyright (C) 2020 Rick Waldron. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/infinity-detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/infinity-detached-buffer.js index 735673dcc1..49c62e1d97 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/infinity-detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/infinity-detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-canonical-index-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-canonical-index-non-strict.js index 9cd26b2c46..998ccdfcb5 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-canonical-index-non-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-canonical-index-non-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-canonical-index-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-canonical-index-strict-strict.js index acd52c7cce..7ec1e47040 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-canonical-index-strict-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-canonical-index-strict-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) 'use strict'; // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -60,7 +61,7 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(TypeError, () => { delete sample[key]; - }, '`delete sample[key]` throws TypeError'); + }); delete TypedArray.prototype[key]; }); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-integer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-integer.js index d8862bd99b..ace2960d39 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-integer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-integer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-minus-zero-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-minus-zero-non-strict.js index 8a60a14c4c..55f72d6b26 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-minus-zero-non-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-minus-zero-non-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-minus-zero-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-minus-zero-strict-strict.js index 33bae05317..82c9f02681 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-minus-zero-strict-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-minus-zero-strict-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) 'use strict'; // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -43,7 +44,7 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(delete sample["-0"], true, 'The value of `delete sample["-0"]` is true'); assert.throws(TypeError, () => { delete sample[-0]; - }, '`delete sample[-0]` throws TypeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-numeric-index-get-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-numeric-index-get-throws.js index 5035a5d733..ff00a8599b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-numeric-index-get-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-numeric-index-get-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -34,7 +35,7 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(Test262Error, () => { sample.foo; - }, '`sample.foo` throws Test262Error'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-numeric-index-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-numeric-index-non-strict.js index 2b9d9a378e..f6995a7195 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-numeric-index-non-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-numeric-index-non-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-numeric-index-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-numeric-index-strict-strict.js index af6397a576..131e8cd229 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-numeric-index-strict-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-numeric-index-strict-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) 'use strict'; // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -42,7 +43,7 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(TypeError, () => { delete sample.bar; - }, '`delete sample.bar` throws TypeError'); + }); assert.sameValue(delete sample.baz, true, 'The value of `delete sample.baz` is true'); }); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-out-of-bounds-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-out-of-bounds-non-strict.js index 63130f39a7..b667906a7c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-out-of-bounds-non-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-out-of-bounds-non-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-out-of-bounds-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-out-of-bounds-strict-strict.js index c668f681c3..b40ccf92a7 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-out-of-bounds-strict-strict.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-out-of-bounds-strict-strict.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) 'use strict'; // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. @@ -44,11 +45,11 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(TypeError, () => { delete sample["0"]; - }, '`delete sample["0"]` throws TypeError'); + }); assert.throws(TypeError, () => { delete sample[0]; - }, '`delete sample[0]` throws TypeError'); + }); assert.sameValue(delete sample["1"], true, 'The value of `delete sample["1"]` is true'); assert.sameValue(delete sample[1], true, 'The value of `delete sample[1]` is true'); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-symbol.js index 6e25155282..3632436587 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2020 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/detached-buffer-key-is-not-numeric-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/detached-buffer-key-is-not-numeric-index.js index 85a5dd2845..bf90a5d26d 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/detached-buffer-key-is-not-numeric-index.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/detached-buffer-key-is-not-numeric-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/detached-buffer-key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/detached-buffer-key-is-symbol.js index 5d7d4fcb48..0ff050471b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/detached-buffer-key-is-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/detached-buffer-key-is-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/detached-buffer-realm.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/detached-buffer-realm.js index 5c54ccfa2f..7619143e23 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/detached-buffer-realm.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/detached-buffer-realm.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/detached-buffer.js index ca6783aa51..5d6f4eb3f3 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/indexed-value-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/indexed-value-sab.js index 508254c872..84d8667464 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/indexed-value-sab.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/indexed-value-sab.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// |reftest| shell-option(--enable-float16array) skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/indexed-value.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/indexed-value.js index f99235ad50..65131490a4 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/indexed-value.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/indexed-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/infinity-detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/infinity-detached-buffer.js index 64cf13940d..1ddf76c524 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/infinity-detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/infinity-detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2017 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-canonical-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-canonical-index.js index 985516626b..3c5729a93c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-canonical-index.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-canonical-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-integer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-integer.js index 3059457150..7ee893d5ce 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-integer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-integer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-minus-zero.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-minus-zero.js index 2810260d97..2576097613 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-minus-zero.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-minus-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-numeric-index-get-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-numeric-index-get-throws.js index 12ad42d27c..b75c4bfe3e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-numeric-index-get-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-numeric-index-get-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-numeric-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-numeric-index.js index 928add152b..81c2fd60b6 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-numeric-index.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-not-numeric-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-out-of-bounds.js index b8534bf612..9d1bcb7ccd 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-out-of-bounds.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-symbol.js index c0dcf29c51..967a046aa1 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/key-is-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer-key-is-not-number.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer-key-is-not-number.js index 59696d38ea..85bb5fb549 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer-key-is-not-number.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer-key-is-not-number.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer-key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer-key-is-symbol.js index 38d405b94b..066e2efe60 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer-key-is-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer-key-is-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer-realm.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer-realm.js index dfb0d554f1..b27fdafcf2 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer-realm.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer-realm.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer.js index c1a7151ae0..c5bd0ec401 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/enumerate-detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/enumerate-detached-buffer.js index 8611cfb434..2b418f6116 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/enumerate-detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/enumerate-detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2017 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/index-prop-desc.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/index-prop-desc.js index 4238cd9e66..1dda5701f6 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/index-prop-desc.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/index-prop-desc.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // Copyright (C) 2020 Apple Inc. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-minus-zero.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-minus-zero.js index 752f3f6204..4abec5bc24 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-minus-zero.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-minus-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-not-canonical-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-not-canonical-index.js index c9fa3e8b54..b51524fe8d 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-not-canonical-index.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-not-canonical-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-not-integer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-not-integer.js index 297e1b14a3..88f386a22c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-not-integer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-not-integer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-not-numeric-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-not-numeric-index.js index 0f78950189..c73b6ef3f5 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-not-numeric-index.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-not-numeric-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-out-of-bounds.js index c4cda461fb..646eebd35a 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-out-of-bounds.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-symbol.js index d686d07edb..422fb577a5 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/GetOwnProperty/key-is-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/abrupt-from-ordinary-has-parent-hasproperty.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/abrupt-from-ordinary-has-parent-hasproperty.js index fcec3e4db7..d63f2757b2 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/abrupt-from-ordinary-has-parent-hasproperty.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/abrupt-from-ordinary-has-parent-hasproperty.js @@ -51,7 +51,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { Reflect.has(sample, "foo"); - }, '`Reflect.has(sample, "foo")` throws Test262Error'); + }); Object.defineProperty(sample, "foo", { value: 42 }); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/abrupt-from-ordinary-has-parent-hasproperty.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/abrupt-from-ordinary-has-parent-hasproperty.js index 3513862b71..319c791173 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/abrupt-from-ordinary-has-parent-hasproperty.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/abrupt-from-ordinary-has-parent-hasproperty.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -51,7 +52,7 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { Reflect.has(sample, "foo"); - }, '`Reflect.has(sample, "foo")` throws Test262Error'); + }); Object.defineProperty(sample, "foo", { value: 42 }); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer-key-is-not-number.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer-key-is-not-number.js index 3a8d2511e5..e84efc6ee8 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer-key-is-not-number.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer-key-is-not-number.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer-key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer-key-is-symbol.js index 80810d3d8c..fd32467bd9 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer-key-is-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer-key-is-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer-realm.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer-realm.js index d9be7d2e18..d46c0ed716 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer-realm.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer-realm.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer.js index 80f3d2aaf3..70b45f1655 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/indexed-value.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/indexed-value.js index 3cb63c33ba..d554390e0b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/indexed-value.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/indexed-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/infinity-with-detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/infinity-with-detached-buffer.js index b71d009764..c7ba3b64d9 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/infinity-with-detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/infinity-with-detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2017 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/inherited-property.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/inherited-property.js index eb736978dc..3e0f0ff400 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/inherited-property.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/inherited-property.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-greater-than-last-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-greater-than-last-index.js index 1c930e4005..172cef5017 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-greater-than-last-index.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-greater-than-last-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-lower-than-zero.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-lower-than-zero.js index 3cbe081f30..7f22872bbc 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-lower-than-zero.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-lower-than-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-minus-zero.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-minus-zero.js index 870cc9a039..d06d116a6d 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-minus-zero.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-minus-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-not-canonical-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-not-canonical-index.js index 4207b866e4..f14c2ca6d2 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-not-canonical-index.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-not-canonical-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-not-integer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-not-integer.js index 3b9b39bae2..0fb7249a70 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-not-integer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-not-integer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-not-numeric-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-not-numeric-index.js index acb5905ae0..d596b8fb16 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-not-numeric-index.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-not-numeric-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-symbol.js index 915af90334..cdb1afacee 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/resizable-array-buffer-auto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/resizable-array-buffer-auto.js index 5e1a504d5e..a24a296a50 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/resizable-array-buffer-auto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/resizable-array-buffer-auto.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/resizable-array-buffer-fixed.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/resizable-array-buffer-fixed.js index 59c5b5ac4c..252cff6c2d 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/resizable-array-buffer-fixed.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/HasProperty/resizable-array-buffer-fixed.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-and-string-and-symbol-keys-.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-and-string-and-symbol-keys-.js index ebf707791b..541796a64c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-and-string-and-symbol-keys-.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-and-string-and-symbol-keys-.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-and-string-keys.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-and-string-keys.js index 00532ce8b2..cdf0fcddf4 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-and-string-keys.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-and-string-keys.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-resizable-array-buffer-auto.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-resizable-array-buffer-auto.js index 83995def30..2560585861 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-resizable-array-buffer-auto.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-resizable-array-buffer-auto.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-resizable-array-buffer-fixed.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-resizable-array-buffer-fixed.js index b6faa1f4ba..9a9d7a7ebc 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-resizable-array-buffer-fixed.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes-resizable-array-buffer-fixed.js @@ -1,4 +1,4 @@ -// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// |reftest| shell-option(--enable-arraybuffer-resizable) shell-option(--enable-float16array) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes.js index b731decd95..acffe3aa3b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/integer-indexes.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/not-enumerable-keys.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/not-enumerable-keys.js index 9c78932877..e2a5d0b48a 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/not-enumerable-keys.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/OwnPropertyKeys/not-enumerable-keys.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-not-numeric-index-set-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-not-numeric-index-set-throws.js index 5b8dd12f01..6e6ec71a53 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-not-numeric-index-set-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-not-numeric-index-set-throws.js @@ -34,7 +34,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { sample.test262 = 1; - }, '`sample.test262 = 1` throws Test262Error'); + }); assert.sameValue(sample.test262, undefined, 'The value of sample.test262 is expected to equal `undefined`'); }); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/null-tobigint.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/null-tobigint.js index 104c5a8509..ecfdccbed8 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/null-tobigint.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/null-tobigint.js @@ -56,7 +56,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { typedArray[0] = null; - }, '`typedArray[0] = null` throws TypeError'); + }); }); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/number-tobigint.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/number-tobigint.js index b7724a0aed..93e6324a44 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/number-tobigint.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/number-tobigint.js @@ -56,31 +56,31 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { typedArray[0] = 1; - }, '`typedArray[0] = 1` throws TypeError'); + }); assert.throws(TypeError, function() { typedArray[0] = Math.pow(2, 63); - }, '`typedArray[0] = Math.pow(2, 63)` throws TypeError'); + }); assert.throws(TypeError, function() { typedArray[0] = +0; - }, '`typedArray[0] = +0` throws TypeError'); + }); assert.throws(TypeError, function() { typedArray[0] = -0; - }, '`typedArray[0] = -0` throws TypeError'); + }); assert.throws(TypeError, function() { typedArray[0] = Infinity; - }, '`typedArray[0] = Infinity` throws TypeError'); + }); assert.throws(TypeError, function() { typedArray[0] = -Infinity; - }, '`typedArray[0] = -Infinity` throws TypeError'); + }); assert.throws(TypeError, function() { typedArray[0] = NaN; - }, '`typedArray[0] = NaN` throws TypeError'); + }); }); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/string-nan-tobigint.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/string-nan-tobigint.js index f0646cc025..898edef334 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/string-nan-tobigint.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/string-nan-tobigint.js @@ -60,7 +60,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(SyntaxError, function() { typedArray[0] = "definately not a number"; - }, '`typedArray[0] = "definately not a number"` throws SyntaxError'); + }); }); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/symbol-tobigint.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/symbol-tobigint.js index 6b5618b568..76dbf5ded1 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/symbol-tobigint.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/symbol-tobigint.js @@ -58,7 +58,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { typedArray[0] = s; - }, '`typedArray[0] = s` throws TypeError'); + }); }); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/undefined-tobigint.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/undefined-tobigint.js index a2152d98f2..b0f99816e4 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/undefined-tobigint.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/BigInt/undefined-tobigint.js @@ -57,7 +57,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { typedArray[0] = undefined; - }, '`typedArray[0] = undefined` throws TypeError'); + }); }); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/bigint-tonumber.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/bigint-tonumber.js index d2355a13c4..5ee59a7075 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/bigint-tonumber.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/bigint-tonumber.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 Valerie Young. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -55,7 +56,7 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(TypeError, function() { typedArray[0] = 1n; - }, '`typedArray[0] = 1n` throws TypeError'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/conversion-operation-consistent-nan.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/conversion-operation-consistent-nan.js index b97ef770e1..079f249552 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/conversion-operation-consistent-nan.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/conversion-operation-consistent-nan.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/conversion-operation.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/conversion-operation.js index 786b0c4bec..896863d4d1 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/conversion-operation.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/conversion-operation.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/detached-buffer-key-is-not-numeric-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/detached-buffer-key-is-not-numeric-index.js index 81a22ef437..733061e5cf 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/detached-buffer-key-is-not-numeric-index.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/detached-buffer-key-is-not-numeric-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/detached-buffer-key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/detached-buffer-key-is-symbol.js index 183070c85b..da083b6c8b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/detached-buffer-key-is-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/detached-buffer-key-is-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/detached-buffer-realm.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/detached-buffer-realm.js index 5e6269b2e9..133f1aa0fa 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/detached-buffer-realm.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/detached-buffer-realm.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/detached-buffer.js index 705b22dca5..f34756f129 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -51,7 +52,7 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { sample['0'] = obj; - }, '`sample[\'0\'] = obj` throws Test262Error'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/indexed-value.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/indexed-value.js index 66cf4571ec..b530dd0da6 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/indexed-value.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/indexed-value.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-minus-zero.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-minus-zero.js index c171aa1a3c..0b388babb5 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-minus-zero.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-minus-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-not-canonical-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-not-canonical-index.js index 72d1f7769a..65a8eead9c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-not-canonical-index.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-not-canonical-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-not-integer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-not-integer.js index a13b9cfe79..2d3957b4b1 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-not-integer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-not-integer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-not-numeric-index-set-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-not-numeric-index-set-throws.js index 13360bfa55..ae41a4ab80 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-not-numeric-index-set-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-not-numeric-index-set-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -34,7 +35,7 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { sample.test262 = 1; - }, '`sample.test262 = 1` throws Test262Error'); + }); assert.sameValue(sample.test262, undefined, 'The value of sample.test262 is expected to equal `undefined`'); }); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-not-numeric-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-not-numeric-index.js index 9db75bd292..bb25303fc9 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-not-numeric-index.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-not-numeric-index.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-out-of-bounds.js index 5470398b71..9fa3d49a53 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-out-of-bounds.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-out-of-bounds.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-symbol.js index fe624e4725..8f1313b9fd 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-symbol.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/key-is-symbol.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/resized-out-of-bounds-to-in-bounds-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/resized-out-of-bounds-to-in-bounds-index.js new file mode 100644 index 0000000000..62268e26b6 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/resized-out-of-bounds-to-in-bounds-index.js @@ -0,0 +1,40 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarraysetelement +description: > + Index is validated after converting the right-hand side operand. +info: | + TypedArraySetElement ( O, index, value ) + ... + 2. Otherwise, let numValue be ? ToNumber(value). + 3. If IsValidIntegerIndex(O, index) is true, then + ... + +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(0, {maxByteLength: 1}); +let ta = new Int8Array(rab); + +// Index is initially out-of-bounds. +let index = 0; + +let value = { + valueOf() { + // Make `index` an in-bounds access. + rab.resize(1); + return 100; + } +}; + +assert.sameValue(ta.length, 0); + +ta[index] = value; + +assert.sameValue(ta.length, 1); +assert.sameValue(ta[0], 100); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/shell.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/shell.js index c32f046213..c888512cb3 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/shell.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/shell.js @@ -53,7 +53,22 @@ var byteConversionValues = { -4294967296, // - ( 2 ** 32 ) Infinity, -Infinity, - 0 + 0, + 2049, // an integer which rounds down under ties-to-even when cast to float16 + 2051, // an integer which rounds up under ties-to-even when cast to float16 + 0.00006103515625, // smallest normal float16 + 0.00006097555160522461, // largest subnormal float16 + 5.960464477539063e-8, // smallest float16 + 2.9802322387695312e-8, // largest double which rounds to 0 when cast to float16 + 2.980232238769532e-8, // smallest double which does not round to 0 when cast to float16 + 8.940696716308594e-8, // a double which rounds up to a subnormal under ties-to-even when cast to float16 + 1.4901161193847656e-7, // a double which rounds down to a subnormal under ties-to-even when cast to float16 + 1.490116119384766e-7, // the next double above the one on the previous line one + 65504, // max finite float16 + 65520, // smallest double which rounds to infinity when cast to float16 + 65519.99999999999, // largest double which does not round to infinity when cast to float16 + 0.000061005353927612305, // smallest double which rounds to a non-subnormal when cast to float16 + 0.0000610053539276123 // largest double which rounds to a subnormal when cast to float16 ], expected: { @@ -98,7 +113,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 1, // 2049 + 3, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + -32, // 65504 + -16, // 65520 + -17, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint8: [ 127, // 127 @@ -141,7 +171,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 1, // 2049 + 3, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 224, // 65504 + 240, // 65520 + 239, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint8Clamped: [ 127, // 127 @@ -184,7 +229,22 @@ var byteConversionValues = { 0, // -4294967296 255, // Infinity 0, // -Infinity - 0 + 0, // 0 + 255, // 2049 + 255, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 255, // 65504 + 255, // 65520 + 255, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Int16: [ 127, // 127 @@ -227,7 +287,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + -32, // 65504 + -16, // 65520 + -17, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint16: [ 127, // 127 @@ -270,7 +345,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Int32: [ 127, // 127 @@ -313,7 +403,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint32: [ 127, // 127 @@ -356,93 +461,138 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Float16: [ - 127, // 127 - 128, // 128 - 32768, // 32767 - 32768, // 32768 - Infinity, // 2147483647 - Infinity, // 2147483648 - 255, // 255 - 256, // 256 - Infinity, // 65535 - Infinity, // 65536 - Infinity, // 4294967295 - Infinity, // 4294967296 - Infinity, // 9007199254740991 - Infinity, // 9007199254740992 - 1.099609375, // 1.1 - 0.0999755859375, // 0.1 - 0.5, // 0.5 - 0.5, // 0.50000001, - 0.60009765625, // 0.6 - 0.7001953125, // 0.7 - NaN, // undefined - -1, // -1 - -0, // -0 - -0.0999755859375, // -0.1 - -1.099609375, // -1.1 - NaN, // NaN - -127, // -127 - -128, // -128 - -32768, // -32767 - -32768, // -32768 - -Infinity, // -2147483647 - -Infinity, // -2147483648 - -255, // -255 - -256, // -256 - -Infinity, // -65535 - -Infinity, // -65536 - -Infinity, // -4294967295 - -Infinity, // -4294967296 - Infinity, // Infinity - -Infinity, // -Infinity - 0 + 127, // 127 + 128, // 128 + 32768, // 32767 + 32768, // 32768 + Infinity, // 2147483647 + Infinity, // 2147483648 + 255, // 255 + 256, // 256 + Infinity, // 65535 + Infinity, // 65536 + Infinity, // 4294967295 + Infinity, // 4294967296 + Infinity, // 9007199254740991 + Infinity, // 9007199254740992 + 1.099609375, // 1.1 + 0.0999755859375, // 0.1 + 0.5, // 0.5 + 0.5, // 0.50000001, + 0.60009765625, // 0.6 + 0.7001953125, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.0999755859375, // -0.1 + -1.099609375, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32768, // -32767 + -32768, // -32768 + -Infinity, // -2147483647 + -Infinity, // -2147483648 + -255, // -255 + -256, // -256 + -Infinity, // -65535 + -Infinity, // -65536 + -Infinity, // -4294967295 + -Infinity, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0, // 0 + 2048, // 2049 + 2052, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 5.960464477539063e-8, // 2.980232238769532e-8 + 1.1920928955078125e-7, // 8.940696716308594e-8 + 1.1920928955078125e-7, // 1.4901161193847656e-7 + 1.7881393432617188e-7, // 1.490116119384766e-7 + 65504, // 65504 + Infinity, // 65520 + 65504, // 65519.99999999999 + 0.00006103515625, // 0.000061005353927612305 + 0.00006097555160522461 // 0.0000610053539276123 ], Float32: [ - 127, // 127 - 128, // 128 - 32767, // 32767 - 32768, // 32768 - 2147483648, // 2147483647 - 2147483648, // 2147483648 - 255, // 255 - 256, // 256 - 65535, // 65535 - 65536, // 65536 - 4294967296, // 4294967295 - 4294967296, // 4294967296 - 9007199254740992, // 9007199254740991 - 9007199254740992, // 9007199254740992 - 1.100000023841858, // 1.1 - 0.10000000149011612, // 0.1 - 0.5, // 0.5 - 0.5, // 0.50000001, - 0.6000000238418579, // 0.6 - 0.699999988079071, // 0.7 - NaN, // undefined - -1, // -1 - -0, // -0 - -0.10000000149011612, // -0.1 - -1.100000023841858, // -1.1 - NaN, // NaN - -127, // -127 - -128, // -128 - -32767, // -32767 - -32768, // -32768 - -2147483648, // -2147483647 - -2147483648, // -2147483648 - -255, // -255 - -256, // -256 - -65535, // -65535 - -65536, // -65536 - -4294967296, // -4294967295 - -4294967296, // -4294967296 - Infinity, // Infinity - -Infinity, // -Infinity - 0 + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483648, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967296, // 4294967295 + 4294967296, // 4294967296 + 9007199254740992, // 9007199254740991 + 9007199254740992, // 9007199254740992 + 1.100000023841858, // 1.1 + 0.10000000149011612, // 0.1 + 0.5, // 0.5 + 0.5, // 0.50000001, + 0.6000000238418579, // 0.6 + 0.699999988079071, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.10000000149011612, // -0.1 + -1.100000023841858, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483648, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + -4294967296, // -4294967295 + -4294967296, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 2.9802322387695312e-8, // 2.9802322387695312e-8 + 2.9802322387695312e-8, // 2.980232238769532e-8 + 8.940696716308594e-8, // 8.940696716308594e-8 + 1.4901161193847656e-7, // 1.4901161193847656e-7 + 1.4901161193847656e-7, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65520, // 65519.99999999999 + 0.000061005353927612305, // 0.000061005353927612305 + 0.000061005353927612305 // 0.0000610053539276123 ], Float64: [ 127, // 127 @@ -485,7 +635,22 @@ var byteConversionValues = { -4294967296, // -4294967296 Infinity, // Infinity -Infinity, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 2.9802322387695312e-8, // 2.9802322387695312e-8 + 2.980232238769532e-8, // 2.980232238769532e-8 + 8.940696716308594e-8, // 8.940696716308594e-8 + 1.4901161193847656e-7, // 1.4901161193847656e-7 + 1.490116119384766e-7, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519.99999999999, // 65519.99999999999 + 0.000061005353927612305, // 0.000061005353927612305 + 0.0000610053539276123 // 0.0000610053539276123 ] } }; diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/tonumber-value-detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/tonumber-value-detached-buffer.js index bdb3a74ae9..b1e0131ab5 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/tonumber-value-detached-buffer.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/tonumber-value-detached-buffer.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/tonumber-value-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/tonumber-value-throws.js index 08f17de272..5991c52715 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/tonumber-value-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Set/tonumber-value-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -37,27 +38,27 @@ testWithTypedArrayConstructors(function(TA) { assert.throws(Test262Error, function() { sample["0"] = obj; - }, '`sample["0"] = obj` throws Test262Error'); + }); assert.throws(Test262Error, function() { sample["1.1"] = obj; - }, '`sample["1.1"] = obj` throws Test262Error'); + }); assert.throws(Test262Error, function() { sample["-0"] = obj; - }, '`sample["-0"] = obj` throws Test262Error'); + }); assert.throws(Test262Error, function() { sample["-1"] = obj; - }, '`sample["-1"] = obj` throws Test262Error'); + }); assert.throws(Test262Error, function() { sample["1"] = obj; - }, '`sample["1"] = obj` throws Test262Error'); + }); assert.throws(Test262Error, function() { sample["2"] = obj; - }, '`sample["2"] = obj` throws Test262Error'); + }); }); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/argument-is-symbol-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/argument-is-symbol-throws.js index ced8ecb0c0..9dd99ec337 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/argument-is-symbol-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/argument-is-symbol-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/argument-number-value-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/argument-number-value-throws.js index 620165d5bb..0ab68585e8 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/argument-number-value-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/argument-number-value-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/custom-ctor-does-not-instantiate-ta-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/custom-ctor-does-not-instantiate-ta-throws.js index 8e6695a8ec..a754ab0d71 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/custom-ctor-does-not-instantiate-ta-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/custom-ctor-does-not-instantiate-ta-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/custom-ctor-returns-other-instance.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/custom-ctor-returns-other-instance.js index 965a569166..6520c8e33c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/custom-ctor-returns-other-instance.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/custom-ctor-returns-other-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/custom-ctor-returns-smaller-instance-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/custom-ctor-returns-smaller-instance-throws.js index 28f5cda441..25e854b154 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/custom-ctor-returns-smaller-instance-throws.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/custom-ctor-returns-smaller-instance-throws.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/custom-ctor.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/custom-ctor.js index 7599583a84..5b390b9a39 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/custom-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/custom-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/inherited.js index 99f528b8a8..f96b15993e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/invoked-as-func.js index ed3b8c02e9..c32c99c58d 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/invoked-as-func.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/invoked-as-func.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/nan-conversion.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/nan-conversion.js index 9c897d862e..c09ef9288c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/nan-conversion.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/nan-conversion.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/new-instance-empty.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/new-instance-empty.js index d6ee42b662..35f7924cfa 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/new-instance-empty.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/new-instance-empty.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/new-instance-from-zero.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/new-instance-from-zero.js index b5f5a0f933..2918d776c2 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/new-instance-from-zero.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/new-instance-from-zero.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/new-instance-using-custom-ctor.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/new-instance-using-custom-ctor.js index f806a5b711..f926f92984 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/new-instance-using-custom-ctor.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/new-instance-using-custom-ctor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/new-instance.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/new-instance.js index 3ae4eed98a..7d96be8f69 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/new-instance.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/new-instance.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/this-is-not-constructor.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/this-is-not-constructor.js index 16e1765df3..03ad2de279 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/of/this-is-not-constructor.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/of/this-is-not-constructor.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/Symbol.iterator.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/Symbol.iterator.js index 6e2f2b41e3..315c53fb91 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/Symbol.iterator.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/Symbol.iterator.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/Symbol.toStringTag/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/Symbol.toStringTag/inherited.js index d60d3c4b7d..65c4c92174 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/Symbol.toStringTag/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/Symbol.toStringTag/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/buffer/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/buffer/inherited.js index 00fdd19d1b..0c8d5af8fa 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/buffer/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/buffer/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/byteLength/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/byteLength/inherited.js index 67aa9848a0..82b3228e56 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/byteLength/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/byteLength/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/byteOffset/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/byteOffset/inherited.js index 874d4abd88..44276ab6f9 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/byteOffset/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/byteOffset/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/copyWithin/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/copyWithin/inherited.js index e831c04e99..8fc3dd290f 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/copyWithin/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/copyWithin/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/entries/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/entries/inherited.js index 217462a687..bfda9c1389 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/entries/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/entries/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/every/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/every/inherited.js index b61168bd9e..cf97c1c576 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/every/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/every/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/fill/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/fill/inherited.js index 0a01168f76..a7cd2bda73 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/fill/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/fill/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/filter/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/filter/inherited.js index 42c177812e..30adb66b63 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/filter/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/filter/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/find/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/find/inherited.js index 1895450c9a..13ca9c7717 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/find/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/find/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/findIndex/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/findIndex/inherited.js index 902a419db4..96fbfb2fae 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/findIndex/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/findIndex/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/forEach/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/forEach/inherited.js index bead9ffae5..fb262d80de 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/forEach/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/forEach/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/indexOf/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/indexOf/inherited.js index 398ba4e107..c8088e1f5a 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/indexOf/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/indexOf/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/join/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/join/inherited.js index 37badbec58..813704926a 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/join/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/join/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/keys/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/keys/inherited.js index a2c0289d1b..6f9b9cb196 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/keys/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/keys/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/lastIndexOf/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/lastIndexOf/inherited.js index f9d7dd8626..57a0c14e0e 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/lastIndexOf/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/lastIndexOf/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/length/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/length/inherited.js index e2b9ea33c3..3416fa6318 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/length/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/length/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/map/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/map/inherited.js index 591322dfe3..c2561db8ce 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/map/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/map/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/reduce/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/reduce/inherited.js index 758118a5d0..41236775b6 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/reduce/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/reduce/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/reduceRight/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/reduceRight/inherited.js index 334b156c1e..9c9350e9a2 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/reduceRight/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/reduceRight/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/reverse/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/reverse/inherited.js index e6758c7916..b1c65bd86b 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/reverse/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/reverse/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/set/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/set/inherited.js index 90822be1b2..343587d6df 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/set/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/set/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/slice/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/slice/inherited.js index 0c4578ee12..e17bf94f1f 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/slice/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/slice/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/some/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/some/inherited.js index 74aefc5a0f..d593d6092c 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/some/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/some/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/sort/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/sort/inherited.js index e42774b2be..1fe3e87773 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/sort/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/sort/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/subarray/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/subarray/inherited.js index 63609b2124..cf4190e361 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/subarray/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/subarray/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/toLocaleString/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/toLocaleString/inherited.js index bd2d3caaf5..576e184ec7 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/toLocaleString/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/toLocaleString/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/toString/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/toString/inherited.js index b79a9b7b20..77372394a1 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/toString/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/toString/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/values/inherited.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/values/inherited.js index 0283231b6b..b3ea9119c3 100644 --- a/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/values/inherited.js +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/prototype/values/inherited.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/built-ins/WeakMap/length.js b/js/src/tests/test262/built-ins/WeakMap/length.js index e5bf7043e3..d398cfa909 100644 --- a/js/src/tests/test262/built-ins/WeakMap/length.js +++ b/js/src/tests/test262/built-ins/WeakMap/length.js @@ -7,10 +7,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(WeakMap.length, 0, 'The value of `WeakMap.length` is `0`'); - -verifyNotEnumerable(WeakMap, 'length'); -verifyNotWritable(WeakMap, 'length'); -verifyConfigurable(WeakMap, 'length'); +verifyProperty(WeakMap, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakMap/name.js b/js/src/tests/test262/built-ins/WeakMap/name.js index d7d4457efe..03bf8dc858 100644 --- a/js/src/tests/test262/built-ins/WeakMap/name.js +++ b/js/src/tests/test262/built-ins/WeakMap/name.js @@ -10,13 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue( - WeakMap.name, 'WeakMap', - 'The value of `WeakMap.name` is "WeakMap"' -); - -verifyNotEnumerable(WeakMap, 'name'); -verifyNotWritable(WeakMap, 'name'); -verifyConfigurable(WeakMap, 'name'); +verifyProperty(WeakMap, "name", { + value: "WeakMap", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/delete/length.js b/js/src/tests/test262/built-ins/WeakMap/prototype/delete/length.js index bfdcaff706..768a17db21 100644 --- a/js/src/tests/test262/built-ins/WeakMap/prototype/delete/length.js +++ b/js/src/tests/test262/built-ins/WeakMap/prototype/delete/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - WeakMap.prototype.delete.length, 1, - 'The value of WeakMap.prototype.delete.length is 1' -); - -verifyNotEnumerable(WeakMap.prototype.delete, 'length'); -verifyNotWritable(WeakMap.prototype.delete, 'length'); -verifyConfigurable(WeakMap.prototype.delete, 'length'); +verifyProperty(WeakMap.prototype.delete, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/delete/name.js b/js/src/tests/test262/built-ins/WeakMap/prototype/delete/name.js index 67bc4d2ee4..129943adcf 100644 --- a/js/src/tests/test262/built-ins/WeakMap/prototype/delete/name.js +++ b/js/src/tests/test262/built-ins/WeakMap/prototype/delete/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - WeakMap.prototype.delete.name, 'delete', - 'The value of WeakMap.prototype.delete.name is "delete"' -); - -verifyNotEnumerable(WeakMap.prototype.delete, 'name'); -verifyNotWritable(WeakMap.prototype.delete, 'name'); -verifyConfigurable(WeakMap.prototype.delete, 'name'); +verifyProperty(WeakMap.prototype.delete, "name", { + value: "delete", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/delete/not-a-constructor.js b/js/src/tests/test262/built-ins/WeakMap/prototype/delete/not-a-constructor.js index 59136bd1ef..eb219ebd2f 100644 --- a/js/src/tests/test262/built-ins/WeakMap/prototype/delete/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/WeakMap/prototype/delete/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let wm = new WeakMap(); new wm.delete(); -}, '`let wm = new WeakMap(); new wm.delete()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/get/length.js b/js/src/tests/test262/built-ins/WeakMap/prototype/get/length.js index eb8f7d546e..5b1f046fb7 100644 --- a/js/src/tests/test262/built-ins/WeakMap/prototype/get/length.js +++ b/js/src/tests/test262/built-ins/WeakMap/prototype/get/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - WeakMap.prototype.get.length, 1, - 'The value of `WeakMap.prototype.get.length` is `1`' -); - -verifyNotEnumerable(WeakMap.prototype.get, 'length'); -verifyNotWritable(WeakMap.prototype.get, 'length'); -verifyConfigurable(WeakMap.prototype.get, 'length'); +verifyProperty(WeakMap.prototype.get, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/get/name.js b/js/src/tests/test262/built-ins/WeakMap/prototype/get/name.js index ce82cdb4e4..cd457ec7db 100644 --- a/js/src/tests/test262/built-ins/WeakMap/prototype/get/name.js +++ b/js/src/tests/test262/built-ins/WeakMap/prototype/get/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - WeakMap.prototype.get.name, 'get', - 'The value of `WeakMap.prototype.get.name` is `"get"`' -); - -verifyNotEnumerable(WeakMap.prototype.get, 'name'); -verifyNotWritable(WeakMap.prototype.get, 'name'); -verifyConfigurable(WeakMap.prototype.get, 'name'); +verifyProperty(WeakMap.prototype.get, "name", { + value: "get", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/get/not-a-constructor.js b/js/src/tests/test262/built-ins/WeakMap/prototype/get/not-a-constructor.js index ec8be07522..5d4e7e6adc 100644 --- a/js/src/tests/test262/built-ins/WeakMap/prototype/get/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/WeakMap/prototype/get/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let wm = new WeakMap(); new wm.get(); -}, '`let wm = new WeakMap(); new wm.get()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/has/length.js b/js/src/tests/test262/built-ins/WeakMap/prototype/has/length.js index a68fa8ecec..fab022f055 100644 --- a/js/src/tests/test262/built-ins/WeakMap/prototype/has/length.js +++ b/js/src/tests/test262/built-ins/WeakMap/prototype/has/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - WeakMap.prototype.has.length, 1, - 'The value of WeakMap.prototype.has.length is 1' -); - -verifyNotEnumerable(WeakMap.prototype.has, 'length'); -verifyNotWritable(WeakMap.prototype.has, 'length'); -verifyConfigurable(WeakMap.prototype.has, 'length'); +verifyProperty(WeakMap.prototype.has, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/has/name.js b/js/src/tests/test262/built-ins/WeakMap/prototype/has/name.js index 558f24335d..15595af753 100644 --- a/js/src/tests/test262/built-ins/WeakMap/prototype/has/name.js +++ b/js/src/tests/test262/built-ins/WeakMap/prototype/has/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - WeakMap.prototype.has.name, 'has', - 'The value of WeakMap.prototype.has.name is "has"' -); - -verifyNotEnumerable(WeakMap.prototype.has, 'name'); -verifyNotWritable(WeakMap.prototype.has, 'name'); -verifyConfigurable(WeakMap.prototype.has, 'name'); +verifyProperty(WeakMap.prototype.has, "name", { + value: "has", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/has/not-a-constructor.js b/js/src/tests/test262/built-ins/WeakMap/prototype/has/not-a-constructor.js index 83df17bbf5..ecdc3c7702 100644 --- a/js/src/tests/test262/built-ins/WeakMap/prototype/has/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/WeakMap/prototype/has/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let wm = new WeakMap(); new wm.has(); -}, '`let wm = new WeakMap(); new wm.has()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/length.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/length.js index 052f181e53..1e5665313e 100644 --- a/js/src/tests/test262/built-ins/WeakMap/prototype/set/length.js +++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/length.js @@ -11,13 +11,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - WeakMap.prototype.set.length, 2, - 'The value of `WeakMap.prototype.set.length` is `2`' -); - -verifyNotEnumerable(WeakMap.prototype.set, 'length'); -verifyNotWritable(WeakMap.prototype.set, 'length'); -verifyConfigurable(WeakMap.prototype.set, 'length'); +verifyProperty(WeakMap.prototype.set, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/name.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/name.js index f1d62ffef5..b30a386faa 100644 --- a/js/src/tests/test262/built-ins/WeakMap/prototype/set/name.js +++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/name.js @@ -11,13 +11,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - WeakMap.prototype.set.name, 'set', - 'The value of WeakMap.prototype.set.name is "set"' -); - -verifyNotEnumerable(WeakMap.prototype.set, 'name'); -verifyNotWritable(WeakMap.prototype.set, 'name'); -verifyConfigurable(WeakMap.prototype.set, 'name'); +verifyProperty(WeakMap.prototype.set, "name", { + value: "set", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakMap/prototype/set/not-a-constructor.js b/js/src/tests/test262/built-ins/WeakMap/prototype/set/not-a-constructor.js index c8d6272217..b3e89c04d1 100644 --- a/js/src/tests/test262/built-ins/WeakMap/prototype/set/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/WeakMap/prototype/set/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let wm = new WeakMap(); new wm.set({}, 1); -}, '`let wm = new WeakMap(); new wm.set({}, 1)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/not-a-constructor.js b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/not-a-constructor.js index 9a97911843..0e5e245076 100644 --- a/js/src/tests/test262/built-ins/WeakRef/prototype/deref/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/WeakRef/prototype/deref/not-a-constructor.js @@ -30,7 +30,7 @@ assert.sameValue( assert.throws(TypeError, () => { let wr = new WeakRef({}); new wr.deref(); -}, '`let wr = new WeakRef({}); new wr.deref()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/length.js b/js/src/tests/test262/built-ins/WeakSet/length.js index a34c33236d..606922e0de 100644 --- a/js/src/tests/test262/built-ins/WeakSet/length.js +++ b/js/src/tests/test262/built-ins/WeakSet/length.js @@ -7,10 +7,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(WeakSet.length, 0, 'The value of `WeakSet.length` is `0`'); - -verifyNotEnumerable(WeakSet, 'length'); -verifyNotWritable(WeakSet, 'length'); -verifyConfigurable(WeakSet, 'length'); +verifyProperty(WeakSet, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/name.js b/js/src/tests/test262/built-ins/WeakSet/name.js index dedd6f4fd0..331b94e501 100644 --- a/js/src/tests/test262/built-ins/WeakSet/name.js +++ b/js/src/tests/test262/built-ins/WeakSet/name.js @@ -10,13 +10,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue( - WeakSet.name, 'WeakSet', - 'The value of `WeakSet.name` is "WeakSet"' -); - -verifyNotEnumerable(WeakSet, 'name'); -verifyNotWritable(WeakSet, 'name'); -verifyConfigurable(WeakSet, 'name'); +verifyProperty(WeakSet, "name", { + value: "WeakSet", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/length.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/length.js index 7112319f12..f6b1312673 100644 --- a/js/src/tests/test262/built-ins/WeakSet/prototype/add/length.js +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/length.js @@ -11,13 +11,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - WeakSet.prototype.add.length, 1, - 'The value of `WeakSet.prototype.add.length` is `1`' -); - -verifyNotEnumerable(WeakSet.prototype.add, 'length'); -verifyNotWritable(WeakSet.prototype.add, 'length'); -verifyConfigurable(WeakSet.prototype.add, 'length'); +verifyProperty(WeakSet.prototype.add, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/name.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/name.js index e81470dc1c..5383bbd19a 100644 --- a/js/src/tests/test262/built-ins/WeakSet/prototype/add/name.js +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/name.js @@ -11,13 +11,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - WeakSet.prototype.add.name, 'add', - 'The value of WeakSet.prototype.add.name is "add"' -); - -verifyNotEnumerable(WeakSet.prototype.add, 'name'); -verifyNotWritable(WeakSet.prototype.add, 'name'); -verifyConfigurable(WeakSet.prototype.add, 'name'); +verifyProperty(WeakSet.prototype.add, "name", { + value: "add", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/not-a-constructor.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/not-a-constructor.js index df2a033c51..3024ce6299 100644 --- a/js/src/tests/test262/built-ins/WeakSet/prototype/add/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let ws = new WeakSet(); new ws.add({}); -}, '`let ws = new WeakSet(); new ws.add({})` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/length.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/length.js index 516b074855..63d20118fd 100644 --- a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/length.js +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - WeakSet.prototype.delete.length, 1, - 'The value of WeakSet.prototype.delete.length is 1' -); - -verifyNotEnumerable(WeakSet.prototype.delete, 'length'); -verifyNotWritable(WeakSet.prototype.delete, 'length'); -verifyConfigurable(WeakSet.prototype.delete, 'length'); +verifyProperty(WeakSet.prototype.delete, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/name.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/name.js index b759002e7c..da0d4f7fa3 100644 --- a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/name.js +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - WeakSet.prototype.delete.name, 'delete', - 'The value of WeakSet.prototype.delete.name is "delete"' -); - -verifyNotEnumerable(WeakSet.prototype.delete, 'name'); -verifyNotWritable(WeakSet.prototype.delete, 'name'); -verifyConfigurable(WeakSet.prototype.delete, 'name'); +verifyProperty(WeakSet.prototype.delete, "name", { + value: "delete", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/not-a-constructor.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/not-a-constructor.js index 3f5c5605d0..b12b0c07f9 100644 --- a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let ws = new WeakSet(); new ws.delete(); -}, '`let ws = new WeakSet(); new ws.delete()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/length.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/length.js index 5e4176a5cc..cec3d5e3f0 100644 --- a/js/src/tests/test262/built-ins/WeakSet/prototype/has/length.js +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/length.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - WeakSet.prototype.has.length, 1, - 'The value of WeakSet.prototype.has.length is 1' -); - -verifyNotEnumerable(WeakSet.prototype.has, 'length'); -verifyNotWritable(WeakSet.prototype.has, 'length'); -verifyConfigurable(WeakSet.prototype.has, 'length'); +verifyProperty(WeakSet.prototype.has, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/name.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/name.js index 6fca676585..11c364e160 100644 --- a/js/src/tests/test262/built-ins/WeakSet/prototype/has/name.js +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/name.js @@ -12,13 +12,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue( - WeakSet.prototype.has.name, 'has', - 'The value of WeakSet.prototype.has.name is "has"' -); - -verifyNotEnumerable(WeakSet.prototype.has, 'name'); -verifyNotWritable(WeakSet.prototype.has, 'name'); -verifyConfigurable(WeakSet.prototype.has, 'name'); +verifyProperty(WeakSet.prototype.has, "name", { + value: "has", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/not-a-constructor.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/not-a-constructor.js index b21d7cb36f..caff7da47f 100644 --- a/js/src/tests/test262/built-ins/WeakSet/prototype/has/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let ws = new WeakSet(); new ws.has(); -}, '`let ws = new WeakSet(); new ws.has()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/decodeURI/name.js b/js/src/tests/test262/built-ins/decodeURI/name.js index 49e92af77d..c6b7c66784 100644 --- a/js/src/tests/test262/built-ins/decodeURI/name.js +++ b/js/src/tests/test262/built-ins/decodeURI/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(decodeURI.name, "decodeURI"); - -verifyNotEnumerable(decodeURI, "name"); -verifyNotWritable(decodeURI, "name"); -verifyConfigurable(decodeURI, "name"); +verifyProperty(decodeURI, "name", { + value: "decodeURI", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/decodeURI/not-a-constructor.js b/js/src/tests/test262/built-ins/decodeURI/not-a-constructor.js index 00a1e05e4c..8fb5c04771 100644 --- a/js/src/tests/test262/built-ins/decodeURI/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/decodeURI/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(decodeURI), false, 'isConstructor(decodeURI) must assert.throws(TypeError, () => { new decodeURI(''); -}, '`new decodeURI(\'\')` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/decodeURIComponent/name.js b/js/src/tests/test262/built-ins/decodeURIComponent/name.js index 35d153a3e9..e52e079ece 100644 --- a/js/src/tests/test262/built-ins/decodeURIComponent/name.js +++ b/js/src/tests/test262/built-ins/decodeURIComponent/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(decodeURIComponent.name, "decodeURIComponent"); - -verifyNotEnumerable(decodeURIComponent, "name"); -verifyNotWritable(decodeURIComponent, "name"); -verifyConfigurable(decodeURIComponent, "name"); +verifyProperty(decodeURIComponent, "name", { + value: "decodeURIComponent", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/decodeURIComponent/not-a-constructor.js b/js/src/tests/test262/built-ins/decodeURIComponent/not-a-constructor.js index dcb99027df..d3a4a2ba4c 100644 --- a/js/src/tests/test262/built-ins/decodeURIComponent/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/decodeURIComponent/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(decodeURIComponent), false, 'isConstructor(decode assert.throws(TypeError, () => { new decodeURIComponent(''); -}, '`new decodeURIComponent(\'\')` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURI/name.js b/js/src/tests/test262/built-ins/encodeURI/name.js index efb7966e6f..21fe9e4f03 100644 --- a/js/src/tests/test262/built-ins/encodeURI/name.js +++ b/js/src/tests/test262/built-ins/encodeURI/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(encodeURI.name, "encodeURI"); - -verifyNotEnumerable(encodeURI, "name"); -verifyNotWritable(encodeURI, "name"); -verifyConfigurable(encodeURI, "name"); +verifyProperty(encodeURI, "name", { + value: "encodeURI", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURI/not-a-constructor.js b/js/src/tests/test262/built-ins/encodeURI/not-a-constructor.js index fa9ab49cf7..a5b50f3570 100644 --- a/js/src/tests/test262/built-ins/encodeURI/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/encodeURI/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(encodeURI), false, 'isConstructor(encodeURI) must assert.throws(TypeError, () => { new encodeURI(''); -}, '`new encodeURI(\'\')` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/name.js b/js/src/tests/test262/built-ins/encodeURIComponent/name.js index 6d3594e181..7a65df4c55 100644 --- a/js/src/tests/test262/built-ins/encodeURIComponent/name.js +++ b/js/src/tests/test262/built-ins/encodeURIComponent/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(encodeURIComponent.name, "encodeURIComponent"); - -verifyNotEnumerable(encodeURIComponent, "name"); -verifyNotWritable(encodeURIComponent, "name"); -verifyConfigurable(encodeURIComponent, "name"); +verifyProperty(encodeURIComponent, "name", { + value: "encodeURIComponent", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/not-a-constructor.js b/js/src/tests/test262/built-ins/encodeURIComponent/not-a-constructor.js index 28030608a2..6bc60833b6 100644 --- a/js/src/tests/test262/built-ins/encodeURIComponent/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/encodeURIComponent/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(encodeURIComponent), false, 'isConstructor(encode assert.throws(TypeError, () => { new encodeURIComponent(''); -}, '`new encodeURIComponent(\'\')` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/eval/name.js b/js/src/tests/test262/built-ins/eval/name.js index c69687839b..09483a3dee 100644 --- a/js/src/tests/test262/built-ins/eval/name.js +++ b/js/src/tests/test262/built-ins/eval/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(eval.name, "eval"); - -verifyNotEnumerable(eval, "name"); -verifyNotWritable(eval, "name"); -verifyConfigurable(eval, "name"); +verifyProperty(eval, "name", { + value: "eval", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/eval/not-a-constructor.js b/js/src/tests/test262/built-ins/eval/not-a-constructor.js index e55f74de38..7cf21ad5bd 100644 --- a/js/src/tests/test262/built-ins/eval/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/eval/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(eval), false, 'isConstructor(eval) must return fa assert.throws(TypeError, () => { new eval(''); -}, '`new eval(\'\')` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/isFinite/length.js b/js/src/tests/test262/built-ins/isFinite/length.js index 6d18559474..5b35b88496 100644 --- a/js/src/tests/test262/built-ins/isFinite/length.js +++ b/js/src/tests/test262/built-ins/isFinite/length.js @@ -8,10 +8,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(isFinite.length, 1, "The value of `isFinite.length` is `1`"); - -verifyNotEnumerable(isFinite, "length"); -verifyNotWritable(isFinite, "length"); -verifyConfigurable(isFinite, "length"); +verifyProperty(isFinite, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/isFinite/name.js b/js/src/tests/test262/built-ins/isFinite/name.js index 46da43f25c..0f4b4ad420 100644 --- a/js/src/tests/test262/built-ins/isFinite/name.js +++ b/js/src/tests/test262/built-ins/isFinite/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(isFinite.name, "isFinite"); - -verifyNotEnumerable(isFinite, "name"); -verifyNotWritable(isFinite, "name"); -verifyConfigurable(isFinite, "name"); +verifyProperty(isFinite, "name", { + value: "isFinite", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/isFinite/not-a-constructor.js b/js/src/tests/test262/built-ins/isFinite/not-a-constructor.js index 465d6f20e5..246ae5391f 100644 --- a/js/src/tests/test262/built-ins/isFinite/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/isFinite/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(isFinite), false, 'isConstructor(isFinite) must r assert.throws(TypeError, () => { new isFinite(1); -}, '`new isFinite(1)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/isNaN/length.js b/js/src/tests/test262/built-ins/isNaN/length.js index 01e06d1602..f323904d00 100644 --- a/js/src/tests/test262/built-ins/isNaN/length.js +++ b/js/src/tests/test262/built-ins/isNaN/length.js @@ -8,10 +8,11 @@ description: > includes: [propertyHelper.js] ---*/ -assert.sameValue(isNaN.length, 1, "The value of `isNaN.length` is `1`"); - -verifyNotEnumerable(isNaN, "length"); -verifyNotWritable(isNaN, "length"); -verifyConfigurable(isNaN, "length"); +verifyProperty(isNaN, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/isNaN/name.js b/js/src/tests/test262/built-ins/isNaN/name.js index 967a74566e..515478acae 100644 --- a/js/src/tests/test262/built-ins/isNaN/name.js +++ b/js/src/tests/test262/built-ins/isNaN/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(isNaN.name, "isNaN"); - -verifyNotEnumerable(isNaN, "name"); -verifyNotWritable(isNaN, "name"); -verifyConfigurable(isNaN, "name"); +verifyProperty(isNaN, "name", { + value: "isNaN", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/isNaN/not-a-constructor.js b/js/src/tests/test262/built-ins/isNaN/not-a-constructor.js index 840489d16b..ca7970390e 100644 --- a/js/src/tests/test262/built-ins/isNaN/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/isNaN/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(isNaN), false, 'isConstructor(isNaN) must return assert.throws(TypeError, () => { new isNaN(1); -}, '`new isNaN(1)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/parseFloat/name.js b/js/src/tests/test262/built-ins/parseFloat/name.js index 05b701e234..75df364955 100644 --- a/js/src/tests/test262/built-ins/parseFloat/name.js +++ b/js/src/tests/test262/built-ins/parseFloat/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(parseFloat.name, "parseFloat"); - -verifyNotEnumerable(parseFloat, "name"); -verifyNotWritable(parseFloat, "name"); -verifyConfigurable(parseFloat, "name"); +verifyProperty(parseFloat, "name", { + value: "parseFloat", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/parseFloat/not-a-constructor.js b/js/src/tests/test262/built-ins/parseFloat/not-a-constructor.js index 4bbe63515e..ffab5bc31c 100644 --- a/js/src/tests/test262/built-ins/parseFloat/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/parseFloat/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(parseFloat), false, 'isConstructor(parseFloat) mu assert.throws(TypeError, () => { new parseFloat(1); -}, '`new parseFloat(1)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/parseInt/name.js b/js/src/tests/test262/built-ins/parseInt/name.js index 973b0707da..3d0fc3e513 100644 --- a/js/src/tests/test262/built-ins/parseInt/name.js +++ b/js/src/tests/test262/built-ins/parseInt/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(parseInt.name, "parseInt", 'The value of parseInt.name is "parseInt"'); - -verifyNotEnumerable(parseInt, "name"); -verifyNotWritable(parseInt, "name"); -verifyConfigurable(parseInt, "name"); +verifyProperty(parseInt, "name", { + value: "parseInt", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/parseInt/not-a-constructor.js b/js/src/tests/test262/built-ins/parseInt/not-a-constructor.js index db318e6a34..9bb720d6c0 100644 --- a/js/src/tests/test262/built-ins/parseInt/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/parseInt/not-a-constructor.js @@ -25,7 +25,7 @@ assert.sameValue(isConstructor(parseInt), false, 'isConstructor(parseInt) must r assert.throws(TypeError, () => { new parseInt(1); -}, '`new parseInt(1)` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/harness/shell.js b/js/src/tests/test262/harness/shell.js index 4e6994c9d3..37ca8bb807 100644 --- a/js/src/tests/test262/harness/shell.js +++ b/js/src/tests/test262/harness/shell.js @@ -193,7 +193,22 @@ var byteConversionValues = { -4294967296, // - ( 2 ** 32 ) Infinity, -Infinity, - 0 + 0, + 2049, // an integer which rounds down under ties-to-even when cast to float16 + 2051, // an integer which rounds up under ties-to-even when cast to float16 + 0.00006103515625, // smallest normal float16 + 0.00006097555160522461, // largest subnormal float16 + 5.960464477539063e-8, // smallest float16 + 2.9802322387695312e-8, // largest double which rounds to 0 when cast to float16 + 2.980232238769532e-8, // smallest double which does not round to 0 when cast to float16 + 8.940696716308594e-8, // a double which rounds up to a subnormal under ties-to-even when cast to float16 + 1.4901161193847656e-7, // a double which rounds down to a subnormal under ties-to-even when cast to float16 + 1.490116119384766e-7, // the next double above the one on the previous line one + 65504, // max finite float16 + 65520, // smallest double which rounds to infinity when cast to float16 + 65519.99999999999, // largest double which does not round to infinity when cast to float16 + 0.000061005353927612305, // smallest double which rounds to a non-subnormal when cast to float16 + 0.0000610053539276123 // largest double which rounds to a subnormal when cast to float16 ], expected: { @@ -238,7 +253,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 1, // 2049 + 3, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + -32, // 65504 + -16, // 65520 + -17, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint8: [ 127, // 127 @@ -281,7 +311,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 1, // 2049 + 3, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 224, // 65504 + 240, // 65520 + 239, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint8Clamped: [ 127, // 127 @@ -324,7 +369,22 @@ var byteConversionValues = { 0, // -4294967296 255, // Infinity 0, // -Infinity - 0 + 0, // 0 + 255, // 2049 + 255, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 255, // 65504 + 255, // 65520 + 255, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Int16: [ 127, // 127 @@ -367,7 +427,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + -32, // 65504 + -16, // 65520 + -17, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint16: [ 127, // 127 @@ -410,7 +485,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Int32: [ 127, // 127 @@ -453,7 +543,22 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Uint32: [ 127, // 127 @@ -496,93 +601,138 @@ var byteConversionValues = { 0, // -4294967296 0, // Infinity 0, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0, // 0.00006103515625 + 0, // 0.00006097555160522461 + 0, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 0, // 2.980232238769532e-8 + 0, // 8.940696716308594e-8 + 0, // 1.4901161193847656e-7 + 0, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519, // 65519.99999999999 + 0, // 0.000061005353927612305 + 0 // 0.0000610053539276123 ], Float16: [ - 127, // 127 - 128, // 128 - 32768, // 32767 - 32768, // 32768 - Infinity, // 2147483647 - Infinity, // 2147483648 - 255, // 255 - 256, // 256 - Infinity, // 65535 - Infinity, // 65536 - Infinity, // 4294967295 - Infinity, // 4294967296 - Infinity, // 9007199254740991 - Infinity, // 9007199254740992 - 1.099609375, // 1.1 - 0.0999755859375, // 0.1 - 0.5, // 0.5 - 0.5, // 0.50000001, - 0.60009765625, // 0.6 - 0.7001953125, // 0.7 - NaN, // undefined - -1, // -1 - -0, // -0 - -0.0999755859375, // -0.1 - -1.099609375, // -1.1 - NaN, // NaN - -127, // -127 - -128, // -128 - -32768, // -32767 - -32768, // -32768 - -Infinity, // -2147483647 - -Infinity, // -2147483648 - -255, // -255 - -256, // -256 - -Infinity, // -65535 - -Infinity, // -65536 - -Infinity, // -4294967295 - -Infinity, // -4294967296 - Infinity, // Infinity - -Infinity, // -Infinity - 0 + 127, // 127 + 128, // 128 + 32768, // 32767 + 32768, // 32768 + Infinity, // 2147483647 + Infinity, // 2147483648 + 255, // 255 + 256, // 256 + Infinity, // 65535 + Infinity, // 65536 + Infinity, // 4294967295 + Infinity, // 4294967296 + Infinity, // 9007199254740991 + Infinity, // 9007199254740992 + 1.099609375, // 1.1 + 0.0999755859375, // 0.1 + 0.5, // 0.5 + 0.5, // 0.50000001, + 0.60009765625, // 0.6 + 0.7001953125, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.0999755859375, // -0.1 + -1.099609375, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32768, // -32767 + -32768, // -32768 + -Infinity, // -2147483647 + -Infinity, // -2147483648 + -255, // -255 + -256, // -256 + -Infinity, // -65535 + -Infinity, // -65536 + -Infinity, // -4294967295 + -Infinity, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0, // 0 + 2048, // 2049 + 2052, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 0, // 2.9802322387695312e-8 + 5.960464477539063e-8, // 2.980232238769532e-8 + 1.1920928955078125e-7, // 8.940696716308594e-8 + 1.1920928955078125e-7, // 1.4901161193847656e-7 + 1.7881393432617188e-7, // 1.490116119384766e-7 + 65504, // 65504 + Infinity, // 65520 + 65504, // 65519.99999999999 + 0.00006103515625, // 0.000061005353927612305 + 0.00006097555160522461 // 0.0000610053539276123 ], Float32: [ - 127, // 127 - 128, // 128 - 32767, // 32767 - 32768, // 32768 - 2147483648, // 2147483647 - 2147483648, // 2147483648 - 255, // 255 - 256, // 256 - 65535, // 65535 - 65536, // 65536 - 4294967296, // 4294967295 - 4294967296, // 4294967296 - 9007199254740992, // 9007199254740991 - 9007199254740992, // 9007199254740992 - 1.100000023841858, // 1.1 - 0.10000000149011612, // 0.1 - 0.5, // 0.5 - 0.5, // 0.50000001, - 0.6000000238418579, // 0.6 - 0.699999988079071, // 0.7 - NaN, // undefined - -1, // -1 - -0, // -0 - -0.10000000149011612, // -0.1 - -1.100000023841858, // -1.1 - NaN, // NaN - -127, // -127 - -128, // -128 - -32767, // -32767 - -32768, // -32768 - -2147483648, // -2147483647 - -2147483648, // -2147483648 - -255, // -255 - -256, // -256 - -65535, // -65535 - -65536, // -65536 - -4294967296, // -4294967295 - -4294967296, // -4294967296 - Infinity, // Infinity - -Infinity, // -Infinity - 0 + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483648, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967296, // 4294967295 + 4294967296, // 4294967296 + 9007199254740992, // 9007199254740991 + 9007199254740992, // 9007199254740992 + 1.100000023841858, // 1.1 + 0.10000000149011612, // 0.1 + 0.5, // 0.5 + 0.5, // 0.50000001, + 0.6000000238418579, // 0.6 + 0.699999988079071, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.10000000149011612, // -0.1 + -1.100000023841858, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483648, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + -4294967296, // -4294967295 + -4294967296, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 2.9802322387695312e-8, // 2.9802322387695312e-8 + 2.9802322387695312e-8, // 2.980232238769532e-8 + 8.940696716308594e-8, // 8.940696716308594e-8 + 1.4901161193847656e-7, // 1.4901161193847656e-7 + 1.4901161193847656e-7, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65520, // 65519.99999999999 + 0.000061005353927612305, // 0.000061005353927612305 + 0.000061005353927612305 // 0.0000610053539276123 ], Float64: [ 127, // 127 @@ -625,7 +775,22 @@ var byteConversionValues = { -4294967296, // -4294967296 Infinity, // Infinity -Infinity, // -Infinity - 0 + 0, // 0 + 2049, // 2049 + 2051, // 2051 + 0.00006103515625, // 0.00006103515625 + 0.00006097555160522461, // 0.00006097555160522461 + 5.960464477539063e-8, // 5.960464477539063e-8 + 2.9802322387695312e-8, // 2.9802322387695312e-8 + 2.980232238769532e-8, // 2.980232238769532e-8 + 8.940696716308594e-8, // 8.940696716308594e-8 + 1.4901161193847656e-7, // 1.4901161193847656e-7 + 1.490116119384766e-7, // 1.490116119384766e-7 + 65504, // 65504 + 65520, // 65520 + 65519.99999999999, // 65519.99999999999 + 0.000061005353927612305, // 0.000061005353927612305 + 0.0000610053539276123 // 0.0000610053539276123 ] } }; @@ -3469,6 +3634,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -3556,6 +3724,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/harness/testTypedArray-conversions-call-error.js b/js/src/tests/test262/harness/testTypedArray-conversions-call-error.js index 6d22f1460c..03e00213bd 100644 --- a/js/src/tests/test262/harness/testTypedArray-conversions-call-error.js +++ b/js/src/tests/test262/harness/testTypedArray-conversions-call-error.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (c) 2017 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/harness/testTypedArray-conversions.js b/js/src/tests/test262/harness/testTypedArray-conversions.js index 3af4b6a528..3642078e25 100644 --- a/js/src/tests/test262/harness/testTypedArray-conversions.js +++ b/js/src/tests/test262/harness/testTypedArray-conversions.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (c) 2017 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/harness/testTypedArray.js b/js/src/tests/test262/harness/testTypedArray.js index 1c7bfb7303..432f0d67d1 100644 --- a/js/src/tests/test262/harness/testTypedArray.js +++ b/js/src/tests/test262/harness/testTypedArray.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (c) 2017 Rick Waldron. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-long-en.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-long-en.js index 13b8f374b3..0e6761b04a 100644 --- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-long-en.js +++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-long-en.js @@ -5,7 +5,7 @@ esid: sec-createdatetimeformat description: Checks basic handling of dayPeriod, long format. features: [Intl.DateTimeFormat-dayPeriod] -locale: [en-US] +locale: [en] ---*/ const d0000 = new Date(2017, 11, 12, 0, 0, 0, 0); diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-narrow-en.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-narrow-en.js index 4d26a5131d..986ff1f157 100644 --- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-narrow-en.js +++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-narrow-en.js @@ -5,7 +5,7 @@ esid: sec-createdatetimeformat description: Checks basic handling of dayPeriod, narrow format. features: [Intl.DateTimeFormat-dayPeriod] -locale: [en-US] +locale: [en] ---*/ const d0000 = new Date(2017, 11, 12, 0, 0, 0, 0); diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-short-en.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-short-en.js index f7b410f24d..dec193c396 100644 --- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-short-en.js +++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-short-en.js @@ -5,7 +5,7 @@ esid: sec-initializedatetimeformat description: Checks basic handling of dayPeriod, short format. features: [Intl.DateTimeFormat-dayPeriod] -locale: [en-US] +locale: [en] ---*/ const d0000 = new Date(2017, 11, 12, 0, 0, 0, 0); diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/fractionalSecondDigits.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/fractionalSecondDigits.js index 25af5ada6d..49218a3b39 100644 --- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/fractionalSecondDigits.js +++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/fractionalSecondDigits.js @@ -5,7 +5,7 @@ esid: sec-createdatetimeformat description: Checks basic handling of fractionalSecondDigits. features: [Intl.DateTimeFormat-fractionalSecondDigits] -locale: [en-US] +locale: [en] ---*/ const d1 = new Date(2019, 7, 10, 1, 2, 3, 234); diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/fractionalSecondDigits.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/fractionalSecondDigits.js index 543dfb2274..046084493c 100644 --- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/fractionalSecondDigits.js +++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/fractionalSecondDigits.js @@ -5,7 +5,7 @@ esid: sec-createdatetimeformat description: Checks basic handling of fractionalSecondDigits. features: [Intl.DateTimeFormat-fractionalSecondDigits] -locale: [en-US] +locale: [en] ---*/ const d1 = new Date(2019, 7, 10, 1, 2, 3, 234); diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/resolvedOptions/hourCycle-default.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/resolvedOptions/hourCycle-default.js index 9063e045a6..c2cccd826c 100644 --- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/resolvedOptions/hourCycle-default.js +++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/resolvedOptions/hourCycle-default.js @@ -21,27 +21,35 @@ info: | c. If hc is null, set hc to dataLocaleData.[[hourCycle]]. 27. Set dateTimeFormat.[[HourCycle]] to hc. -locale: [en, fr, it, ja, zh, ko, ar, hi, en-u-hc-h24] +locale: [en, fr, it, ja, zh, ko, ar, hi] ---*/ -let locales = ["en", "fr", "it", "ja", "ja-u-hc-h11", "zh", "ko", "ar", "hi", "en-u-hc-h24"]; +let locales = ["en", "fr", "it", "ja", "zh", "ko", "ar", "hi"]; -locales.forEach(function(locale) { - let hcDefault = new Intl.DateTimeFormat(locale, { hour: "numeric" }).resolvedOptions().hourCycle; - if (hcDefault === "h11" || hcDefault === "h12") { - assert.sameValue(new Intl.DateTimeFormat(locale, { hour: "numeric", hour12: true }).resolvedOptions().hourCycle, hcDefault); +for (let locale of locales) { + let hcDefault = new Intl.DateTimeFormat(locale, {hour: "numeric"}).resolvedOptions().hourCycle; + assert( + hcDefault === "h11" || hcDefault === "h12" || hcDefault === "h23" || hcDefault === "h24", + "hcDefault is one of [h11, h12, h23, h24]" + ); - // no locale has "h24" as a default. see https://github.com/tc39/ecma402/pull/758#issue-1622377292 - assert.sameValue(new Intl.DateTimeFormat(locale, { hour: "numeric", hour12: false }).resolvedOptions().hourCycle, "h23"); - } + let hour12 = new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: true}).resolvedOptions().hourCycle; + assert(hour12 === "h11" || hour12 === "h12", "hour12 is one of [h11, h12]"); + + let hour24 = new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: false}).resolvedOptions().hourCycle; + assert(hour24 === "h23" || hour24 === "h24", "hour24 is one of [h23, h24]"); - // however, "h24" can be set via locale extension. - if (hcDefault === "h23" || hcDefault === "h24") { - assert.sameValue(new Intl.DateTimeFormat(locale, { hour: "numeric", hour12: false }).resolvedOptions().hourCycle, hcDefault); + if (hcDefault === "h11" || hcDefault === "h12") { + assert.sameValue(hour12, hcDefault, "hour12 matches hcDefault"); + } else { + assert.sameValue(hour24, hcDefault, "hour24 matches hcDefault"); } - let hcHour12 = new Intl.DateTimeFormat(locale, { hour: "numeric", hour12: true }).resolvedOptions().hourCycle; - assert(hcHour12 === "h11" || hcHour12 === "h12", "Expected `hourCycle`: " + hcHour12 + " to be in [\"h11\", \"h12\"]"); -}); + // 24-hour clock uses the "h23" format in all locales. + assert.sameValue(hour24, "h23"); + + // 12-hour clock uses the "h12" format in all locales except "ja". + assert.sameValue(hour12, locale === "ja" ? "h11" : "h12"); +} reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DateTimeFormat/timezone-legacy-non-iana.js b/js/src/tests/test262/intl402/DateTimeFormat/timezone-legacy-non-iana.js new file mode 100644 index 0000000000..d99cf18df4 --- /dev/null +++ b/js/src/tests/test262/intl402/DateTimeFormat/timezone-legacy-non-iana.js @@ -0,0 +1,45 @@ +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-initializedatetimeformat +description: Only IANA time zone identifiers are allowed. +---*/ + +// List of non-IANA link names, copied from: +// https://github.com/unicode-org/icu/blob/main/icu4c/source/tools/tzcode/icuzones +const invalidTimeZones = [ + "ACT", + "AET", + "AGT", + "ART", + "AST", + "BET", + "BST", + "CAT", + "CNT", + "CST", + "CTT", + "EAT", + "ECT", + "IET", + "IST", + "JST", + "MIT", + "NET", + "NST", + "PLT", + "PNT", + "PRT", + "PST", + "SST", + "VST", +]; + +for (let timeZone of invalidTimeZones) { + assert.throws(RangeError, () => { + new Intl.DateTimeFormat(undefined, {timeZone}); + }, "Time zone: " + timeZone); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-region-invalid.js b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-region-invalid.js index 0fcce4ac7e..3c5608d162 100644 --- a/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-region-invalid.js +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-region-invalid.js @@ -14,7 +14,7 @@ features: [Intl.DisplayNames] ---*/ // https://unicode.org/reports/tr35/#unicode_region_subtag -// unicode_region_subtag = (alpha{2} | digit{3}) ; +// unicode_region_subtag = (alpha{2} | digit{3}) ; var displayNames = new Intl.DisplayNames(undefined, {type: 'region'}); diff --git a/js/src/tests/test262/intl402/DurationFormat/constructor-unit-style-defaults.js b/js/src/tests/test262/intl402/DurationFormat/constructor-unit-style-defaults.js new file mode 100644 index 0000000000..93f54dcab4 --- /dev/null +++ b/js/src/tests/test262/intl402/DurationFormat/constructor-unit-style-defaults.js @@ -0,0 +1,34 @@ +// |reftest| skip -- Intl.DurationFormat is not supported +// Copyright 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat +description: Verifies that default style settings for units following units with "numeric" or "2-digit" style are honored. +info: | + GetDurationUnitOptions (unit, options, baseStyle, stylesList, digitalBase, prevStyle) + (...) + 3. If style is undefined, then + (...) + i. If prevStyle is "fractional", "numeric" or "2-digit", then + (...) + 2. Set style to "numeric". + (...) + 9. If prevStyle is "numeric" or "2-digit", then + (...) + b. If unit is "minutes" or "seconds", then + i. Set style to "2-digit". +features: [Intl.DurationFormat] +---*/ + +for (const numericLikeStyle of ["numeric", "2-digit"]){ + var opts = new Intl.DurationFormat([], {hours: numericLikeStyle}).resolvedOptions(); + + assert.sameValue(opts.minutes, "2-digit", `minutes default value should be '2-digit' when following any ${numericLikeStyle}-styled unit`); + assert.sameValue(opts.seconds, "2-digit", `seconds default value should be '2-digit' when following any ${numericLikeStyle}-styled unit`); + assert.sameValue(opts.milliseconds, "numeric", `milliseconds default value should be 'numeric' when following any ${numericLikeStyle}-styled unit`); + assert.sameValue(opts.microseconds, "numeric", `microseconds default value should be 'numeric' when following any ${numericLikeStyle}-styled unit`); + assert.sameValue(opts.nanoseconds, "numeric", `nanoseconds default value should be 'numeric' when following any ${numericLikeStyle}-styled unit`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/fractions-of-subsecond-units-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/fractions-of-subsecond-units-en.js new file mode 100644 index 0000000000..342fa613cf --- /dev/null +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/fractions-of-subsecond-units-en.js @@ -0,0 +1,65 @@ +// |reftest| skip -- Intl.DurationFormat is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.prototype.format +description: Checks that fractional milliseconds and microseconds are formatted correctly when microseconds or nanoseconds are the first units with "numeric" style. +info: | + PartitionDurationFormatPattern ( durationFormat, duration ) + (...) + 9. + (...) + g. If unit is "seconds", "milliseconds", or "microseconds", then + i. If unit is "seconds", then + 1. Let nextStyle be durationFormat.[[MillisecondsStyle]]. + ii. Else if unit is "milliseconds", then + 1. Let nextStyle be durationFormat.[[MicrosecondsStyle]]. + iii. Else, + 1. Let nextStyle be durationFormat.[[NanosecondsStyle]]. + iv. If nextStyle is "fractional", then + 1. Set value to value + AddFractionalDigits(durationFormat, duration). + 2. If durationFormat.[[FractionalDigits]] is undefined, then + a. Let maximumFractionDigits be 9𝔽. + b. Let minimumFractionDigits be +0𝔽. + 3. Else, + a. Let maximumFractionDigits be 𝔽(durationFormat.[[FractionalDigits]]). + b. Let minimumFractionDigits be 𝔽(durationFormat.[[FractionalDigits]]). + 4. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", maximumFractionDigits ). + 5. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", minimumFractionDigits ). + 6. Perform ! CreateDataPropertyOrThrow(nfOpts, "roundingMode", "trunc"). + 7. Set done to true. + +locale: [en] +features: [Intl.DurationFormat] +---*/ + + +const locale = "en"; +const decimalSeparator = "."; + +let d = {seconds: 3, milliseconds: 444, microseconds: 55, nanoseconds: 6}; +let dfOpts = {microseconds: "numeric"}; + +let expectedList = []; +expectedList.push(new Intl.NumberFormat(locale, {style: "unit", unit: "second", unitDisplay: "short"}).format(d.seconds)); +expectedList.push(new Intl.NumberFormat(locale, {style: "unit", unit: "millisecond", unitDisplay: "short", minimumFractionDigits:0, maximumFractionDigits: 9}).format(d.milliseconds.toString() + decimalSeparator + d.microseconds.toString().padStart(3, '0') + d.nanoseconds.toString().padStart(3, '0'))); + +let expected = new Intl.ListFormat(locale, {style: "short"}).format(expectedList); +let actual = new Intl.DurationFormat(locale, dfOpts).format(d); + +// assert.sameValue(actual, expected, `DurationFormat output when microseconds first "numeric" unit`); + +dfOpts = {nanoseconds: "numeric"}; +expectedList = []; + +expectedList.push(new Intl.NumberFormat(locale, {style: "unit", unit: "second", unitDisplay: "short"}).format(d.seconds)); +expectedList.push(new Intl.NumberFormat(locale, {style: "unit", unit: "millisecond", unitDisplay: "short"}).format(d.milliseconds)); +expectedList.push(new Intl.NumberFormat(locale, {style: "unit", unit: "microsecond", unitDisplay: "short", minimumFractionDigits:0, maximumFractionDigits: 9}).format(d.microseconds.toString() + decimalSeparator + d.nanoseconds.toString().padStart(3, '0'))); + +expected = new Intl.ListFormat(locale, {style: "short"}).format(expectedList); +actual = new Intl.DurationFormat(locale, dfOpts).format(d); + +assert.sameValue(actual, expected, `DurationFormat output when nanoseconds first "numeric" unit`); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-non-numeric-styles-es.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-non-numeric-styles-es.js new file mode 100644 index 0000000000..33ec1a2776 --- /dev/null +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-non-numeric-styles-es.js @@ -0,0 +1,88 @@ +// |reftest| skip -- Intl.DurationFormat is not supported +// Copyright 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.prototype.format +description: Test if format method formats duration correctly with mixed non-numeric settings for unit styles. Compares output from format method to output produced through using NumberFormat and ListFormat as used by DurationFormat. +info: | + PartitionDurationFormatPattern ( durationFormat, duration ) + ... + 9. While done is false, repeat for each row in Table 2 in table order, except the header row: + ... + k. If value is not 0 or display is not "auto" or displayRequired is "true", then + ... + v. If style is not "fractional", "numeric", or "2-digit", then + 1. Perform ! CreateDataPropertyOrThrow(nfOpts, "style", "unit"). + 2. Perform ! CreateDataPropertyOrThrow(nfOpts, "unit", numberFormatUnit). + 3. Perform ! CreateDataPropertyOrThrow(nfOpts, "unitDisplay", style). + ... + ix. Let parts be ! PartitionNumberPattern(nf, value). + ... + 14. Perform ! CreateDataPropertyOrThrow(lfOpts, "style", listStyle). + 15. Let lf be ! Construct(%ListFormat%, « durationFormat.[[Locale]], lfOpts »). + ... + 18. Let formatted be CreatePartsFromList(lf, strings). + +locale: [es] +features: [Intl.DurationFormat] +---*/ + +function formatDuration(locale, duration, dfOpts){ + let result = []; + for (const unit in duration){ + let nfUnit = unit.substring(0, unit.length - 1); + let nf = new Intl.NumberFormat(locale, {style: "unit", unit: nfUnit, unitDisplay: dfOpts[unit]}); + result.push(nf.format(duration[unit])); + } + + for (const baseStyle of ["long", "short", "narrow"]){ + let lf = new Intl.ListFormat(locale, {type: "unit", style: baseStyle}); + let expected = lf.format(result); + dfOpts.style = baseStyle; + let df = new Intl.DurationFormat(locale, dfOpts); + let actual = df.format(duration); + assert.sameValue(actual, expected); + } +} + +const duration = { + years: 1, + months: 2, + weeks: 3, + days: 0, + hours: 4, + minutes: 5, + seconds: 6, + milliseconds: 7, + microseconds: 8, + nanoseconds: 9, +}; + +const locale = "es"; + +formatDuration(locale, duration, { + years: "narrow", + months: "narrow", + weeks: "narrow", + days: "short", + hours: "short", + minutes: "short", + seconds: "long", + milliseconds: "long", + microseconds: "long", + nanoseconds: "narrow", }); + +formatDuration(locale, duration, { + years: "long", + months: "short", + weeks: "narrow", + days: "long", + hours: "short", + minutes: "narrow", + seconds: "long", + milliseconds: "short", + microseconds: "narrow", + nanoseconds: "long", }); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-short-and-numeric.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-short-and-numeric.js new file mode 100644 index 0000000000..19adbfbd47 --- /dev/null +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-short-and-numeric.js @@ -0,0 +1,37 @@ +// |reftest| skip -- Intl.DurationFormat is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.prototype.format +description: Checks that durations containing a mixture of numericlike and non-numericlike styles are formatted using the "short" style when DurationFormat base style is *undefined*. +info: | + PartitionDurationFormatPattern ( durationFormat, duration ) + + 12. Let listStyle be durationFormat.[[Style]]. + (...) + 14. Perform ! CreateDataPropertyOrThrow(lfOpts, "style", listStyle). + +locale: [en] +features: [Intl.DurationFormat] +---*/ + +const locale = "en"; +const timeSeparator = ":"; + + +let d = {days: 5, hours: 1, minutes: 2, seconds: 3}; +let dfOpts = {minutes: "numeric", seconds: "numeric"}; + +let expectedList = []; +expectedList.push(new Intl.NumberFormat(locale, {style: "unit", unit: "day", unitDisplay: "short"}).format(d.days)); +expectedList.push(new Intl.NumberFormat(locale, {style: "unit", unit: "hour", unitDisplay: "short"}).format(d.hours)); +expectedList.push(new Intl.NumberFormat(locale).format(d.minutes) + timeSeparator + new Intl.NumberFormat(locale, {minimumIntegerDigits: 2}).format(d.seconds)); + +let expected = new Intl.ListFormat(locale, {style: "short"}).format(expectedList); +let actual = new Intl.DurationFormat(locale, dfOpts).format(d); + +assert.sameValue(actual, expected); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-duration-style-default-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-duration-style-default-en.js index c6b58a5dfc..3c0f1d6dd5 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-duration-style-default-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-duration-style-default-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.format description: > Test format method with negative duration and default style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-duration-style-short-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-duration-style-short-en.js index 83eb5b4639..9ebf996341 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-duration-style-short-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-duration-style-short-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.format description: > Test format method with negative duration and "short" style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-digital-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-digital-en.js index c9f119c368..e26f198cd5 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-digital-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-digital-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.format description: > Test format method with negative duration and "digital" style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-long-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-long-en.js index fe074d488e..d7654f5630 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-long-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-long-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.format description: > Test format method with negative duration and "long" style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-narrow-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-narrow-en.js index 4d1db5dc67..1735112336 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-narrow-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-narrow-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.format description: > Test format method with negative duration and "narrow" style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/numeric-hour-with-zero-minutes-and-non-zero-seconds.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/numeric-hour-with-zero-minutes-and-non-zero-seconds.js index dc5ad4ea84..3c37afa1b4 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/numeric-hour-with-zero-minutes-and-non-zero-seconds.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/numeric-hour-with-zero-minutes-and-non-zero-seconds.js @@ -5,8 +5,8 @@ /*--- esid: sec-Intl.DurationFormat.prototype.format description: > - The correct separator is used for numeric hours with zero minutes and non-zero seconds. -locale: [en-US] + Minutes with numeric or 2-digit style are included in the output when between displayed hours and seconds, even when the minutes value is zero. +locale: [en] features: [Intl.DurationFormat] ---*/ @@ -15,30 +15,18 @@ const df = new Intl.DurationFormat("en", { hours: "numeric", }); -const lf = new Intl.ListFormat("en", { - type: "unit", - style: "short", -}); - const duration = { hours: 1, - - // Minutes is omitted from the output when its value is zero. minutes: 0, - - // Either seconds or sub-seconds must be non-zero. seconds: 3, }; -const expected = lf.format([ - new Intl.NumberFormat("en", {minimumIntegerDigits: 1}).format(duration.hours), - new Intl.NumberFormat("en", {minimumIntegerDigits: 2}).format(duration.seconds), -]); +const expected = "1:00:03" assert.sameValue( df.format(duration), expected, - `No time separator is used when minutes is zero` + `Minutes always displayed when between displayed hours and seconds, even if minutes is 0` ); reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/precision-exact-mathematical-values.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/precision-exact-mathematical-values.js index 5518450d6a..dbb34d39f7 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/precision-exact-mathematical-values.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/precision-exact-mathematical-values.js @@ -25,7 +25,7 @@ info: | 7. Let parts be ! PartitionNumberPattern(nf, value). ... -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-default-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-default-en.js index 6eb5c4999e..dae05ae5f1 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-default-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-default-en.js @@ -5,7 +5,7 @@ /*--- esid: sec-Intl.DurationFormat.prototype.format description: Test if format method formats duration correctly with different "style" arguments -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-en.js index 4f34d50aa9..cc2dd3342f 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-en.js @@ -6,7 +6,7 @@ /*--- esid: sec-Intl.DurationFormat.prototype.format description: Test if format method formats duration correctly with different "style" arguments -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-en.js new file mode 100644 index 0000000000..60c2232d6a --- /dev/null +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-en.js @@ -0,0 +1,51 @@ +// |reftest| skip -- Intl.DurationFormat is not supported +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-partitiondurationformatpattern +description: > + Test to ensure that correct number of fractional digits is displayed if fractionalDigits is explicitly specified. + +info: | + 4. If durationFormat.[[FractionalDigits]] is undefined, then + a. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", 9). + b. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", 0). + 5. Else, + a. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", durationFormat.[[FractionalDigits]]). + b. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", durationFormat.[[FractionalDigits]]). +locale: [en] +features: [Intl.DurationFormat] +---*/ + +const duration = { + hours: 1, + minutes: 22, + seconds: 33, + milliseconds: 111, + microseconds: 222, + nanoseconds: 333, +}; + + +const style = "digital"; +const df = new Intl.DurationFormat("en", {style, fractionalDigits: 0}); +const dfMilli = new Intl.DurationFormat("en", {style, fractionalDigits: 3}); +const dfFourDigits = new Intl.DurationFormat("en", {style, fractionalDigits: 4}); +const dfMicro = new Intl.DurationFormat("en", {style, fractionalDigits: 6}); +const dfEightDigits = new Intl.DurationFormat("en", {style, fractionalDigits: 8}); +const dfNano = new Intl.DurationFormat("en", {style, fractionalDigits: 9}); + +assert.sameValue(df.format(duration), "1:22:33", `format output without sub-second digits using ${style} style option`); + +assert.sameValue(dfMilli.format(duration), "1:22:33.111", `format output with sub-second digits and fractionalDigits: 3 using ${style} style option`); + +assert.sameValue(dfFourDigits.format(duration), "1:22:33.1112", `format output with sub-second digits and fractionalDigits: 4 using ${style} style option`); + +assert.sameValue(dfMicro.format(duration), "1:22:33.111222", `format output with sub-second digits and fractionalDigits: 6 using ${style} style option`); + +assert.sameValue(dfEightDigits.format(duration), "1:22:33.11122233", `format output with sub-second digits and fractionalDigits: 8 using ${style} style option`); + +assert.sameValue(dfNano.format(duration), "1:22:33.111222333", `format output with sub-second digits and fractionalDigits: 9 using ${style} style option`); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-undefined-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-undefined-en.js new file mode 100644 index 0000000000..b297c0c7ba --- /dev/null +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-undefined-en.js @@ -0,0 +1,80 @@ +// |reftest| skip -- Intl.DurationFormat is not supported +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-partitiondurationformatpattern +description: > + Test to ensure that correct number of fractional digits is displayed (i.e. however many are necessary to represent the data fully) if the fractionalDigits option is left *undefined* + +info: | + 4. If durationFormat.[[FractionalDigits]] is undefined, then + a. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", 9). + b. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", 0). + 5. Else, + a. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", durationFormat.[[FractionalDigits]]). + b. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", durationFormat.[[FractionalDigits]]). +locale: [en] +features: [Intl.DurationFormat] +---*/ + + +const durationNano = { + hours: 1, + minutes: 22, + seconds: 33, + milliseconds: 111, + microseconds: 222, + nanoseconds: 333 +}; + +const durationMicro = { + hours: 1, + minutes: 22, + seconds: 33, + milliseconds: 111, + microseconds: 222 +}; + +const durationMilli = { + hours: 1, + minutes: 22, + seconds: 33, + milliseconds: 111 +}; + +const durationNoSubsecond = { + hours: 1, + minutes: 22, + seconds: 33 +}; + +const durationFiveFractional = { + hours: 2, + minutes: 30, + seconds: 10, + milliseconds: 111, + microseconds: 220, +}; + +const durationSevenFractional = { + hours: 2, + minutes: 30, + seconds: 10, + milliseconds: 111, + microseconds: 220, + nanoseconds: 300 +}; + +const style = "digital"; +const df = new Intl.DurationFormat("en", {style, fractionalDigits: undefined}); + +assert.sameValue(df.format(durationNano), "1:22:33.111222333", `format output with nanosecond digits and fractionalDigits: undefined using ${style} style option`); +assert.sameValue(df.format(durationMicro), "1:22:33.111222", `format output with microsecond digits and fractionalDigits: undefined using ${style} style option`); +assert.sameValue(df.format(durationMilli), "1:22:33.111", `format output with millisecond digits and fractionalDigits: undefined using ${style} style option`); +assert.sameValue(df.format(durationNoSubsecond), "1:22:33", `format output with no subsecond digits and fractionalDigits: undefined using ${style} style option`); + +assert.sameValue(df.format(durationFiveFractional), "2:30:10.11122", `format output with five subsecond digits and fractionalDigits: undefined using ${style} style option`); +assert.sameValue(df.format(durationSevenFractional), "2:30:10.1112203", `format output with seven subsecond digits and fractionalDigits: undefined using ${style} style option`); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-undefined.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-undefined.js deleted file mode 100644 index 631e6c36eb..0000000000 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-undefined.js +++ /dev/null @@ -1,71 +0,0 @@ -// |reftest| skip -- Intl.DurationFormat is not supported -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-partitiondurationformatpattern -description: > - Test to ensure that correct number of fractional digits is displayed (i.e. however many are necessary to represent the data fully) if the fractionalDigits option is left *undefined* - -info: | - 4. If durationFormat.[[FractionalDigits]] is undefined, then - a. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", 9). - b. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", 0). - 5. Else, - a. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", durationFormat.[[FractionalDigits]]). - b. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", durationFormat.[[FractionalDigits]]). -features: [Intl.DurationFormat] ----*/ - - -const durationNano = { - hours: 1, - minutes: 22, - seconds: 33, - milliseconds: 111, - microseconds: 222, - nanoseconds: 333 -}; - -const durationMicro = { - hours: 1, - minutes: 22, - seconds: 33, - milliseconds: 111, - microseconds: 222 -}; - -const durationMill = { - hours: 1, - minutes: 22, - seconds: 33, - milliseconds: 111 -}; - -const durationNoSubsecond = { - hours: 1, - minutes: 22, - seconds: 33 -}; - -const durationSevenFractional = { - hours: 2, - minutes: 30, - seconds: 10, - milliseconds: 111, - microseconds: 220, - nanoseconds: 300 -}; - -const style = "digital"; -const df = new Intl.DurationFormat(undefined, {style, fractionalDigits: undefined}); - -assert.sameValue(df.format(durationNano), "1:22:33.111222333", `format output with nanosecond digits and fractionalDigits: undefined using ${style} style option`); -assert.sameValue(df.format(durationMicro), "1:22:33.111222", `format output with microsecond digits and fractionalDigits: undefined using ${style} style option`); -assert.sameValue(df.format(durationMilli), "1:22:33.111", `format output with millisecond digits and fractionalDigits: undefined using ${style} style option`); -assert.sameValue(df.format(durationNoSubsecond), "1:22:33", `format output with no subsecond digits and fractionalDigits: undefined using ${style} style option`); - -assert.sameValue(df.format(durationFiveFractional), "2:30:11122", `format output with five subsecond digits and fractionalDigits: undefined using ${style} style option`); -assert.sameValue(df.format(durationSevenFractional), "2:30:1112203", `format output with seven subsecond digits and fractionalDigits: undefined using ${style} style option`); - -reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits.js deleted file mode 100644 index d75f51b14a..0000000000 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits.js +++ /dev/null @@ -1,50 +0,0 @@ -// |reftest| skip -- Intl.DurationFormat is not supported -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-partitiondurationformatpattern -description: > - Test to ensure that correct number of fractional digits is displayed if fractionalDigits is explicitly specified. - -info: | - 4. If durationFormat.[[FractionalDigits]] is undefined, then - a. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", 9). - b. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", 0). - 5. Else, - a. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", durationFormat.[[FractionalDigits]]). - b. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", durationFormat.[[FractionalDigits]]). -features: [Intl.DurationFormat] ----*/ - -const duration = { - hours: 1, - minutes: 22, - seconds: 33, - milliseconds: 111, - microseconds: 222, - nanoseconds: 333, -}; - - -const style = "digital"; -const df = new Intl.DurationFormat(undefined, {style, fractionalDigits: 0}); -const dfMilli = new Intl.DurationFormat(undefined, {style, fractionalDigits: 3}); -const dfFourDigits = new Intl.DurationFormat(undefined, {style, fractionalDigits: 4}); -const dfMicro = new Intl.DurationFormat(undefined, {style, fractionalDigits: 6}); -const dfEightDigits = new Intl.DurationFormat(undefined, {style, fractionalDigits: 8}); -const dfNano = new Intl.DurationFormat(undefined, {style, fractionalDigits: 9}); - -assert.sameValue(df.format(duration), "1:22:33", `format output without sub-second digits using ${style} style option`); - -assert.sameValue(dfMilli.format(duration), "1:22:33.111", `format output with sub-second digits and fractionalDigits: 3 using ${style} style option`); - -assert.sameValue(dfFourDigits.format(duration), "1:22:33.1112", `format output with sub-second digits and fractionalDigits: 4 using ${style} style option`); - -assert.sameValue(dfMicro.format(duration), "1:22:33.111222", `format output with sub-second digits and fractionalDigits: 6 using ${style} style option`); - -assert.sameValue(dfEightDigits.format(duration), "1:22:33.11122233", `format output with sub-second digits and fractionalDigits: 8 using ${style} style option`); - -assert.sameValue(dfNano.format(duration), "1:22:33.111222333", `format output with sub-second digits and fractionalDigits: 9 using ${style} style option`); - -reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-long-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-long-en.js index d9e6fc6cbb..74524da674 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-long-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-long-en.js @@ -5,7 +5,7 @@ /*--- esid: sec-Intl.DurationFormat.prototype.format description: Test if format method formats duration correctly with different "style" arguments -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-narrow-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-narrow-en.js index 66b2258761..e75dc17170 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-narrow-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-narrow-en.js @@ -5,7 +5,7 @@ /*--- esid: sec-Intl.DurationFormat.prototype.format description: Test if format method formats duration correctly with different "style" arguments -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-short-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-short-en.js index 2a66c01b06..049e034681 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-short-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-short-en.js @@ -5,7 +5,7 @@ /*--- esid: sec-Intl.DurationFormat.prototype.format description: Test if format method formats duration correctly with different "style" arguments -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-default-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-default-en.js index bfc182c34b..5ce6300268 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-default-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-default-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.formatToParts description: > Test formatToParts method with negative duration and default style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-digital-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-digital-en.js index 52a40072ba..6978739ac3 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-digital-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-digital-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.formatToParts description: > Test formatToParts method with negative duration and "digital" style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-long-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-long-en.js index 3756db8a84..638f5922f1 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-long-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-long-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.formatToParts description: > Test formatToParts method with negative duration and "long" style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-narrow-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-narrow-en.js index a9717ce67a..b138100f8a 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-narrow-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-narrow-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.formatToParts description: > Test formatToParts method with negative duration and "narrow" style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-short-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-short-en.js index bc2ed69c5b..76ce8ccbf1 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-short-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-short-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.formatToParts description: > Test formatToParts method with negative duration and "short" style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/Locale/constructor-options-collation-invalid.js b/js/src/tests/test262/intl402/Locale/constructor-options-collation-invalid.js index d256093257..10f5cd5e4a 100644 --- a/js/src/tests/test262/intl402/Locale/constructor-options-collation-invalid.js +++ b/js/src/tests/test262/intl402/Locale/constructor-options-collation-invalid.js @@ -30,7 +30,7 @@ const invalidCollationOptions = [ for (const invalidCollationOption of invalidCollationOptions) { assert.throws(RangeError, function() { new Intl.Locale("en", {collation: invalidCollationOption}); - }, '`new Intl.Locale("en", {collation: invalidCollationOption})` throws RangeError'); + }); } reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Locale/prototype/calendar/canonicalize.js b/js/src/tests/test262/intl402/Locale/prototype/calendar/canonicalize.js new file mode 100644 index 0000000000..5ade4fe795 --- /dev/null +++ b/js/src/tests/test262/intl402/Locale/prototype/calendar/canonicalize.js @@ -0,0 +1,22 @@ +// Copyright 2024 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-apply-unicode-extension-to-tag +description: Checks canonicalize value of extension in ApplyUnicodeExtensionToTag. +info: | + ApplyUnicodeExtensionToTag + 1. Let _optionsUValue_ be the ASCII-lowercase of _optionsValue_. + 1. Set _value_ to the String value resulting from canonicalizing _optionsUValue_ as a value of key _key_ per <a href="https://unicode.org/reports/tr35/#processing-localeids">Unicode Technical Standard #35 Part 1 Core, Annex C LocaleId Canonicalization Section 5 Canonicalizing Syntax, Processing LocaleIds</a>. +features: [Intl.Locale] +---*/ + +const loc = new Intl.Locale('en', {calendar: 'islamicc'}); + +assert.sameValue(loc.toString(), "en-u-ca-islamic-civil", + "'islamicc' should be canonicalize to 'islamic-civil'"); + +assert.sameValue(loc.calendar, "islamic-civil", + "'islamicc' should be canonicalize to 'islamic-civil'"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateAdd/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateAdd/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateAdd/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateAdd/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateFromFields/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateFromFields/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateFromFields/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateFromFields/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateUntil/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateUntil/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateUntil/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateUntil/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/day/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/day/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/day/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/day/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dayOfWeek/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dayOfWeek/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dayOfWeek/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dayOfWeek/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dayOfYear/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dayOfYear/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dayOfYear/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dayOfYear/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInMonth/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInMonth/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInMonth/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInMonth/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInWeek/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInWeek/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInWeek/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInWeek/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInYear/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInYear/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInYear/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInYear/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..2772960abe --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.era +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.era(arg); + assert.sameValue(result, undefined, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-year-zero.js index d0698c070c..57df6364f9 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.era(arg), diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..f34a405169 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.era +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.era(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/shell.js index 32df7c4217..63bc783738 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/shell.js @@ -2046,6 +2046,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2133,6 +2136,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..2899ea877c --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.erayear +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.eraYear(arg); + assert.sameValue(result, undefined, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-year-zero.js index 65675a5894..eaa93d916a 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.eraYear(arg), diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..7bec3d6a54 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.erayear +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.eraYear(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/shell.js index 32df7c4217..63bc783738 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/shell.js @@ -2046,6 +2046,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2133,6 +2136,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/inLeapYear/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/inLeapYear/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/inLeapYear/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/inLeapYear/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/month/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/month/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/month/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/month/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthCode/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthCode/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthCode/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthCode/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthDayFromFields/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthDayFromFields/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthDayFromFields/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthDayFromFields/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthsInYear/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthsInYear/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthsInYear/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthsInYear/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/gregory-iso-weekofyear.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/gregory-iso-weekofyear.js new file mode 100644 index 0000000000..3eeb8186ef --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/gregory-iso-weekofyear.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.weekofyear +description: > + In the ISO 8601 week calendar, calendar week number 1 of a calendar year is + the week including the first Thursday of that year (based on the principle + that a week belongs to the same calendar year as the majority of its calendar + days). Because of this, some calendar days of the first calendar week of a + calendar year may be part of the preceding date calendar year, and some + calendar days of the last calendar week of a calendar year may be part of + the next calendar year. +features: [Temporal] +---*/ + +// + +let calendar = new Temporal.Calendar("gregory"); +const date = { month: 1, day: 1, year: 2021, calendar}; + +assert.sameValue(calendar.weekOfYear({...date}), 1); + +calendar = new Temporal.Calendar("iso8601"); +const isodate = { month: 1, day: 1, year: 2021, calendar}; + +assert.sameValue(calendar.weekOfYear({...isodate}), 53); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/non-iso-week-of-year.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/non-iso-week-of-year.js new file mode 100644 index 0000000000..9392c0c13b --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/non-iso-week-of-year.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.weekofyear +description: > + Temporal.Calendar.prototype.weekOfYear returns undefined for all + non-ISO calendars without a well-defined week numbering system. +features: [Temporal] +---*/ + +// Gregorian calendar has a well defined week-numbering system. + +let calendar = new Temporal.Calendar("gregory"); +const date = { month: 1, day: 1, year: 2024, calendar}; + +assert.sameValue(calendar.weekOfYear({...date}), 1); + +calendar = new Temporal.Calendar("hebrew"); +const nonisodate = { month: 1, day: 1, year: 2024, calendar}; + +assert.sameValue(calendar.weekOfYear({...nonisodate}), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/year/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/year/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/year/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/year/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearMonthFromFields/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearMonthFromFields/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearMonthFromFields/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearMonthFromFields/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/gregory-iso-weekofyear.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/gregory-iso-weekofyear.js new file mode 100644 index 0000000000..ff2d9c0b60 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/gregory-iso-weekofyear.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.yearofweek +description: > + In the ISO 8601 week calendar, calendar week number 1 of a calendar year is + the week including the first Thursday of that year (based on the principle + that a week belongs to the same calendar year as the majority of its calendar + days). Because of this, some calendar days of the first calendar week of a + calendar year may be part of the preceding date calendar year, and some + calendar days of the last calendar week of a calendar year may be part of + the next calendar year. +features: [Temporal] +---*/ + +// + +let calendar = new Temporal.Calendar("gregory"); +const date = { month: 1, day: 1, year: 2021, calendar}; + +assert.sameValue(calendar.yearOfWeek({...date}), 2021); + +calendar = new Temporal.Calendar("iso8601"); +const isodate = { month: 1, day: 1, year: 2021, calendar}; + +assert.sameValue(calendar.yearOfWeek({...isodate}), 2020); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/non-iso-week-of-year.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/non-iso-week-of-year.js new file mode 100644 index 0000000000..9abf674f0f --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/non-iso-week-of-year.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.yearofweek +description: > + Temporal.Calendar.prototype.yearOfWeek returns undefined for all + non-ISO calendars without a well-defined week numbering system. +features: [Temporal] +---*/ + +// Gregorian calendar has a well defined week-numbering system. + +let calendar = new Temporal.Calendar("gregory"); +const date = { month: 1, day: 1, year: 2024, calendar}; + +assert.sameValue(calendar.yearOfWeek({...date}), 2024); + +calendar = new Temporal.Calendar("hebrew"); +const nonisodate = { month: 1, day: 1, year: 2024, calendar}; + +assert.sameValue(calendar.yearOfWeek({...nonisodate}), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Duration/prototype/add/shell.js b/js/src/tests/test262/intl402/Temporal/Duration/prototype/add/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Duration/prototype/add/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Duration/prototype/add/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Duration/prototype/round/shell.js b/js/src/tests/test262/intl402/Temporal/Duration/prototype/round/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Duration/prototype/round/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Duration/prototype/round/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Duration/prototype/subtract/shell.js b/js/src/tests/test262/intl402/Temporal/Duration/prototype/subtract/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Duration/prototype/subtract/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Duration/prototype/subtract/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Duration/prototype/total/shell.js b/js/src/tests/test262/intl402/Temporal/Duration/prototype/total/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Duration/prototype/total/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Duration/prototype/total/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/dateStyle.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/dateStyle.js new file mode 100644 index 0000000000..2d0614deb9 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/dateStyle.js @@ -0,0 +1,31 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.prototype.tolocalestring +description: Basic tests that dateStyle option affects output +locale: [en-u-ca-gregory, en-u-ca-islamic] +features: [Temporal, Intl.DateTimeFormat-datetimestyle] +---*/ + +const instant = new Temporal.Instant(1711475200_000_000_000n); + +assert( + instant.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"), + "dateStyle: long writes month of March out in full" +); +assert( + !instant.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"), + "dateStyle: short does not write month of March out in full" +); +assert( + instant.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"), + "dateStyle: long writes month of Ramadan out in full" +); +assert( + !instant.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"), + "dateStyle: short does not write month of Ramadan out in full" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/compare/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDate/compare/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDate/compare/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/compare/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/from/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDate/from/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDate/from/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/from/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/equals/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/equals/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/equals/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/equals/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/since/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/since/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/since/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/since/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/toLocaleString/dateStyle.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/toLocaleString/dateStyle.js new file mode 100644 index 0000000000..0bb42308d5 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/toLocaleString/dateStyle.js @@ -0,0 +1,34 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.tolocalestring +description: Basic tests that dateStyle option affects output +locale: [en-u-ca-gregory, en-u-ca-islamic] +features: [Temporal, Intl.DateTimeFormat-datetimestyle] +---*/ + +const dateGregorian = new Temporal.PlainDate(2024, 3, 26, "gregory"); + +assert( + dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"), + "dateStyle: long writes month of March out in full" +); +assert( + !dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"), + "dateStyle: short does not write month of March out in full" +); + +const dateIslamic = new Temporal.PlainDate(2024, 3, 26, "islamic"); + +assert( + dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"), + "dateStyle: long writes month of Ramadan out in full" +); +assert( + !dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"), + "dateStyle: short does not write month of Ramadan out in full" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/until/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/until/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/until/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/until/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/browser.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/browser.js diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/gregory-iso-weekofyear.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/gregory-iso-weekofyear.js new file mode 100644 index 0000000000..312d87afd6 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/gregory-iso-weekofyear.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.weekofyear +description: > + In the ISO 8601 week calendar, calendar week number 1 of a calendar year is + the week including the first Thursday of that year (based on the principle + that a week belongs to the same calendar year as the majority of its calendar + days). Because of this, some calendar days of the first calendar week of a + calendar year may be part of the preceding date calendar year, and some + calendar days of the last calendar week of a calendar year may be part of + the next calendar year. +features: [Temporal] +---*/ + +// + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.PlainDate(2021, 1, 1, calendar); + +assert.sameValue(date.weekOfYear, 1); + +calendar = new Temporal.Calendar("iso8601"); +const isodate = new Temporal.PlainDate(2021, 1, 1, calendar); + +assert.sameValue(isodate.weekOfYear, 53); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/non-iso-week-of-year.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/non-iso-week-of-year.js new file mode 100644 index 0000000000..b9717b8eba --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/non-iso-week-of-year.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.weekofyear +description: > + Temporal.PlainDate.prototype.weekOfYear returns undefined for all + non-ISO calendars without a well-defined week numbering system. +features: [Temporal] +---*/ + +// Gregorian calendar has a well defined week-numbering system. + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.PlainDate(2024, 1, 1, calendar); + +assert.sameValue(date.weekOfYear, 1); + +calendar = new Temporal.Calendar("hebrew"); +const nonisodate = new Temporal.PlainDate(2024, 1, 1, calendar); + +assert.sameValue(nonisodate.weekOfYear, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/shell.js diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/browser.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/browser.js diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/gregory-iso-weekofyear.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/gregory-iso-weekofyear.js new file mode 100644 index 0000000000..d8556f309a --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/gregory-iso-weekofyear.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.yearofweek +description: > + In the ISO 8601 week calendar, calendar week number 1 of a calendar year is + the week including the first Thursday of that year (based on the principle + that a week belongs to the same calendar year as the majority of its calendar + days). Because of this, some calendar days of the first calendar week of a + calendar year may be part of the preceding date calendar year, and some + calendar days of the last calendar week of a calendar year may be part of + the next calendar year. +features: [Temporal] +---*/ + +// + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.PlainDate(2021, 1, 1, calendar); + +assert.sameValue(date.yearOfWeek, 2021); + +calendar = new Temporal.Calendar("iso8601"); +const isodate = new Temporal.PlainDate(2021, 1, 1, calendar); + +assert.sameValue(isodate.yearOfWeek, 2020); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/non-iso-week-of-year.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/non-iso-week-of-year.js new file mode 100644 index 0000000000..047166e765 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/non-iso-week-of-year.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.yearofweek +description: > + Temporal.PlainDate.prototype.yearOfWeek returns undefined for all + non-ISO calendars without a well-defined week numbering system. +features: [Temporal] +---*/ + +// Gregorian calendar has a well defined week-numbering system. + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.PlainDate(2024, 1, 1, calendar); + +assert.sameValue(date.yearOfWeek, 2024); + +calendar = new Temporal.Calendar("hebrew"); +const nonisodate = new Temporal.PlainDate(2024, 1, 1, calendar); + +assert.sameValue(nonisodate.yearOfWeek, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/shell.js diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/compare/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/compare/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDateTime/compare/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/compare/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/from/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/from/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDateTime/from/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/from/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/equals/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/equals/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/equals/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/equals/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/since/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/since/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/since/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/since/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/toLocaleString/dateStyle.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/toLocaleString/dateStyle.js new file mode 100644 index 0000000000..9abc7e4128 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/toLocaleString/dateStyle.js @@ -0,0 +1,34 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tolocalestring +description: Basic tests that dateStyle option affects output +locale: [en-u-ca-gregory, en-u-ca-islamic] +features: [Temporal, Intl.DateTimeFormat-datetimestyle] +---*/ + +const dateGregorian = new Temporal.PlainDateTime(2024, 3, 26, 10, 30, 0, 0, 0, 0, "gregory"); + +assert( + dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"), + "dateStyle: long writes month of March out in full" +); +assert( + !dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"), + "dateStyle: short does not write month of March out in full" +); + +const dateIslamic = new Temporal.PlainDateTime(2024, 3, 26, 10, 30, 0, 0, 0, 0, "islamic"); + +assert( + dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"), + "dateStyle: long writes month of Ramadan out in full" +); +assert( + !dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"), + "dateStyle: short does not write month of Ramadan out in full" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/until/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/until/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/until/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/until/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/browser.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/browser.js diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js new file mode 100644 index 0000000000..5b0fce3473 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.weekofyear +description: > + In the ISO 8601 week calendar, calendar week number 1 of a calendar year is + the week including the first Thursday of that year (based on the principle + that a week belongs to the same calendar year as the majority of its calendar + days). Because of this, some calendar days of the first calendar week of a + calendar year may be part of the preceding date calendar year, and some + calendar days of the last calendar week of a calendar year may be part of + the next calendar year. +features: [Temporal] +---*/ + +// + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar); + +assert.sameValue(date.weekOfYear, 1); + +calendar = new Temporal.Calendar("iso8601"); +const isodate = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar); + +assert.sameValue(isodate.weekOfYear, 53); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/non-iso-week-of-year.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/non-iso-week-of-year.js new file mode 100644 index 0000000000..b90a9cde8d --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/non-iso-week-of-year.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.weekofyear +description: > + Temporal.PlainDateTime.prototype.weekOfYear returns undefined for all + non-ISO calendars without a well-defined week numbering system. +features: [Temporal] +---*/ + +// Gregorian calendar has a well defined week-numbering system. + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); + +assert.sameValue(date.weekOfYear, 1); + +calendar = new Temporal.Calendar("hebrew"); +const nonisodate = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); + +assert.sameValue(nonisodate.weekOfYear, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/shell.js diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/withPlainDate/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/withPlainDate/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/withPlainDate/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/withPlainDate/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/browser.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/browser.js diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js new file mode 100644 index 0000000000..a3846e5d01 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.yearofweek +description: > + In the ISO 8601 week calendar, calendar week number 1 of a calendar year is + the week including the first Thursday of that year (based on the principle + that a week belongs to the same calendar year as the majority of its calendar + days). Because of this, some calendar days of the first calendar week of a + calendar year may be part of the preceding date calendar year, and some + calendar days of the last calendar week of a calendar year may be part of + the next calendar year. +features: [Temporal] +---*/ + +// + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar); + +assert.sameValue(date.yearOfWeek, 2021); + +calendar = new Temporal.Calendar("iso8601"); +const isodate = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar); + +assert.sameValue(isodate.yearOfWeek, 2020); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/non-iso-week-of-year.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/non-iso-week-of-year.js new file mode 100644 index 0000000000..cffb030267 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/non-iso-week-of-year.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.yearofweek +description: > + Temporal.PlainDateTime.prototype.yearOfWeek returns undefined for all + non-ISO calendars without a well-defined week numbering system. +features: [Temporal] +---*/ + +// Gregorian calendar has a well defined week-numbering system. + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); + +assert.sameValue(date.yearOfWeek, 2024); + +calendar = new Temporal.Calendar("hebrew"); +const nonisodate = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); + +assert.sameValue(nonisodate.yearOfWeek, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/shell.js diff --git a/js/src/tests/test262/intl402/Temporal/PlainMonthDay/from/shell.js b/js/src/tests/test262/intl402/Temporal/PlainMonthDay/from/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainMonthDay/from/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainMonthDay/from/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/equals/shell.js b/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/equals/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/equals/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/equals/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/dateStyle.js b/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/dateStyle.js new file mode 100644 index 0000000000..9011393592 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/dateStyle.js @@ -0,0 +1,34 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.tolocalestring +description: Basic tests that dateStyle option affects output +locale: [en-u-ca-gregory, en-u-ca-islamic] +features: [Temporal, Intl.DateTimeFormat-datetimestyle] +---*/ + +const dateGregorian = Temporal.PlainMonthDay.from({ monthCode: "M03", day: 26, calendar: "gregory" }); + +assert( + dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"), + "dateStyle: long writes month of March out in full" +); +assert( + !dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"), + "dateStyle: short does not write month of March out in full" +); + +const dateIslamic = Temporal.PlainMonthDay.from({ monthCode: "M09", day: 16, calendar: "islamic" }); + +assert( + dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"), + "dateStyle: long writes month of Ramadan out in full" +); +assert( + !dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"), + "dateStyle: short does not write month of Ramadan out in full" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/toPlainDate/shell.js b/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/toPlainDate/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/toPlainDate/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/toPlainDate/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainTime/prototype/toPlainDateTime/shell.js b/js/src/tests/test262/intl402/Temporal/PlainTime/prototype/toPlainDateTime/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainTime/prototype/toPlainDateTime/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainTime/prototype/toPlainDateTime/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainTime/prototype/toZonedDateTime/shell.js b/js/src/tests/test262/intl402/Temporal/PlainTime/prototype/toZonedDateTime/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainTime/prototype/toZonedDateTime/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainTime/prototype/toZonedDateTime/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/compare/shell.js b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/compare/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/compare/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/compare/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/from/shell.js b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/from/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/from/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/from/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/equals/shell.js b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/equals/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/equals/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/equals/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/since/shell.js b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/since/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/since/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/since/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/dateStyle.js b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/dateStyle.js new file mode 100644 index 0000000000..b4816e1b19 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/dateStyle.js @@ -0,0 +1,34 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.tolocalestring +description: Basic tests that dateStyle option affects output +locale: [en-u-ca-gregory, en-u-ca-islamic] +features: [Temporal, Intl.DateTimeFormat-datetimestyle] +---*/ + +const dateGregorian = Temporal.PlainYearMonth.from({ year: 2024, monthCode: "M03", calendar: "gregory" }); + +assert( + dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"), + "dateStyle: long writes month of March out in full" +); +assert( + !dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"), + "dateStyle: short does not write month of March out in full" +); + +const dateIslamic = Temporal.PlainYearMonth.from({ year: 1445, monthCode: "M09", calendar: "islamic" }); + +assert( + dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"), + "dateStyle: long writes month of Ramadan out in full" +); +assert( + !dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"), + "dateStyle: short does not write month of Ramadan out in full" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/until/shell.js b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/until/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/until/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/until/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/TimeZone/from/timezone-string-legacy-non-iana.js b/js/src/tests/test262/intl402/Temporal/TimeZone/from/timezone-string-legacy-non-iana.js new file mode 100644 index 0000000000..90f7e9f4f6 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/TimeZone/from/timezone-string-legacy-non-iana.js @@ -0,0 +1,47 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.from +description: Only IANA time zone identifiers are allowed. +features: [Temporal] +---*/ + +// List of non-IANA link names, copied from: +// https://github.com/unicode-org/icu/blob/main/icu4c/source/tools/tzcode/icuzones +const invalidTimeZones = [ + "ACT", + "AET", + "AGT", + "ART", + "AST", + "BET", + "BST", + "CAT", + "CNT", + "CST", + "CTT", + "EAT", + "ECT", + "IET", + "IST", + "JST", + "MIT", + "NET", + "NST", + "PLT", + "PNT", + "PRT", + "PST", + "SST", + "VST", +]; + +for (let timeZone of invalidTimeZones) { + assert.throws(RangeError, () => { + Temporal.TimeZone.from(timeZone); + }, "Time zone: " + timeZone); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/TimeZone/legacy-non-iana.js b/js/src/tests/test262/intl402/Temporal/TimeZone/legacy-non-iana.js new file mode 100644 index 0000000000..aaf9dd1a80 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/TimeZone/legacy-non-iana.js @@ -0,0 +1,47 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone +description: Only IANA time zone identifiers are allowed. +features: [Temporal] +---*/ + +// List of non-IANA link names, copied from: +// https://github.com/unicode-org/icu/blob/main/icu4c/source/tools/tzcode/icuzones +const invalidTimeZones = [ + "ACT", + "AET", + "AGT", + "ART", + "AST", + "BET", + "BST", + "CAT", + "CNT", + "CST", + "CTT", + "EAT", + "ECT", + "IET", + "IST", + "JST", + "MIT", + "NET", + "NST", + "PLT", + "PNT", + "PRT", + "PST", + "SST", + "VST", +]; + +for (let timeZone of invalidTimeZones) { + assert.throws(RangeError, () => { + new Temporal.TimeZone(timeZone); + }, "Time zone: " + timeZone); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getInstantFor/shell.js b/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getInstantFor/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getInstantFor/shell.js +++ b/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getInstantFor/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/shell.js b/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/shell.js +++ b/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getPossibleInstantsFor/shell.js b/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getPossibleInstantsFor/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getPossibleInstantsFor/shell.js +++ b/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getPossibleInstantsFor/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/compare/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/compare/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/compare/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/compare/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/from/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/from/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/from/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/from/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/equals/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/equals/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/equals/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/equals/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/era/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/era/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/era/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/era/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/eraYear/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/eraYear/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/eraYear/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/eraYear/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/since/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/since/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/since/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/since/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/dateStyle.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/dateStyle.js new file mode 100644 index 0000000000..b8235d824d --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/dateStyle.js @@ -0,0 +1,34 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.tolocalestring +description: Basic tests that dateStyle option affects output +locale: [en-u-ca-gregory, en-u-ca-islamic] +features: [Temporal, Intl.DateTimeFormat-datetimestyle] +---*/ + +const dateGregorian = new Temporal.ZonedDateTime(1711475200_000_000_000n, "UTC", "gregory"); + +assert( + dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"), + "dateStyle: long writes month of March out in full" +); +assert( + !dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"), + "dateStyle: short does not write month of March out in full" +); + +const dateIslamic = new Temporal.ZonedDateTime(1711475200_000_000_000n, "UTC", "islamic"); + +assert( + dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"), + "dateStyle: long writes month of Ramadan out in full" +); +assert( + !dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"), + "dateStyle: short does not write month of Ramadan out in full" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/until/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/until/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/until/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/until/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/browser.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/browser.js diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js new file mode 100644 index 0000000000..bf1ddaaaeb --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.weekofyear +description: > + In the ISO 8601 week calendar, calendar week number 1 of a calendar year is + the week including the first Thursday of that year (based on the principle + that a week belongs to the same calendar year as the majority of its calendar + days). Because of this, some calendar days of the first calendar week of a + calendar year may be part of the preceding date calendar year, and some + calendar days of the last calendar week of a calendar year may be part of + the next calendar year. +features: [Temporal] +---*/ + +// + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar); + +assert.sameValue(date.weekOfYear, 1); + +calendar = new Temporal.Calendar("iso8601"); +const isodate = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar); + +assert.sameValue(isodate.weekOfYear, 53); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/non-iso-week-of-year.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/non-iso-week-of-year.js new file mode 100644 index 0000000000..79769e6d19 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/non-iso-week-of-year.js @@ -0,0 +1,27 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.weekofyear +description: > + Temporal.ZonedDateTime.prototype.weekOfYear returns undefined for all + non-ISO calendars without a well-defined week numbering system. +features: [Temporal] +---*/ + +// Gregorian calendar has a well defined week-numbering system. + +let calendar = new Temporal.Calendar("gregory"); + +// Epoch Nanoseconds for new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); +const date = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar); + +assert.sameValue(date.weekOfYear, 1); + +calendar = new Temporal.Calendar("hebrew"); +const nonisodate = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar); + +assert.sameValue(nonisodate.weekOfYear, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/shell.js diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/with/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/with/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/with/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/with/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/withPlainDate/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/withPlainDate/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/withPlainDate/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/withPlainDate/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/browser.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/browser.js diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js new file mode 100644 index 0000000000..afa4ce7165 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.yearofweek +description: > + In the ISO 8601 week calendar, calendar week number 1 of a calendar year is + the week including the first Thursday of that year (based on the principle + that a week belongs to the same calendar year as the majority of its calendar + days). Because of this, some calendar days of the first calendar week of a + calendar year may be part of the preceding date calendar year, and some + calendar days of the last calendar week of a calendar year may be part of + the next calendar year. +features: [Temporal] +---*/ + +// + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar); + +assert.sameValue(date.yearOfWeek, 2021); + +calendar = new Temporal.Calendar("iso8601"); +const isodate = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar); + +assert.sameValue(isodate.yearOfWeek, 2020); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/non-iso-week-of-year.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/non-iso-week-of-year.js new file mode 100644 index 0000000000..58f0b6a5ff --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/non-iso-week-of-year.js @@ -0,0 +1,27 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.yearofweek +description: > + Temporal.ZonedDateTime.prototype.yearOfWeek returns undefined for all + non-ISO calendars without a well-defined week numbering system. +features: [Temporal] +---*/ + +// Gregorian calendar has a well defined week-numbering system. + +let calendar = new Temporal.Calendar("gregory"); + +// Epoch Nanoseconds for new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); +const date = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar); + +assert.sameValue(date.yearOfWeek, 2024); + +calendar = new Temporal.Calendar("hebrew"); +const nonisodate = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar); + +assert.sameValue(nonisodate.yearOfWeek, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/shell.js diff --git a/js/src/tests/test262/intl402/TypedArray/prototype/toLocaleString/calls-toLocaleString-number-elements.js b/js/src/tests/test262/intl402/TypedArray/prototype/toLocaleString/calls-toLocaleString-number-elements.js index c6b895e5db..133d6bb5d7 100644 --- a/js/src/tests/test262/intl402/TypedArray/prototype/toLocaleString/calls-toLocaleString-number-elements.js +++ b/js/src/tests/test262/intl402/TypedArray/prototype/toLocaleString/calls-toLocaleString-number-elements.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. diff --git a/js/src/tests/test262/jstests.list b/js/src/tests/test262/jstests.list index 84cb15a834..e904904c30 100644 --- a/js/src/tests/test262/jstests.list +++ b/js/src/tests/test262/jstests.list @@ -1,5 +1,8 @@ # GENERATED, DO NOT EDIT +test262-raw error:Test262Error script annexB/language/comments/single-line-html-close-first-line-1.js +test262-raw error:Test262Error script annexB/language/comments/single-line-html-close-first-line-2.js +test262-raw error:Test262Error script annexB/language/comments/single-line-html-close-first-line-3.js test262-raw error:SyntaxError script language/comments/hashbang/escaped-bang-041.js test262-raw error:SyntaxError script language/comments/hashbang/escaped-bang-u0021.js test262-raw error:SyntaxError script language/comments/hashbang/escaped-bang-u21.js diff --git a/js/src/tests/test262/language/expressions/assignment/S11.13.1_A7_T3.js b/js/src/tests/test262/language/expressions/assignment/S11.13.1_A7_T3.js deleted file mode 100644 index 8675448e23..0000000000 --- a/js/src/tests/test262/language/expressions/assignment/S11.13.1_A7_T3.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: Assignment Operator evaluates its operands from left to right. -description: > - The left-hand side expression is evaluated before the right-hand side. - Left-hand side expression is MemberExpression: base[prop]. Evaluating - ToPropertyKey(prop) throws an error. ----*/ - -function DummyError() { } - -assert.throws(DummyError, function() { - var base = {}; - var prop = { - toString: function() { - throw new DummyError(); - } - }; - var expr = function() { - throw new Test262Error("right-hand side expression evaluated"); - }; - - base[prop] = expr(); -}); - -reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/assignment/target-member-computed-reference.js b/js/src/tests/test262/language/expressions/assignment/target-member-computed-reference.js new file mode 100644 index 0000000000..fefc73370f --- /dev/null +++ b/js/src/tests/test262/language/expressions/assignment/target-member-computed-reference.js @@ -0,0 +1,42 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// Copyright (C) 2024 Sony Interactive Entertainment Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-assignment-operators +description: Assignment Operator evaluates its operands from left to right (formerly S11.13.1_A7_T3) +info: | + The left-hand side expression is evaluated before the right-hand side. + Left-hand side expression is MemberExpression: base[prop]. + ToPropertyKey(prop) occurs after both sides are evaluated. +---*/ + +function DummyError() { } + +assert.throws(DummyError, function() { + var base = {}; + var prop = function() { + throw new DummyError(); + }; + var expr = function() { + throw new Test262Error("right-hand side expression evaluated"); + }; + + base[prop()] = expr(); +}); + +assert.throws(DummyError, function() { + var base = {}; + var prop = { + toString: function() { + throw new Test262Error("property key evaluated"); + } + }; + var expr = function() { + throw new DummyError(); + }; + + base[prop] = expr(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/assignment/target-super-computed-reference.js b/js/src/tests/test262/language/expressions/assignment/target-super-computed-reference.js new file mode 100644 index 0000000000..39d692a81b --- /dev/null +++ b/js/src/tests/test262/language/expressions/assignment/target-super-computed-reference.js @@ -0,0 +1,51 @@ +// Copyright (C) 2024 Sony Interactive Entertainment Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-assignment-operators +description: Assignment Operator evaluates its operands from left to right +info: | + The left-hand side expression is evaluated before the right-hand side. + Left-hand side expression is MemberExpression: super[prop]. + ToPropertyKey(prop) occurs after both sides are evaluated. +---*/ + +function DummyError() {} + +assert.throws(DummyError, function() { + var prop = function() { + throw new DummyError(); + }; + var expr = function() { + throw new Test262Error("right-hand side expression evaluated"); + }; + + class C extends class {} { + m() { + super[prop()] = expr(); + } + } + + (new C()).m(); +}); + +assert.throws(DummyError, function() { + var prop = { + toString: function() { + throw new Test262Error("property key evaluated"); + } + }; + var expr = function() { + throw new DummyError(); + }; + + class C extends class {} { + m() { + super[prop] = expr(); + } + } + + (new C()).m(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/global-code/script-decl-lex-var-declared-via-eval-sloppy.js b/js/src/tests/test262/language/global-code/script-decl-lex-var-declared-via-eval-sloppy.js deleted file mode 100644 index 85c144b666..0000000000 --- a/js/src/tests/test262/language/global-code/script-decl-lex-var-declared-via-eval-sloppy.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2023 Alexey Shvayka. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-globaldeclarationinstantiation -description: Let binding collision with existing var declaration that was created via eval(). -info: | - [...] - 3. For each element name of lexNames, do - a. If env.HasVarDeclaration(name) is true, throw a SyntaxError exception. -flags: [noStrict] ----*/ - -eval('var test262Var;'); -eval('function test262Fn() {}'); - -assert.throws(SyntaxError, function() { - $262.evalScript('var x; let test262Var;'); -}, 'variable'); - -assert.throws(ReferenceError, function() { - x; -}, 'no bindings created (script shadowing variable)'); - -assert.throws(SyntaxError, function() { - $262.evalScript('var x; let test262Fn;'); -}, 'function'); - -assert.throws(ReferenceError, function() { - x; -}, 'no bindings created (script shadowing function)'); - -reportCompare(0, 0); diff --git a/js/src/tests/test262/language/global-code/script-decl-lex-var-declared-via-eval-strict-strict.js b/js/src/tests/test262/language/global-code/script-decl-lex-var-declared-via-eval-strict-strict.js deleted file mode 100644 index 34c2685a80..0000000000 --- a/js/src/tests/test262/language/global-code/script-decl-lex-var-declared-via-eval-strict-strict.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; -// Copyright (C) 2023 Alexey Shvayka. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-globaldeclarationinstantiation -description: No let binding collision with existing var declaration due to strict-mode eval(). -info: | - PerformEval ( x, strictCaller, direct ) - - [...] - 16. If direct is true, then - a. Let lexEnv be NewDeclarativeEnvironment(runningContext's LexicalEnvironment). - [...] - 18. If strictEval is true, set varEnv to lexEnv. -flags: [onlyStrict] ----*/ - -eval('var test262Var;'); -eval('function test262Fn() {}'); - -$262.evalScript('let test262Var = 1;'); -assert.sameValue(test262Var, 1); - -$262.evalScript('const test262Fn = 2;'); -assert.sameValue(test262Fn, 2); - -reportCompare(0, 0); diff --git a/js/src/tests/test262/language/global-code/script-decl-lex-var-declared-via-eval.js b/js/src/tests/test262/language/global-code/script-decl-lex-var-declared-via-eval.js new file mode 100644 index 0000000000..a92cca7b41 --- /dev/null +++ b/js/src/tests/test262/language/global-code/script-decl-lex-var-declared-via-eval.js @@ -0,0 +1,38 @@ +// Copyright (C) 2023 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-globaldeclarationinstantiation +description: No let binding collision with existing var declaration due to eval(). +info: | + In strict mode: + + PerformEval ( x, strictCaller, direct ) + + [...] + 16. If direct is true, then + a. Let lexEnv be NewDeclarativeEnvironment(runningContext's LexicalEnvironment). + [...] + 18. If strictEval is true, set varEnv to lexEnv. + + In sloppy mode: + + GlobalDeclarationInstantiation ( script, env ) + + [...] + 3. For each element name of lexNames, do + a. If env.HasLexicalDeclaration(name) is true, throw a SyntaxError exception. + b. Let hasRestrictedGlobal be ? env.HasRestrictedGlobalProperty(name). + c. NOTE: Global var and function bindings (except those that are introduced by non-strict direct eval) are non-configurable and are therefore restricted global properties. + d. If hasRestrictedGlobal is true, throw a SyntaxError exception. +---*/ + +eval('var test262Var;'); +eval('function test262Fn() {}'); + +$262.evalScript('let test262Var = 1;'); +assert.sameValue(test262Var, 1); + +$262.evalScript('const test262Fn = 2;'); +assert.sameValue(test262Fn, 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-add-remove-i.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-add-remove-i.js new file mode 100644 index 0000000000..a63c3e1af7 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-add-remove-i.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?i-i:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-add-remove-m.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-add-remove-m.js new file mode 100644 index 0000000000..c3b44f4796 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-add-remove-m.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?m-m:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-add-remove-multi-duplicate.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-add-remove-multi-duplicate.js new file mode 100644 index 0000000000..92cfb0457d --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-add-remove-multi-duplicate.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?ims-m:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-add-remove-s-escape.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-add-remove-s-escape.js new file mode 100644 index 0000000000..b8937aaa07 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-add-remove-s-escape.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?\u{0073}-s:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-add-remove-s.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-add-remove-s.js new file mode 100644 index 0000000000..e8d09f4cc6 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-add-remove-s.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?s-s:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-both-empty.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-both-empty.js new file mode 100644 index 0000000000..db06a2eb86 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-both-empty.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by the first RegularExpressionFlags and the source text matched by the second RegularExpressionFlags are both empty. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-code-point-repeat-i-1.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-code-point-repeat-i-1.js new file mode 100644 index 0000000000..78c275e17f --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-code-point-repeat-i-1.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-ii:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-code-point-repeat-i-2.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-code-point-repeat-i-2.js new file mode 100644 index 0000000000..16f52d86f5 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-code-point-repeat-i-2.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-imsi:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-no-colon-1.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-no-colon-1.js new file mode 100644 index 0000000000..a392d5b0e0 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-no-colon-1.js @@ -0,0 +1,19 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Regular expression modifiers should not parse without the colon. +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... +---*/ + +$DONOTEVALUATE(); + +/(?ms-i)/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-no-colon-2.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-no-colon-2.js new file mode 100644 index 0000000000..46c3f4db43 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-no-colon-2.js @@ -0,0 +1,19 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Regular expression modifiers should not parse without the colon. +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... +---*/ + +$DONOTEVALUATE(); + +/(?-s)/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-no-colon-3.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-no-colon-3.js new file mode 100644 index 0000000000..e44077389c --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-no-colon-3.js @@ -0,0 +1,19 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Regular expression modifiers should not parse without the colon. +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... +---*/ + +$DONOTEVALUATE(); + +/(?i-)/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-arbitrary.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-arbitrary.js new file mode 100644 index 0000000000..62a138a3aa --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-arbitrary.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-1:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-combining-i.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-combining-i.js new file mode 100644 index 0000000000..958024fe65 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-combining-i.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-iͥ:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-combining-m.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-combining-m.js new file mode 100644 index 0000000000..45284e6d38 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-combining-m.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-mͫ:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-combining-s.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-combining-s.js new file mode 100644 index 0000000000..35bda819bd --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-combining-s.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-s̀:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-d.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-d.js new file mode 100644 index 0000000000..6567f99c37 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-d.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-d:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-g.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-g.js new file mode 100644 index 0000000000..ec8b2f03f8 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-g.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-g:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-non-display-1.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-non-display-1.js Binary files differnew file mode 100644 index 0000000000..e88cb7a696 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-non-display-1.js diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-non-display-2.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-non-display-2.js new file mode 100644 index 0000000000..90816752fb --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-non-display-2.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-s:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-non-flag.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-non-flag.js new file mode 100644 index 0000000000..cd8ae0baf9 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-non-flag.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-Q:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-u.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-u.js new file mode 100644 index 0000000000..23a1f23b72 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-u.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-u:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-uppercase-I.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-uppercase-I.js new file mode 100644 index 0000000000..be6d2e61dc --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-uppercase-I.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-I:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-y.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-y.js new file mode 100644 index 0000000000..d65d6e6874 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-y.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-y:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-zwj.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-zwj.js new file mode 100644 index 0000000000..84e7253ef8 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-zwj.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-s:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-zwnbsp.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-zwnbsp.js new file mode 100644 index 0000000000..7acc6a49e3 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-zwnbsp.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-s:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-zwnj.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-zwnj.js new file mode 100644 index 0000000000..118ff69976 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-other-code-point-zwnj.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-s:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-i.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-i.js new file mode 100644 index 0000000000..a63c3e1af7 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-i.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?i-i:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-m.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-m.js new file mode 100644 index 0000000000..c3b44f4796 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-m.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?m-m:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-multi-duplicate.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-multi-duplicate.js new file mode 100644 index 0000000000..20ad04b60d --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-multi-duplicate.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?m-ims:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-s-escape.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-s-escape.js new file mode 100644 index 0000000000..a3b3263fdf --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-s-escape.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?s-\u{0073}:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-s.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-s.js new file mode 100644 index 0000000000..e8d09f4cc6 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-add-remove-s.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?s-s:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-code-point-repeat-i-1.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-code-point-repeat-i-1.js new file mode 100644 index 0000000000..80352f948e --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-code-point-repeat-i-1.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?ii-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-code-point-repeat-i-2.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-code-point-repeat-i-2.js new file mode 100644 index 0000000000..1793724cfa --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-code-point-repeat-i-2.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?imsi-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-arbitrary.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-arbitrary.js new file mode 100644 index 0000000000..996963dbd0 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-arbitrary.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?1-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-combining-i.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-combining-i.js new file mode 100644 index 0000000000..616a537acb --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-combining-i.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?iͥ-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-combining-m.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-combining-m.js new file mode 100644 index 0000000000..6fa734c89a --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-combining-m.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?mͫ-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-combining-s.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-combining-s.js new file mode 100644 index 0000000000..d3d5aa8ce3 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-combining-s.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?s̀-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-d.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-d.js new file mode 100644 index 0000000000..b91c8bd612 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-d.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?d-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-g.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-g.js new file mode 100644 index 0000000000..c1e99de1ad --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-g.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?g-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-non-display-1.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-non-display-1.js Binary files differnew file mode 100644 index 0000000000..eec06fce52 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-non-display-1.js diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-non-display-2.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-non-display-2.js new file mode 100644 index 0000000000..6a00b90484 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-non-display-2.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?s-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-non-flag.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-non-flag.js new file mode 100644 index 0000000000..e351dd2e3b --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-non-flag.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?Q-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-u.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-u.js new file mode 100644 index 0000000000..ae33a9ae34 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-u.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?u-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-uppercase-I.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-uppercase-I.js new file mode 100644 index 0000000000..c177ef76c7 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-uppercase-I.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?I-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-y.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-y.js new file mode 100644 index 0000000000..65383882cc --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-y.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?y-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-zwj.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-zwj.js new file mode 100644 index 0000000000..c3d3032ea0 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-zwj.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?s-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-zwnbsp.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-zwnbsp.js new file mode 100644 index 0000000000..e4b702e4a7 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-zwnbsp.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?s-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-zwnj.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-zwnj.js new file mode 100644 index 0000000000..eff2688281 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-other-code-point-zwnj.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?s-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-case-fold-i.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-case-fold-i.js new file mode 100644 index 0000000000..7b922f651c --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-case-fold-i.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?I-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-case-fold-m.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-case-fold-m.js new file mode 100644 index 0000000000..189fce143c --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-case-fold-m.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?M-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-case-fold-s.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-case-fold-s.js new file mode 100644 index 0000000000..47dbf5aa9a --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-case-fold-s.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?S-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-i.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-i.js new file mode 100644 index 0000000000..106b9b2add --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-i.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?İ-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-s.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-s.js new file mode 100644 index 0000000000..7b15fe7a09 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-s.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?ſ-:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-should-not-case-fold-i.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-should-not-case-fold-i.js new file mode 100644 index 0000000000..c07e0041c0 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-should-not-case-fold-i.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-I:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-should-not-case-fold-m.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-should-not-case-fold-m.js new file mode 100644 index 0000000000..4afe34ff44 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-should-not-case-fold-m.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-M:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-should-not-case-fold-s.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-should-not-case-fold-s.js new file mode 100644 index 0000000000..e83af36569 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-should-not-case-fold-s.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-S:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-should-not-unicode-case-fold-i.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-should-not-unicode-case-fold-i.js new file mode 100644 index 0000000000..2a948073f0 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-should-not-unicode-case-fold-i.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-İ:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-should-not-unicode-case-fold-s.js b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-should-not-unicode-case-fold-s.js new file mode 100644 index 0000000000..7c2f23c502 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-arithmetic-modifiers-should-not-unicode-case-fold-s.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +$DONOTEVALUATE(); + +/(?-ſ:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-code-point-repeat-i-1.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-code-point-repeat-i-1.js new file mode 100644 index 0000000000..ff0d589e26 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-code-point-repeat-i-1.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?ii:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-code-point-repeat-i-2.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-code-point-repeat-i-2.js new file mode 100644 index 0000000000..7975935725 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-code-point-repeat-i-2.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?imsi:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-arbitrary.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-arbitrary.js new file mode 100644 index 0000000000..6569bbef01 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-arbitrary.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?1:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-combining-i.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-combining-i.js new file mode 100644 index 0000000000..7d557532d8 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-combining-i.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?iͥ:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-combining-m.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-combining-m.js new file mode 100644 index 0000000000..a09130e2df --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-combining-m.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?mͫ:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-combining-s.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-combining-s.js new file mode 100644 index 0000000000..a83fe10f9d --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-combining-s.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?s̀:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-d.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-d.js new file mode 100644 index 0000000000..559b7b4566 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-d.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?d:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-g.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-g.js new file mode 100644 index 0000000000..92304ef165 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-g.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?g:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-non-display-1.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-non-display-1.js Binary files differnew file mode 100644 index 0000000000..102dee02bc --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-non-display-1.js diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-non-display-2.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-non-display-2.js new file mode 100644 index 0000000000..b005b43c67 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-non-display-2.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?s:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-non-flag.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-non-flag.js new file mode 100644 index 0000000000..d144b58bd1 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-non-flag.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?Q:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-u.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-u.js new file mode 100644 index 0000000000..94805b1c8e --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-u.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?u:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-uppercase-I.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-uppercase-I.js new file mode 100644 index 0000000000..a1bd269c61 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-uppercase-I.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?I:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-y.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-y.js new file mode 100644 index 0000000000..399f5d8837 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-y.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?y:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-zwj.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-zwj.js new file mode 100644 index 0000000000..5f3c392313 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-zwj.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?s:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-zwnbsp.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-zwnbsp.js new file mode 100644 index 0000000000..37b0bf301b --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-zwnbsp.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?s:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-zwnj.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-zwnj.js new file mode 100644 index 0000000000..5889fc154d --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-other-code-point-zwnj.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?s:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-case-fold-i.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-case-fold-i.js new file mode 100644 index 0000000000..0c50a15058 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-case-fold-i.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?I:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-case-fold-m.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-case-fold-m.js new file mode 100644 index 0000000000..38e290647e --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-case-fold-m.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?M:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-case-fold-s.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-case-fold-s.js new file mode 100644 index 0000000000..a2c4ba26db --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-case-fold-s.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?S:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-unicode-case-fold-i.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-unicode-case-fold-i.js new file mode 100644 index 0000000000..3a4efff07d --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-unicode-case-fold-i.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?İ:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-unicode-case-fold-s.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-unicode-case-fold-s.js new file mode 100644 index 0000000000..32ebb024e2 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-unicode-case-fold-s.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?ſ:a)//*{ global-modifiers }*/; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-unicode-escape-i.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-unicode-escape-i.js new file mode 100644 index 0000000000..b2493e3855 --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-unicode-escape-i.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Source text cannot use unicode escape sequences to express code points "i", "m", "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?\u0069:a)/u /* i */; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-unicode-escape-m.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-unicode-escape-m.js new file mode 100644 index 0000000000..cd1e66099c --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-unicode-escape-m.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Source text cannot use unicode escape sequences to express code points "i", "m", "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?\u006D:a)/u /* m */; diff --git a/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-unicode-escape-s.js b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-unicode-escape-s.js new file mode 100644 index 0000000000..145ab4fe4a --- /dev/null +++ b/js/src/tests/test262/language/literals/regexp/early-err-modifiers-should-not-unicode-escape-s.js @@ -0,0 +1,20 @@ +// |reftest| skip error:SyntaxError -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Source text cannot use unicode escape sequences to express code points "i", "m", "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +negative: + phase: parse + type: SyntaxError +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +$DONOTEVALUATE(); + +/(?\u0073:a)/u /* s */; diff --git a/js/src/tests/test262/language/module-code/import-attributes/allow-nlt-before-with.js b/js/src/tests/test262/language/module-code/import-attributes/allow-nlt-before-with.js index ed6c329c92..73131843af 100644 --- a/js/src/tests/test262/language/module-code/import-attributes/allow-nlt-before-with.js +++ b/js/src/tests/test262/language/module-code/import-attributes/allow-nlt-before-with.js @@ -7,7 +7,7 @@ description: > esid: sec-modules info: | ImportDeclaration: - import ModuleSpecifier[no LineTerminator here] WithClause; + import ModuleSpecifier WithClause; WithClause: AttributesKeyword {} diff --git a/js/src/tests/test262/language/module-code/top-level-await/async-module-does-not-block-sibling-modules.js b/js/src/tests/test262/language/module-code/top-level-await/async-module-does-not-block-sibling-modules.js new file mode 100644 index 0000000000..c7c5e2f35f --- /dev/null +++ b/js/src/tests/test262/language/module-code/top-level-await/async-module-does-not-block-sibling-modules.js @@ -0,0 +1,17 @@ +// |reftest| module async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-innermoduleevaluation +description: > + While an asynchronous module is waiting for a promise resolution, + sibling modules in the modules graph must be evaluated. +flags: [module, async] +features: [top-level-await] +---*/ + +import "./async-module-tla_FIXTURE.js"; +import { check } from "./async-module-sync_FIXTURE.js"; +assert.sameValue(check, false); +$DONE(); diff --git a/js/src/tests/test262/language/module-code/top-level-await/async-module-sync_FIXTURE.js b/js/src/tests/test262/language/module-code/top-level-await/async-module-sync_FIXTURE.js new file mode 100644 index 0000000000..a6595716be --- /dev/null +++ b/js/src/tests/test262/language/module-code/top-level-await/async-module-sync_FIXTURE.js @@ -0,0 +1,5 @@ +// |reftest| skip -- not a test file +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export const { check } = globalThis; diff --git a/js/src/tests/test262/language/module-code/top-level-await/async-module-tla_FIXTURE.js b/js/src/tests/test262/language/module-code/top-level-await/async-module-tla_FIXTURE.js new file mode 100644 index 0000000000..b5a0b046b2 --- /dev/null +++ b/js/src/tests/test262/language/module-code/top-level-await/async-module-tla_FIXTURE.js @@ -0,0 +1,7 @@ +// |reftest| skip -- not a test file +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +globalThis.check = false; +await 0; +globalThis.check = true; diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/regular-subclassing.js index dc22b74e0f..69722f58e3 100644 --- a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/regular-subclassing.js +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/regular-subclassing.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/super-must-be-called.js index 04b4638390..e75fbfe30b 100644 --- a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/super-must-be-called.js +++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/TypedArray/super-must-be-called.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/js/src/tests/test262/staging/Intl402/Temporal/old/non-iso-calendars.js b/js/src/tests/test262/staging/Intl402/Temporal/old/non-iso-calendars.js index a4f1a2908f..4639e58e9e 100644 --- a/js/src/tests/test262/staging/Intl402/Temporal/old/non-iso-calendars.js +++ b/js/src/tests/test262/staging/Intl402/Temporal/old/non-iso-calendars.js @@ -6,6 +6,26 @@ esid: sec-temporal-intl description: Non-ISO Calendars features: [Temporal, Array.prototype.includes] +locale: + - en-US-u-ca-iso8601 + - en-US-u-ca-buddhist + - en-US-u-ca-chinese + - en-US-u-ca-coptic + - en-US-u-ca-dangi + - en-US-u-ca-ethioaa + - en-US-u-ca-ethiopic + - en-US-u-ca-gregory + - en-US-u-ca-hebrew + - en-US-u-ca-indian + - en-US-u-ca-islamic + - en-US-u-ca-islamic-umalqura + - en-US-u-ca-islamic-tbla + - en-US-u-ca-islamic-civil + - en-US-u-ca-islamic-rgsa + - en-US-u-ca-islamicc + - en-US-u-ca-japanese + - en-US-u-ca-persian + - en-US-u-ca-roc ---*/ var testChineseData = new Date("2001-02-01T00:00Z").toLocaleString("en-US-u-ca-chinese", { @@ -18,69 +38,256 @@ var testChineseData = new Date("2001-02-01T00:00Z").toLocaleString("en-US-u-ca-c var hasOutdatedChineseIcuData = !testChineseData.endsWith("2001"); // verify that Intl.DateTimeFormat.formatToParts output matches snapshot data -var getLocalizedDates = isoString => { - var calendars = [ - "iso8601", - "buddhist", - "chinese", - "coptic", - "dangi", - "ethioaa", - "ethiopic", - "gregory", - "hebrew", - "indian", - "islamic", - "islamic-umalqura", - "islamic-tbla", - "islamic-civil", - "islamic-rgsa", - "islamicc", - "japanese", - "persian", - "roc" - ]; - var date = new Date(isoString); - return calendars.map(id => `${ id }: ${ date.toLocaleDateString(`en-US-u-ca-${ id }`, { timeZone: "UTC" }) }`).join("\n"); -}; -var year2000Content = getLocalizedDates("2000-01-01T00:00Z"); -var year1Content = getLocalizedDates("0001-01-01T00:00Z"); -var year2000Snapshot = "iso8601: 1/1/2000\n" + "buddhist: 1/1/2543 BE\n" + "chinese: 11/25/1999\n" + "coptic: 4/22/1716 ERA1\n" + "dangi: 11/25/1999\n" + "ethioaa: 4/22/7492 ERA0\n" + "ethiopic: 4/22/1992 ERA1\n" + "gregory: 1/1/2000\n" + "hebrew: 23 Tevet 5760\n" + "indian: 10/11/1921 Saka\n" + "islamic: 9/25/1420 AH\n" + "islamic-umalqura: 9/24/1420 AH\n" + "islamic-tbla: 9/25/1420 AH\n" + "islamic-civil: 9/24/1420 AH\n" + "islamic-rgsa: 9/25/1420 AH\n" + "islamicc: 9/24/1420 AH\n" + "japanese: 1/1/12 H\n" + "persian: 10/11/1378 AP\n" + "roc: 1/1/89 Minguo"; -assert.sameValue(year2000Content, year2000Snapshot); +function compareFormatToPartsSnapshot(isoString, expected) { + const date = new Date(isoString); + Object.entries(expected).forEach(([calendar, expectedComponents]) => { + const formatter = new Intl.DateTimeFormat(`en-US-u-ca-${calendar}`, { timeZone: "UTC" }); + const actualComponents = formatter.formatToParts(date); + Object.entries(expectedComponents).forEach(([expectedType, expectedValue]) => { + const part = actualComponents.find(({type}) => type === expectedType); + const contextMessage = `${expectedType} component of ${isoString} formatted in ${calendar}`; + assert.notSameValue(part, undefined, contextMessage); + assert.sameValue(part.value, `${expectedValue}`, contextMessage); + }); + }); +} + +compareFormatToPartsSnapshot("2000-01-01T00:00Z", { + iso8601: { + year: 2000, + month: 1, + day: 1, + }, + buddhist: { + year: 2543, + era: "BE", + month: 1, + day: 1, + }, + chinese: { + relatedYear: 1999, + month: 11, + day: 25, + }, + coptic: { + year: 1716, + era: "ERA1", + month: 4, + day: 22, + }, + dangi: { + relatedYear: 1999, + month: 11, + day: 25, + }, + ethioaa: { + year: 7492, + era: "ERA0", + month: 4, + day: 22, + }, + ethiopic: { + year: 1992, + era: "ERA1", + month: 4, + day: 22, + }, + gregory: { + year: 2000, + month: 1, + day: 1, + }, + hebrew: { + year: 5760, + month: "Tevet", + day: 23, + }, + indian: { + year: 1921, + era: "Saka", + month: 10, + day: 11, + }, + islamic: { + year: 1420, + era: "AH", + month: 9, + day: 25, + }, + "islamic-umalqura": { + year: 1420, + era: "AH", + month: 9, + day: 24, + }, + "islamic-tbla": { + year: 1420, + era: "AH", + month: 9, + day: 25, + }, + "islamic-civil": { + year: 1420, + era: "AH", + month: 9, + day: 24, + }, + "islamic-rgsa": { + year: 1420, + era: "AH", + month: 9, + day: 25, + }, + islamicc: { + year: 1420, + era: "AH", + month: 9, + day: 24, + }, + japanese: { + year: 12, + era: "H", + month: 1, + day: 1, + }, + persian: { + year: 1378, + era: "AP", + month: 10, + day: 11, + }, + roc: { + year: 89, + era: "Minguo", + month: 1, + day: 1, + }, +}); // Several calendars based on the Gregorian calendar use Julian dates (not // proleptic Gregorian dates) before the Gregorian switchover in Oct 1582. See // https://bugs.chromium.org/p/chromium/issues/detail?id=1173158. The code below // allows these tests to pass regardless of the bug, while still remaining // sensitive to other bugs that may crop up. -const yearOneMonthDay = new Map( +const yearOneDay = new Map( ["iso8601", "gregory", "roc", "buddhist", "japanese"].map(calendar => { hasGregorianSwitchoverBug = new Date("+001001-01-01T00:00Z") .toLocaleDateString(`en-US-u-ca-${calendar}`, { timeZone: "UTC" }) .startsWith("12"); - return [calendar, hasGregorianSwitchoverBug ? "1/3" : "1/1"] + return [calendar, hasGregorianSwitchoverBug ? 3 : 1] })); -var year1Snapshot = - `iso8601: ${yearOneMonthDay.get("iso8601")}/1\n` + - `buddhist: ${yearOneMonthDay.get("buddhist")}/544 BE\n` + - "chinese: 11/21/0\n" + - "coptic: 5/8/284 ERA0\n" + - "dangi: 11/21/0\n" + - "ethioaa: 5/8/5493 ERA0\n" + - "ethiopic: 5/8/5493 ERA0\n" + - `gregory: ${yearOneMonthDay.get("gregory")}/1\n` + - "hebrew: 18 Tevet 3761\n" + - "indian: 10/11/-78 Saka\n" + - "islamic: 5/20/-640 AH\n" + - "islamic-umalqura: 5/18/-640 AH\n" + - "islamic-tbla: 5/19/-640 AH\n" + - "islamic-civil: 5/18/-640 AH\n" + - "islamic-rgsa: 5/20/-640 AH\n" + - "islamicc: 5/18/-640 AH\n" + - `japanese: ${yearOneMonthDay.get("japanese")}/-643 Taika (645\u2013650)\n` + - "persian: 10/11/-621 AP\n" + - `roc: ${yearOneMonthDay.get("roc")}/1911 B.R.O.C.`; -assert.sameValue(year1Content, year1Snapshot); +compareFormatToPartsSnapshot("0001-01-01T00:00Z", { + iso8601: { + year: 1, + month: 1, + day: yearOneDay.get("iso8601"), + }, + buddhist: { + year: 544, + era: "BE", + month: 1, + day: yearOneDay.get("buddhist"), + }, + chinese: { + relatedYear: 0, + month: 11, + day: 21, + }, + coptic: { + year: 284, + era: "ERA0", + month: 5, + day: 8, + }, + dangi: { + relatedYear: 0, + month: 11, + day: 21, + }, + ethioaa: { + year: 5493, + era: "ERA0", + month: 5, + day: 8, + }, + ethiopic: { + year: 5493, + era: "ERA0", + month: 5, + day: 8, + }, + gregory: { + year: 1, + month: 1, + day: yearOneDay.get("gregory"), + }, + hebrew: { + year: 3761, + month: "Tevet", + day: 18, + }, + indian: { + year: -78, + era: "Saka", + month: 10, + day: 11, + }, + islamic: { + year: -640, + era: "AH", + month: 5, + day: 20, + }, + "islamic-umalqura": { + year: -640, + era: "AH", + month: 5, + day: 18, + }, + "islamic-tbla": { + year: -640, + era: "AH", + month: 5, + day: 19, + }, + "islamic-civil": { + year: -640, + era: "AH", + month: 5, + day: 18, + }, + "islamic-rgsa": { + year: -640, + era: "AH", + month: 5, + day: 20, + }, + islamicc: { + year: -640, + era: "AH", + month: 5, + day: 18, + }, + japanese: { + year: -643, + era: "Taika (645\u2013650)", + month: 1, + day: yearOneDay.get("japanese"), + }, + persian: { + year: -621, + era: "AP", + month: 10, + day: 11, + }, + roc: { + year: 1911, + era: "B.R.O.C.", + month: 1, + day: yearOneDay.get("roc"), + }, +}); + var fromWithCases = { iso8601: { year2000: { @@ -331,8 +538,6 @@ var fromWithCases = { year1: RangeError } }; -var logPerf = false; -var totalNow = 0; for (var [id, tests] of Object.entries(fromWithCases)) { var dates = { year2000: Temporal.PlainDate.from("2000-01-01"), @@ -342,7 +547,6 @@ for (var [id, tests] of Object.entries(fromWithCases)) { var values = tests[name]; var errorExpected = values === RangeError; if ((id === "chinese" || id === "dangi") && hasOutdatedChineseIcuData ) { - var now = globalThis.performance ? globalThis.performance.now() : Date.now(); if (errorExpected) { assert.throws(RangeError, () => { var inCal = date.withCalendar(id); @@ -411,13 +615,8 @@ for (var [id, tests] of Object.entries(fromWithCases)) { monthCode: values.monthCode, year: values.year })); - var ms = (globalThis.performance ? globalThis.performance.now() : Date.now()) - now; - totalNow += ms; - if (logPerf) - console.log(`from: ${ id } ${ name }: ${ ms.toFixed(2) }ms, total: ${ totalNow.toFixed(2) }ms`); }; if ((id === "chinese" || id === "dangi") && hasOutdatedChineseIcuData ) { - var now = globalThis.performance ? globalThis.performance.now() : Date.now(); var inCal = date.withCalendar(id); if (errorExpected) { assert.throws(RangeError, () => inCal.with({ day: 1 }).year); @@ -437,10 +636,6 @@ for (var [id, tests] of Object.entries(fromWithCases)) { assert.sameValue(`${ t } year: ${ afterWithYear.year }`, `${ t } year: 2220`); assert.sameValue(`${ t } month: ${ afterWithYear.month }`, `${ t } month: 1`); assert.sameValue(`${ t } day: ${ afterWithYear.day }`, `${ t } day: 1`); - var ms = (globalThis.performance ? globalThis.performance.now() : Date.now()) - now; - totalNow += ms; - if (logPerf) - console.log(`with: ${ id } ${ name }: ${ ms.toFixed(2) }ms, total: ${ totalNow.toFixed(2) }ms`); }; } } @@ -660,13 +855,11 @@ var tests = { } } }; -var calendars = Object.keys(addMonthsCases); -for (var id of calendars) { +for (var id of Object.keys(addMonthsCases)) { for (var [unit, {duration, results, startDate}] of Object.entries(tests)) { var values = results[id]; duration = Temporal.Duration.from(duration); if ((id === "chinese" || id === "dangi") && hasOutdatedChineseIcuData ) { - var now = globalThis.performance ? globalThis.performance.now() : Date.now(); if (values === RangeError) { assert.throws(RangeError, () => Temporal.PlainDate.from({ ...startDate, @@ -722,10 +915,6 @@ for (var id of calendars) { assert.sameValue(`subtract from end-of-month ${ unit } ${ id } month: ${ startReverseNextDay.month }`, `subtract from end-of-month ${ unit } ${ id } month: ${ start.month }`); assert.sameValue(`subtract from end-of-month ${ unit } ${ id } monthCode: ${ startReverseNextDay.monthCode }`, `subtract from end-of-month ${ unit } ${ id } monthCode: ${ start.monthCode }`); } - var ms = (globalThis.performance ? globalThis.performance.now() : Date.now()) - now; - totalNow += ms; - if (logPerf) - console.log(`${ id } add ${ duration }: ${ ms.toFixed(2) }ms, total: ${ totalNow.toFixed(2) }ms`); }; } } @@ -1080,7 +1269,7 @@ var daysInMonthCases = { } }; totalNow = 0; -for (var id of calendars) { +for (var id of Object.keys(daysInMonthCases)) { var {year, leap, days} = daysInMonthCases[id]; var date = hasOutdatedChineseIcuData && (id === "chinese" || id === "dangi") ? undefined : Temporal.PlainDate.from({ year, @@ -1098,7 +1287,6 @@ for (var id of calendars) { } }; if ((id === "chinese" || id === "dangi") && hasOutdatedChineseIcuData ) { - var now = globalThis.performance ? globalThis.performance.now() : Date.now(); var {monthsInYear} = date; assert.sameValue(monthsInYear, days.length); for (var i = monthsInYear, leapMonthIndex = undefined, monthStart = undefined; i >= 1; i--) { @@ -1142,10 +1330,6 @@ for (var id of calendars) { var oneDayPastMonthEnd = monthStart.with({ day: daysInMonth + 1 }); assert.sameValue(oneDayPastMonthEnd.day, daysInMonth); } - var ms = (globalThis.performance ? globalThis.performance.now() : Date.now()) - now; - totalNow += ms; - if (logPerf) - console.log(`${ id } months check ${ id }: ${ ms.toFixed(2) }ms, total: ${ totalNow.toFixed(2) }ms`); }; } var monthDayCases = [ diff --git a/js/src/tests/test262/staging/Temporal/Duration/old/shell.js b/js/src/tests/test262/staging/Temporal/Duration/old/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/staging/Temporal/Duration/old/shell.js +++ b/js/src/tests/test262/staging/Temporal/Duration/old/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/staging/Temporal/TimeZone/old/shell.js b/js/src/tests/test262/staging/Temporal/TimeZone/old/shell.js index eaa8761415..cd31c09e9b 100644 --- a/js/src/tests/test262/staging/Temporal/TimeZone/old/shell.js +++ b/js/src/tests/test262/staging/Temporal/TimeZone/old/shell.js @@ -2351,6 +2351,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2438,6 +2441,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/staging/Temporal/ZonedDateTime/old/round.js b/js/src/tests/test262/staging/Temporal/ZonedDateTime/old/round.js index 3dfb21989d..6c613fa47b 100644 --- a/js/src/tests/test262/staging/Temporal/ZonedDateTime/old/round.js +++ b/js/src/tests/test262/staging/Temporal/ZonedDateTime/old/round.js @@ -217,17 +217,19 @@ var bal = Temporal.ZonedDateTime.from("1976-11-18T23:59:59.999999999+01:00[+01:0 var timeZone = TemporalHelpers.springForwardFallBackTimeZone(); // rounds correctly to a 25-hour day +// (the 12.5 hour is the halfway point, which is 11:30 local time, since 2:00-2:59 repeats) var roundTo = { smallestUnit: "day" }; -var roundMeDown = Temporal.PlainDateTime.from("2000-10-29T12:29:59").toZonedDateTime(timeZone); +var roundMeDown = Temporal.PlainDateTime.from("2000-10-29T11:29:59").toZonedDateTime(timeZone); assert.sameValue(`${ roundMeDown.round(roundTo) }`, "2000-10-29T00:00:00-07:00[Custom/Spring_Fall]"); -var roundMeUp = Temporal.PlainDateTime.from("2000-10-29T12:30:01").toZonedDateTime(timeZone); +var roundMeUp = Temporal.PlainDateTime.from("2000-10-29T11:30:01").toZonedDateTime(timeZone); assert.sameValue(`${ roundMeUp.round(roundTo) }`, "2000-10-30T00:00:00-08:00[Custom/Spring_Fall]"); // rounds correctly to a 23-hour day +// (the 11.5 hour is the halfway point, which is 12:30 local time, since 2:00-2:59 skips) var roundTo = { smallestUnit: "day" }; -var roundMeDown = Temporal.PlainDateTime.from("2000-04-02T11:29:59").toZonedDateTime(timeZone); +var roundMeDown = Temporal.PlainDateTime.from("2000-04-02T12:29:59").toZonedDateTime(timeZone); assert.sameValue(`${ roundMeDown.round(roundTo) }`, "2000-04-02T00:00:00-08:00[Custom/Spring_Fall]"); -var roundMeUp = Temporal.PlainDateTime.from("2000-04-02T11:30:01").toZonedDateTime(timeZone); +var roundMeUp = Temporal.PlainDateTime.from("2000-04-02T12:30:01").toZonedDateTime(timeZone); assert.sameValue(`${ roundMeUp.round(roundTo) }`, "2000-04-03T00:00:00-07:00[Custom/Spring_Fall]"); // rounding up to a nonexistent wall-clock time diff --git a/js/src/tests/test262/staging/Temporal/ZonedDateTime/old/shell.js b/js/src/tests/test262/staging/Temporal/ZonedDateTime/old/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/staging/Temporal/ZonedDateTime/old/shell.js +++ b/js/src/tests/test262/staging/Temporal/ZonedDateTime/old/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/staging/built-ins/Array/browser.js b/js/src/tests/test262/staging/built-ins/Array/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/Array/browser.js diff --git a/js/src/tests/test262/staging/built-ins/Array/prototype/browser.js b/js/src/tests/test262/staging/built-ins/Array/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/Array/prototype/browser.js diff --git a/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/browser.js b/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/browser.js diff --git a/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/callback-with-side-effects.js b/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/callback-with-side-effects.js new file mode 100644 index 0000000000..83d2057623 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/callback-with-side-effects.js @@ -0,0 +1,30 @@ +// Copyright (C) 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.flatMap +description: > + Array.prototype.flatMap is given a callback that modifies the array being + iterated. +includes: [compareArray.js] +---*/ + +(function TestGrow() { + let array = [0,1,2,3]; + function f(e) { + array[4] = 42; + return e; + } + assert.compareArray(array.flatMap(f), [0,1,2,3]); +})(); + +(function TestShrink() { + let array = [0,1,2,3]; + function f(e) { + array.length = 3; + return e; + } + assert.compareArray(array.flatMap(f), [0,1,2]); +})(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/shell.js b/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/shell.js diff --git a/js/src/tests/test262/staging/built-ins/Array/prototype/shell.js b/js/src/tests/test262/staging/built-ins/Array/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/Array/prototype/shell.js diff --git a/js/src/tests/test262/staging/built-ins/Array/shell.js b/js/src/tests/test262/staging/built-ins/Array/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/Array/shell.js diff --git a/js/src/tests/test262/staging/built-ins/RegExp/browser.js b/js/src/tests/test262/staging/built-ins/RegExp/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/RegExp/browser.js diff --git a/js/src/tests/test262/staging/built-ins/RegExp/named-groups/browser.js b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/browser.js diff --git a/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups-replace.js b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups-replace.js new file mode 100644 index 0000000000..f26eebab4d --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups-replace.js @@ -0,0 +1,31 @@ +// |reftest| skip -- regexp-duplicate-named-groups is not supported +// Copyright (C) 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Test replace function with duplicate names in alteration. +features: [regexp-duplicate-named-groups] +includes: [compareArray.js] +---*/ + +assert.compareArray( + '2xyy', 'xxyy'.replace(/(?:(?:(?<a>x)|(?<a>y))\k<a>)/, '2$<a>')); +assert.compareArray( + 'x2zyyxxy', + 'xzzyyxxy'.replace( + /(?:(?:(?<a>x)|(?<a>y)|(a)|(?<b>b)|(?<a>z))\k<a>)/, '2$<a>')); +assert.compareArray( + '2x(x,)yy', 'xxyy'.replace(/(?:(?:(?<a>x)|(?<a>y))\k<a>)/, '2$<a>($1,$2)')); +assert.compareArray( + 'x2z(,,,,z)yyxxy', + 'xzzyyxxy'.replace( + /(?:(?:(?<a>x)|(?<a>y)|(a)|(?<b>b)|(?<a>z))\k<a>)/, + '2$<a>($1,$2,$3,$4,$5)')); +assert.compareArray( + '2x2y', 'xxyy'.replace(/(?:(?:(?<a>x)|(?<a>y))\k<a>)/g, '2$<a>')); +assert.compareArray( + 'x2z2y2xy', + 'xzzyyxxy'.replace( + /(?:(?:(?<a>x)|(?<a>y)|(a)|(?<b>b)|(?<a>z))\k<a>)/g, '2$<a>')); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups-search.js b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups-search.js new file mode 100644 index 0000000000..27a2b22a82 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups-search.js @@ -0,0 +1,16 @@ +// |reftest| skip -- regexp-duplicate-named-groups is not supported +// Copyright (C) 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Test search function with duplicate names in alteration. +features: [regexp-duplicate-named-groups] +includes: [compareArray.js] +---*/ + +assert.compareArray(3, 'abcxyz'.search(/(?<a>x)|(?<a>y)/)); +assert.compareArray(3, 'abcxyz'.search(/(?<a>y)|(?<a>x)/)); +assert.compareArray(1, 'aybcxyz'.search(/(?<a>x)|(?<a>y)/)); +assert.compareArray(1, 'aybcxyz'.search(/(?<a>y)|(?<a>x)/)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups.js b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups.js new file mode 100644 index 0000000000..d28346f13b --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-duplicate-named-groups is not supported +// Copyright (C) 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Test different functions with duplicate names in alteration. +features: [regexp-duplicate-named-groups] +includes: [compareArray.js] +---*/ + +assert.compareArray( + ['xxyy', undefined, 'y'], /(?:(?:(?<a>x)|(?<a>y))\k<a>){2}/.exec('xxyy')); +assert.compareArray( + ['zzyyxx', 'x', undefined, undefined, undefined, undefined], + /(?:(?:(?<a>x)|(?<a>y)|(a)|(?<b>b)|(?<a>z))\k<a>){3}/.exec('xzzyyxxy')); +assert.compareArray( + ['xxyy', undefined, 'y'], 'xxyy'.match(/(?:(?:(?<a>x)|(?<a>y))\k<a>){2}/)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/staging/built-ins/RegExp/named-groups/shell.js b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/shell.js diff --git a/js/src/tests/test262/staging/built-ins/RegExp/shell.js b/js/src/tests/test262/staging/built-ins/RegExp/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/RegExp/shell.js diff --git a/js/src/tests/test262/staging/built-ins/browser.js b/js/src/tests/test262/staging/built-ins/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/browser.js diff --git a/js/src/tests/test262/staging/built-ins/shell.js b/js/src/tests/test262/staging/built-ins/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/shell.js diff --git a/js/src/tests/test262/staging/explicit-resource-management/Symbol/browser.js b/js/src/tests/test262/staging/explicit-resource-management/Symbol/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/Symbol/browser.js diff --git a/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/browser.js b/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/browser.js diff --git a/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/cross-realm.js b/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/cross-realm.js new file mode 100644 index 0000000000..40a3a9a54c --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/cross-realm.js @@ -0,0 +1,17 @@ +// |reftest| skip -- explicit-resource-management is not supported +// Copyright (C) 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Value shared by all realms +info: | + Unless otherwise specified, well-known symbols values are shared by all + realms. +features: [cross-realm, explicit-resource-management] +---*/ + +var OSymbol = $262.createRealm().global.Symbol; + +assert.sameValue(Symbol.dispose, OSymbol.dispose); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/prop-desc.js b/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/prop-desc.js new file mode 100644 index 0000000000..8f4330035c --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/prop-desc.js @@ -0,0 +1,20 @@ +// |reftest| skip -- explicit-resource-management is not supported +// Copyright (C) 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + `Symbol.dispose` property descriptor +info: | + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: false }. +includes: [propertyHelper.js] +features: [explicit-resource-management] +---*/ + +assert.sameValue(typeof Symbol.dispose, 'symbol'); +verifyNotEnumerable(Symbol, 'dispose'); +verifyNotWritable(Symbol, 'dispose'); +verifyNotConfigurable(Symbol, 'dispose'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/shell.js b/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/shell.js diff --git a/js/src/tests/test262/staging/explicit-resource-management/Symbol/shell.js b/js/src/tests/test262/staging/explicit-resource-management/Symbol/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/Symbol/shell.js diff --git a/js/src/tests/test262/staging/explicit-resource-management/browser.js b/js/src/tests/test262/staging/explicit-resource-management/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/browser.js diff --git a/js/src/tests/test262/staging/explicit-resource-management/call-dispose-methods.js b/js/src/tests/test262/staging/explicit-resource-management/call-dispose-methods.js new file mode 100644 index 0000000000..55189d2150 --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/call-dispose-methods.js @@ -0,0 +1,194 @@ +// |reftest| skip -- explicit-resource-management is not supported +// Copyright (C) 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Test if disposed methods are called in correct syntax. +includes: [compareArray.js] +features: [explicit-resource-management] +---*/ + +// Block ---------------- +let blockValues = []; + +(function TestUsingInBlock() { + { + using x = { + value: 1, + [Symbol.dispose]() { + blockValues.push(42); + } + }; + blockValues.push(43); + } +})(); +assert.compareArray(blockValues, [43, 42]); + +// CaseBlock -------------- +let caseBlockValues = []; + +(function TestUsingInCaseBlock() { + let label = 1; + switch (label) { + case 1: + using x = { + value: 1, + [Symbol.dispose]() { + caseBlockValues.push(42); + } + }; + } + caseBlockValues.push(43); +})(); +assert.compareArray(caseBlockValues, [42, 43]); + +// ForStatement -------------- +let forStatementValues = []; + +(function TestUsingInForStatement() { + for (let i = 0; i < 3; i++) { + using x = { + value: i, + [Symbol.dispose]() { + forStatementValues.push(this.value); + } + }; + } + forStatementValues.push(3); +})(); +assert.compareArray(forStatementValues, [0, 1, 2, 3]); + +// ForInStatement -------------- +let forInStatementValues = []; + +(function TestUsingInForInStatement() { + for (let i in [0, 1]) { + using x = { + value: i, + [Symbol.dispose]() { + forInStatementValues.push(this.value); + } + }; + } + forInStatementValues.push('2'); +})(); +assert.compareArray(forInStatementValues, ['0', '1', '2']); + +// ForOfStatement -------------- +let forOfStatementValues = []; + +(function TestUsingInForOfStatement() { + for (let i of [0, 1]) { + using x = { + value: i, + [Symbol.dispose]() { + forOfStatementValues.push(this.value); + } + }; + } + forOfStatementValues.push(2); +})(); +assert.compareArray(forOfStatementValues, [0, 1, 2]); + +// FunctionBody -------------- +let functionBodyValues = []; + +(function TestUsingInFunctionBody() { + using x = { + value: 1, + [Symbol.dispose]() { + functionBodyValues.push(42); + } + }; + using y = { + value: 2, + [Symbol.dispose]() { + functionBodyValues.push(43); + } + }; +})(); +assert.compareArray(functionBodyValues, [43, 42]); + +// GeneratorBody -------------- +let generatorBodyValues = []; + +function* gen() { + using x = { + value: 1, + [Symbol.dispose]() { + generatorBodyValues.push(42); + } + }; + yield x; +} + +(function TestUsingInGeneratorBody() { + let iter = gen(); + iter.next(); + iter.next(); + generatorBodyValues.push(43); +})(); +assert.compareArray(generatorBodyValues, [42, 43]); + +// ClassStaticBlockBody -------------- +let classStaticBlockBodyValues = []; + +class staticBlockClass { + static { + using x = { + value: 1, + [Symbol.dispose]() { + classStaticBlockBodyValues.push(42); + } + }; + } +} + +(function TestUsingInAsyncFunctionBody() { + let example = new staticBlockClass(); +})(); +assert.compareArray(classStaticBlockBodyValues, [42]); + +// Derived constructor case +let derivedConstructorValues = []; + +class baseClass { + constructor() { + derivedConstructorValues.push(43); + } +} + +class subClass extends baseClass { + constructor() { + try { + using x = { + value: 1, + [Symbol.dispose]() { + derivedConstructorValues.push(42); + } + }; + } catch (e) { + return; + } finally { + super(); + } + } +} + +(function TestUsingInDerivedConstructor() { + let example = new subClass(); +})(); +assert.compareArray(derivedConstructorValues, [42, 43]); + +// Lack of dispose method +let values = []; + +function TestUsingWithoutDisposeMethod() { + { + using x = {value: 1}; + values.push(43); + } +} +assert.throws(TypeError, TestUsingWithoutDisposeMethod, 'No dispose method'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/staging/explicit-resource-management/shell.js b/js/src/tests/test262/staging/explicit-resource-management/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/shell.js diff --git a/js/src/threading/ConditionVariable.h b/js/src/threading/ConditionVariable.h index e2b8865cbf..5ff0590c5c 100644 --- a/js/src/threading/ConditionVariable.h +++ b/js/src/threading/ConditionVariable.h @@ -55,7 +55,7 @@ class ConditionVariable { lock.postLockChecks(); #endif } - void wait(UniqueLock<Mutex>& lock) { wait(lock.lock); } + void wait(UniqueLock<Mutex>& lock) { wait(lock.mutex); } // As with |wait|, block the current thread of execution until woken from // another thread. This method will resume waiting once woken until the given @@ -100,15 +100,15 @@ class ConditionVariable { CVStatus wait_for(UniqueLock<Mutex>& lock, const mozilla::TimeDuration& rel_time) { #ifdef DEBUG - lock.lock.preUnlockChecks(); + lock.mutex.preUnlockChecks(); #endif CVStatus res = - impl_.wait_for(lock.lock.impl_, rel_time) == mozilla::CVStatus::Timeout + impl_.wait_for(lock.mutex.impl_, rel_time) == mozilla::CVStatus::Timeout ? CVStatus::Timeout : CVStatus::NoTimeout; #ifdef DEBUG - lock.lock.preLockChecks(); - lock.lock.postLockChecks(); + lock.mutex.preLockChecks(); + lock.mutex.postLockChecks(); #endif return res; } diff --git a/js/src/threading/ExclusiveData.h b/js/src/threading/ExclusiveData.h index 38e89f10a1..2d8ca831bf 100644 --- a/js/src/threading/ExclusiveData.h +++ b/js/src/threading/ExclusiveData.h @@ -109,11 +109,6 @@ class ExclusiveData { explicit ExclusiveData(const MutexId& id, Args&&... args) : lock_(id), value_(std::forward<Args>(args)...) {} - ExclusiveData(ExclusiveData&& rhs) - : lock_(std::move(rhs.lock)), value_(std::move(rhs.value_)) { - MOZ_ASSERT(&rhs != this, "self-move disallowed!"); - } - ExclusiveData& operator=(ExclusiveData&& rhs) { this->~ExclusiveData(); new (mozilla::KnownNotNull, this) ExclusiveData(std::move(rhs)); diff --git a/js/src/threading/LockGuard.h b/js/src/threading/LockGuard.h index d6d7976648..8a72570225 100644 --- a/js/src/threading/LockGuard.h +++ b/js/src/threading/LockGuard.h @@ -11,31 +11,34 @@ namespace js { -template <typename Mutex> +template <typename GuardT> class MOZ_RAII UnlockGuard; template <typename Mutex> class MOZ_RAII LockGuard { - friend class UnlockGuard<Mutex>; + friend class UnlockGuard<LockGuard<Mutex>>; friend class ConditionVariable; - Mutex& lock; + Mutex& mutex; public: - explicit LockGuard(Mutex& aLock) : lock(aLock) { lock.lock(); } - ~LockGuard() { lock.unlock(); } + explicit LockGuard(Mutex& mutex) : mutex(mutex) { lock(); } + ~LockGuard() { unlock(); } LockGuard(const LockGuard& other) = delete; + + protected: + void lock() { mutex.lock(); } + void unlock() { mutex.unlock(); } }; -template <typename Mutex> +// RAII class to temporarily unlock a LockGuard. +template <typename GuardT> class MOZ_RAII UnlockGuard { - Mutex& lock; + GuardT& guard; public: - explicit UnlockGuard(LockGuard<Mutex>& aGuard) : lock(aGuard.lock) { - lock.unlock(); - } - ~UnlockGuard() { lock.lock(); } + explicit UnlockGuard(GuardT& guard) : guard(guard) { guard.unlock(); } + ~UnlockGuard() { guard.lock(); } UnlockGuard(const UnlockGuard& other) = delete; }; diff --git a/js/src/vm/ArrayBufferObject.cpp b/js/src/vm/ArrayBufferObject.cpp index 14039af574..1610a59ae9 100644 --- a/js/src/vm/ArrayBufferObject.cpp +++ b/js/src/vm/ArrayBufferObject.cpp @@ -207,6 +207,7 @@ void* js::MapBufferMemory(wasm::IndexType t, size_t mappedSize, void* data = nullptr; if (int err = posix_memalign(&data, gc::SystemPageSize(), mappedSize)) { MOZ_ASSERT(err == ENOMEM); + (void)err; return nullptr; } MOZ_ASSERT(data); @@ -2578,8 +2579,15 @@ size_t ArrayBufferObject::objectMoved(JSObject* obj, JSObject* old) { auto& dst = obj->as<ArrayBufferType>(); const auto& src = old->as<ArrayBufferType>(); - MOZ_ASSERT( - !obj->runtimeFromMainThread()->gc.nursery().isInside(src.dataPointer())); +#ifdef DEBUG + // Check the data pointer is not inside the nursery, but take account of the + // fact that inline data pointers for zero length buffers can point to the end + // of a chunk which can abut the start of the nursery. + if (src.byteLength() != 0 || (uintptr_t(src.dataPointer()) & gc::ChunkMask)) { + Nursery& nursery = obj->runtimeFromMainThread()->gc.nursery(); + MOZ_ASSERT(!nursery.isInside(src.dataPointer())); + } +#endif // Fix up possible inline data pointer. if (src.hasInlineData()) { diff --git a/js/src/vm/ArrayBufferObject.h b/js/src/vm/ArrayBufferObject.h index ce78b26cb2..fef5c7d4d9 100644 --- a/js/src/vm/ArrayBufferObject.h +++ b/js/src/vm/ArrayBufferObject.h @@ -202,7 +202,10 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared { static const uint8_t RESERVED_SLOTS = 4; - static const size_t ARRAY_BUFFER_ALIGNMENT = 8; + // Alignment for ArrayBuffer objects. Must match the largest possible + // TypedArray scalar to ensure TypedArray and Atomics accesses are always + // aligned. + static constexpr size_t ARRAY_BUFFER_ALIGNMENT = 8; static_assert(FLAGS_SLOT == JS_ARRAYBUFFER_FLAGS_SLOT, "self-hosted code with burned-in constants must get the " @@ -306,6 +309,7 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared { void* freeUserData_; friend class ArrayBufferObject; + friend class ResizableArrayBufferObject; BufferContents(uint8_t* data, BufferKind kind, JS::BufferContentsFreeFunc freeFunc = nullptr, @@ -321,6 +325,43 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared { // BufferContents does not outlive the data. } +#ifdef DEBUG + // Checks if the buffer contents are properly aligned. + // + // `malloc(0)` is implementation defined and may return a pointer which + // isn't aligned to `max_align_t`, so we only require proper alignment when + // `byteLength` is non-zero. + // + // jemalloc doesn't implement restriction, but instead uses `sizeof(void*)` + // for its smallest allocation class. Larger allocations are guaranteed to + // be eight byte aligned. + bool isAligned(size_t byteLength) const { + // `malloc(0)` has implementation defined behavior. + if (byteLength == 0) { + return true; + } + + // Allow jemalloc tiny allocations to have smaller alignment requirements + // than `std::malloc`. + if (sizeof(void*) < ArrayBufferObject::ARRAY_BUFFER_ALIGNMENT) { + if (byteLength <= sizeof(void*)) { + return true; + } + } + + // `std::malloc` returns memory at least as strictly aligned as for + // max_align_t and the alignment of max_align_t is a multiple of the array + // buffer alignment. + static_assert(alignof(std::max_align_t) % + ArrayBufferObject::ARRAY_BUFFER_ALIGNMENT == + 0); + + // Otherwise the memory must be correctly alignment. + auto ptr = reinterpret_cast<uintptr_t>(data()); + return ptr % ArrayBufferObject::ARRAY_BUFFER_ALIGNMENT == 0; + } +#endif + public: static BufferContents createInlineData(void* data) { return BufferContents(static_cast<uint8_t*>(data), INLINE_DATA); @@ -590,6 +631,7 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared { } void initialize(size_t byteLength, BufferContents contents) { + MOZ_ASSERT(contents.isAligned(byteLength)); setByteLength(byteLength); setFlags(0); setFirstView(nullptr); @@ -670,6 +712,7 @@ class ResizableArrayBufferObject : public ArrayBufferObject { void initialize(size_t byteLength, size_t maxByteLength, BufferContents contents) { + MOZ_ASSERT(contents.isAligned(byteLength)); setByteLength(byteLength); setMaxByteLength(maxByteLength); setFlags(RESIZABLE); diff --git a/js/src/vm/BytecodeFormatFlags.h b/js/src/vm/BytecodeFormatFlags.h index 893f0f0823..bca2b0717f 100644 --- a/js/src/vm/BytecodeFormatFlags.h +++ b/js/src/vm/BytecodeFormatFlags.h @@ -41,10 +41,7 @@ enum { JOF_STRING = 26, /* uint32_t constant index */ JOF_TYPEMASK = 0xFF, /* mask for above immediate types */ - JOF_NAME = 1 << 8, /* name operation */ - JOF_PROP = 2 << 8, /* obj.prop operation */ - JOF_ELEM = 3 << 8, /* obj[index] operation */ - JOF_MODEMASK = 0xFF << 8, /* mask for above addressing modes */ + /* Bits 0xFF00 are available for future usage */ JOF_PROPSET = 1 << 16, /* property/element/name set operation */ JOF_PROPINIT = 1 << 17, /* property/element/name init operation */ diff --git a/js/src/vm/BytecodeLocation-inl.h b/js/src/vm/BytecodeLocation-inl.h index 46c945ddad..ee5281f16b 100644 --- a/js/src/vm/BytecodeLocation-inl.h +++ b/js/src/vm/BytecodeLocation-inl.h @@ -32,6 +32,11 @@ inline JSString* BytecodeLocation::getString(const JSScript* script) const { return script->getString(this->rawBytecode_); } +inline bool BytecodeLocation::atomizeString(JSContext* cx, JSScript* script) { + MOZ_ASSERT(this->isValid()); + return script->atomizeString(cx, this->rawBytecode_); +} + inline PropertyName* BytecodeLocation::getPropertyName( const JSScript* script) const { MOZ_ASSERT(this->isValid()); diff --git a/js/src/vm/BytecodeLocation.h b/js/src/vm/BytecodeLocation.h index 8109b5f2fa..c5bd1d2f5d 100644 --- a/js/src/vm/BytecodeLocation.h +++ b/js/src/vm/BytecodeLocation.h @@ -15,6 +15,7 @@ #include "vm/CompletionKind.h" // CompletionKind #include "vm/FunctionPrefixKind.h" // FunctionPrefixKind #include "vm/GeneratorResumeKind.h" +#include "vm/TypeofEqOperand.h" // TypeofEqOperand namespace js { @@ -103,6 +104,7 @@ class BytecodeLocation { inline JSAtom* getAtom(const JSScript* script) const; inline JSString* getString(const JSScript* script) const; + inline bool atomizeString(JSContext* cx, JSScript* script); inline PropertyName* getPropertyName(const JSScript* script) const; inline JS::BigInt* getBigInt(const JSScript* script) const; inline JSObject* getObject(const JSScript* script) const; @@ -198,8 +200,6 @@ class BytecodeLocation { bool isStrictSetOp() const { return IsStrictSetPC(rawBytecode_); } - bool isNameOp() const { return IsNameOp(getOp()); } - bool isSpreadOp() const { return IsSpreadOp(getOp()); } bool isInvokeOp() const { return IsInvokeOp(getOp()); } @@ -279,6 +279,11 @@ class BytecodeLocation { return index; } + TypeofEqOperand getTypeofEqOperand() const { + MOZ_ASSERT(is(JSOp::TypeofEq)); + return TypeofEqOperand::fromRawValue(GET_UINT8(rawBytecode_)); + } + FunctionPrefixKind getFunctionPrefixKind() const { MOZ_ASSERT(is(JSOp::SetFunName)); return FunctionPrefixKind(GET_UINT8(rawBytecode_)); diff --git a/js/src/vm/BytecodeUtil.cpp b/js/src/vm/BytecodeUtil.cpp index cc8f545387..82b21cb508 100644 --- a/js/src/vm/BytecodeUtil.cpp +++ b/js/src/vm/BytecodeUtil.cpp @@ -53,7 +53,8 @@ #include "vm/Opcodes.h" #include "vm/Realm.h" #include "vm/Shape.h" -#include "vm/ToSource.h" // js::ValueToSource +#include "vm/ToSource.h" // js::ValueToSource +#include "vm/TypeofEqOperand.h" // TypeofEqOperand #include "gc/GC-inl.h" #include "vm/BytecodeIterator-inl.h" @@ -1893,6 +1894,16 @@ bool ExpressionDecompiler::decompilePC(jsbytecode* pc, uint8_t defIndex) { return write("(typeof ") && decompilePCForStackOperand(pc, -1) && write(")"); + case JSOp::TypeofEq: { + auto operand = TypeofEqOperand::fromRawValue(GET_UINT8(pc)); + JSType type = operand.type(); + JSOp compareOp = operand.compareOp(); + + return write("(typeof ") && decompilePCForStackOperand(pc, -1) && + write(compareOp == JSOp::Ne ? " != \"" : " == \"") && + write(JSTypeToString(type)) && write("\")"); + } + case JSOp::InitElemArray: return write("[...]"); diff --git a/js/src/vm/BytecodeUtil.h b/js/src/vm/BytecodeUtil.h index 09ff4387bb..3f0d4d07e4 100644 --- a/js/src/vm/BytecodeUtil.h +++ b/js/src/vm/BytecodeUtil.h @@ -39,10 +39,6 @@ class JS_PUBLIC_API StringPrinter; static inline uint32_t JOF_TYPE(uint32_t fmt) { return fmt & JOF_TYPEMASK; } -/* Shorthand for mode from format. */ - -static inline uint32_t JOF_MODE(uint32_t fmt) { return fmt & JOF_MODEMASK; } - /* * Immediate operand getters, setters, and bounds. */ @@ -462,8 +458,6 @@ inline bool IsCheckStrictOp(JSOp op) { return CodeSpec(op).format & JOF_CHECKSTRICT; } -inline bool IsNameOp(JSOp op) { return CodeSpec(op).format & JOF_NAME; } - #ifdef DEBUG inline bool IsCheckSloppyOp(JSOp op) { return CodeSpec(op).format & JOF_CHECKSLOPPY; @@ -510,10 +504,6 @@ inline bool IsSetElemOp(JSOp op) { inline bool IsSetElemPC(const jsbytecode* pc) { return IsSetElemOp(JSOp(*pc)); } -inline bool IsElemPC(const jsbytecode* pc) { - return CodeSpec(JSOp(*pc)).format & JOF_ELEM; -} - inline bool IsInvokeOp(JSOp op) { return CodeSpec(op).format & JOF_INVOKE; } inline bool IsInvokePC(jsbytecode* pc) { return IsInvokeOp(JSOp(*pc)); } @@ -534,6 +524,12 @@ inline bool IsSpreadOp(JSOp op) { return CodeSpec(op).format & JOF_SPREAD; } inline bool IsSpreadPC(const jsbytecode* pc) { return IsSpreadOp(JSOp(*pc)); } +// Returns true if the specified opcode is for `typeof name` where `name` is +// single identifier. +inline bool IsTypeOfNameOp(JSOp op) { + return op == JSOp::Typeof || op == JSOp::TypeofEq; +} + inline bool OpUsesEnvironmentChain(JSOp op) { return CodeSpec(op).format & JOF_USES_ENV; } diff --git a/js/src/vm/Caches.h b/js/src/vm/Caches.h index dcd0c78822..82979c1283 100644 --- a/js/src/vm/Caches.h +++ b/js/src/vm/Caches.h @@ -43,10 +43,15 @@ struct EvalCacheEntry { }; struct EvalCacheLookup { - explicit EvalCacheLookup(JSContext* cx) : str(cx), callerScript(cx) {} - Rooted<JSLinearString*> str; - RootedScript callerScript; - MOZ_INIT_OUTSIDE_CTOR jsbytecode* pc; + JSLinearString* str = nullptr; + JSScript* callerScript = nullptr; + MOZ_INIT_OUTSIDE_CTOR jsbytecode* pc = nullptr; + + EvalCacheLookup() = default; + EvalCacheLookup(JSLinearString* str, JSScript* callerScript, jsbytecode* pc) + : str(str), callerScript(callerScript), pc(pc) {} + + void trace(JSTracer* trc); }; struct EvalCacheHashPolicy { diff --git a/js/src/vm/CharacterEncoding.cpp b/js/src/vm/CharacterEncoding.cpp index 3d05275e2d..8911612a7a 100644 --- a/js/src/vm/CharacterEncoding.cpp +++ b/js/src/vm/CharacterEncoding.cpp @@ -286,7 +286,6 @@ static bool InflateUTF8ToUTF16(JSContext* cx, const UTF8Chars& src, break; } } else { - #define INVALID(report, arg, n2) \ do { \ if (ErrorAction == OnUTF8Error::Throw) { \ diff --git a/js/src/vm/CommonPropertyNames.h b/js/src/vm/CommonPropertyNames.h index 5fa3f2b633..a8e874d410 100644 --- a/js/src/vm/CommonPropertyNames.h +++ b/js/src/vm/CommonPropertyNames.h @@ -185,6 +185,7 @@ MACRO_(exponentSeparator, "exponentSeparator") \ MACRO_(export_, "export") \ MACRO_(extends, "extends") \ + MACRO_(f16round, "f16round") \ MACRO_(false_, "false") \ MACRO_(few, "few") \ IF_DECORATORS(MACRO_(field, "field")) \ @@ -233,6 +234,7 @@ MACRO_(GetBuiltinConstructor, "GetBuiltinConstructor") \ MACRO_(GetBuiltinPrototype, "GetBuiltinPrototype") \ MACRO_(GetBuiltinSymbol, "GetBuiltinSymbol") \ + MACRO_(getFloat16, "getFloat16") \ MACRO_(GetInternalError, "GetInternalError") \ MACRO_(getInternals, "getInternals") \ MACRO_(GetIterator, "GetIterator") \ @@ -335,6 +337,7 @@ MACRO_(iterate, "iterate") \ MACRO_(join, "join") \ MACRO2(js, "js") \ + MACRO_(jsTag, "JSTag") \ MACRO_(jsStringModule, "js-string") \ MACRO_(json, "json") \ MACRO_(keys, "keys") \ @@ -508,6 +511,7 @@ MACRO_(setBigUint64, "setBigUint64") \ MACRO_(SetCanonicalName, "SetCanonicalName") \ MACRO_(SetConstructorInit, "SetConstructorInit") \ + MACRO_(setFloat16, "setFloat16") \ MACRO_(SetIsInlinableLargeFunction, "SetIsInlinableLargeFunction") \ MACRO_(Set_Iterator_, "Set Iterator") \ MACRO_(setFromBase64, "setFromBase64") \ diff --git a/js/src/vm/Compartment.cpp b/js/src/vm/Compartment.cpp index 4efb92366b..749342b167 100644 --- a/js/src/vm/Compartment.cpp +++ b/js/src/vm/Compartment.cpp @@ -52,14 +52,10 @@ Compartment::Compartment(Zone* zone, bool invisibleToDebugger) void Compartment::checkObjectWrappersAfterMovingGC() { for (ObjectWrapperEnum e(this); !e.empty(); e.popFront()) { - // Assert that the postbarriers have worked and that nothing is left in the - // wrapper map that points into the nursery, and that the hash table entries - // are discoverable. auto key = e.front().key(); - CheckGCThingAfterMovingGC(key.get()); - - auto ptr = crossCompartmentObjectWrappers.lookup(key); - MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &e.front()); + CheckGCThingAfterMovingGC(key.get()); // Keys may be in a different zone. + CheckGCThingAfterMovingGC(e.front().value().unbarrieredGet(), zone()); + CheckTableEntryAfterMovingGC(crossCompartmentObjectWrappers, e, key); } } diff --git a/js/src/vm/EnvironmentObject.cpp b/js/src/vm/EnvironmentObject.cpp index 008cfca260..0d5f214f53 100644 --- a/js/src/vm/EnvironmentObject.cpp +++ b/js/src/vm/EnvironmentObject.cpp @@ -2613,18 +2613,20 @@ void DebugEnvironments::checkHashTablesAfterMovingGC() { * This is called at the end of StoreBuffer::mark() to check that our * postbarriers have worked and that no hashtable keys (or values) are left * pointing into the nursery. + * + * |proxiedEnvs| is checked automatically because it is a WeakMap. */ - proxiedEnvs.checkAfterMovingGC(); - for (MissingEnvironmentMap::Range r = missingEnvs.all(); !r.empty(); - r.popFront()) { - CheckGCThingAfterMovingGC(r.front().key().scope()); + CheckTableAfterMovingGC(missingEnvs, [this](const auto& entry) { + CheckGCThingAfterMovingGC(entry.key().scope(), zone()); // Use unbarrieredGet() to prevent triggering read barrier while collecting. - CheckGCThingAfterMovingGC(r.front().value().unbarrieredGet()); - } - for (LiveEnvironmentMap::Range r = liveEnvs.all(); !r.empty(); r.popFront()) { - CheckGCThingAfterMovingGC(r.front().key()); - CheckGCThingAfterMovingGC(r.front().value().scope_.get()); - } + CheckGCThingAfterMovingGC(entry.value().unbarrieredGet(), zone()); + return entry.key(); + }); + CheckTableAfterMovingGC(liveEnvs, [this](const auto& entry) { + CheckGCThingAfterMovingGC(entry.key(), zone()); + CheckGCThingAfterMovingGC(entry.value().scope_.get(), zone()); + return entry.key().unbarrieredGet(); + }); } #endif diff --git a/js/src/vm/Float16.h b/js/src/vm/Float16.h new file mode 100644 index 0000000000..e9c3268af4 --- /dev/null +++ b/js/src/vm/Float16.h @@ -0,0 +1,150 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: set ts=8 sts=2 et sw=2 tw=80: + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef vm_Float16_h +#define vm_Float16_h + +#include <cstdint> +#include <cstring> +#include <limits> + +namespace js { + +namespace half { +// This is extracted from Version 2.2.0 of the half library by Christian Rau. +// See https://sourceforge.net/projects/half/. +// The original copyright and MIT license are reproduced below: + +// half - IEEE 754-based half-precision floating-point library. +// +// Copyright (c) 2012-2021 Christian Rau <rauy@users.sourceforge.net> +// +// 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, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +/// Type traits for floating-point bits. +template <typename T> +struct bits { + typedef unsigned char type; +}; +template <typename T> +struct bits<const T> : bits<T> {}; +template <typename T> +struct bits<volatile T> : bits<T> {}; +template <typename T> +struct bits<const volatile T> : bits<T> {}; + +/// Unsigned integer of (at least) 64 bits width. +template <> +struct bits<double> { + typedef std::uint_least64_t type; +}; + +/// Fastest unsigned integer of (at least) 32 bits width. +typedef std::uint_fast32_t uint32; + +/// Half-precision overflow. +/// \param sign half-precision value with sign bit only +/// \return rounded overflowing half-precision value +constexpr unsigned int overflow(unsigned int sign = 0) { return sign | 0x7C00; } + +/// Half-precision underflow. +/// \param sign half-precision value with sign bit only +/// \return rounded underflowing half-precision value +constexpr unsigned int underflow(unsigned int sign = 0) { return sign; } + +/// Round half-precision number. +/// \param value finite half-precision number to round +/// \param g guard bit (most significant discarded bit) +/// \param s sticky bit (or of all but the most significant discarded bits) +/// \return rounded half-precision value +constexpr unsigned int rounded(unsigned int value, int g, int s) { + return value + (g & (s | value)); +} + +/// Convert IEEE double-precision to half-precision. +/// \param value double-precision value to convert +/// \return rounded half-precision value +inline unsigned int float2half_impl(double value) { + bits<double>::type dbits; + std::memcpy(&dbits, &value, sizeof(double)); + uint32 hi = dbits >> 32, lo = dbits & 0xFFFFFFFF; + unsigned int sign = (hi >> 16) & 0x8000; + hi &= 0x7FFFFFFF; + if (hi >= 0x7FF00000) + return sign | 0x7C00 | + ((dbits & 0xFFFFFFFFFFFFF) ? (0x200 | ((hi >> 10) & 0x3FF)) : 0); + if (hi >= 0x40F00000) return overflow(sign); + if (hi >= 0x3F100000) + return rounded(sign | (((hi >> 20) - 1008) << 10) | ((hi >> 10) & 0x3FF), + (hi >> 9) & 1, ((hi & 0x1FF) | lo) != 0); + if (hi >= 0x3E600000) { + int i = 1018 - (hi >> 20); + hi = (hi & 0xFFFFF) | 0x100000; + return rounded(sign | (hi >> (i + 1)), (hi >> i) & 1, + ((hi & ((static_cast<uint32>(1) << i) - 1)) | lo) != 0); + } + if ((hi | lo) != 0) return underflow(sign); + return sign; +} + +/// Convert half-precision to IEEE double-precision. +/// \param value half-precision value to convert +/// \return double-precision value +inline double half2float_impl(unsigned int value) { + uint32 hi = static_cast<uint32>(value & 0x8000) << 16; + unsigned int abs = value & 0x7FFF; + if (abs) { + hi |= 0x3F000000 << static_cast<unsigned>(abs >= 0x7C00); + for (; abs < 0x400; abs <<= 1, hi -= 0x100000) + ; + hi += static_cast<uint32>(abs) << 10; + } + bits<double>::type dbits = static_cast<bits<double>::type>(hi) << 32; + double out; + std::memcpy(&out, &dbits, sizeof(double)); + return out; +} +} // namespace half + +struct float16 { + uint16_t val; + + float16() = default; + float16(const float16& other) = default; + + explicit float16(double x) { *this = x; } + + float16& operator=(const float16& x) = default; + + float16& operator=(double x) { + this->val = half::float2half_impl(x); + return *this; + } + + double toDouble() { return half::half2float_impl(this->val); } +}; + +static_assert(sizeof(float16) == 2, "float16 has no extra padding"); + +} // namespace js + +#endif // vm_Float16_h diff --git a/js/src/vm/FunctionFlags.h b/js/src/vm/FunctionFlags.h index 27d51c214a..558c71a6b7 100644 --- a/js/src/vm/FunctionFlags.h +++ b/js/src/vm/FunctionFlags.h @@ -94,6 +94,11 @@ class FunctionFlags { BASESCRIPT = 1 << 5, SELFHOSTLAZY = 1 << 6, + // This Native function has a JIT entry which emulates the + // js::BaseScript::jitCodeRaw mechanism. Used for Wasm functions and + // TrampolineNative builtins. + NATIVE_JIT_ENTRY = 1 << 7, + // Function may be called as a constructor. This corresponds in the spec as // having a [[Construct]] internal method. // @@ -103,12 +108,7 @@ class FunctionFlags { // This flag is used both by scripted functions and native functions. // // WARNING: This is independent from FunctionKind::ClassConstructor. - CONSTRUCTOR = 1 << 7, - - // Function is either getter or setter, with "get " or "set " prefix, - // but JSFunction::AtomSlot contains unprefixed name, and the function name - // is lazily constructed on the first access. - LAZY_ACCESSOR_NAME = 1 << 8, + CONSTRUCTOR = 1 << 8, // Function comes from a FunctionExpression, ArrowFunction, or Function() // call (not a FunctionDeclaration). @@ -116,10 +116,10 @@ class FunctionFlags { // This flag is used only by scripted functions and AsmJS. LAMBDA = 1 << 9, - // This Native function has a JIT entry which emulates the - // js::BaseScript::jitCodeRaw mechanism. Used for Wasm functions and - // TrampolineNative builtins. - NATIVE_JIT_ENTRY = 1 << 10, + // Function is either getter or setter, with "get " or "set " prefix, + // but JSFunction::AtomSlot contains unprefixed name, and the function name + // is lazily constructed on the first access. + LAZY_ACCESSOR_NAME = 1 << 10, // Function had no explicit name, but a name was set by SetFunctionName at // compile time or SetFunctionName at runtime. @@ -436,12 +436,8 @@ class FunctionFlags { FunctionFlags& setIsGhost() { return setFlags(GHOST_FUNCTION); } bool isGhost() const { return hasFlags(GHOST_FUNCTION); } - static uint16_t HasJitEntryFlags(bool isConstructing) { - uint16_t flags = BASESCRIPT | SELFHOSTLAZY; - if (!isConstructing) { - flags |= NATIVE_JIT_ENTRY; - } - return flags; + static constexpr uint16_t HasJitEntryFlags() { + return BASESCRIPT | SELFHOSTLAZY | NATIVE_JIT_ENTRY; } static FunctionFlags clearMutableflags(FunctionFlags flags) { diff --git a/js/src/vm/GeckoProfiler.cpp b/js/src/vm/GeckoProfiler.cpp index dbf1eb9081..91f03b3432 100644 --- a/js/src/vm/GeckoProfiler.cpp +++ b/js/src/vm/GeckoProfiler.cpp @@ -371,12 +371,11 @@ void GeckoProfilerRuntime::fixupStringsMapAfterMovingGC() { #ifdef JSGC_HASH_TABLE_CHECKS void GeckoProfilerRuntime::checkStringsMapAfterMovingGC() { - for (auto r = strings().all(); !r.empty(); r.popFront()) { - BaseScript* script = r.front().key(); + CheckTableAfterMovingGC(strings(), [](const auto& entry) { + BaseScript* script = entry.key(); CheckGCThingAfterMovingGC(script); - auto ptr = strings().lookup(script); - MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front()); - } + return script; + }); } #endif diff --git a/js/src/vm/GlobalObject.cpp b/js/src/vm/GlobalObject.cpp index 6782433fd3..8bdfd3ee75 100644 --- a/js/src/vm/GlobalObject.cpp +++ b/js/src/vm/GlobalObject.cpp @@ -186,6 +186,9 @@ bool GlobalObject::skipDeselectedConstructor(JSContext* cx, JSProtoKey key) { #ifdef ENABLE_WASM_TYPE_REFLECTIONS case JSProto_WasmFunction: #endif +#ifdef ENABLE_WASM_JSPI + case JSProto_WasmSuspending: +#endif case JSProto_WasmException: return false; @@ -241,6 +244,11 @@ bool GlobalObject::skipDeselectedConstructor(JSContext* cx, JSProtoKey key) { case JSProto_ShadowRealm: return !JS::Prefs::experimental_shadow_realms(); +#ifdef NIGHTLY_BUILD + case JSProto_Float16Array: + return !JS::Prefs::experimental_float16array(); +#endif + default: MOZ_CRASH("unexpected JSProtoKey"); } @@ -920,6 +928,10 @@ bool GlobalObject::getSelfHostedFunction(JSContext* cx, return true; } + // Don't collect metadata for self-hosted functions or intrinsics. + // This is similar to the suppression in GlobalObject::resolveConstructor. + AutoSuppressAllocationMetadataBuilder suppressMetadata(cx); + JSRuntime* runtime = cx->runtime(); frontend::ScriptIndex index = runtime->getSelfHostedScriptIndexRange(selfHostedName)->start; @@ -940,6 +952,10 @@ bool GlobalObject::getIntrinsicValueSlow(JSContext* cx, Handle<GlobalObject*> global, Handle<PropertyName*> name, MutableHandleValue value) { + // Don't collect metadata for self-hosted functions or intrinsics. + // This is similar to the suppression in GlobalObject::resolveConstructor. + AutoSuppressAllocationMetadataBuilder suppressMetadata(cx); + // If this is a C++ intrinsic, simply define the function on the intrinsics // holder. if (const JSFunctionSpec* spec = js::FindIntrinsicSpec(name)) { diff --git a/js/src/vm/HelperThreadState.h b/js/src/vm/HelperThreadState.h index a43efef7af..8bd8b797b4 100644 --- a/js/src/vm/HelperThreadState.h +++ b/js/src/vm/HelperThreadState.h @@ -81,9 +81,6 @@ typedef Vector<Tier2GeneratorTask*, 0, SystemAllocPolicy> // Per-process state for off thread work items. class GlobalHelperThreadState { - friend class AutoLockHelperThreadState; - friend class AutoUnlockHelperThreadState; - public: // A single tier-2 ModuleGenerator job spawns many compilation jobs, and we // do not want to allow more than one such ModuleGenerator to run at a time. @@ -182,6 +179,7 @@ class GlobalHelperThreadState { // JS::SetHelperThreadTaskCallback. If this is not set the internal thread // pool is used. JS::HelperThreadTaskCallback dispatchTaskCallback = nullptr; + friend class AutoHelperTaskQueue; // The number of tasks dispatched to the thread pool that have not started // running yet. @@ -228,7 +226,7 @@ class GlobalHelperThreadState { void assertIsLockedByCurrentThread() const; #endif - void wait(AutoLockHelperThreadState& locked, + void wait(AutoLockHelperThreadState& lock, mozilla::TimeDuration timeout = mozilla::TimeDuration::Forever()); void notifyAll(const AutoLockHelperThreadState&); diff --git a/js/src/vm/HelperThreads.cpp b/js/src/vm/HelperThreads.cpp index da8231c1dc..d50c9a134a 100644 --- a/js/src/vm/HelperThreads.cpp +++ b/js/src/vm/HelperThreads.cpp @@ -889,25 +889,23 @@ void GlobalHelperThreadState::assertIsLockedByCurrentThread() const { } #endif // DEBUG -void GlobalHelperThreadState::dispatch( - DispatchReason reason, const AutoLockHelperThreadState& locked) { - if (canStartTasks(locked) && tasksPending_ < threadCount) { +void GlobalHelperThreadState::dispatch(DispatchReason reason, + const AutoLockHelperThreadState& lock) { + if (canStartTasks(lock) && tasksPending_ < threadCount) { // This doesn't guarantee that we don't dispatch more tasks to the external // pool than necessary if tasks are taking a long time to start, but it does // limit the number. tasksPending_++; - // The hazard analysis can't tell that the callback doesn't GC. - JS::AutoSuppressGCAnalysis nogc; - - dispatchTaskCallback(reason); + lock.queueTaskToDispatch(reason); } } void GlobalHelperThreadState::wait( - AutoLockHelperThreadState& locked, + AutoLockHelperThreadState& lock, TimeDuration timeout /* = TimeDuration::Forever() */) { - consumerWakeup.wait_for(locked, timeout); + MOZ_ASSERT(!lock.hasQueuedTasks()); + consumerWakeup.wait_for(lock, timeout); } void GlobalHelperThreadState::notifyAll(const AutoLockHelperThreadState&) { @@ -1534,6 +1532,10 @@ void js::RunPendingSourceCompressions(JSRuntime* runtime) { HelperThreadState().startHandlingCompressionTasks( GlobalHelperThreadState::ScheduleCompressionTask::API, nullptr, lock); + { + // Dispatch tasks. + AutoUnlockHelperThreadState unlock(lock); + } // Wait until all tasks have started compression. while (!HelperThreadState().compressionWorklist(lock).empty()) { @@ -1735,3 +1737,28 @@ void GlobalHelperThreadState::runTaskLocked(HelperThreadTask* task, js::oom::SetThreadType(js::THREAD_TYPE_NONE); } + +void AutoHelperTaskQueue::queueTaskToDispatch(JS::DispatchReason reason) const { + // This is marked const because it doesn't release the mutex. + + if (reason == JS::DispatchReason::FinishedTask) { + finishedTasksToDispatch++; + return; + } + + newTasksToDispatch++; +} + +void AutoHelperTaskQueue::dispatchQueuedTasks() { + // The hazard analysis can't tell that the callback doesn't GC. + JS::AutoSuppressGCAnalysis nogc; + + for (size_t i = 0; i < newTasksToDispatch; i++) { + HelperThreadState().dispatchTaskCallback(JS::DispatchReason::NewTask); + } + for (size_t i = 0; i < finishedTasksToDispatch; i++) { + HelperThreadState().dispatchTaskCallback(JS::DispatchReason::FinishedTask); + } + newTasksToDispatch = 0; + finishedTasksToDispatch = 0; +} diff --git a/js/src/vm/HelperThreads.h b/js/src/vm/HelperThreads.h index 430511d104..3827168f98 100644 --- a/js/src/vm/HelperThreads.h +++ b/js/src/vm/HelperThreads.h @@ -14,6 +14,7 @@ #include "mozilla/Variant.h" #include "js/AllocPolicy.h" +#include "js/HelperThreadAPI.h" #include "js/shadow/Zone.h" #include "js/UniquePtr.h" #include "js/Vector.h" @@ -68,21 +69,44 @@ using UniqueTier2GeneratorTask = UniquePtr<Tier2GeneratorTask>; */ extern Mutex gHelperThreadLock MOZ_UNANNOTATED; -class MOZ_RAII AutoLockHelperThreadState : public LockGuard<Mutex> { - using Base = LockGuard<Mutex>; - +// Set of tasks to dispatch when the helper thread state lock is released. +class AutoHelperTaskQueue { public: - explicit AutoLockHelperThreadState() : Base(gHelperThreadLock) {} + ~AutoHelperTaskQueue() { dispatchQueuedTasks(); } + bool hasQueuedTasks() const { + return newTasksToDispatch || finishedTasksToDispatch; + } + void queueTaskToDispatch(JS::DispatchReason reason) const; + void dispatchQueuedTasks(); + + private: + mutable uint32_t newTasksToDispatch = 0; + mutable uint32_t finishedTasksToDispatch = 0; }; -class MOZ_RAII AutoUnlockHelperThreadState : public UnlockGuard<Mutex> { - using Base = UnlockGuard<Mutex>; - +// A lock guard for data protected by the helper thread lock. +// +// This can also queue helper thread tasks to be triggered when the lock is +// released. +class MOZ_RAII AutoLockHelperThreadState + : public AutoHelperTaskQueue, // Must come before LockGuard. + public LockGuard<Mutex> { public: - explicit AutoUnlockHelperThreadState(AutoLockHelperThreadState& locked) - : Base(locked) {} + AutoLockHelperThreadState() : LockGuard<Mutex>(gHelperThreadLock) {} + AutoLockHelperThreadState(const AutoLockHelperThreadState&) = delete; + + private: + friend class UnlockGuard<AutoLockHelperThreadState>; + void unlock() { + LockGuard<Mutex>::unlock(); + dispatchQueuedTasks(); + } + + friend class GlobalHelperThreadState; }; +using AutoUnlockHelperThreadState = UnlockGuard<AutoLockHelperThreadState>; + // Create data structures used by helper threads. bool CreateHelperThreadsState(); diff --git a/js/src/vm/InternalThreadPool.cpp b/js/src/vm/InternalThreadPool.cpp index 483e995254..c6cdac1d44 100644 --- a/js/src/vm/InternalThreadPool.cpp +++ b/js/src/vm/InternalThreadPool.cpp @@ -187,7 +187,10 @@ void InternalThreadPool::DispatchTask(JS::DispatchReason reason) { } void InternalThreadPool::dispatchTask(JS::DispatchReason reason) { - gHelperThreadLock.assertOwnedByCurrentThread(); + // This could now use a separate mutex like TaskController, but continues to + // use the helper thread state lock for convenience. + AutoLockHelperThreadState lock; + queuedTasks++; if (reason == JS::DispatchReason::NewTask) { wakeup.notify_one(); @@ -279,7 +282,9 @@ void HelperThread::threadLoop(InternalThreadPool* pool) { while (!pool->terminating) { if (pool->queuedTasks != 0) { pool->queuedTasks--; - HelperThreadState().runOneTask(lock); + + AutoUnlockHelperThreadState unlock(lock); + JS::RunHelperThreadTask(); continue; } diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index f4cdc86f18..f005c12949 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -63,6 +63,7 @@ #include "vm/StringType.h" #include "vm/ThrowMsgKind.h" // ThrowMsgKind #include "vm/Time.h" +#include "vm/TypeofEqOperand.h" // TypeofEqOperand #ifdef ENABLE_RECORD_TUPLE # include "vm/RecordType.h" # include "vm/TupleType.h" @@ -249,7 +250,7 @@ static inline bool GetNameOperation(JSContext* cx, HandleObject envChain, Handle<PropertyName*> name, JSOp nextOp, MutableHandleValue vp) { /* Kludge to allow (typeof foo == "undefined") tests. */ - if (nextOp == JSOp::Typeof) { + if (IsTypeOfNameOp(nextOp)) { return GetEnvironmentName<GetNameMode::TypeOf>(cx, envChain, name, vp); } return GetEnvironmentName<GetNameMode::Normal>(cx, envChain, name, vp); @@ -2650,6 +2651,16 @@ bool MOZ_NEVER_INLINE JS_HAZ_JSNATIVE_CALLER js::Interpret(JSContext* cx, } END_CASE(Typeof) + CASE(TypeofEq) { + auto operand = TypeofEqOperand::fromRawValue(GET_UINT8(REGS.pc)); + bool result = js::TypeOfValue(REGS.sp[-1]) == operand.type(); + if (operand.compareOp() == JSOp::Ne) { + result = !result; + } + REGS.sp[-1].setBoolean(result); + } + END_CASE(TypeofEq) + CASE(Void) { REGS.sp[-1].setUndefined(); } END_CASE(Void) @@ -4140,13 +4151,7 @@ bool MOZ_NEVER_INLINE JS_HAZ_JSNATIVE_CALLER js::Interpret(JSContext* cx, } if (!DebugAPI::onResumeFrame(cx, REGS.fp())) { - if (cx->isPropagatingForcedReturn()) { - MOZ_ASSERT_IF( - REGS.fp() - ->callee() - .isGenerator(), // as opposed to an async function - gen->isClosed()); - } + MOZ_ASSERT_IF(cx->isPropagatingForcedReturn(), gen->isClosed()); goto error; } } diff --git a/js/src/vm/JSAtomUtils.cpp b/js/src/vm/JSAtomUtils.cpp index 2f8b066f0c..157e788964 100644 --- a/js/src/vm/JSAtomUtils.cpp +++ b/js/src/vm/JSAtomUtils.cpp @@ -666,6 +666,10 @@ JSAtom* js::AtomizeString(JSContext* cx, JSString* str) { return &str->asAtom(); } + if (str->isAtomRef()) { + return str->atom(); + } + if (JSAtom* atom = cx->caches().stringToAtomCache.lookup(str)) { return atom; } @@ -691,6 +695,7 @@ JSAtom* js::AtomizeString(JSContext* cx, JSString* str) { // not done in lookup() itself, because #including JSContext.h there // causes some non-trivial #include ordering issues. cx->markAtom(atom); + str->tryReplaceWithAtomRef(atom); return atom; } } @@ -723,7 +728,9 @@ JSAtom* js::AtomizeString(JSContext* cx, JSString* str) { return nullptr; } - cx->caches().stringToAtomCache.maybePut(str, atom, key); + if (!str->tryReplaceWithAtomRef(atom)) { + cx->caches().stringToAtomCache.maybePut(str, atom, key); + } return atom; } diff --git a/js/src/vm/JSContext.cpp b/js/src/vm/JSContext.cpp index 3cc2c4807c..6ffe04b190 100644 --- a/js/src/vm/JSContext.cpp +++ b/js/src/vm/JSContext.cpp @@ -1038,6 +1038,16 @@ JSContext::JSContext(JSRuntime* runtime, const JS::ContextOptions& options) JS::RootingContext::get(this)); } +#ifdef ENABLE_WASM_JSPI +bool js::IsSuspendableStackActive(JSContext* cx) { + return cx->wasm().suspendableStackLimit != JS::NativeStackLimitMin; +} + +JS::NativeStackLimit js::GetSuspendableStackLimit(JSContext* cx) { + return cx->wasm().suspendableStackLimit; +} +#endif + JSContext::~JSContext() { #ifdef DEBUG // Clear the initialized_ first, so that ProtectedData checks will allow us to @@ -1256,6 +1266,9 @@ void JSContext::trace(JSTracer* trc) { if (isolate) { irregexp::TraceIsolate(trc, isolate.ref()); } +#ifdef ENABLE_WASM_JSPI + wasm().promiseIntegration.trace(trc); +#endif } JS::NativeStackLimit JSContext::stackLimitForJitCode(JS::StackKind kind) { diff --git a/js/src/vm/JSContext.h b/js/src/vm/JSContext.h index ba665d6c1a..df09fa40c8 100644 --- a/js/src/vm/JSContext.h +++ b/js/src/vm/JSContext.h @@ -416,6 +416,16 @@ struct JS_PUBLIC_API JSContext : public JS::RootingContext, /* If non-null, report JavaScript entry points to this monitor. */ js::ContextData<JS::dbg::AutoEntryMonitor*> entryMonitor; + // In brittle mode, any failure will produce a diagnostic assertion rather + // than propagating an error or throwing an exception. This is used for + // intermittent crash diagnostics: if an operation is failing for unknown + // reasons, turn on brittle mode and annotate the operations within + // SpiderMonkey that the failing operation uses with: + // + // MOZ_DIAGNOSTIC_ASSERT(!cx->brittleMode, "specific failure"); + // + bool brittleMode = false; + /* * Stack of debuggers that currently disallow debuggee execution. * diff --git a/js/src/vm/JSONParser.cpp b/js/src/vm/JSONParser.cpp index 7a440e3090..54e15176a6 100644 --- a/js/src/vm/JSONParser.cpp +++ b/js/src/vm/JSONParser.cpp @@ -1428,35 +1428,34 @@ class MOZ_STACK_CLASS DelegateHandler { } inline bool setBooleanValue(bool value, mozilla::Span<const CharT>&& source) { - return true; - } - inline bool setNullValue(mozilla::Span<const CharT>&& source) { return true; } - - inline DummyValue numberValue() const { return DummyValue(); } - - inline DummyValue stringValue() const { return DummyValue(); } - - inline DummyValue booleanValue(bool value) { if (hadHandlerError_) { - return DummyValue(); + return false; } if (!handler_->booleanValue(value)) { hadHandlerError_ = true; } - return DummyValue(); + return !hadHandlerError_; } - inline DummyValue nullValue() { + inline bool setNullValue(mozilla::Span<const CharT>&& source) { if (hadHandlerError_) { - return DummyValue(); + return false; } if (!handler_->nullValue()) { hadHandlerError_ = true; } - return DummyValue(); + return !hadHandlerError_; } + inline DummyValue numberValue() const { return DummyValue(); } + + inline DummyValue stringValue() const { return DummyValue(); } + + inline DummyValue booleanValue(bool value) { return DummyValue(); } + + inline DummyValue nullValue() { return DummyValue(); } + inline bool objectOpen(Vector<StackEntry, 10>& stack, PropertyVector** properties) { if (hadHandlerError_) { diff --git a/js/src/vm/JSObject.cpp b/js/src/vm/JSObject.cpp index 8bc8bc0d52..663b9c2260 100644 --- a/js/src/vm/JSObject.cpp +++ b/js/src/vm/JSObject.cpp @@ -1215,6 +1215,10 @@ void JSObject::swap(JSContext* cx, HandleObject a, HandleObject b, MOZ_RELEASE_ASSERT(js::ObjectMayBeSwapped(a)); MOZ_RELEASE_ASSERT(js::ObjectMayBeSwapped(b)); + // Don't allow a GC which may observe intermediate state or run before we + // execute all necessary barriers. + gc::AutoSuppressGC nogc(cx); + if (!Watchtower::watchObjectSwap(cx, a, b)) { oomUnsafe.crash("watchObjectSwap"); } @@ -1305,10 +1309,6 @@ void JSObject::swap(JSContext* cx, HandleObject a, HandleObject b, a->as<ProxyObject>().setInlineValueArray(); } } else { - // Avoid GC in here to avoid confusing the tracing code with our - // intermediate state. - gc::AutoSuppressGC suppress(cx); - // When the objects have different sizes, they will have different numbers // of fixed slots before and after the swap, so the slots for native objects // will need to be rearranged. Remember the original values from the @@ -2204,7 +2204,6 @@ JS_PUBLIC_API bool js::ShouldIgnorePropertyDefinition(JSContext* cx, return true; } -#ifdef NIGHTLY_BUILD if (key == JSProto_Set && !JS::Prefs::experimental_new_set_methods() && (id == NameToId(cx->names().union_) || id == NameToId(cx->names().difference) || @@ -2216,6 +2215,7 @@ JS_PUBLIC_API bool js::ShouldIgnorePropertyDefinition(JSContext* cx, return true; } +#ifdef NIGHTLY_BUILD if (key == JSProto_ArrayBuffer && !JS::Prefs::arraybuffer_transfer() && (id == NameToId(cx->names().transfer) || id == NameToId(cx->names().transferToFixedLength) || @@ -2267,6 +2267,18 @@ JS_PUBLIC_API bool js::ShouldIgnorePropertyDefinition(JSContext* cx, } #endif +#ifdef NIGHTLY_BUILD + if (key == JSProto_Math && !JS::Prefs::experimental_float16array() && + (id == NameToId(cx->names().f16round))) { + return true; + } + if (key == JSProto_DataView && !JS::Prefs::experimental_float16array() && + (id == NameToId(cx->names().getFloat16) || + id == NameToId(cx->names().setFloat16))) { + return true; + } +#endif + return false; } diff --git a/js/src/vm/JSScript.h b/js/src/vm/JSScript.h index 4e44d22304..c46ff65d2d 100644 --- a/js/src/vm/JSScript.h +++ b/js/src/vm/JSScript.h @@ -2040,6 +2040,23 @@ class JSScript : public js::BaseScript { return getString(GET_GCTHING_INDEX(pc)); } + bool atomizeString(JSContext* cx, jsbytecode* pc) { + MOZ_ASSERT(containsPC<js::GCThingIndex>(pc)); + MOZ_ASSERT(js::JOF_OPTYPE((JSOp)*pc) == JOF_STRING); + js::GCThingIndex index = GET_GCTHING_INDEX(pc); + JSString* str = getString(index); + if (str->isAtom()) { + return true; + } + JSAtom* atom = js::AtomizeString(cx, str); + if (!atom) { + return false; + } + js::gc::CellPtrPreWriteBarrier(data_->gcthings()[index]); + data_->gcthings()[index] = JS::GCCellPtr(atom); + return true; + } + JSAtom* getAtom(js::GCThingIndex index) const { return &gcthings()[index].as<JSString>().asAtom(); } diff --git a/js/src/vm/JitActivation.cpp b/js/src/vm/JitActivation.cpp index 83ec19df8a..e3ff3dd990 100644 --- a/js/src/vm/JitActivation.cpp +++ b/js/src/vm/JitActivation.cpp @@ -13,6 +13,7 @@ #include <utility> // std::move #include "debugger/DebugAPI.h" // js::DebugAPI +#include "jit/Invalidation.h" // js::jit::Invalidate #include "jit/JSJitFrameIter.h" // js::jit::InlineFrameIterator #include "jit/RematerializedFrame.h" // js::jit::RematerializedFrame #include "js/AllocPolicy.h" // js::ReportOutOfMemory @@ -58,7 +59,9 @@ js::jit::JitActivation::~JitActivation() { // Traps get handled immediately. MOZ_ASSERT(!isWasmTrapping()); - clearRematerializedFrames(); + // Rematerialized frames must have been removed by either the bailout code or + // the exception handler. + MOZ_ASSERT_IF(rematerializedFrames_, rematerializedFrames_->empty()); } void js::jit::JitActivation::setBailoutData( @@ -82,20 +85,9 @@ void js::jit::JitActivation::removeRematerializedFrame(uint8_t* top) { } } -void js::jit::JitActivation::clearRematerializedFrames() { - if (!rematerializedFrames_) { - return; - } - - for (RematerializedFrameTable::Enum e(*rematerializedFrames_); !e.empty(); - e.popFront()) { - e.removeFront(); - } -} - js::jit::RematerializedFrame* js::jit::JitActivation::getRematerializedFrame( JSContext* cx, const JSJitFrameIter& iter, size_t inlineDepth, - MaybeReadFallback::FallbackConsequence consequence) { + IsLeavingFrame leaving) { MOZ_ASSERT(iter.activation() == this); MOZ_ASSERT(iter.isIonScripted()); @@ -117,6 +109,14 @@ js::jit::RematerializedFrame* js::jit::JitActivation::getRematerializedFrame( // preserve identity. Therefore, we always rematerialize an uninlined // frame and all its inlined frames at once. InlineFrameIterator inlineIter(cx, &iter); + + // We can run recover instructions without invalidating if we're always + // leaving the frame. + MaybeReadFallback::FallbackConsequence consequence = + MaybeReadFallback::Fallback_Invalidate; + if (leaving == IsLeavingFrame::Yes) { + consequence = MaybeReadFallback::Fallback_DoNothing; + } MaybeReadFallback recover(cx, this, &iter, consequence); // Frames are often rematerialized with the cx inside a Debugger's @@ -124,6 +124,14 @@ js::jit::RematerializedFrame* js::jit::JitActivation::getRematerializedFrame( // be in the script's realm. AutoRealmUnchecked ar(cx, iter.script()->realm()); + // The Ion frame must be invalidated to ensure the rematerialized frame will + // be removed by the bailout code or the exception handler. If we're always + // leaving the frame, the caller is responsible for cleaning up the + // rematerialized frame. + if (leaving == IsLeavingFrame::No && !iter.checkInvalidation()) { + jit::Invalidate(cx, iter.script()); + } + if (!RematerializedFrame::RematerializeInlineFrames(cx, top, inlineIter, recover, frames)) { return nullptr; diff --git a/js/src/vm/JitActivation.h b/js/src/vm/JitActivation.h index be2d63066c..54ca5924d9 100644 --- a/js/src/vm/JitActivation.h +++ b/js/src/vm/JitActivation.h @@ -40,6 +40,8 @@ namespace jit { class BailoutFrameInfo; +enum class IsLeavingFrame { No, Yes }; + // A JitActivation is used for frames running in Baseline or Ion. class JitActivation : public Activation { // If Baseline, Ion or Wasm code is on the stack, and has called into C++, @@ -94,8 +96,6 @@ class JitActivation : public Activation { // purposes. Wasm code can't trap reentrantly. mozilla::Maybe<wasm::TrapData> wasmTrapData_; - void clearRematerializedFrames(); - #ifdef CHECK_OSIPOINT_REGISTERS protected: // Used to verify that live registers don't change between a VM call and @@ -156,8 +156,7 @@ class JitActivation : public Activation { // The inlineDepth must be within bounds of the frame pointed to by iter. RematerializedFrame* getRematerializedFrame( JSContext* cx, const JSJitFrameIter& iter, size_t inlineDepth = 0, - MaybeReadFallback::FallbackConsequence consequence = - MaybeReadFallback::Fallback_Invalidate); + IsLeavingFrame leaving = IsLeavingFrame::No); // Look up a rematerialized frame by the fp. If inlineDepth is out of // bounds of what has been rematerialized, nullptr is returned. diff --git a/js/src/vm/ModuleBuilder.h b/js/src/vm/ModuleBuilder.h index 31f8ec2826..738006c069 100644 --- a/js/src/vm/ModuleBuilder.h +++ b/js/src/vm/ModuleBuilder.h @@ -90,7 +90,7 @@ class MOZ_STACK_CLASS ModuleBuilder { MaybeModuleRequestIndex appendModuleRequest( frontend::TaggedParserAtomIndex specifier, - frontend::ListNode* assertionList); + frontend::ListNode* attributeList); bool appendExportEntry(frontend::TaggedParserAtomIndex exportName, frontend::TaggedParserAtomIndex localName, @@ -101,10 +101,10 @@ class MOZ_STACK_CLASS ModuleBuilder { void markUsedByStencil(frontend::TaggedParserAtomIndex name); - [[nodiscard]] bool processAssertions(frontend::StencilModuleRequest& request, - frontend::ListNode* assertionList); + [[nodiscard]] bool processAttributes(frontend::StencilModuleRequest& request, + frontend::ListNode* attributeList); - [[nodiscard]] bool isAssertionSupported(frontend::TaggedParserAtomIndex key); + [[nodiscard]] bool isAttributeSupported(frontend::TaggedParserAtomIndex key); }; template <typename T> diff --git a/js/src/vm/Modules.cpp b/js/src/vm/Modules.cpp index 917083a238..867201baa9 100644 --- a/js/src/vm/Modules.cpp +++ b/js/src/vm/Modules.cpp @@ -310,7 +310,9 @@ JS_PUBLIC_API JSObject* JS::CreateModuleRequest( return nullptr; } - return ModuleRequestObject::create(cx, specifierAtom, nullptr); + Rooted<UniquePtr<ImportAttributeVector>> attributes(cx); + + return ModuleRequestObject::create(cx, specifierAtom, &attributes); } JS_PUBLIC_API JSString* JS::GetModuleRequestSpecifier( @@ -1256,6 +1258,36 @@ static bool ModuleLink(JSContext* cx, Handle<ModuleObject*> module) { return true; } +// https://tc39.es/proposal-import-attributes/#sec-AllImportAttributesSupported +static bool AllImportAttributesSupported( + JSContext* cx, mozilla::Span<const ImportAttribute> attributes) { + // Step 1. Let supported be HostGetSupportedImportAttributes(). + // + // Note: This should be driven by a host hook + // (HostGetSupportedImportAttributes), however the infrastructure of said host + // hook is deeply unclear, and so right now embedders will not have the + // ability to alter or extend the set of supported attributes. See + // https://bugzilla.mozilla.org/show_bug.cgi?id=1840723. + + // Step 2. For each ImportAttribute Record attribute of attributes, do + for (const ImportAttribute& attribute : attributes) { + // Step 2.a. If supported does not contain attribute.[[Key]], return false. + if (attribute.key() != cx->names().type) { + UniqueChars printableKey = AtomToPrintableString(cx, attribute.key()); + if (!printableKey) { + return false; + } + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_IMPORT_ATTRIBUTES_UNSUPPORTED_ATTRIBUTE, + printableKey.get()); + return false; + } + } + + // Step 3. Return true. + return true; +} + // https://tc39.es/ecma262/#sec-InnerModuleLinking // ES2023 16.2.1.5.1.1 InnerModuleLinking static bool InnerModuleLinking(JSContext* cx, Handle<ModuleObject*> module, @@ -1312,6 +1344,13 @@ static bool InnerModuleLinking(JSContext* cx, Handle<ModuleObject*> module, for (const RequestedModule& request : module->requestedModules()) { moduleRequest = request.moduleRequest(); + // According to the spec, this should be in InnerModuleLoading, but + // currently, our module code is not aligned with the spec text. + // https://bugzilla.mozilla.org/show_bug.cgi?id=1894729 + if (!AllImportAttributesSupported(cx, moduleRequest->attributes())) { + return false; + } + // Step 9.a. Let requiredModule be ? HostResolveImportedModule(module, // required). requiredModule = HostResolveImportedModule(cx, module, moduleRequest, diff --git a/js/src/vm/Monitor.h b/js/src/vm/Monitor.h index 6c0fbff0d9..5a2c168729 100644 --- a/js/src/vm/Monitor.h +++ b/js/src/vm/Monitor.h @@ -20,7 +20,6 @@ namespace js { class Monitor { protected: friend class AutoLockMonitor; - friend class AutoUnlockMonitor; Mutex lock_ MOZ_UNANNOTATED; ConditionVariable condVar_; @@ -53,20 +52,6 @@ class AutoLockMonitor : public LockGuard<Mutex> { void notifyAll() { notifyAll(monitor.condVar_); } }; -class AutoUnlockMonitor { - private: - Monitor& monitor; - - public: - explicit AutoUnlockMonitor(Monitor& monitor) : monitor(monitor) { - monitor.lock_.unlock(); - } - - ~AutoUnlockMonitor() { monitor.lock_.lock(); } - - bool isFor(Monitor& other) const { return &monitor.lock_ == &other.lock_; } -}; - } // namespace js #endif /* vm_Monitor_h */ diff --git a/js/src/vm/Opcodes.h b/js/src/vm/Opcodes.h index 438f361bcf..6db658701d 100644 --- a/js/src/vm/Opcodes.h +++ b/js/src/vm/Opcodes.h @@ -412,6 +412,19 @@ MACRO(Typeof, typeof_, NULL, 1, 1, 1, JOF_BYTE|JOF_IC) \ MACRO(TypeofExpr, typeof_expr, NULL, 1, 1, 1, JOF_BYTE|JOF_IC) \ /* + * A compound opcode for `typeof val === "type"` or `typeof val !== "type"`, + * where `val` is single identifier. + * + * Infallible. The result is always a boolean that depends on the type of + * `val` and `"type"` string, and the comparison operator. + * + * Category: Expressions + * Type: Other expressions + * Operands: TypeofEqOperand operand + * Stack: val => (typeof val CMP "type") + */ \ + MACRO(TypeofEq, typeof_eq, NULL, 2, 1, 1, JOF_UINT8|JOF_IC) \ + /* * [The unary `+` operator][1]. * * `+val` doesn't do any actual math. It just calls [ToNumber][2](val). @@ -909,7 +922,7 @@ * Operands: uint32_t nameIndex * Stack: obj, val => obj */ \ - MACRO(InitProp, init_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPINIT|JOF_IC) \ + MACRO(InitProp, init_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPINIT|JOF_IC) \ /* * Like `JSOp::InitProp`, but define a non-enumerable property. * @@ -925,7 +938,7 @@ * Operands: uint32_t nameIndex * Stack: obj, val => obj */ \ - MACRO(InitHiddenProp, init_hidden_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPINIT|JOF_IC) \ + MACRO(InitHiddenProp, init_hidden_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPINIT|JOF_IC) \ /* * Like `JSOp::InitProp`, but define a non-enumerable, non-writable, * non-configurable property. @@ -942,7 +955,7 @@ * Operands: uint32_t nameIndex * Stack: obj, val => obj */ \ - MACRO(InitLockedProp, init_locked_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPINIT|JOF_IC) \ + MACRO(InitLockedProp, init_locked_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPINIT|JOF_IC) \ /* * Define a data property on `obj` with property key `id` and value `val`. * @@ -964,9 +977,9 @@ * Operands: * Stack: obj, id, val => obj */ \ - MACRO(InitElem, init_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPINIT|JOF_IC) \ - MACRO(InitHiddenElem, init_hidden_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPINIT|JOF_IC) \ - MACRO(InitLockedElem, init_locked_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPINIT|JOF_IC) \ + MACRO(InitElem, init_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPINIT|JOF_IC) \ + MACRO(InitHiddenElem, init_hidden_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPINIT|JOF_IC) \ + MACRO(InitLockedElem, init_locked_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPINIT|JOF_IC) \ /* * Define an accessor property on `obj` with the given `getter`. * `nameIndex` gives the property name. @@ -981,8 +994,8 @@ * Operands: uint32_t nameIndex * Stack: obj, getter => obj */ \ - MACRO(InitPropGetter, init_prop_getter, NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPINIT) \ - MACRO(InitHiddenPropGetter, init_hidden_prop_getter, NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPINIT) \ + MACRO(InitPropGetter, init_prop_getter, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPINIT) \ + MACRO(InitHiddenPropGetter, init_hidden_prop_getter, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPINIT) \ /* * Define an accessor property on `obj` with property key `id` and the given `getter`. * @@ -998,8 +1011,8 @@ * Operands: * Stack: obj, id, getter => obj */ \ - MACRO(InitElemGetter, init_elem_getter, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPINIT) \ - MACRO(InitHiddenElemGetter, init_hidden_elem_getter, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPINIT) \ + MACRO(InitElemGetter, init_elem_getter, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPINIT) \ + MACRO(InitHiddenElemGetter, init_hidden_elem_getter, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPINIT) \ /* * Define an accessor property on `obj` with the given `setter`. * @@ -1015,8 +1028,8 @@ * Operands: uint32_t nameIndex * Stack: obj, setter => obj */ \ - MACRO(InitPropSetter, init_prop_setter, NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPINIT) \ - MACRO(InitHiddenPropSetter, init_hidden_prop_setter, NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPINIT) \ + MACRO(InitPropSetter, init_prop_setter, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPINIT) \ + MACRO(InitHiddenPropSetter, init_hidden_prop_setter, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPINIT) \ /* * Define an accesssor property on `obj` with property key `id` and the * given `setter`. @@ -1032,8 +1045,8 @@ * Operands: * Stack: obj, id, setter => obj */ \ - MACRO(InitElemSetter, init_elem_setter, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPINIT) \ - MACRO(InitHiddenElemSetter, init_hidden_elem_setter, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPINIT) \ + MACRO(InitElemSetter, init_elem_setter, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPINIT) \ + MACRO(InitHiddenElemSetter, init_hidden_elem_setter, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPINIT) \ /* * Get the value of the property `obj.name`. This can call getters and * proxy traps. @@ -1048,7 +1061,7 @@ * Operands: uint32_t nameIndex * Stack: obj => obj[name] */ \ - MACRO(GetProp, get_prop, NULL, 5, 1, 1, JOF_ATOM|JOF_PROP|JOF_IC) \ + MACRO(GetProp, get_prop, NULL, 5, 1, 1, JOF_ATOM|JOF_IC) \ /* * Get the value of the property `obj[key]`. * @@ -1062,7 +1075,7 @@ * Operands: * Stack: obj, key => obj[key] */ \ - MACRO(GetElem, get_elem, NULL, 1, 2, 1, JOF_BYTE|JOF_ELEM|JOF_IC) \ + MACRO(GetElem, get_elem, NULL, 1, 2, 1, JOF_BYTE|JOF_IC) \ /* * Non-strict assignment to a property, `obj.name = val`. * @@ -1079,7 +1092,7 @@ * Operands: uint32_t nameIndex * Stack: obj, val => val */ \ - MACRO(SetProp, set_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPSET|JOF_CHECKSLOPPY|JOF_IC) \ + MACRO(SetProp, set_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPSET|JOF_CHECKSLOPPY|JOF_IC) \ /* * Like `JSOp::SetProp`, but for strict mode code. Throw a TypeError if * `obj[key]` exists but is non-writable, if it's an accessor property with @@ -1090,7 +1103,7 @@ * Operands: uint32_t nameIndex * Stack: obj, val => val */ \ - MACRO(StrictSetProp, strict_set_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPSET|JOF_CHECKSTRICT|JOF_IC) \ + MACRO(StrictSetProp, strict_set_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPSET|JOF_CHECKSTRICT|JOF_IC) \ /* * Non-strict assignment to a property, `obj[key] = val`. * @@ -1103,7 +1116,7 @@ * Operands: * Stack: obj, key, val => val */ \ - MACRO(SetElem, set_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPSET|JOF_CHECKSLOPPY|JOF_IC) \ + MACRO(SetElem, set_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPSET|JOF_CHECKSLOPPY|JOF_IC) \ /* * Like `JSOp::SetElem`, but for strict mode code. Throw a TypeError if * `obj[key]` exists but is non-writable, if it's an accessor property with @@ -1114,7 +1127,7 @@ * Operands: * Stack: obj, key, val => val */ \ - MACRO(StrictSetElem, strict_set_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPSET|JOF_CHECKSTRICT|JOF_IC) \ + MACRO(StrictSetElem, strict_set_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPSET|JOF_CHECKSTRICT|JOF_IC) \ /* * Delete a property from `obj`. Push true on success, false if the * property existed but could not be deleted. This implements `delete @@ -1131,7 +1144,7 @@ * Operands: uint32_t nameIndex * Stack: obj => succeeded */ \ - MACRO(DelProp, del_prop, NULL, 5, 1, 1, JOF_ATOM|JOF_PROP|JOF_CHECKSLOPPY) \ + MACRO(DelProp, del_prop, NULL, 5, 1, 1, JOF_ATOM|JOF_CHECKSLOPPY) \ /* * Like `JSOp::DelProp`, but for strict mode code. Push `true` on success, * else throw a TypeError. @@ -1141,7 +1154,7 @@ * Operands: uint32_t nameIndex * Stack: obj => succeeded */ \ - MACRO(StrictDelProp, strict_del_prop, NULL, 5, 1, 1, JOF_ATOM|JOF_PROP|JOF_CHECKSTRICT) \ + MACRO(StrictDelProp, strict_del_prop, NULL, 5, 1, 1, JOF_ATOM|JOF_CHECKSTRICT) \ /* * Delete the property `obj[key]` and push `true` on success, `false` * if the property existed but could not be deleted. @@ -1157,7 +1170,7 @@ * Operands: * Stack: obj, key => succeeded */ \ - MACRO(DelElem, del_elem, NULL, 1, 2, 1, JOF_BYTE|JOF_ELEM|JOF_CHECKSLOPPY) \ + MACRO(DelElem, del_elem, NULL, 1, 2, 1, JOF_BYTE|JOF_CHECKSLOPPY) \ /* * Like `JSOp::DelElem, but for strict mode code. Push `true` on success, * else throw a TypeError. @@ -1167,7 +1180,7 @@ * Operands: * Stack: obj, key => succeeded */ \ - MACRO(StrictDelElem, strict_del_elem, NULL, 1, 2, 1, JOF_BYTE|JOF_ELEM|JOF_CHECKSTRICT) \ + MACRO(StrictDelElem, strict_del_elem, NULL, 1, 2, 1, JOF_BYTE|JOF_CHECKSTRICT) \ /* * Push true if `obj` has an own property `id`. * @@ -1245,7 +1258,7 @@ * Operands: uint32_t nameIndex * Stack: receiver, obj => super.name */ \ - MACRO(GetPropSuper, get_prop_super, NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_IC) \ + MACRO(GetPropSuper, get_prop_super, NULL, 5, 2, 1, JOF_ATOM|JOF_IC) \ /* * Get the value of `receiver[key]`, starting the property search at `obj`. * In spec terms, `obj.[[Get]](key, receiver)`. @@ -1263,7 +1276,7 @@ * Operands: * Stack: receiver, key, obj => super[key] */ \ - MACRO(GetElemSuper, get_elem_super, NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_IC) \ + MACRO(GetElemSuper, get_elem_super, NULL, 1, 3, 1, JOF_BYTE|JOF_IC) \ /* * Assign `val` to `receiver.name`, starting the search for an existing * property at `obj`. In spec terms, `obj.[[Set]](name, val, receiver)`. @@ -1280,7 +1293,7 @@ * Operands: uint32_t nameIndex * Stack: receiver, obj, val => val */ \ - MACRO(SetPropSuper, set_prop_super, NULL, 5, 3, 1, JOF_ATOM|JOF_PROP|JOF_PROPSET|JOF_CHECKSLOPPY) \ + MACRO(SetPropSuper, set_prop_super, NULL, 5, 3, 1, JOF_ATOM|JOF_PROPSET|JOF_CHECKSLOPPY) \ /* * Like `JSOp::SetPropSuper`, but for strict mode code. * @@ -1289,7 +1302,7 @@ * Operands: uint32_t nameIndex * Stack: receiver, obj, val => val */ \ - MACRO(StrictSetPropSuper, strict_set_prop_super, NULL, 5, 3, 1, JOF_ATOM|JOF_PROP|JOF_PROPSET|JOF_CHECKSTRICT) \ + MACRO(StrictSetPropSuper, strict_set_prop_super, NULL, 5, 3, 1, JOF_ATOM|JOF_PROPSET|JOF_CHECKSTRICT) \ /* * Assign `val` to `receiver[key]`, strating the search for an existing * property at `obj`. In spec terms, `obj.[[Set]](key, val, receiver)`. @@ -1306,7 +1319,7 @@ * Operands: * Stack: receiver, key, obj, val => val */ \ - MACRO(SetElemSuper, set_elem_super, NULL, 1, 4, 1, JOF_BYTE|JOF_ELEM|JOF_PROPSET|JOF_CHECKSLOPPY) \ + MACRO(SetElemSuper, set_elem_super, NULL, 1, 4, 1, JOF_BYTE|JOF_PROPSET|JOF_CHECKSLOPPY) \ /* * Like `JSOp::SetElemSuper`, but for strict mode code. * @@ -1315,7 +1328,7 @@ * Operands: * Stack: receiver, key, obj, val => val */ \ - MACRO(StrictSetElemSuper, strict_set_elem_super, NULL, 1, 4, 1, JOF_BYTE|JOF_ELEM|JOF_PROPSET|JOF_CHECKSTRICT) \ + MACRO(StrictSetElemSuper, strict_set_elem_super, NULL, 1, 4, 1, JOF_BYTE|JOF_PROPSET|JOF_CHECKSTRICT) \ /* * Set up a for-in loop by pushing a `PropertyIteratorObject` over the * enumerable properties of `val`. @@ -1521,7 +1534,7 @@ * Operands: uint32_t index * Stack: array, val => array */ \ - MACRO(InitElemArray, init_elem_array, NULL, 5, 2, 1, JOF_UINT32|JOF_ELEM|JOF_PROPINIT) \ + MACRO(InitElemArray, init_elem_array, NULL, 5, 2, 1, JOF_UINT32|JOF_PROPINIT) \ /* * Initialize an array element `array[index++]` with value `val`. * @@ -1553,7 +1566,7 @@ * Operands: * Stack: array, index, val => array, (index + 1) */ \ - MACRO(InitElemInc, init_elem_inc, NULL, 1, 3, 2, JOF_BYTE|JOF_ELEM|JOF_PROPINIT|JOF_IC) \ + MACRO(InitElemInc, init_elem_inc, NULL, 1, 3, 2, JOF_BYTE|JOF_PROPINIT|JOF_IC) \ /* * Push `MagicValue(JS_ELEMENTS_HOLE)`, representing an *Elision* in an * array literal (like the missing property 0 in the array `[, 1]`). @@ -2650,7 +2663,7 @@ * Operands: uint32_t nameIndex * Stack: */ \ - MACRO(ThrowSetConst, throw_set_const, NULL, 5, 0, 0, JOF_ATOM|JOF_NAME) \ + MACRO(ThrowSetConst, throw_set_const, NULL, 5, 0, 0, JOF_ATOM) \ /* * No-op instruction that marks the top of the bytecode for a * *TryStatement*. @@ -2751,7 +2764,7 @@ * Operands: uint24_t localno * Stack: v => v */ \ - MACRO(InitLexical, init_lexical, NULL, 4, 1, 1, JOF_LOCAL|JOF_NAME) \ + MACRO(InitLexical, init_lexical, NULL, 4, 1, 1, JOF_LOCAL) \ /* * Initialize a global lexical binding. * @@ -2766,7 +2779,7 @@ * Operands: uint32_t nameIndex * Stack: val => val */ \ - MACRO(InitGLexical, init_g_lexical, NULL, 5, 1, 1, JOF_ATOM|JOF_NAME|JOF_PROPINIT|JOF_GNAME|JOF_IC) \ + MACRO(InitGLexical, init_g_lexical, NULL, 5, 1, 1, JOF_ATOM|JOF_PROPINIT|JOF_GNAME|JOF_IC) \ /* * Initialize an aliased lexical binding; or mark it as uninitialized. * @@ -2784,7 +2797,7 @@ * Operands: uint8_t hops, uint24_t slot * Stack: v => v */ \ - MACRO(InitAliasedLexical, init_aliased_lexical, NULL, 5, 1, 1, JOF_ENVCOORD|JOF_NAME|JOF_PROPINIT) \ + MACRO(InitAliasedLexical, init_aliased_lexical, NULL, 5, 1, 1, JOF_ENVCOORD|JOF_PROPINIT) \ /* * Throw a ReferenceError if the value on top of the stack is uninitialized. * @@ -2801,7 +2814,7 @@ * Operands: uint24_t localno * Stack: v => v */ \ - MACRO(CheckLexical, check_lexical, NULL, 4, 1, 1, JOF_LOCAL|JOF_NAME) \ + MACRO(CheckLexical, check_lexical, NULL, 4, 1, 1, JOF_LOCAL) \ /* * Like `JSOp::CheckLexical` but for aliased bindings. * @@ -2816,7 +2829,7 @@ * Operands: uint8_t hops, uint24_t slot * Stack: v => v */ \ - MACRO(CheckAliasedLexical, check_aliased_lexical, NULL, 5, 1, 1, JOF_ENVCOORD|JOF_NAME) \ + MACRO(CheckAliasedLexical, check_aliased_lexical, NULL, 5, 1, 1, JOF_ENVCOORD) \ /* * Throw a ReferenceError if the value on top of the stack is * `MagicValue(JS_UNINITIALIZED_LEXICAL)`. Used in derived class @@ -2843,7 +2856,7 @@ * Operands: uint32_t nameIndex * Stack: => global */ \ - MACRO(BindGName, bind_g_name, NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_GNAME|JOF_IC) \ + MACRO(BindGName, bind_g_name, NULL, 5, 0, 1, JOF_ATOM|JOF_GNAME|JOF_IC) \ /* * Look up a name on the environment chain and push the environment which * contains a binding for that name. If no such binding exists, push the @@ -2854,13 +2867,14 @@ * Operands: uint32_t nameIndex * Stack: => env */ \ - MACRO(BindName, bind_name, NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_IC|JOF_USES_ENV) \ + MACRO(BindName, bind_name, NULL, 5, 0, 1, JOF_ATOM|JOF_IC|JOF_USES_ENV) \ /* * Find a binding on the environment chain and push its value. * * If the binding is an uninitialized lexical, throw a ReferenceError. If * no such binding exists, throw a ReferenceError unless the next - * instruction is `JSOp::Typeof`, in which case push `undefined`. + * instruction is `JSOp::Typeof` or `JSOp::TypeofEq` (see IsTypeOfNameOp), + * in which case push `undefined`. * * Implements: [ResolveBinding][1] followed by [GetValue][2] * (adjusted hackily for `typeof`). @@ -2876,7 +2890,7 @@ * Operands: uint32_t nameIndex * Stack: => val */ \ - MACRO(GetName, get_name, NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_IC|JOF_USES_ENV) \ + MACRO(GetName, get_name, NULL, 5, 0, 1, JOF_ATOM|JOF_IC|JOF_USES_ENV) \ /* * Find a global binding and push its value. * @@ -2900,7 +2914,7 @@ * Operands: uint32_t nameIndex * Stack: => val */ \ - MACRO(GetGName, get_g_name, NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_GNAME|JOF_IC) \ + MACRO(GetGName, get_g_name, NULL, 5, 0, 1, JOF_ATOM|JOF_GNAME|JOF_IC) \ /* * Push the value of an argument that is stored in the stack frame * or in an `ArgumentsObject`. @@ -2910,7 +2924,7 @@ * Operands: uint16_t argno * Stack: => arguments[argno] */ \ - MACRO(GetArg, get_arg, NULL, 3, 0, 1, JOF_QARG|JOF_NAME) \ + MACRO(GetArg, get_arg, NULL, 3, 0, 1, JOF_QARG) \ /* * Push the value of an argument that is stored in the stack frame. Like * `JSOp::GetArg`, but ignores the frame's `ArgumentsObject` and doesn't @@ -2921,7 +2935,7 @@ * Operands: uint16_t argno * Stack: => arguments[argno] */ \ - MACRO(GetFrameArg, get_frame_arg, NULL, 3, 0, 1, JOF_QARG|JOF_NAME) \ + MACRO(GetFrameArg, get_frame_arg, NULL, 3, 0, 1, JOF_QARG) \ /* * Push the value of an optimized local variable. * @@ -2933,7 +2947,7 @@ * Operands: uint24_t localno * Stack: => val */ \ - MACRO(GetLocal, get_local, NULL, 4, 0, 1, JOF_LOCAL|JOF_NAME) \ + MACRO(GetLocal, get_local, NULL, 4, 0, 1, JOF_LOCAL) \ /* * Push the number of actual arguments as Int32Value. * @@ -2983,7 +2997,7 @@ * Operands: uint8_t hops, uint24_t slot * Stack: => aliasedVar */ \ - MACRO(GetAliasedVar, get_aliased_var, NULL, 5, 0, 1, JOF_ENVCOORD|JOF_NAME|JOF_USES_ENV) \ + MACRO(GetAliasedVar, get_aliased_var, NULL, 5, 0, 1, JOF_ENVCOORD|JOF_USES_ENV) \ /* * Push the value of an aliased binding, which may have to bypass a DebugEnvironmentProxy * on the environment chain. @@ -2993,7 +3007,7 @@ * Operands: uint8_t hops, uint24_t slot * Stack: => aliasedVar */ \ - MACRO(GetAliasedDebugVar, get_aliased_debug_var, NULL, 5, 0, 1, JOF_DEBUGCOORD|JOF_NAME) \ + MACRO(GetAliasedDebugVar, get_aliased_debug_var, NULL, 5, 0, 1, JOF_DEBUGCOORD) \ /* * Get the value of a module import by name and pushes it onto the stack. * @@ -3002,7 +3016,7 @@ * Operands: uint32_t nameIndex * Stack: => val */ \ - MACRO(GetImport, get_import, NULL, 5, 0, 1, JOF_ATOM|JOF_NAME) \ + MACRO(GetImport, get_import, NULL, 5, 0, 1, JOF_ATOM) \ /* * Get the value of a binding from the environment `env`. If the name is * not bound in `env`, throw a ReferenceError. @@ -3027,7 +3041,7 @@ * Operands: uint32_t nameIndex * Stack: env => v */ \ - MACRO(GetBoundName, get_bound_name, NULL, 5, 1, 1, JOF_ATOM|JOF_NAME|JOF_IC) \ + MACRO(GetBoundName, get_bound_name, NULL, 5, 1, 1, JOF_ATOM|JOF_IC) \ /* * Push the value of an intrinsic onto the stack. * @@ -3040,7 +3054,7 @@ * Operands: uint32_t nameIndex * Stack: => intrinsic[name] */ \ - MACRO(GetIntrinsic, get_intrinsic, NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_IC) \ + MACRO(GetIntrinsic, get_intrinsic, NULL, 5, 0, 1, JOF_ATOM|JOF_IC) \ /* * Pushes the currently executing function onto the stack. * @@ -3100,7 +3114,7 @@ * Operands: uint32_t nameIndex * Stack: env, val => val */ \ - MACRO(SetName, set_name, NULL, 5, 2, 1, JOF_ATOM|JOF_NAME|JOF_PROPSET|JOF_CHECKSLOPPY|JOF_IC|JOF_USES_ENV) \ + MACRO(SetName, set_name, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPSET|JOF_CHECKSLOPPY|JOF_IC|JOF_USES_ENV) \ /* * Like `JSOp::SetName`, but throw a TypeError if there is no binding for * the specified name in `env`, or if the binding is immutable (a `const` @@ -3115,7 +3129,7 @@ * Operands: uint32_t nameIndex * Stack: env, val => val */ \ - MACRO(StrictSetName, strict_set_name, NULL, 5, 2, 1, JOF_ATOM|JOF_NAME|JOF_PROPSET|JOF_CHECKSTRICT|JOF_IC|JOF_USES_ENV) \ + MACRO(StrictSetName, strict_set_name, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPSET|JOF_CHECKSTRICT|JOF_IC|JOF_USES_ENV) \ /* * Like `JSOp::SetName`, but for assigning to globals. `env` must be an * environment pushed by `JSOp::BindGName`. @@ -3125,7 +3139,7 @@ * Operands: uint32_t nameIndex * Stack: env, val => val */ \ - MACRO(SetGName, set_g_name, NULL, 5, 2, 1, JOF_ATOM|JOF_NAME|JOF_PROPSET|JOF_GNAME|JOF_CHECKSLOPPY|JOF_IC) \ + MACRO(SetGName, set_g_name, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPSET|JOF_GNAME|JOF_CHECKSLOPPY|JOF_IC) \ /* * Like `JSOp::StrictSetGName`, but for assigning to globals. `env` must be * an environment pushed by `JSOp::BindGName`. @@ -3135,7 +3149,7 @@ * Operands: uint32_t nameIndex * Stack: env, val => val */ \ - MACRO(StrictSetGName, strict_set_g_name, NULL, 5, 2, 1, JOF_ATOM|JOF_NAME|JOF_PROPSET|JOF_GNAME|JOF_CHECKSTRICT|JOF_IC) \ + MACRO(StrictSetGName, strict_set_g_name, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPSET|JOF_GNAME|JOF_CHECKSTRICT|JOF_IC) \ /* * Assign `val` to an argument binding that's stored in the stack frame or * in an `ArgumentsObject`. @@ -3145,7 +3159,7 @@ * Operands: uint16_t argno * Stack: val => val */ \ - MACRO(SetArg, set_arg, NULL, 3, 1, 1, JOF_QARG|JOF_NAME) \ + MACRO(SetArg, set_arg, NULL, 3, 1, 1, JOF_QARG) \ /* * Assign to an optimized local binding. * @@ -3154,7 +3168,7 @@ * Operands: uint24_t localno * Stack: v => v */ \ - MACRO(SetLocal, set_local, NULL, 4, 1, 1, JOF_LOCAL|JOF_NAME) \ + MACRO(SetLocal, set_local, NULL, 4, 1, 1, JOF_LOCAL) \ /* * Assign to an aliased binding. * @@ -3169,7 +3183,7 @@ * Operands: uint8_t hops, uint24_t slot * Stack: val => val */ \ - MACRO(SetAliasedVar, set_aliased_var, NULL, 5, 1, 1, JOF_ENVCOORD|JOF_NAME|JOF_PROPSET|JOF_USES_ENV) \ + MACRO(SetAliasedVar, set_aliased_var, NULL, 5, 1, 1, JOF_ENVCOORD|JOF_PROPSET|JOF_USES_ENV) \ /* * Assign to an intrinsic. * @@ -3183,7 +3197,7 @@ * Operands: uint32_t nameIndex * Stack: val => val */ \ - MACRO(SetIntrinsic, set_intrinsic, NULL, 5, 1, 1, JOF_ATOM|JOF_NAME) \ + MACRO(SetIntrinsic, set_intrinsic, NULL, 5, 1, 1, JOF_ATOM) \ /* * Push a lexical environment onto the environment chain. * @@ -3429,7 +3443,7 @@ * Operands: uint32_t nameIndex * Stack: => succeeded */ \ - MACRO(DelName, del_name, NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_CHECKSLOPPY|JOF_USES_ENV) \ + MACRO(DelName, del_name, NULL, 5, 0, 1, JOF_ATOM|JOF_CHECKSLOPPY|JOF_USES_ENV) \ /* * Create and push the `arguments` object for the current function activation. * @@ -3635,14 +3649,13 @@ * a power of two. Use this macro to do so. */ #define FOR_EACH_TRAILING_UNUSED_OPCODE(MACRO) \ - IF_RECORD_TUPLE(/* empty */, MACRO(235)) \ IF_RECORD_TUPLE(/* empty */, MACRO(236)) \ IF_RECORD_TUPLE(/* empty */, MACRO(237)) \ IF_RECORD_TUPLE(/* empty */, MACRO(238)) \ IF_RECORD_TUPLE(/* empty */, MACRO(239)) \ IF_RECORD_TUPLE(/* empty */, MACRO(240)) \ IF_RECORD_TUPLE(/* empty */, MACRO(241)) \ - MACRO(242) \ + IF_RECORD_TUPLE(/* empty */, MACRO(242)) \ MACRO(243) \ MACRO(244) \ MACRO(245) \ diff --git a/js/src/vm/PortableBaselineInterpret.cpp b/js/src/vm/PortableBaselineInterpret.cpp index 2588f12009..17310a325d 100644 --- a/js/src/vm/PortableBaselineInterpret.cpp +++ b/js/src/vm/PortableBaselineInterpret.cpp @@ -47,6 +47,7 @@ #include "vm/Opcodes.h" #include "vm/PlainObject.h" #include "vm/Shape.h" +#include "vm/TypeofEqOperand.h" // TypeofEqOperand #include "debugger/DebugAPI-inl.h" #include "jit/BaselineFrame-inl.h" @@ -1262,9 +1263,8 @@ ICInterpretOps(BaselineFrame* frame, VMFrameManager& frameMgr, State& state, CACHEOP_CASE(GuardFunctionHasJitEntry) { ObjOperandId funId = icregs.cacheIRReader.objOperandId(); - bool constructing = icregs.cacheIRReader.readBool(); JSObject* fun = reinterpret_cast<JSObject*>(icregs.icVals[funId.id()]); - uint16_t flags = FunctionFlags::HasJitEntryFlags(constructing); + uint16_t flags = FunctionFlags::HasJitEntryFlags(); if (!fun->as<JSFunction>().flags().hasFlags(flags)) { return ICInterpretOpResult::NextIC; } @@ -1274,7 +1274,7 @@ ICInterpretOps(BaselineFrame* frame, VMFrameManager& frameMgr, State& state, CACHEOP_CASE(GuardFunctionHasNoJitEntry) { ObjOperandId funId = icregs.cacheIRReader.objOperandId(); JSObject* fun = reinterpret_cast<JSObject*>(icregs.icVals[funId.id()]); - uint16_t flags = FunctionFlags::HasJitEntryFlags(/*constructing =*/false); + uint16_t flags = FunctionFlags::HasJitEntryFlags(); if (fun->as<JSFunction>().flags().hasFlags(flags)) { return ICInterpretOpResult::NextIC; } @@ -1714,6 +1714,7 @@ ICInterpretOps(BaselineFrame* frame, VMFrameManager& frameMgr, State& state, v = Int32Value(rhs); break; + case Scalar::Float16: case Scalar::Float32: case Scalar::Float64: v = Value::fromRawBits(rhs); @@ -2690,6 +2691,7 @@ ICInterpretOps(BaselineFrame* frame, VMFrameManager& frameMgr, State& state, CACHEOP_CASE_UNIMPL(LoadConstantString) CACHEOP_CASE_UNIMPL(LoadInstanceOfObjectResult) CACHEOP_CASE_UNIMPL(LoadTypeOfObjectResult) + CACHEOP_CASE_UNIMPL(LoadTypeOfEqObjectResult) CACHEOP_CASE_UNIMPL(DoubleAddResult) CACHEOP_CASE_UNIMPL(DoubleSubResult) CACHEOP_CASE_UNIMPL(DoubleMulResult) @@ -2876,6 +2878,14 @@ DEFINE_IC(Typeof, 1, { } }); +DEFINE_IC(TypeofEq, 1, { + IC_LOAD_VAL(value0, 0); + PUSH_FALLBACK_IC_FRAME(); + if (!DoTypeOfEqFallback(cx, frame, fallback, value0, &state.res)) { + goto error; + } +}); + DEFINE_IC(GetName, 1, { IC_LOAD_OBJ(obj0, 0); PUSH_FALLBACK_IC_FRAME(); @@ -3423,6 +3433,23 @@ PBIResult PortableBaselineInterpret(JSContext* cx_, State& state, Stack& stack, END_OP(Typeof); } + CASE(TypeofEq) { + if (kHybridICs) { + TypeofEqOperand operand = TypeofEqOperand::fromRawValue(GET_UINT8(pc)); + bool result = js::TypeOfValue(Stack::handle(sp)) == operand.type(); + if (operand.compareOp() == JSOp::Ne) { + result = !result; + } + sp[0] = StackVal(BooleanValue(result)); + NEXT_IC(); + } else { + IC_POP_ARG(0); + INVOKE_IC(TypeofEq); + IC_PUSH_RESULT(); + } + END_OP(TypeofEq); + } + CASE(Pos) { if (sp[0].asValue().isNumber()) { // Nothing! diff --git a/js/src/vm/PropMap.cpp b/js/src/vm/PropMap.cpp index 8c1acaeea8..9fd6fbe3eb 100644 --- a/js/src/vm/PropMap.cpp +++ b/js/src/vm/PropMap.cpp @@ -966,18 +966,20 @@ void PropMapTable::trace(JSTracer* trc) { } #ifdef JSGC_HASH_TABLE_CHECKS -void PropMapTable::checkAfterMovingGC() { - for (Set::Enum e(set_); !e.empty(); e.popFront()) { - PropMap* map = e.front().map(); +void PropMapTable::checkAfterMovingGC(JS::Zone* zone) { + CheckTableAfterMovingGC(set_, [zone](const auto& entry) { + PropMap* map = entry.map(); MOZ_ASSERT(map); - CheckGCThingAfterMovingGC(map); + CheckGCThingAfterMovingGC(map, zone); - PropertyKey key = map->getKey(e.front().index()); + PropertyKey key = map->getKey(entry.index()); MOZ_RELEASE_ASSERT(!key.isVoid()); + if (key.isGCThing()) { + CheckGCThingAfterMovingGC(key.toGCThing(), zone); + } - auto p = lookupRaw(key); - MOZ_RELEASE_ASSERT(p.found() && *p == e.front()); - } + return key; + }); } #endif diff --git a/js/src/vm/PropMap.h b/js/src/vm/PropMap.h index 17792cdfe7..139bba442b 100644 --- a/js/src/vm/PropMap.h +++ b/js/src/vm/PropMap.h @@ -409,7 +409,7 @@ class PropMapTable { void trace(JSTracer* trc); #ifdef JSGC_HASH_TABLE_CHECKS - void checkAfterMovingGC(); + void checkAfterMovingGC(JS::Zone* zone); #endif }; diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp index 5170b072fb..940ca72fa0 100644 --- a/js/src/vm/SelfHosting.cpp +++ b/js/src/vm/SelfHosting.cpp @@ -73,7 +73,8 @@ #include "vm/Compression.h" #include "vm/DateObject.h" #include "vm/ErrorReporting.h" // js::MaybePrintAndClearPendingException -#include "vm/FrameIter.h" // js::ScriptFrameIter +#include "vm/Float16.h" +#include "vm/FrameIter.h" // js::ScriptFrameIter #include "vm/GeneratorObject.h" #include "vm/Interpreter.h" #include "vm/Iteration.h" @@ -1025,6 +1026,8 @@ static bool intrinsic_GetTypedArrayKind(JSContext* cx, unsigned argc, "TYPEDARRAY_KIND_BIGINT64 doesn't match the scalar type"); static_assert(TYPEDARRAY_KIND_BIGUINT64 == Scalar::Type::BigUint64, "TYPEDARRAY_KIND_BIGUINT64 doesn't match the scalar type"); + static_assert(TYPEDARRAY_KIND_FLOAT16 == Scalar::Type::Float16, + "TYPEDARRAY_KIND_FLOAT16 doesn't match the scalar type"); JSObject* obj = &args[0].toObject(); Scalar::Type type = JS_GetArrayBufferViewType(obj); @@ -1235,6 +1238,9 @@ static bool IsTypedArrayBitwiseSlice(Scalar::Type sourceType, case Scalar::Uint32: return targetType == Scalar::Int32 || targetType == Scalar::Uint32; + case Scalar::Float16: + return targetType == Scalar::Float16; + case Scalar::Float32: return targetType == Scalar::Float32; @@ -2204,7 +2210,6 @@ static const JSFunctionSpec intrinsic_functions[] = { JS_INLINABLE_FN("TypedArrayLengthZeroOnOutOfBounds", intrinsic_TypedArrayLengthZeroOnOutOfBounds, 1, 0, IntrinsicTypedArrayLengthZeroOnOutOfBounds), - JS_FN("TypedArrayNativeSort", intrinsic_TypedArrayNativeSort, 1, 0), JS_INLINABLE_FN("UnsafeGetInt32FromReservedSlot", intrinsic_UnsafeGetInt32FromReservedSlot, 2, 0, IntrinsicUnsafeGetInt32FromReservedSlot), @@ -2379,6 +2384,8 @@ static const JSFunctionSpec intrinsic_functions[] = { #ifdef ENABLE_RECORD_TUPLE JS_FN("std_Tuple_unchecked", tuple_construct, 1, 0), #endif + JS_TRAMPOLINE_FN("std_TypedArray_sort", TypedArrayObject::sort, 1, 0, + TypedArraySort), JS_FS_END}; diff --git a/js/src/vm/ShapeZone.cpp b/js/src/vm/ShapeZone.cpp index 760fde2e69..840426de61 100644 --- a/js/src/vm/ShapeZone.cpp +++ b/js/src/vm/ShapeZone.cpp @@ -12,6 +12,7 @@ #include "vm/Shape-inl.h" using namespace js; +using namespace js::gc; void ShapeZone::fixupPropMapShapeTableAfterMovingGC() { for (PropMapShapeSet::Enum e(propMapShapes); !e.empty(); e.popFront()) { @@ -27,73 +28,65 @@ void ShapeZone::fixupPropMapShapeTableAfterMovingGC() { } #ifdef JSGC_HASH_TABLE_CHECKS -void ShapeZone::checkTablesAfterMovingGC() { - // Assert that the moving GC worked and that nothing is left in the tables - // that points into the nursery, and that the hash table entries are - // discoverable. - - for (auto r = initialPropMaps.all(); !r.empty(); r.popFront()) { - SharedPropMap* map = r.front().unbarrieredGet(); - CheckGCThingAfterMovingGC(map); - - InitialPropMapHasher::Lookup lookup(map->getKey(0), - map->getPropertyInfo(0)); - InitialPropMapSet::Ptr ptr = initialPropMaps.lookup(lookup); - MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front()); - } - - for (auto r = baseShapes.all(); !r.empty(); r.popFront()) { - BaseShape* base = r.front().unbarrieredGet(); - CheckGCThingAfterMovingGC(base); - - BaseShapeHasher::Lookup lookup(base->clasp(), base->realm(), base->proto()); - BaseShapeSet::Ptr ptr = baseShapes.lookup(lookup); - MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front()); - } - - for (auto r = initialShapes.all(); !r.empty(); r.popFront()) { - SharedShape* shape = r.front().unbarrieredGet(); - CheckGCThingAfterMovingGC(shape); - - using Lookup = InitialShapeHasher::Lookup; - Lookup lookup(shape->getObjectClass(), shape->realm(), shape->proto(), - shape->numFixedSlots(), shape->objectFlags()); - InitialShapeSet::Ptr ptr = initialShapes.lookup(lookup); - MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front()); - } - - for (auto r = propMapShapes.all(); !r.empty(); r.popFront()) { - SharedShape* shape = r.front().unbarrieredGet(); - CheckGCThingAfterMovingGC(shape); - - using Lookup = PropMapShapeHasher::Lookup; - Lookup lookup(shape->base(), shape->numFixedSlots(), shape->propMap(), - shape->propMapLength(), shape->objectFlags()); - PropMapShapeSet::Ptr ptr = propMapShapes.lookup(lookup); - MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front()); - } - - for (auto r = proxyShapes.all(); !r.empty(); r.popFront()) { - ProxyShape* shape = r.front().unbarrieredGet(); - CheckGCThingAfterMovingGC(shape); - - using Lookup = ProxyShapeHasher::Lookup; - Lookup lookup(shape->getObjectClass(), shape->realm(), shape->proto(), - shape->objectFlags()); - ProxyShapeSet::Ptr ptr = proxyShapes.lookup(lookup); - MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front()); - } - - for (auto r = wasmGCShapes.all(); !r.empty(); r.popFront()) { - WasmGCShape* shape = r.front().unbarrieredGet(); - CheckGCThingAfterMovingGC(shape); - - using Lookup = WasmGCShapeHasher::Lookup; - Lookup lookup(shape->getObjectClass(), shape->realm(), shape->proto(), - shape->recGroup(), shape->objectFlags()); - WasmGCShapeSet::Ptr ptr = wasmGCShapes.lookup(lookup); - MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front()); - } +void ShapeZone::checkTablesAfterMovingGC(JS::Zone* zone) { + CheckTableAfterMovingGC(initialPropMaps, [zone](const auto& entry) { + SharedPropMap* map = entry.unbarrieredGet(); + CheckGCThingAfterMovingGC(map, zone); + PropertyKey key = map->getKey(0); + if (key.isGCThing()) { + CheckGCThingAfterMovingGC(key.toGCThing(), zone); + } + + return InitialPropMapHasher::Lookup(key, map->getPropertyInfo(0)); + }); + + CheckTableAfterMovingGC(baseShapes, [zone](const auto& entry) { + BaseShape* base = entry.unbarrieredGet(); + CheckGCThingAfterMovingGC(base, zone); + CheckProtoAfterMovingGC(base->proto(), zone); + + return BaseShapeHasher::Lookup(base->clasp(), base->realm(), base->proto()); + }); + + CheckTableAfterMovingGC(initialShapes, [zone](const auto& entry) { + SharedShape* shape = entry.unbarrieredGet(); + CheckGCThingAfterMovingGC(shape, zone); + CheckProtoAfterMovingGC(shape->proto(), zone); + + return InitialShapeHasher::Lookup(shape->getObjectClass(), shape->realm(), + shape->proto(), shape->numFixedSlots(), + shape->objectFlags()); + }); + + CheckTableAfterMovingGC(propMapShapes, [zone](const auto& entry) { + SharedShape* shape = entry.unbarrieredGet(); + CheckGCThingAfterMovingGC(shape, zone); + CheckGCThingAfterMovingGC(shape->base(), zone); + CheckGCThingAfterMovingGC(shape->propMap(), zone); + + return PropMapShapeHasher::Lookup(shape->base(), shape->numFixedSlots(), + shape->propMap(), shape->propMapLength(), + shape->objectFlags()); + }); + + CheckTableAfterMovingGC(proxyShapes, [zone](const auto& entry) { + ProxyShape* shape = entry.unbarrieredGet(); + CheckGCThingAfterMovingGC(shape, zone); + CheckProtoAfterMovingGC(shape->proto(), zone); + + return ProxyShapeHasher::Lookup(shape->getObjectClass(), shape->realm(), + shape->proto(), shape->objectFlags()); + }); + + CheckTableAfterMovingGC(wasmGCShapes, [zone](const auto& entry) { + WasmGCShape* shape = entry.unbarrieredGet(); + CheckGCThingAfterMovingGC(shape, zone); + CheckProtoAfterMovingGC(shape->proto(), zone); + + return WasmGCShapeHasher::Lookup(shape->getObjectClass(), shape->realm(), + shape->proto(), shape->recGroup(), + shape->objectFlags()); + }); } #endif // JSGC_HASH_TABLE_CHECKS diff --git a/js/src/vm/ShapeZone.h b/js/src/vm/ShapeZone.h index 784465a395..9680af93d9 100644 --- a/js/src/vm/ShapeZone.h +++ b/js/src/vm/ShapeZone.h @@ -236,7 +236,7 @@ struct ShapeZone { void fixupPropMapShapeTableAfterMovingGC(); #ifdef JSGC_HASH_TABLE_CHECKS - void checkTablesAfterMovingGC(); + void checkTablesAfterMovingGC(JS::Zone* zone); #endif }; diff --git a/js/src/vm/SharedArrayObject.cpp b/js/src/vm/SharedArrayObject.cpp index e3e25e3de5..cf31660692 100644 --- a/js/src/vm/SharedArrayObject.cpp +++ b/js/src/vm/SharedArrayObject.cpp @@ -71,6 +71,23 @@ SharedArrayRawBuffer* SharedArrayRawBuffer::Allocate(bool isGrowable, if (!p) { return nullptr; } + MOZ_ASSERT(reinterpret_cast<uintptr_t>(p) % + ArrayBufferObject::ARRAY_BUFFER_ALIGNMENT == + 0, + "shared array buffer memory is aligned"); + + // jemalloc tiny allocations can produce allocations not aligned to the + // smallest std::malloc allocation. Ensure shared array buffer allocations + // don't have to worry about this special case. + static_assert(sizeof(SharedArrayRawBuffer) > sizeof(void*), + "SharedArrayRawBuffer doesn't fit in jemalloc tiny allocation"); + + static_assert(sizeof(SharedArrayRawBuffer) % + ArrayBufferObject::ARRAY_BUFFER_ALIGNMENT == + 0, + "sizeof(SharedArrayRawBuffer) is a multiple of the array " + "buffer alignment, so |p + sizeof(SharedArrayRawBuffer)| is " + "also array buffer aligned"); uint8_t* buffer = p + sizeof(SharedArrayRawBuffer); return new (p) SharedArrayRawBuffer(isGrowable, buffer, length); @@ -587,6 +604,7 @@ SharedArrayBufferType* SharedArrayBufferObject::NewWith( bool SharedArrayBufferObject::acceptRawBuffer(SharedArrayRawBuffer* buffer, size_t length) { + MOZ_ASSERT(!isInitialized()); if (!zone()->addSharedMemory(buffer, SharedArrayMappedSize(buffer->isWasm(), length), MemoryUse::SharedArrayRawBuffer)) { @@ -595,6 +613,7 @@ bool SharedArrayBufferObject::acceptRawBuffer(SharedArrayRawBuffer* buffer, setFixedSlot(RAWBUF_SLOT, PrivateValue(buffer)); setFixedSlot(LENGTH_SLOT, PrivateValue(length)); + MOZ_ASSERT(isInitialized()); return true; } @@ -605,6 +624,7 @@ void SharedArrayBufferObject::dropRawBuffer() { MemoryUse::SharedArrayRawBuffer); rawBufferObject()->dropReference(); setFixedSlot(RAWBUF_SLOT, UndefinedValue()); + MOZ_ASSERT(!isInitialized()); } SharedArrayRawBuffer* SharedArrayBufferObject::rawBufferObject() const { @@ -639,6 +659,11 @@ void SharedArrayBufferObject::addSizeOfExcludingThis( // the refcount goes down). But that's unlikely and hard to avoid, so we // just live with the risk. const SharedArrayBufferObject& buf = obj->as<SharedArrayBufferObject>(); + + if (MOZ_UNLIKELY(!buf.isInitialized())) { + return; + } + size_t nbytes = buf.byteLengthOrMaxByteLength(); size_t owned = nbytes / buf.rawBufferObject()->refcount(); if (buf.isWasm()) { @@ -683,6 +708,7 @@ SharedArrayBufferObject* SharedArrayBufferObject::createFromNewRawBuffer( if (!obj->acceptRawBuffer(buffer, initialSize)) { buffer->dropReference(); + js::ReportOutOfMemory(cx); return nullptr; } diff --git a/js/src/vm/SharedArrayObject.h b/js/src/vm/SharedArrayObject.h index 525ee78451..e3d14254d4 100644 --- a/js/src/vm/SharedArrayObject.h +++ b/js/src/vm/SharedArrayObject.h @@ -344,6 +344,13 @@ class SharedArrayBufferObject : public ArrayBufferObjectMaybeShared { return rawBufferObject()->volatileByteLength(); } + private: + bool isInitialized() const { + bool initialized = getFixedSlot(RAWBUF_SLOT).isDouble(); + MOZ_ASSERT_IF(initialized, getFixedSlot(LENGTH_SLOT).isDouble()); + return initialized; + } + public: // Returns either the byte length for fixed-length shared arrays. Or the // maximum byte length for growable shared arrays. diff --git a/js/src/vm/StringType-inl.h b/js/src/vm/StringType-inl.h index 4548e5d7ea..5c600531a1 100644 --- a/js/src/vm/StringType-inl.h +++ b/js/src/vm/StringType-inl.h @@ -376,6 +376,7 @@ inline JSDependentString::JSDependentString(JSLinearString* base, size_t start, setLengthAndFlags(length, INIT_DEPENDENT_FLAGS); d.s.u2.nonInlineCharsTwoByte = base->twoByteChars(nogc) + start; } + base->setDependedOn(); d.s.u3.base = base; if (isTenured() && !base->isTenured()) { base->storeBuffer()->putWholeCell(this); diff --git a/js/src/vm/StringType.cpp b/js/src/vm/StringType.cpp index b735b91b71..b6bd22e3d4 100644 --- a/js/src/vm/StringType.cpp +++ b/js/src/vm/StringType.cpp @@ -359,7 +359,7 @@ const char* RepresentationToString(const JSString* s) { template <typename KnownF, typename UnknownF> void ForEachStringFlag(const JSString* str, uint32_t flags, KnownF known, UnknownF unknown) { - for (uint32_t i = js::Bit(3); i < js::Bit(16); i = i << 1) { + for (uint32_t i = js::Bit(3); i < js::Bit(17); i = i << 1) { if (!(flags & i)) { continue; } @@ -406,7 +406,11 @@ void ForEachStringFlag(const JSString* str, uint32_t flags, KnownF known, known("LATIN1_CHARS_BIT"); break; case JSString::ATOM_IS_INDEX_BIT: - known("ATOM_IS_INDEX_BIT"); + if (str->isAtom()) { + known("ATOM_IS_INDEX_BIT"); + } else { + known("ATOM_REF_BIT"); + } break; case JSString::INDEX_VALUE_BIT: known("INDEX_VALUE_BIT"); @@ -418,7 +422,7 @@ void ForEachStringFlag(const JSString* str, uint32_t flags, KnownF known, if (str->isRope()) { known("FLATTEN_VISIT_RIGHT"); } else { - known("NON_DEDUP_BIT"); + known("DEPENDED_ON_BIT"); } break; case JSString::FLATTEN_FINISH_NODE: @@ -429,7 +433,7 @@ void ForEachStringFlag(const JSString* str, uint32_t flags, KnownF known, } else if (str->isAtom()) { known("PINNED_ATOM_BIT"); } else { - unknown(i); + known("NON_DEDUP_BIT"); } break; default: @@ -936,6 +940,7 @@ JSLinearString* JSRope::flattenInternal(JSRope* root) { const size_t wholeLength = root->length(); size_t wholeCapacity; CharT* wholeChars; + uint32_t newRootFlags = 0; AutoCheckCannotGC nogc; @@ -1041,6 +1046,7 @@ finish_node: { StringFlagsForCharType<CharT>(INIT_DEPENDENT_FLAGS)); str->d.s.u3.base = reinterpret_cast<JSLinearString*>(root); /* will be true on exit */ + newRootFlags |= DEPENDED_ON_BIT; // Every interior (rope) node in the rope's tree will be visited during // the traversal and post-barriered here, so earlier additions of @@ -1079,10 +1085,24 @@ finish_root: JSString& left = *leftmostChild; RemoveCellMemory(&left, left.allocSize(), MemoryUse::StringContents); + // Inherit NON_DEDUP_BIT from the leftmost string. + newRootFlags |= left.flags() & NON_DEDUP_BIT; + + // Set root's DEPENDED_ON_BIT because the leftmost string is now a + // dependent. + newRootFlags |= DEPENDED_ON_BIT; + uint32_t flags = INIT_DEPENDENT_FLAGS; if (left.inStringToAtomCache()) { flags |= IN_STRING_TO_ATOM_CACHE; } + // If left was depended on, we need to make sure we preserve that. Even + // though the string that depended on left's buffer will now depend on + // root's buffer, if left is the only edge to root, replacing left with an + // atom ref would break that edge and allow root's buffer to be freed. + if (left.isDependedOn()) { + flags |= DEPENDED_ON_BIT; + } left.setLengthAndFlags(left.length(), StringFlagsForCharType<CharT>(flags)); left.d.s.u3.base = &root->asLinear(); if (left.isTenured() && !root->isTenured()) { @@ -1091,10 +1111,12 @@ finish_root: // being freed (because the leftmost child may have a tenured dependent // string that cannot be updated.) root->storeBuffer()->putWholeCell(&left); - root->setNonDeduplicatable(); + newRootFlags |= NON_DEDUP_BIT; } } + root->setHeaderFlagBit(newRootFlags); + return &root->asLinear(); } @@ -1477,18 +1499,17 @@ uint32_t JSAtom::getIndexSlow() const { : AtomCharsToIndex(twoByteChars(nogc), len); } -// Prevent the actual owner of the string's characters from being deduplicated -// (and thus freeing its characters, which would invalidate the ASSC's chars -// pointer). Intermediate dependent strings on the chain can be deduplicated, -// since the base will be updated to the root base during tenuring anyway and -// the intermediates won't matter. -void PreventRootBaseDeduplication(JSLinearString* s) { +// Ensure that the incoming s.chars pointer is stable, as in, it cannot be +// changed even across a GC. That requires that the string that owns the chars +// not be collected or deduplicated. +void AutoStableStringChars::holdStableChars(JSLinearString* s) { while (s->hasBase()) { s = s->base(); } if (!s->isTenured()) { s->setNonDeduplicatable(); } + s_ = s; } bool AutoStableStringChars::init(JSContext* cx, JSString* s) { @@ -1498,6 +1519,7 @@ bool AutoStableStringChars::init(JSContext* cx, JSString* s) { } MOZ_ASSERT(state_ == Uninitialized); + length_ = linearString->length(); // Inline and nursery-allocated chars may move during a GC, so copy them // out into a temporary malloced buffer. Note that we cannot update the @@ -1516,9 +1538,7 @@ bool AutoStableStringChars::init(JSContext* cx, JSString* s) { twoByteChars_ = linearString->rawTwoByteChars(); } - PreventRootBaseDeduplication(linearString); - - s_ = linearString; + holdStableChars(linearString); return true; } @@ -1529,6 +1549,7 @@ bool AutoStableStringChars::initTwoByte(JSContext* cx, JSString* s) { } MOZ_ASSERT(state_ == Uninitialized); + length_ = linearString->length(); if (linearString->hasLatin1Chars()) { return copyAndInflateLatin1Chars(cx, linearString); @@ -1542,9 +1563,7 @@ bool AutoStableStringChars::initTwoByte(JSContext* cx, JSString* s) { state_ = TwoByte; twoByteChars_ = linearString->rawTwoByteChars(); - PreventRootBaseDeduplication(linearString); - - s_ = linearString; + holdStableChars(linearString); return true; } @@ -1574,16 +1593,18 @@ T* AutoStableStringChars::allocOwnChars(JSContext* cx, size_t count) { bool AutoStableStringChars::copyAndInflateLatin1Chars( JSContext* cx, Handle<JSLinearString*> linearString) { - size_t length = linearString->length(); - char16_t* chars = allocOwnChars<char16_t>(cx, length); + MOZ_ASSERT(state_ == Uninitialized); + MOZ_ASSERT(s_ == nullptr); + + char16_t* chars = allocOwnChars<char16_t>(cx, length_); if (!chars) { return false; } // Copy |src[0..length]| to |dest[0..length]| when copying doesn't narrow and // therefore can't lose information. - auto src = AsChars(Span(linearString->rawLatin1Chars(), length)); - auto dest = Span(chars, length); + auto src = AsChars(Span(linearString->rawLatin1Chars(), length_)); + auto dest = Span(chars, length_); ConvertLatin1toUtf16(src, dest); state_ = TwoByte; @@ -1594,13 +1615,15 @@ bool AutoStableStringChars::copyAndInflateLatin1Chars( bool AutoStableStringChars::copyLatin1Chars( JSContext* cx, Handle<JSLinearString*> linearString) { - size_t length = linearString->length(); - JS::Latin1Char* chars = allocOwnChars<JS::Latin1Char>(cx, length); + MOZ_ASSERT(state_ == Uninitialized); + MOZ_ASSERT(s_ == nullptr); + + JS::Latin1Char* chars = allocOwnChars<JS::Latin1Char>(cx, length_); if (!chars) { return false; } - PodCopy(chars, linearString->rawLatin1Chars(), length); + PodCopy(chars, linearString->rawLatin1Chars(), length_); state_ = Latin1; latin1Chars_ = chars; @@ -1610,13 +1633,15 @@ bool AutoStableStringChars::copyLatin1Chars( bool AutoStableStringChars::copyTwoByteChars( JSContext* cx, Handle<JSLinearString*> linearString) { - size_t length = linearString->length(); - char16_t* chars = allocOwnChars<char16_t>(cx, length); + MOZ_ASSERT(state_ == Uninitialized); + MOZ_ASSERT(s_ == nullptr); + + char16_t* chars = allocOwnChars<char16_t>(cx, length_); if (!chars) { return false; } - PodCopy(chars, linearString->rawTwoByteChars(), length); + PodCopy(chars, linearString->rawTwoByteChars(), length_); state_ = TwoByte; twoByteChars_ = chars; @@ -2501,6 +2526,55 @@ bool JSString::fillWithRepresentatives(JSContext* cx, return true; } +bool JSString::tryReplaceWithAtomRef(JSAtom* atom) { + MOZ_ASSERT(!isAtomRef()); + + if (isDependedOn() || isInline() || isExternal()) { + return false; + } + + AutoCheckCannotGC nogc; + if (hasOutOfLineChars()) { + void* buffer = asLinear().nonInlineCharsRaw(); + // This is a little cheeky and so deserves a comment. If the string is + // not tenured, then either its buffer lives purely in the nursery, in + // which case it will just be forgotten and blown away in the next + // minor GC, or it is tracked in the nursery's mallocedBuffers hashtable, + // in which case it will be freed for us in the next minor GC. We opt + // to let the GC take care of it since there's a chance it will run + // during idle time. + if (isTenured()) { + RemoveCellMemory(this, allocSize(), MemoryUse::StringContents); + js_free(buffer); + } + } + + // Pre-barrier for d.s.u3 which is overwritten and d.s.u2 which is ignored + // for atom refs. + MOZ_ASSERT(isRope() || isLinear()); + if (isRope()) { + PreWriteBarrier(d.s.u2.left); + PreWriteBarrier(d.s.u3.right); + } else if (isDependent()) { + PreWriteBarrier(d.s.u3.base); + } + + uint32_t flags = INIT_ATOM_REF_FLAGS; + d.s.u3.atom = atom; + if (atom->hasLatin1Chars()) { + flags |= LATIN1_CHARS_BIT; + setLengthAndFlags(length(), flags); + setNonInlineChars(atom->chars<Latin1Char>(nogc)); + } else { + setLengthAndFlags(length(), flags); + setNonInlineChars(atom->chars<char16_t>(nogc)); + } + // Redundant, but just a reminder that this needs to be true or else we need + // to check and conditionally put ourselves in the store buffer + MOZ_ASSERT(atom->isTenured()); + return true; +} + /*** Conversions ************************************************************/ UniqueChars js::EncodeLatin1(JSContext* cx, JSString* str) { diff --git a/js/src/vm/StringType.h b/js/src/vm/StringType.h index 38dea85c60..4073c45c70 100644 --- a/js/src/vm/StringType.h +++ b/js/src/vm/StringType.h @@ -147,6 +147,8 @@ bool CheckStringIsIndex(const CharT* s, size_t length, uint32_t* indexp); * JSLinearString latin1Chars, twoByteChars / - * | * +-- JSDependentString base / - + * | | + * | +-- JSAtomRefString - / base points to an atom * | * +-- JSExternalString - / char array memory managed by embedding * | @@ -275,6 +277,7 @@ class JSString : public js::gc::CellWithLengthAndFlags { } u2; union { JSLinearString* base; /* JSDependentString */ + JSAtom* atom; /* JSAtomRefString */ JSString* right; /* JSRope */ size_t capacity; /* JSLinearString (extensible) */ const JSExternalStringCallbacks* @@ -317,28 +320,30 @@ class JSString : public js::gc::CellWithLengthAndFlags { * String Instance Subtype * type encoding predicate * ----------------------------------------- - * Rope 000000 000 xxxx0x xxx - * Linear 000010 000 xxxx1x xxx - * Dependent 000110 000 xxx1xx xxx - * External 100010 000 100010 xxx - * Extensible 010010 000 010010 xxx - * Inline 001010 000 xx1xxx xxx - * FatInline 011010 000 x11xxx xxx - * JSAtom - xxxxx1 xxx - * NormalAtom 000011 000 xx0xx1 xxx - * PermanentAtom 100011 000 1xxxx1 xxx - * ThinInlineAtom 001011 000 x01xx1 xxx - * FatInlineAtom 011011 000 x11xx1 xxx - * |||||| ||| - * |||||| ||\- [0] reserved (FORWARD_BIT) - * |||||| |\-- [1] reserved - * |||||| \--- [2] reserved - * |||||\----- [3] IsAtom - * ||||\------ [4] IsLinear - * |||\------- [5] IsDependent - * ||\-------- [6] IsInline - * |\--------- [7] FatInlineAtom/Extensible - * \---------- [8] External/Permanent + * Rope 0000000 000 xxxxx0x xxx + * Linear 0000010 000 xxxxx1x xxx + * Dependent 0000110 000 xxxx1xx xxx + * AtomRef 1000110 000 1xxxxxx xxx + * External 0100010 000 x100010 xxx + * Extensible 0010010 000 x010010 xxx + * Inline 0001010 000 xxx1xxx xxx + * FatInline 0011010 000 xx11xxx xxx + * JSAtom - xxxxxx1 xxx + * NormalAtom 0000011 000 xxx0xx1 xxx + * PermanentAtom 0100011 000 x1xxxx1 xxx + * ThinInlineAtom 0001011 000 xx01xx1 xxx + * FatInlineAtom 0011011 000 xx11xx1 xxx + * ||||||| ||| + * ||||||| ||\- [0] reserved (FORWARD_BIT) + * ||||||| |\-- [1] reserved + * ||||||| \--- [2] reserved + * ||||||\----- [3] IsAtom + * |||||\------ [4] IsLinear + * ||||\------- [5] IsDependent + * |||\-------- [6] IsInline + * ||\--------- [7] FatInlineAtom/Extensible + * |\---------- [8] External/Permanent + * \----------- [9] AtomRef * * Bits 0..2 are reserved for use by the GC (see * gc::CellFlagBitsReservedForGC). In particular, bit 0 is currently used for @@ -364,6 +369,8 @@ class JSString : public js::gc::CellWithLengthAndFlags { static const uint32_t LINEAR_BIT = js::Bit(4); static const uint32_t DEPENDENT_BIT = js::Bit(5); static const uint32_t INLINE_CHARS_BIT = js::Bit(6); + // Indicates a dependent string pointing to an atom + static const uint32_t ATOM_REF_BIT = js::Bit(9); static const uint32_t LINEAR_IS_EXTENSIBLE_BIT = js::Bit(7); static const uint32_t INLINE_IS_FAT_BIT = js::Bit(7); @@ -383,11 +390,19 @@ class JSString : public js::gc::CellWithLengthAndFlags { static const uint32_t INIT_ROPE_FLAGS = 0; static const uint32_t INIT_LINEAR_FLAGS = LINEAR_BIT; static const uint32_t INIT_DEPENDENT_FLAGS = LINEAR_BIT | DEPENDENT_BIT; + static const uint32_t INIT_ATOM_REF_FLAGS = + INIT_DEPENDENT_FLAGS | ATOM_REF_BIT; - static const uint32_t TYPE_FLAGS_MASK = js::BitMask(9) - js::BitMask(3); + static const uint32_t TYPE_FLAGS_MASK = js::BitMask(10) - js::BitMask(3); static_assert((TYPE_FLAGS_MASK & js::gc::HeaderWord::RESERVED_MASK) == 0, "GC reserved bits must not be used for Strings"); + // Whether this atom's characters store an uint32 index value less than or + // equal to MAX_ARRAY_INDEX. This bit means something different if the + // string is not an atom (see ATOM_REF_BIT) + // See JSLinearString::isIndex. + static const uint32_t ATOM_IS_INDEX_BIT = js::Bit(9); + // Linear strings: // - Content and representation are Latin-1 characters. // - Unmodifiable after construction. @@ -397,12 +412,7 @@ class JSString : public js::gc::CellWithLengthAndFlags { // - Flag may be cleared when the rope is changed into a dependent string. // // Also see LATIN1_CHARS_BIT description under "Flag Encoding". - static const uint32_t LATIN1_CHARS_BIT = js::Bit(9); - - // Whether this atom's characters store an uint32 index value less than or - // equal to MAX_ARRAY_INDEX. Not used for non-atomized strings. - // See JSLinearString::isIndex. - static const uint32_t ATOM_IS_INDEX_BIT = js::Bit(10); + static const uint32_t LATIN1_CHARS_BIT = js::Bit(10); static const uint32_t INDEX_VALUE_BIT = js::Bit(11); static const uint32_t INDEX_VALUE_SHIFT = 16; @@ -424,6 +434,11 @@ class JSString : public js::gc::CellWithLengthAndFlags { static const uint32_t FLATTEN_MASK = FLATTEN_VISIT_RIGHT | FLATTEN_FINISH_NODE; + // Indicates that this string is depended on by another string. A rope should + // never be depended on, and this should never be set during flattening, so + // we can reuse the FLATTEN_VISIT_RIGHT bit. + static const uint32_t DEPENDED_ON_BIT = FLATTEN_VISIT_RIGHT; + static const uint32_t PINNED_ATOM_BIT = js::Bit(15); static const uint32_t PERMANENT_ATOM_MASK = ATOM_BIT | PINNED_ATOM_BIT | ATOM_IS_PERMANENT_BIT; @@ -543,6 +558,35 @@ class JSString : public js::gc::CellWithLengthAndFlags { return flags() >> INDEX_VALUE_SHIFT; } + /* + * Whether any dependent strings point to this string's chars. This is needed + * so that we don't replace the string with a forwarded atom and free its + * buffer. + * + * NOTE: we specifically do not set this for atoms, because they are accessed + * on many threads and we don't want to mess with their flags if we don't + * have to, and it is safe because atoms will never be replaced by an atom + * ref. + */ + bool isDependedOn() const { + bool result = flags() & DEPENDED_ON_BIT; + MOZ_ASSERT_IF(result, !isRope() && !isAtom()); + return result; + } + + bool assertIsValidBase() const { + // See isDependedOn comment for why we're excluding atoms + return isAtom() || isDependedOn(); + } + + void setDependedOn() { + MOZ_ASSERT(!isRope()); + if (isAtom()) { + return; + } + setFlagBit(DEPENDED_ON_BIT); + } + inline size_t allocSize() const; /* Fallible conversions to more-derived string types. */ @@ -573,6 +617,11 @@ class JSString : public js::gc::CellWithLengthAndFlags { bool isDependent() const { return flags() & DEPENDENT_BIT; } MOZ_ALWAYS_INLINE + bool isAtomRef() const { + return (flags() & ATOM_REF_BIT) && !(flags() & ATOM_BIT); + } + + MOZ_ALWAYS_INLINE JSDependentString& asDependent() const { MOZ_ASSERT(isDependent()); return *(JSDependentString*)this; @@ -668,6 +717,8 @@ class JSString : public js::gc::CellWithLengthAndFlags { inline JSLinearString* base() const; + inline JSAtom* atom() const; + // The base may be forwarded and becomes a relocation overlay. // The return value can be a relocation overlay when the base is forwarded, // or the return value can be the actual base when it is not forwarded. @@ -678,6 +729,8 @@ class JSString : public js::gc::CellWithLengthAndFlags { // Only called by the GC during nursery collection. inline void setBase(JSLinearString* newBase); + bool tryReplaceWithAtomRef(JSAtom* atom); + void traceBase(JSTracer* trc); /* Only called by the GC for strings with the AllocKind::STRING kind. */ @@ -1182,6 +1235,20 @@ class JSDependentString : public JSLinearString { static_assert(sizeof(JSDependentString) == sizeof(JSString), "string subclasses must be binary-compatible with JSString"); +class JSAtomRefString : public JSDependentString { + friend class JSString; + friend class js::gc::CellAllocator; + friend class js::jit::MacroAssembler; + + public: + inline static size_t offsetOfAtom() { + return offsetof(JSAtomRefString, d.s.u3.atom); + } +}; + +static_assert(sizeof(JSAtomRefString) == sizeof(JSString), + "string subclasses must be binary-compatible with JSString"); + class JSExtensibleString : public JSLinearString { /* Vacuous and therefore unimplemented. */ bool isExtensible() const = delete; @@ -1737,7 +1804,9 @@ inline JSLinearString* NewStringCopy( } /* Copy a counted string and GC-allocate a descriptor for it. */ -template <js::AllowGC allowGC, typename CharT> +template < + js::AllowGC allowGC, typename CharT, + typename std::enable_if_t<!std::is_same_v<CharT, unsigned char>>* = nullptr> inline JSLinearString* NewStringCopy( JSContext* cx, std::basic_string_view<CharT> s, js::gc::Heap heap = js::gc::Heap::Default) { @@ -2030,10 +2099,19 @@ MOZ_ALWAYS_INLINE JSLinearString* JSString::ensureLinear(JSContext* cx) { inline JSLinearString* JSString::base() const { MOZ_ASSERT(hasBase()); - MOZ_ASSERT(!d.s.u3.base->isInline()); + MOZ_ASSERT_IF(!isAtomRef(), !d.s.u3.base->isInline()); + MOZ_ASSERT(d.s.u3.base->assertIsValidBase()); + if (isAtomRef()) { + return static_cast<JSLinearString*>(d.s.u3.atom); + } return d.s.u3.base; } +inline JSAtom* JSString::atom() const { + MOZ_ASSERT(isAtomRef()); + return d.s.u3.atom; +} + inline JSLinearString* JSString::nurseryBaseOrRelocOverlay() const { MOZ_ASSERT(hasBase()); return d.s.u3.base; @@ -2184,7 +2262,9 @@ MOZ_ALWAYS_INLINE bool JSAtom::lengthFitsInline<char16_t>(size_t length) { template <> MOZ_ALWAYS_INLINE void JSString::setNonInlineChars(const char16_t* chars) { // Check that the new buffer is located in the StringBufferArena - checkStringCharsArena(chars); + if (!(isAtomRef() && atom()->isInline())) { + checkStringCharsArena(chars); + } d.s.u2.nonInlineCharsTwoByte = chars; } @@ -2192,7 +2272,9 @@ template <> MOZ_ALWAYS_INLINE void JSString::setNonInlineChars( const JS::Latin1Char* chars) { // Check that the new buffer is located in the StringBufferArena - checkStringCharsArena(chars); + if (!(isAtomRef() && atom()->isInline())) { + checkStringCharsArena(chars); + } d.s.u2.nonInlineCharsLatin1 = chars; } diff --git a/js/src/vm/TypedArrayObject-inl.h b/js/src/vm/TypedArrayObject-inl.h index ffb9a3c9f6..741ebe27fb 100644 --- a/js/src/vm/TypedArrayObject-inl.h +++ b/js/src/vm/TypedArrayObject-inl.h @@ -28,6 +28,7 @@ #include "util/Memory.h" #include "vm/ArrayObject.h" #include "vm/BigIntType.h" +#include "vm/Float16.h" #include "vm/NativeObject.h" #include "vm/Uint8Clamped.h" @@ -41,6 +42,68 @@ template <typename To, typename From> inline To ConvertNumber(From src); template <> +inline int8_t ConvertNumber<int8_t, float16>(float16 src) { + return JS::ToInt8(src.toDouble()); +} + +template <> +inline uint8_t ConvertNumber<uint8_t, float16>(float16 src) { + return JS::ToUint8(src.toDouble()); +} + +template <> +inline uint8_clamped ConvertNumber<uint8_clamped, float16>(float16 src) { + return uint8_clamped(src.toDouble()); +} + +template <> +inline float16 ConvertNumber<float16, float16>(float16 src) { + return src; +} + +template <> +inline int16_t ConvertNumber<int16_t, float16>(float16 src) { + return JS::ToInt16(src.toDouble()); +} + +template <> +inline uint16_t ConvertNumber<uint16_t, float16>(float16 src) { + return JS::ToUint16(src.toDouble()); +} + +template <> +inline int32_t ConvertNumber<int32_t, float16>(float16 src) { + return JS::ToInt32(src.toDouble()); +} + +template <> +inline uint32_t ConvertNumber<uint32_t, float16>(float16 src) { + return JS::ToUint32(src.toDouble()); +} + +template <> +inline int64_t ConvertNumber<int64_t, float16>(float16 src) { + return JS::ToInt64(src.toDouble()); +} + +template <> +inline uint64_t ConvertNumber<uint64_t, float16>(float16 src) { + return JS::ToUint64(src.toDouble()); +} + +// Float16 is a bit of a special case in that it's floating point, +// but std::is_floating_point_v doesn't know about it. +template <> +inline float ConvertNumber<float, float16>(float16 src) { + return static_cast<float>(src.toDouble()); +} + +template <> +inline double ConvertNumber<double, float16>(float16 src) { + return src.toDouble(); +} + +template <> inline int8_t ConvertNumber<int8_t, float>(float src) { return JS::ToInt8(src); } @@ -56,6 +119,11 @@ inline uint8_clamped ConvertNumber<uint8_clamped, float>(float src) { } template <> +inline float16 ConvertNumber<float16, float>(float src) { + return float16(src); +} + +template <> inline int16_t ConvertNumber<int16_t, float>(float src) { return JS::ToInt16(src); } @@ -101,6 +169,11 @@ inline uint8_clamped ConvertNumber<uint8_clamped, double>(double src) { } template <> +inline float16 ConvertNumber<float16, double>(double src) { + return float16(src); +} + +template <> inline int16_t ConvertNumber<int16_t, double>(double src) { return JS::ToInt16(src); } @@ -183,6 +256,11 @@ struct TypeIDOfType<uint64_t> { static const JSProtoKey protoKey = JSProto_BigUint64Array; }; template <> +struct TypeIDOfType<float16> { + static const Scalar::Type id = Scalar::Float16; + static const JSProtoKey protoKey = JSProto_Float16Array; +}; +template <> struct TypeIDOfType<float> { static const Scalar::Type id = Scalar::Float32; static const JSProtoKey protoKey = JSProto_Float32Array; @@ -309,11 +387,25 @@ class ElementSpecific { MOZ_ASSERT(offset <= targetLength); MOZ_ASSERT(sourceLength <= targetLength - offset); + // Return early when copying no elements. + // + // Note: `SharedMem::cast` asserts the memory is properly aligned. Non-zero + // memory is correctly aligned, this is statically asserted below. Zero + // memory can have a different alignment, so we have to return early. + if (sourceLength == 0) { + return true; + } + if (TypedArrayObject::sameBuffer(target, source)) { return setFromOverlappingTypedArray(target, targetLength, source, sourceLength, offset); } + // `malloc` returns memory at least as strictly aligned as for max_align_t + // and the alignment of max_align_t is a multiple of the size of `T`, + // so `SharedMem::cast` will be called with properly aligned memory. + static_assert(alignof(std::max_align_t) % sizeof(T) == 0); + SharedMem<T*> dest = target->dataPointerEither().template cast<T*>() + offset; size_t count = sourceLength; @@ -383,6 +475,13 @@ class ElementSpecific { } break; } + case Scalar::Float16: { + SharedMem<float16*> src = data.cast<float16*>(); + for (size_t i = 0; i < count; ++i) { + Ops::store(dest++, ConvertNumber<T>(Ops::load(src++))); + } + break; + } case Scalar::Float32: { SharedMem<float*> src = data.cast<float*>(); for (size_t i = 0; i < count; ++i) { diff --git a/js/src/vm/TypedArrayObject.cpp b/js/src/vm/TypedArrayObject.cpp index 935a902abe..1594bf7e30 100644 --- a/js/src/vm/TypedArrayObject.cpp +++ b/js/src/vm/TypedArrayObject.cpp @@ -12,6 +12,7 @@ #include "mozilla/IntegerTypeTraits.h" #include "mozilla/Likely.h" #include "mozilla/PodOperations.h" +#include "mozilla/ScopeExit.h" #include "mozilla/TextUtils.h" #include <algorithm> @@ -33,6 +34,7 @@ #include "gc/Barrier.h" #include "gc/MaybeRooted.h" #include "jit/InlinableNatives.h" +#include "jit/TrampolineNatives.h" #include "js/Conversions.h" #include "js/experimental/TypedData.h" // JS_GetArrayBufferViewType, JS_GetTypedArray{Length,ByteOffset,ByteLength}, JS_IsTypedArrayObject #include "js/friend/ErrorMessages.h" // js::GetErrorMessage, JSMSG_* @@ -45,8 +47,10 @@ #include "util/Text.h" #include "util/WindowsWrapper.h" #include "vm/ArrayBufferObject.h" +#include "vm/Float16.h" #include "vm/FunctionFlags.h" // js::FunctionFlags #include "vm/GlobalObject.h" +#include "vm/Interpreter.h" #include "vm/JSContext.h" #include "vm/JSObject.h" #include "vm/PIC.h" @@ -55,6 +59,7 @@ #include "vm/Uint8Clamped.h" #include "vm/WrapperObject.h" +#include "builtin/Sorting-inl.h" #include "gc/Nursery-inl.h" #include "vm/ArrayBufferObject-inl.h" #include "vm/Compartment-inl.h" @@ -94,6 +99,7 @@ bool TypedArrayObject::convertValue(JSContext* cx, HandleValue v, case Scalar::Uint16: case Scalar::Int32: case Scalar::Uint32: + case Scalar::Float16: case Scalar::Float32: case Scalar::Float64: case Scalar::Uint8Clamped: { @@ -3153,7 +3159,7 @@ static bool uint8array_toHex(JSContext* cx, unsigned argc, Value* vp) { JS_SELF_HOSTED_FN("reverse", "TypedArrayReverse", 0, 0), JS_SELF_HOSTED_FN("slice", "TypedArraySlice", 2, 0), JS_SELF_HOSTED_FN("some", "TypedArraySome", 1, 0), - JS_SELF_HOSTED_FN("sort", "TypedArraySort", 1, 0), + JS_TRAMPOLINE_FN("sort", TypedArrayObject::sort, 1, 0, TypedArraySort), JS_SELF_HOSTED_FN("entries", "TypedArrayEntries", 0, 0), JS_SELF_HOSTED_FN("keys", "TypedArrayKeys", 0, 0), JS_SELF_HOSTED_FN("values", "$TypedArrayValues", 0, 0), @@ -3236,6 +3242,25 @@ bool TypedArrayObjectTemplate<uint32_t>::getElementPure( } template <> +bool TypedArrayObjectTemplate<float16>::getElementPure(TypedArrayObject* tarray, + size_t index, + Value* vp) { + float16 f16 = getIndex(tarray, index); + /* + * Doubles in typed arrays could be typed-punned arrays of integers. This + * could allow user code to break the engine-wide invariant that only + * canonical nans are stored into jsvals, which means user code could + * confuse the engine into interpreting a double-typed jsval as an + * object-typed jsval. + * + * This could be removed for platforms/compilers known to convert a 32-bit + * non-canonical nan to a 64-bit canonical nan. + */ + *vp = JS::CanonicalizedDoubleValue(f16.toDouble()); + return true; +} + +template <> bool TypedArrayObjectTemplate<float>::getElementPure(TypedArrayObject* tarray, size_t index, Value* vp) { float val = getIndex(tarray, index); @@ -3373,8 +3398,8 @@ bool TypedArrayObject::getElementPure(size_t index, Value* vp) { /* static */ bool TypedArrayObject::getElements(JSContext* cx, Handle<TypedArrayObject*> tarray, - Value* vp) { - size_t length = tarray->length().valueOr(0); + size_t length, Value* vp) { + MOZ_ASSERT(length <= tarray->length().valueOr(0)); MOZ_ASSERT_IF(length > 0, !tarray->hasDetachedBuffer()); switch (tarray->type()) { @@ -3934,6 +3959,26 @@ static constexpr return val ^ FloatingPoint::kSignBit; } +template <typename T, typename UnsignedT> +static constexpr + typename std::enable_if_t<std::is_same_v<T, float16>, UnsignedT> + UnsignedSortValue(UnsignedT val) { + // Flip sign bit for positive numbers; flip all bits for negative numbers, + // except negative NaNs. + + // FC00 is negative infinity, (FC00, FFFF] are all NaNs with + // the sign-bit set. So any value + // larger than negative infinity is a negative NaN. + constexpr UnsignedT NegativeInfinity = 0xFC00; + if (val > NegativeInfinity) { + return val; + } + if (val & 0x8000) { + return ~val; + } + return val ^ 0x8000; +} + template <typename T> static typename std::enable_if_t<std::is_integral_v<T> || std::is_same_v<T, uint8_clamped>> @@ -3943,8 +3988,9 @@ TypedArrayStdSort(SharedMem<void*> data, size_t length) { } template <typename T> -static typename std::enable_if_t<std::is_floating_point_v<T>> TypedArrayStdSort( - SharedMem<void*> data, size_t length) { +static typename std::enable_if_t<std::is_floating_point_v<T> || + std::is_same_v<T, float16>> +TypedArrayStdSort(SharedMem<void*> data, size_t length) { // Sort on the unsigned representation for performance reasons. using UnsignedT = typename mozilla::UnsignedStdintTypeForSize<sizeof(T)>::Type; @@ -4159,7 +4205,13 @@ template <typename T, typename Ops> static constexpr typename std::enable_if_t<sizeof(T) == 2 || sizeof(T) == 4, TypedArraySortFn> TypedArraySort() { - return TypedArrayRadixSort<T, Ops>; + if constexpr (std::is_same_v<T, float16>) { + // TODO: Support radix sort for Float16, see + // https://bugzilla.mozilla.org/show_bug.cgi?id=1893229 + return TypedArrayStdSort<T, Ops>; + } else { + return TypedArrayRadixSort<T, Ops>; + } } template <typename T, typename Ops> @@ -4168,45 +4220,261 @@ TypedArraySort() { return TypedArrayStdSort<T, Ops>; } -bool js::intrinsic_TypedArrayNativeSort(JSContext* cx, unsigned argc, - Value* vp) { - CallArgs args = CallArgsFromVp(argc, vp); - MOZ_ASSERT(args.length() == 1); - - TypedArrayObject* typedArray = - UnwrapAndDowncastValue<TypedArrayObject>(cx, args[0]); - if (!typedArray) { - return false; - } - - auto length = typedArray->length(); - MOZ_RELEASE_ASSERT(length, - "TypedArray is neither detached nor out-of-bounds"); - +static bool TypedArraySortWithoutComparator(JSContext* cx, + TypedArrayObject* typedArray, + size_t len) { bool isShared = typedArray->isSharedMemory(); switch (typedArray->type()) { -#define SORT(_, T, N) \ - case Scalar::N: \ - if (isShared) { \ - if (!TypedArraySort<T, SharedOps>()(cx, typedArray, *length)) { \ - return false; \ - } \ - } else { \ - if (!TypedArraySort<T, UnsharedOps>()(cx, typedArray, *length)) { \ - return false; \ - } \ - } \ +#define SORT(_, T, N) \ + case Scalar::N: \ + if (isShared) { \ + if (!TypedArraySort<T, SharedOps>()(cx, typedArray, len)) { \ + return false; \ + } \ + } else { \ + if (!TypedArraySort<T, UnsharedOps>()(cx, typedArray, len)) { \ + return false; \ + } \ + } \ break; JS_FOR_EACH_TYPED_ARRAY(SORT) #undef SORT default: MOZ_CRASH("Unsupported TypedArray type"); } + return true; +} + +static MOZ_ALWAYS_INLINE bool TypedArraySortPrologue(JSContext* cx, + Handle<Value> thisv, + Handle<Value> comparefn, + ArraySortData* d, + bool* done) { + // https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort + // 23.2.3.29 %TypedArray%.prototype.sort ( comparefn ) + + // Step 1. + if (MOZ_UNLIKELY(!comparefn.isUndefined() && !IsCallable(comparefn))) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_BAD_TYPEDARRAY_SORT_ARG); + return false; + } + + // Steps 2-3. + Rooted<TypedArrayObject*> tarrayUnwrapped( + cx, UnwrapAndTypeCheckValue<TypedArrayObject>(cx, thisv, [cx, &thisv]() { + JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, + JSMSG_INCOMPATIBLE_METHOD, "sort", "method", + InformalValueTypeName(thisv)); + })); + if (!tarrayUnwrapped) { + return false; + } + auto arrayLength = tarrayUnwrapped->length(); + if (!arrayLength) { + ReportOutOfBounds(cx, tarrayUnwrapped); + return false; + } - args.rval().set(args[0]); + // Step 4. + size_t len = *arrayLength; + + // Arrays with less than two elements remain unchanged when sorted. + if (len <= 1) { + d->setReturnValue(&thisv.toObject()); + *done = true; + return true; + } + + // Fast path for sorting without a comparator. + if (comparefn.isUndefined()) { + if (!TypedArraySortWithoutComparator(cx, tarrayUnwrapped, len)) { + return false; + } + d->setReturnValue(&thisv.toObject()); + *done = true; + return true; + } + + // Ensure length * 2 (used below) doesn't overflow UINT32_MAX. + if (MOZ_UNLIKELY(len > UINT32_MAX / 2)) { + ReportAllocationOverflow(cx); + return false; + } + + // Merge sort requires extra scratch space. + bool needsScratchSpace = len > ArraySortData::InsertionSortMaxLength; + + Rooted<ArraySortData::ValueVector> vec(cx); + if (MOZ_UNLIKELY(!vec.resize(needsScratchSpace ? (2 * len) : len))) { + ReportOutOfMemory(cx); + return false; + } + + // Copy elements to JS Value vector. + if (!TypedArrayObject::getElements(cx, tarrayUnwrapped, len, vec.begin())) { + return false; + } + + d->init(&thisv.toObject(), &comparefn.toObject(), std::move(vec.get()), len, + len); + + // Continue in ArraySortData::sortTypedArrayWithComparator. + MOZ_ASSERT(!*done); return true; } +// Copies sorted elements back to the typed array. +template <typename T, typename Ops> +static void StoreSortedElements(TypedArrayObject* tarray, Value* elements, + size_t len) { + SharedMem<T*> data = tarray->dataPointerEither().cast<T*>(); + for (size_t i = 0; i < len; i++) { + T val; + if constexpr (TypeIsFloatingPoint<T>()) { + val = elements[i].toDouble(); + } else if constexpr (std::is_same_v<T, int64_t>) { + val = BigInt::toInt64(elements[i].toBigInt()); + } else if constexpr (std::is_same_v<T, uint64_t>) { + val = BigInt::toUint64(elements[i].toBigInt()); + } else if constexpr (std::is_same_v<T, uint32_t>) { + val = uint32_t(elements[i].toNumber()); + } else { + val = elements[i].toInt32(); + } + Ops::store(data + i, val); + } +} + +// static +ArraySortResult ArraySortData::sortTypedArrayWithComparator(ArraySortData* d) { + ArraySortResult result = + sortWithComparatorShared<ArraySortKind::TypedArray>(d); + if (result != ArraySortResult::Done) { + return result; + } + + // Copy sorted elements to the typed array. + JSContext* cx = d->cx(); + Rooted<TypedArrayObject*> tarrayUnwrapped( + cx, UnwrapAndDowncastObject<TypedArrayObject>(cx, d->obj_)); + if (MOZ_UNLIKELY(!tarrayUnwrapped)) { + return ArraySortResult::Failure; + } + + auto length = tarrayUnwrapped->length(); + if (MOZ_LIKELY(length)) { + size_t len = std::min<size_t>(*length, d->denseLen); + Value* elements = d->list; + bool isShared = tarrayUnwrapped->isSharedMemory(); + switch (tarrayUnwrapped->type()) { +#define SORT(_, T, N) \ + case Scalar::N: \ + if (isShared) { \ + StoreSortedElements<T, SharedOps>(tarrayUnwrapped, elements, len); \ + } else { \ + StoreSortedElements<T, UnsharedOps>(tarrayUnwrapped, elements, len); \ + } \ + break; + JS_FOR_EACH_TYPED_ARRAY(SORT) +#undef SORT + default: + MOZ_CRASH("Unsupported TypedArray type"); + } + } + + d->freeMallocData(); + d->setReturnValue(d->obj_); + return ArraySortResult::Done; +} + +// https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort +// 23.2.3.29 %TypedArray%.prototype.sort ( comparefn ) +// static +bool TypedArrayObject::sort(JSContext* cx, unsigned argc, Value* vp) { + AutoJSMethodProfilerEntry pseudoFrame(cx, "[TypedArray].prototype", "sort"); + CallArgs args = CallArgsFromVp(argc, vp); + + // If we have a comparator argument, use the JIT trampoline implementation + // instead. This avoids a performance cliff (especially with large arrays) + // because C++ => JIT calls are much slower than Trampoline => JIT calls. + if (args.hasDefined(0) && jit::IsBaselineInterpreterEnabled()) { + return CallTrampolineNativeJitCode( + cx, jit::TrampolineNative::TypedArraySort, args); + } + + Rooted<ArraySortData> data(cx, cx); + + // On all return paths other than ArraySortData::sortTypedArrayWithComparator + // returning Done, we call freeMallocData to not fail debug assertions. This + // matches the JIT trampoline where we can't rely on C++ destructors. + auto freeData = + mozilla::MakeScopeExit([&]() { data.get().freeMallocData(); }); + + bool done = false; + if (!TypedArraySortPrologue(cx, args.thisv(), args.get(0), data.address(), + &done)) { + return false; + } + if (done) { + args.rval().set(data.get().returnValue()); + return true; + } + + FixedInvokeArgs<2> callArgs(cx); + Rooted<Value> rval(cx); + + while (true) { + ArraySortResult res = + ArraySortData::sortTypedArrayWithComparator(data.address()); + switch (res) { + case ArraySortResult::Failure: + return false; + + case ArraySortResult::Done: + freeData.release(); + args.rval().set(data.get().returnValue()); + return true; + + case ArraySortResult::CallJS: + case ArraySortResult::CallJSSameRealmNoRectifier: + MOZ_ASSERT(data.get().comparatorThisValue().isUndefined()); + MOZ_ASSERT(&args[0].toObject() == data.get().comparator()); + callArgs[0].set(data.get().comparatorArg(0)); + callArgs[1].set(data.get().comparatorArg(1)); + if (!js::Call(cx, args[0], UndefinedHandleValue, callArgs, &rval)) { + return false; + } + data.get().setComparatorReturnValue(rval); + break; + } + } +} + +ArraySortResult js::TypedArraySortFromJit( + JSContext* cx, jit::TrampolineNativeFrameLayout* frame) { + // Initialize the ArraySortData class stored in the trampoline frame. + void* dataUninit = frame->getFrameData<ArraySortData>(); + auto* data = new (dataUninit) ArraySortData(cx); + + Rooted<Value> thisv(cx, frame->thisv()); + Rooted<Value> comparefn(cx); + if (frame->numActualArgs() > 0) { + comparefn = frame->actualArgs()[0]; + } + + bool done = false; + if (!TypedArraySortPrologue(cx, thisv, comparefn, data, &done)) { + return ArraySortResult::Failure; + } + if (done) { + data->freeMallocData(); + return ArraySortResult::Done; + } + + return ArraySortData::sortTypedArrayWithComparator(data); +} + /* JS Public API */ #define IMPL_TYPED_ARRAY_JSAPI_CONSTRUCTORS(ExternalType, NativeType, Name) \ diff --git a/js/src/vm/TypedArrayObject.h b/js/src/vm/TypedArrayObject.h index 6905e83600..a768e4a579 100644 --- a/js/src/vm/TypedArrayObject.h +++ b/js/src/vm/TypedArrayObject.h @@ -22,6 +22,12 @@ namespace js { +enum class ArraySortResult : uint32_t; + +namespace jit { +class TrampolineNativeFrameLayout; +} + /* * TypedArrayObject * @@ -101,11 +107,11 @@ class TypedArrayObject : public ArrayBufferViewObject { bool getElementPure(size_t index, Value* vp); /* - * Copy all elements from this typed array to vp. vp must point to rooted - * memory. + * Copy |length| elements from this typed array to vp. vp must point to rooted + * memory. |length| must not exceed the typed array's current length. */ static bool getElements(JSContext* cx, Handle<TypedArrayObject*> tarray, - Value* vp); + size_t length, Value* vp); static bool GetTemplateObjectForNative(JSContext* cx, Native native, const JS::HandleValueArray args, @@ -131,6 +137,7 @@ class TypedArrayObject : public ArrayBufferViewObject { static bool set(JSContext* cx, unsigned argc, Value* vp); static bool copyWithin(JSContext* cx, unsigned argc, Value* vp); + static bool sort(JSContext* cx, unsigned argc, Value* vp); bool convertValue(JSContext* cx, HandleValue v, MutableHandleValue result) const; @@ -307,10 +314,6 @@ bool DefineTypedArrayElement(JSContext* cx, Handle<TypedArrayObject*> obj, uint64_t index, Handle<PropertyDescriptor> desc, ObjectOpResult& result); -// Sort a typed array in ascending order. The typed array may be wrapped, but -// must not be detached. -bool intrinsic_TypedArrayNativeSort(JSContext* cx, unsigned argc, Value* vp); - static inline constexpr unsigned TypedArrayShift(Scalar::Type viewType) { switch (viewType) { case Scalar::Int8: @@ -319,6 +322,7 @@ static inline constexpr unsigned TypedArrayShift(Scalar::Type viewType) { return 0; case Scalar::Int16: case Scalar::Uint16: + case Scalar::Float16: return 1; case Scalar::Int32: case Scalar::Uint32: @@ -338,6 +342,9 @@ static inline constexpr unsigned TypedArrayElemSize(Scalar::Type viewType) { return 1u << TypedArrayShift(viewType); } +extern ArraySortResult TypedArraySortFromJit( + JSContext* cx, jit::TrampolineNativeFrameLayout* frame); + } // namespace js template <> diff --git a/js/src/vm/TypeofEqOperand.h b/js/src/vm/TypeofEqOperand.h new file mode 100644 index 0000000000..b3236baed6 --- /dev/null +++ b/js/src/vm/TypeofEqOperand.h @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: set ts=8 sts=2 et sw=2 tw=80: + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef vm_TypeofEqOperand_h +#define vm_TypeofEqOperand_h + +#include "mozilla/Assertions.h" // MOZ_ASSERT + +#include <stdint.h> // uint8_t + +#include "jspubtd.h" // JSType +#include "vm/Opcodes.h" // JSOp + +namespace js { + +struct TypeofEqOperand { + static constexpr uint8_t TYPE_MASK = 0x0f; + static constexpr uint8_t NEQ_BIT = 0x80; + + private: + uint8_t value; + + static uint8_t toNeqBit(JSOp compareOp) { + MOZ_ASSERT(compareOp == JSOp::Eq || compareOp == JSOp::Ne); + return compareOp == JSOp::Ne ? NEQ_BIT : 0; + } + + explicit TypeofEqOperand(uint8_t value) : value(value) {} + + public: + TypeofEqOperand(JSType type, JSOp compareOp) + : value(type | toNeqBit(compareOp)) {} + + static TypeofEqOperand fromRawValue(uint8_t value) { + return TypeofEqOperand(value); + } + + JSType type() const { return JSType(value & TYPE_MASK); } + JSOp compareOp() const { return (value & NEQ_BIT) ? JSOp::Ne : JSOp::Eq; } + uint8_t rawValue() const { return value; } +}; + +static_assert((JSTYPE_LIMIT & TypeofEqOperand::TYPE_MASK) == JSTYPE_LIMIT); + +} // namespace js + +#endif // vm_TypeofEqOperand_h diff --git a/js/src/vm/Uint8Clamped.h b/js/src/vm/Uint8Clamped.h index 5cc391f4b7..07a1e5627e 100644 --- a/js/src/vm/Uint8Clamped.h +++ b/js/src/vm/Uint8Clamped.h @@ -9,6 +9,8 @@ #include <stdint.h> +#include "vm/Float16.h" + namespace js { extern uint32_t ClampDoubleToUint8(const double x); @@ -91,6 +93,10 @@ inline constexpr bool TypeIsFloatingPoint() { return false; } template <> +inline constexpr bool TypeIsFloatingPoint<float16>() { + return true; +} +template <> inline constexpr bool TypeIsFloatingPoint<float>() { return true; } diff --git a/js/src/wasm/WasmBinary.h b/js/src/wasm/WasmBinary.h index da17a0a864..4176b3d8c2 100644 --- a/js/src/wasm/WasmBinary.h +++ b/js/src/wasm/WasmBinary.h @@ -709,7 +709,8 @@ inline bool Decoder::readPackedType(const TypeContext& types, *type = RefType::fromTypeCode(TypeCode(code), true); return true; } - case uint8_t(TypeCode::ExnRef): { + case uint8_t(TypeCode::ExnRef): + case uint8_t(TypeCode::NullExnRef): { if (!features.exnref) { return fail("exnref not enabled"); } @@ -792,7 +793,8 @@ inline bool Decoder::readHeapType(const TypeContext& types, case uint8_t(TypeCode::ExternRef): *type = RefType::fromTypeCode(TypeCode(code), nullable); return true; - case uint8_t(TypeCode::ExnRef): { + case uint8_t(TypeCode::ExnRef): + case uint8_t(TypeCode::NullExnRef): { if (!features.exnref) { return fail("exnref not enabled"); } diff --git a/js/src/wasm/WasmBuiltinModule.yaml b/js/src/wasm/WasmBuiltinModule.yaml index 755e0e5e74..eb04ecc7cf 100644 --- a/js/src/wasm/WasmBuiltinModule.yaml +++ b/js/src/wasm/WasmBuiltinModule.yaml @@ -285,7 +285,9 @@ export: fromCharCode params: - 'i32' - result: 'externref' + result: + code: 'extern' + nullable: false fail_mode: FailOnNullPtr uses_memory: false @@ -297,7 +299,9 @@ export: fromCodePoint params: - 'i32' - result: 'externref' + result: + code: 'extern' + nullable: false fail_mode: FailOnNullPtr uses_memory: false @@ -348,7 +352,9 @@ params: - 'externref' - 'externref' - result: 'externref' + result: + code: 'extern' + nullable: false fail_mode: FailOnNullPtr uses_memory: false @@ -362,7 +368,9 @@ - 'externref' - 'i32' - 'i32' - result: 'externref' + result: + code: 'extern' + nullable: false fail_mode: FailOnNullPtr uses_memory: false @@ -393,3 +401,55 @@ uses_memory: false #endif // ENABLE_WASM_JS_STRING_BUILTINS + +#if defined(ENABLE_WASM_JSPI) + +- op: CheckSuspender + symbolic_address: + name: CheckSuspender + type: Args_General2 + entry: CheckSuspender + export: suspenderCheck + params: + - 'externref' + result: 'externref' + fail_mode: FailOnNullPtr + uses_memory: false + +- op: CurrentSuspender + symbolic_address: + name: CurrentSuspender + type: Args_General_GeneralInt32 + entry: CurrentSuspender + export: currentSuspender + params: + - 'i32' + result: 'externref' + fail_mode: FailOnNullPtr + uses_memory: false + +- op: GetSuspendingPromiseResult + symbolic_address: + name: GetSuspendingPromiseResult + type: Args_General2 + entry: GetSuspendingPromiseResult + export: getSuspendingPromiseResult + params: + - 'externref' + result: 'anyref' + fail_mode: FailOnNullPtr + uses_memory: false + +- op: SetPromisingPromiseResults + symbolic_address: + name: SetPromisingPromiseResults + type: Args_Int32_GeneralGeneralGeneral + entry: SetPromisingPromiseResults + export: setPromisingPromiseResults + params: + - 'externref' + - 'anyref' + fail_mode: FailOnNegI32 + uses_memory: false + +#endif // ENABLE_WASM_JSPI diff --git a/js/src/wasm/WasmBuiltins.cpp b/js/src/wasm/WasmBuiltins.cpp index f0773583ac..342f55598f 100644 --- a/js/src/wasm/WasmBuiltins.cpp +++ b/js/src/wasm/WasmBuiltins.cpp @@ -19,6 +19,7 @@ #include "wasm/WasmBuiltins.h" #include "mozilla/Atomics.h" +#include "mozilla/ScopeExit.h" #include "fdlibm.h" #include "jslibmath.h" @@ -42,6 +43,7 @@ #include "wasm/WasmDebugFrame.h" #include "wasm/WasmGcObject.h" #include "wasm/WasmInstance.h" +#include "wasm/WasmPI.h" #include "wasm/WasmStubs.h" #include "debugger/DebugAPI-inl.h" @@ -404,6 +406,15 @@ const SymbolicAddressSignature SASigArrayCopy = { FOR_EACH_BUILTIN_MODULE_FUNC(VISIT_BUILTIN_FUNC) #undef VISIT_BUILTIN_FUNC +#ifdef ENABLE_WASM_JSPI +const SymbolicAddressSignature SASigUpdateSuspenderState = { + SymbolicAddress::UpdateSuspenderState, + _VOID, + _Infallible, + 3, + {_PTR, _PTR, _I32, _END}}; +#endif + } // namespace wasm } // namespace js @@ -660,12 +671,21 @@ bool wasm::HandleThrow(JSContext* cx, WasmFrameIter& iter, // WasmFrameIter iterates down wasm frames in the activation starting at // JitActivation::wasmExitFP(). Calling WasmFrameIter::startUnwinding pops // JitActivation::wasmExitFP() once each time WasmFrameIter is incremented, - // ultimately leaving exit FP null when the WasmFrameIter is done(). This - // is necessary to prevent a DebugFrame from being observed again after we - // just called onLeaveFrame (which would lead to the frame being re-added + // ultimately leaving no wasm exit FP when the WasmFrameIter is done(). This + // is necessary to prevent a wasm::DebugFrame from being observed again after + // we just called onLeaveFrame (which would lead to the frame being re-added // to the map of live frames, right as it becomes trash). MOZ_ASSERT(CallingActivation(cx) == iter.activation()); +#ifdef DEBUG + auto onExit = mozilla::MakeScopeExit([cx] { + MOZ_ASSERT(!cx->activation()->asJit()->isWasmTrapping(), + "unwinding clears the trapping state"); + MOZ_ASSERT(!cx->activation()->asJit()->hasWasmExitFP(), + "unwinding leaves no wasm exit fp"); + }); +#endif + MOZ_ASSERT(!iter.done()); iter.setUnwind(WasmFrameIter::Unwind::True); @@ -722,6 +742,7 @@ bool wasm::HandleThrow(JSContext* cx, WasmFrameIter& iter, if (activation->isWasmTrapping()) { activation->finishWasmTrap(); } + activation->setWasmExitFP(nullptr); return true; } @@ -761,9 +782,6 @@ bool wasm::HandleThrow(JSContext* cx, WasmFrameIter& iter, frame->leave(cx); } - MOZ_ASSERT(!cx->activation()->asJit()->isWasmTrapping(), - "unwinding clears the trapping state"); - // Assert that any pending exception escaping to non-wasm code is not a // wrapper exception object #ifdef DEBUG @@ -1504,6 +1522,13 @@ void* wasm::AddressOf(SymbolicAddress imm, ABIFunctionType* abiType) { MOZ_ASSERT(*abiType == ToABIType(SASigThrowException)); return FuncCast(Instance::throwException, *abiType); +#ifdef ENABLE_WASM_JSPI + case SymbolicAddress::UpdateSuspenderState: + *abiType = Args_Int32_GeneralGeneralInt32; + MOZ_ASSERT(*abiType == ToABIType(SASigUpdateSuspenderState)); + return FuncCast(UpdateSuspenderState, *abiType); +#endif + #ifdef WASM_CODEGEN_DEBUG case SymbolicAddress::PrintI32: *abiType = Args_General1; @@ -1691,6 +1716,9 @@ bool wasm::NeedsBuiltinThunk(SymbolicAddress sym) { case SymbolicAddress::sa_name: FOR_EACH_BUILTIN_MODULE_FUNC(VISIT_BUILTIN_FUNC) #undef VISIT_BUILTIN_FUNC +#ifdef ENABLE_WASM_JSPI + case SymbolicAddress::UpdateSuspenderState: +#endif return true; case SymbolicAddress::Limit: diff --git a/js/src/wasm/WasmBuiltins.h b/js/src/wasm/WasmBuiltins.h index ea6de48327..55f9b55a9c 100644 --- a/js/src/wasm/WasmBuiltins.h +++ b/js/src/wasm/WasmBuiltins.h @@ -146,8 +146,11 @@ enum class SymbolicAddress { #define VISIT_BUILTIN_FUNC(op, export, sa_name, ...) sa_name, FOR_EACH_BUILTIN_MODULE_FUNC(VISIT_BUILTIN_FUNC) #undef VISIT_BUILTIN_FUNC +#ifdef ENABLE_WASM_JSPI + UpdateSuspenderState, +#endif #ifdef WASM_CODEGEN_DEBUG - PrintI32, + PrintI32, PrintPtr, PrintF32, PrintF64, @@ -280,6 +283,7 @@ extern const SymbolicAddressSignature SASigArrayNewElem; extern const SymbolicAddressSignature SASigArrayInitData; extern const SymbolicAddressSignature SASigArrayInitElem; extern const SymbolicAddressSignature SASigArrayCopy; +extern const SymbolicAddressSignature SASigUpdateSuspenderState; #define VISIT_BUILTIN_FUNC(op, export, sa_name, ...) \ extern const SymbolicAddressSignature SASig##sa_name; FOR_EACH_BUILTIN_MODULE_FUNC(VISIT_BUILTIN_FUNC) diff --git a/js/src/wasm/WasmCode.h b/js/src/wasm/WasmCode.h index e03a2f596e..002e4c3846 100644 --- a/js/src/wasm/WasmCode.h +++ b/js/src/wasm/WasmCode.h @@ -364,6 +364,7 @@ struct MetadataCacheablePod { BuiltinModuleIds builtinModules; FeatureUsage featureUsage; bool filenameIsURL; + bool parsedBranchHints; uint32_t typeDefsOffsetStart; uint32_t memoriesOffsetStart; uint32_t tablesOffsetStart; @@ -372,15 +373,16 @@ struct MetadataCacheablePod { WASM_CHECK_CACHEABLE_POD(kind, instanceDataLength, startFuncIndex, nameCustomSectionIndex, builtinModules, featureUsage, - filenameIsURL, typeDefsOffsetStart, - memoriesOffsetStart, tablesOffsetStart, - tagsOffsetStart) + filenameIsURL, parsedBranchHints, + typeDefsOffsetStart, memoriesOffsetStart, + tablesOffsetStart, tagsOffsetStart) explicit MetadataCacheablePod(ModuleKind kind) : kind(kind), instanceDataLength(0), featureUsage(FeatureUsage::None), filenameIsURL(false), + parsedBranchHints(false), typeDefsOffsetStart(UINT32_MAX), memoriesOffsetStart(UINT32_MAX), tablesOffsetStart(UINT32_MAX), diff --git a/js/src/wasm/WasmCodegenTypes.h b/js/src/wasm/WasmCodegenTypes.h index 7e54ad15f7..c01f1d4d37 100644 --- a/js/src/wasm/WasmCodegenTypes.h +++ b/js/src/wasm/WasmCodegenTypes.h @@ -554,6 +554,7 @@ class CallSiteDesc { EnterFrame, // call to a enter frame handler LeaveFrame, // call to a leave frame handler CollapseFrame, // call to a leave frame handler during tail call + StackSwitch, // stack switch point Breakpoint // call to instruction breakpoint }; CallSiteDesc() : lineOrBytecode_(0), kind_(0) {} @@ -576,9 +577,10 @@ class CallSiteDesc { bool isIndirectCall() const { return kind() == CallSiteDesc::Indirect; } bool isFuncRefCall() const { return kind() == CallSiteDesc::FuncRef; } bool isReturnStub() const { return kind() == CallSiteDesc::ReturnStub; } + bool isStackSwitch() const { return kind() == CallSiteDesc::StackSwitch; } bool mightBeCrossInstance() const { return isImportCall() || isIndirectCall() || isFuncRefCall() || - isReturnStub(); + isReturnStub() || isStackSwitch(); } }; diff --git a/js/src/wasm/WasmCompile.cpp b/js/src/wasm/WasmCompile.cpp index fbf4df3e71..516863744f 100644 --- a/js/src/wasm/WasmCompile.cpp +++ b/js/src/wasm/WasmCompile.cpp @@ -170,6 +170,16 @@ FeatureArgs FeatureArgs::build(JSContext* cx, const FeatureOptions& options) { if (features.jsStringBuiltins) { features.builtinModules.jsString = options.jsStringBuiltins; } +#ifdef ENABLE_WASM_GC + if (options.requireGC) { + features.gc = true; + } +#endif +#ifdef ENABLE_WASM_TAIL_CALLS + if (options.requireTailCalls) { + features.tailCalls = true; + } +#endif return features; } diff --git a/js/src/wasm/WasmCompileArgs.h b/js/src/wasm/WasmCompileArgs.h index af85026b93..74b03bfe03 100644 --- a/js/src/wasm/WasmCompileArgs.h +++ b/js/src/wasm/WasmCompileArgs.h @@ -74,7 +74,19 @@ class Tiers { // available under prefs.) struct FeatureOptions { - FeatureOptions() : isBuiltinModule(false), jsStringBuiltins(false) {} + FeatureOptions() + : isBuiltinModule(false), + jsStringBuiltins(false) +#ifdef ENABLE_WASM_GC + , + requireGC(false) +#endif +#ifdef ENABLE_WASM_TAIL_CALLS + , + requireTailCalls(false) +#endif + { + } // Enables builtin module opcodes, only set in WasmBuiltinModule.cpp. bool isBuiltinModule; @@ -82,6 +94,15 @@ struct FeatureOptions { // is also enabled. bool jsStringBuiltins; +#ifdef ENABLE_WASM_GC + // Enable GC support. + bool requireGC; +#endif +#ifdef ENABLE_WASM_TAIL_CALLS + // Enable tail-calls support. + bool requireTailCalls; +#endif + // Parse the compile options bag. [[nodiscard]] bool init(JSContext* cx, HandleValue val); }; diff --git a/js/src/wasm/WasmConstants.h b/js/src/wasm/WasmConstants.h index 0ce741b2d0..8d339d5cf3 100644 --- a/js/src/wasm/WasmConstants.h +++ b/js/src/wasm/WasmConstants.h @@ -94,6 +94,9 @@ enum class TypeCode { // A null reference in the func hierarchy. NullFuncRef = 0x73, // SLEB128(-0x0D) + // A null reference in the exn hierarchy. + NullExnRef = 0x74, // SLEB128(-0x0C) + // A reference to any struct value. StructRef = 0x6b, // SLEB128(-0x15) @@ -994,6 +997,19 @@ struct BuiltinModuleIds { WASM_DECLARE_CACHEABLE_POD(BuiltinModuleIds) +enum class StackSwitchKind { + SwitchToSuspendable, + SwitchToMain, + ContinueOnSuspendable, +}; + +enum class UpdateSuspenderStateAction { + Enter, + Suspend, + Resume, + Leave, +}; + enum class MozOp { // ------------------------------------------------------------------------ // These operators are emitted internally when compiling asm.js and are @@ -1041,6 +1057,8 @@ enum class MozOp { // particular operation id. See BuiltinModuleFuncId above. CallBuiltinModuleFunc, + StackSwitch, + Limit }; @@ -1092,6 +1110,7 @@ struct OpBytes { static const char NameSectionName[] = "name"; static const char SourceMappingURLSectionName[] = "sourceMappingURL"; +static const char BranchHintingSectionName[] = "metadata.code.branch_hint"; enum class NameType { Module = 0, Function = 1, Local = 2 }; @@ -1151,6 +1170,7 @@ static_assert(uint64_t(MaxArrayPayloadBytes) < static const unsigned MaxTryTableCatches = 10000; static const unsigned MaxBrTableElems = 1000000; static const unsigned MaxCodeSectionBytes = MaxModuleBytes; +static const unsigned MaxBranchHintValue = 2; // 512KiB should be enough, considering how Rabaldr uses the stack and // what the standard limits are: @@ -1163,6 +1183,21 @@ static const unsigned MaxCodeSectionBytes = MaxModuleBytes; static const unsigned MaxFrameSize = 512 * 1024; +// Limit for the amount of stacks present in the runtime. +static const size_t SuspendableStacksMaxCount = 100; + +// Max size of an allocated stack. +static const size_t SuspendableStackSize = 0x100000; + +// Size of additional space at the top of a suspendable stack. +// The space is allocated to C++ handlers such as error/trap handlers, +// or stack snapshots utilities. +static const size_t SuspendableRedZoneSize = 0x6000; + +// Total size of a suspendable stack to be reserved. +static constexpr size_t SuspendableStackPlusRedZoneSize = + SuspendableStackSize + SuspendableRedZoneSize; + // Asserted by Decoder::readVarU32. static const unsigned MaxVarU32DecodedBytes = 5; diff --git a/js/src/wasm/WasmContext.h b/js/src/wasm/WasmContext.h index 5064401a81..873f98f1a2 100644 --- a/js/src/wasm/WasmContext.h +++ b/js/src/wasm/WasmContext.h @@ -19,23 +19,61 @@ #ifndef wasm_context_h #define wasm_context_h -namespace js { -namespace wasm { +#include "mozilla/DoublyLinkedList.h" + +namespace js::wasm { + +#ifdef ENABLE_WASM_JSPI + +class SuspenderObject; +class SuspenderObjectData; + +class SuspenderContext { + private: + HeapPtr<SuspenderObject*> activeSuspender_; + // Using double-linked list to avoid allocation in the JIT code. + mozilla::DoublyLinkedList<SuspenderObjectData> suspendedStacks_; + + public: + SuspenderContext(); + ~SuspenderContext(); + SuspenderObject* activeSuspender(); + void setActiveSuspender(SuspenderObject* obj); + void trace(JSTracer* trc); + void traceRoots(JSTracer* trc); + + friend class SuspenderObject; +}; +#endif // ENABLE_WASM_JSPI // wasm::Context lives in JSContext and contains the wasm-related per-context // state. class Context { public: - Context() : triedToInstallSignalHandlers(false), haveSignalHandlers(false) {} + Context() + : triedToInstallSignalHandlers(false), + haveSignalHandlers(false) +#ifdef ENABLE_WASM_JSPI + , + suspendableStackLimit(JS::NativeStackLimitMin), + suspendableStacksCount(0) +#endif + { + } // Used by wasm::EnsureThreadSignalHandlers(cx) to install thread signal // handlers once per JSContext/thread. bool triedToInstallSignalHandlers; bool haveSignalHandlers; + +#ifdef ENABLE_WASM_JSPI + JS::NativeStackLimit suspendableStackLimit; + mozilla::Atomic<uint32_t> suspendableStacksCount; + SuspenderContext promiseIntegration; +#endif }; -} // namespace wasm -} // namespace js +} // namespace js::wasm #endif // wasm_context_h diff --git a/js/src/wasm/WasmDump.cpp b/js/src/wasm/WasmDump.cpp index 2af9ebece2..f92125077a 100644 --- a/js/src/wasm/WasmDump.cpp +++ b/js/src/wasm/WasmDump.cpp @@ -78,6 +78,9 @@ void wasm::Dump(RefType type, GenericPrinter& out) { case RefType::NoFunc: literal = "nullfuncref"; break; + case RefType::NoExn: + literal = "nullexn"; + break; case RefType::NoExtern: literal = "nullexternref"; break; @@ -122,6 +125,9 @@ void wasm::Dump(RefType type, GenericPrinter& out) { case RefType::NoFunc: heapType = "nofunc"; break; + case RefType::NoExn: + heapType = "noexn"; + break; case RefType::NoExtern: heapType = "noextern"; break; diff --git a/js/src/wasm/WasmFrameIter.cpp b/js/src/wasm/WasmFrameIter.cpp index 90555720da..e9f27bbda0 100644 --- a/js/src/wasm/WasmFrameIter.cpp +++ b/js/src/wasm/WasmFrameIter.cpp @@ -26,6 +26,7 @@ #include "wasm/WasmDebugFrame.h" #include "wasm/WasmInstance.h" #include "wasm/WasmInstanceData.h" +#include "wasm/WasmPI.h" #include "wasm/WasmStubs.h" #include "jit/MacroAssembler-inl.h" @@ -65,7 +66,8 @@ WasmFrameIter::WasmFrameIter(JitActivation* activation, wasm::Frame* fp) unwind_(Unwind::False), unwoundAddressOfReturnAddress_(nullptr), resumePCinCurrentFrame_(nullptr), - failedUnwindSignatureMismatch_(false) { + failedUnwindSignatureMismatch_(false), + stackSwitched_(false) { MOZ_ASSERT(fp_); instance_ = GetNearestEffectiveInstance(fp_); @@ -88,6 +90,19 @@ WasmFrameIter::WasmFrameIter(JitActivation* activation, wasm::Frame* fp) lineOrBytecode_ = trapData.bytecodeOffset; failedUnwindSignatureMismatch_ = trapData.failedUnwindSignatureMismatch; +#ifdef ENABLE_WASM_TAIL_CALLS + // The debugEnabled() relies on valid value of resumePCinCurrentFrame_ + // to identify DebugFrame. Normally this field is updated at popFrame(). + // The only case when this can happend is during IndirectCallBadSig + // trapping and stack unwinding. The top frame will never be at ReturnStub + // callsite, except during IndirectCallBadSig unwinding. + const CallSite* site = code_->lookupCallSite(unwoundPC); + if (site && site->kind() == CallSite::ReturnStub) { + MOZ_ASSERT(trapData.trap == Trap::IndirectCallBadSig); + resumePCinCurrentFrame_ = (uint8_t*)unwoundPC; + } +#endif + MOZ_ASSERT(!done()); return; } @@ -102,6 +117,39 @@ WasmFrameIter::WasmFrameIter(JitActivation* activation, wasm::Frame* fp) MOZ_ASSERT(!done() || unwoundCallerFP_); } +WasmFrameIter::WasmFrameIter(FrameWithInstances* fp, void* returnAddress) + : activation_(nullptr), + code_(nullptr), + codeRange_(nullptr), + lineOrBytecode_(0), + fp_(fp), + instance_(fp->calleeInstance()), + unwoundCallerFP_(nullptr), + unwind_(Unwind::False), + unwoundAddressOfReturnAddress_(nullptr), + resumePCinCurrentFrame_((uint8_t*)returnAddress), + failedUnwindSignatureMismatch_(false), + stackSwitched_(false) { + // Specialized implementation to avoid popFrame() interation. + // It is expected that the iterator starts at a callsite that is in + // the function body and has instance reference. + code_ = LookupCode(returnAddress, &codeRange_); + MOZ_ASSERT(code_ && codeRange_ && codeRange_->kind() == CodeRange::Function); + + const CallSite* callsite = code_->lookupCallSite(returnAddress); + MOZ_ASSERT(callsite && callsite->mightBeCrossInstance()); + +#ifdef ENABLE_WASM_JSPI + stackSwitched_ = callsite->isStackSwitch(); +#endif + + MOZ_ASSERT(code_ == &instance_->code()); + lineOrBytecode_ = callsite->lineOrBytecode(); + failedUnwindSignatureMismatch_ = false; + + MOZ_ASSERT(!done()); +} + bool WasmFrameIter::done() const { MOZ_ASSERT(!!fp_ == !!code_); MOZ_ASSERT(!!fp_ == !!codeRange_); @@ -145,6 +193,9 @@ static inline void AssertDirectJitCall(const void* fp) { void WasmFrameIter::popFrame() { uint8_t* returnAddress = fp_->returnAddress(); code_ = LookupCode(returnAddress, &codeRange_); +#ifdef ENABLE_WASM_JSPI + stackSwitched_ = false; +#endif if (!code_) { // This is a direct call from the jit into the wasm function's body. The @@ -241,6 +292,13 @@ void WasmFrameIter::popFrame() { instance_ = ExtractCallerInstanceFromFrameWithInstances(prevFP); } +#ifdef ENABLE_WASM_JSPI + stackSwitched_ = callsite->isStackSwitch(); + if (stackSwitched_ && unwind_ == Unwind::True) { + wasm::UnwindStackSwitch(activation_->cx()); + } +#endif + MOZ_ASSERT(code_ == &instance()->code()); lineOrBytecode_ = callsite->lineOrBytecode(); failedUnwindSignatureMismatch_ = false; @@ -1811,6 +1869,10 @@ static const char* ThunkedNativeToDescription(SymbolicAddress func) { return "call to native " #op " builtin (in wasm)"; FOR_EACH_BUILTIN_MODULE_FUNC(VISIT_BUILTIN_FUNC) #undef VISIT_BUILTIN_FUNC +#ifdef ENABLE_WASM_JSPI + case SymbolicAddress::UpdateSuspenderState: + return "call to native update suspender state util"; +#endif #ifdef WASM_CODEGEN_DEBUG case SymbolicAddress::PrintI32: case SymbolicAddress::PrintPtr: diff --git a/js/src/wasm/WasmFrameIter.h b/js/src/wasm/WasmFrameIter.h index 59590b1b2a..a6fda0b6ec 100644 --- a/js/src/wasm/WasmFrameIter.h +++ b/js/src/wasm/WasmFrameIter.h @@ -45,6 +45,7 @@ struct CallableOffsets; struct FuncOffsets; struct Offsets; class Frame; +class FrameWithInstances; using RegisterState = JS::ProfilingFrameIterator::RegisterState; @@ -73,12 +74,14 @@ class WasmFrameIter { uint8_t* resumePCinCurrentFrame_; // See wasm::TrapData for more information. bool failedUnwindSignatureMismatch_; + bool stackSwitched_; void popFrame(); public: // See comment above this class definition. explicit WasmFrameIter(jit::JitActivation* activation, Frame* fp = nullptr); + WasmFrameIter(FrameWithInstances* fp, void* returnAddress); const jit::JitActivation* activation() const { return activation_; } void setUnwind(Unwind unwind) { unwind_ = unwind; } void operator++(); @@ -99,6 +102,7 @@ class WasmFrameIter { uint8_t* unwoundCallerFP() const { return unwoundCallerFP_; } Frame* frame() const { return fp_; } Instance* instance() const { return instance_; } + bool stackSwitched() const { return stackSwitched_; } // Returns the address of the next instruction that will execute in this // frame, once control returns to this frame. diff --git a/js/src/wasm/WasmGcObject.cpp b/js/src/wasm/WasmGcObject.cpp index 3ccb08d381..4bf574aa12 100644 --- a/js/src/wasm/WasmGcObject.cpp +++ b/js/src/wasm/WasmGcObject.cpp @@ -516,6 +516,15 @@ js::gc::AllocKind js::WasmStructObject::allocKindForTypeDef( return gc::GetGCObjectKindForBytes(nbytes); } +bool WasmStructObject::getField(JSContext* cx, uint32_t index, + MutableHandle<Value> val) { + const StructType& resultType = typeDef().structType(); + MOZ_ASSERT(index <= resultType.fields_.length()); + const StructField& field = resultType.fields_[index]; + StorageType ty = field.type.storageType(); + return ToJSValue(cx, fieldOffsetToAddress(ty, field.offset), ty, val); +} + /* static */ void WasmStructObject::obj_trace(JSTracer* trc, JSObject* object) { WasmStructObject& structObj = object->as<WasmStructObject>(); diff --git a/js/src/wasm/WasmGcObject.h b/js/src/wasm/WasmGcObject.h index 45569c3061..d88061c238 100644 --- a/js/src/wasm/WasmGcObject.h +++ b/js/src/wasm/WasmGcObject.h @@ -408,6 +408,9 @@ class WasmStructObject : public WasmGcObject, inline uint8_t* fieldOffsetToAddress(StorageType fieldType, uint32_t fieldOffset); + // Gets JS Value of the structure field. + bool getField(JSContext* cx, uint32_t index, MutableHandle<Value> val); + // JIT accessors static const uint32_t inlineDataAlignment = 8; static constexpr size_t offsetOfOutlineData() { diff --git a/js/src/wasm/WasmGenerator.cpp b/js/src/wasm/WasmGenerator.cpp index 338812e1d6..d755c87519 100644 --- a/js/src/wasm/WasmGenerator.cpp +++ b/js/src/wasm/WasmGenerator.cpp @@ -470,6 +470,7 @@ bool ModuleGenerator::linkCallSites() { case CallSiteDesc::FuncRef: case CallSiteDesc::FuncRefFast: case CallSiteDesc::ReturnStub: + case CallSiteDesc::StackSwitch: break; case CallSiteDesc::ReturnFunc: case CallSiteDesc::Func: { @@ -1135,6 +1136,7 @@ SharedMetadata ModuleGenerator::finishMetadata(const Bytes& bytecode) { metadata_->nameCustomSectionIndex = moduleEnv_->nameCustomSectionIndex; metadata_->moduleName = moduleEnv_->moduleName; metadata_->funcNames = std::move(moduleEnv_->funcNames); + metadata_->parsedBranchHints = moduleEnv_->parsedBranchHints; // Copy over additional debug information. diff --git a/js/src/wasm/WasmInstance.cpp b/js/src/wasm/WasmInstance.cpp index 606601581d..9183715ca7 100644 --- a/js/src/wasm/WasmInstance.cpp +++ b/js/src/wasm/WasmInstance.cpp @@ -53,11 +53,13 @@ #include "wasm/WasmCode.h" #include "wasm/WasmDebug.h" #include "wasm/WasmDebugFrame.h" +#include "wasm/WasmFeatures.h" #include "wasm/WasmInitExpr.h" #include "wasm/WasmJS.h" #include "wasm/WasmMemory.h" #include "wasm/WasmModule.h" #include "wasm/WasmModuleTypes.h" +#include "wasm/WasmPI.h" #include "wasm/WasmStubs.h" #include "wasm/WasmTypeDef.h" #include "wasm/WasmValType.h" @@ -307,6 +309,13 @@ bool Instance::callImport(JSContext* cx, uint32_t funcImportIndex, return true; } +#ifdef ENABLE_WASM_JSPI + // Disable jit exit optimization when JSPI is enabled. + if (JSPromiseIntegrationAvailable(cx)) { + return true; + } +#endif + // The import may already have become optimized. for (auto t : code().tiers()) { void* jitExitCode = codeBase(t) + fi.jitExitCodeOffset(); @@ -346,6 +355,11 @@ bool Instance::callImport(JSContext* cx, uint32_t funcImportIndex, Instance::callImport_general(Instance* instance, int32_t funcImportIndex, int32_t argc, uint64_t* argv) { JSContext* cx = instance->cx(); +#ifdef ENABLE_WASM_JSPI + if (IsSuspendableStackActive(cx)) { + return CallImportOnMainThread(cx, instance, funcImportIndex, argc, argv); + } +#endif return instance->callImport(cx, funcImportIndex, argc, argv); } @@ -2373,6 +2387,23 @@ bool Instance::init(JSContext* cx, const JSObjectVector& funcImports, Tier callerTier = code_->bestTier(); for (size_t i = 0; i < metadata(callerTier).funcImports.length(); i++) { JSObject* f = funcImports[i]; + +#ifdef ENABLE_WASM_JSPI + if (JSObject* suspendingObject = MaybeUnwrapSuspendingObject(f)) { + // Compile suspending function Wasm wrapper. + const FuncImport& fi = metadata(callerTier).funcImports[i]; + const FuncType& funcType = metadata().getFuncImportType(fi); + RootedObject wrapped(cx, suspendingObject); + RootedFunction wrapper( + cx, WasmSuspendingFunctionCreate(cx, wrapped, funcType)); + if (!wrapper) { + return false; + } + MOZ_ASSERT(IsWasmExportedFunction(wrapper)); + f = wrapper; + } +#endif + MOZ_ASSERT(f->isCallable()); const FuncImport& fi = metadata(callerTier).funcImports[i]; const FuncType& funcType = metadata().getFuncImportType(fi); @@ -2617,9 +2648,27 @@ bool Instance::isInterrupted() const { void Instance::resetInterrupt(JSContext* cx) { interrupt_ = false; +#ifdef ENABLE_WASM_JSPI + if (cx->wasm().suspendableStackLimit != JS::NativeStackLimitMin) { + stackLimit_ = cx->wasm().suspendableStackLimit; + return; + } +#endif stackLimit_ = cx->stackLimitForJitCode(JS::StackForUntrustedScript); } +void Instance::setTemporaryStackLimit(JS::NativeStackLimit limit) { + if (!isInterrupted()) { + stackLimit_ = limit; + } +} + +void Instance::resetTemporaryStackLimit(JSContext* cx) { + if (!isInterrupted()) { + stackLimit_ = cx->stackLimitForJitCode(JS::StackForUntrustedScript); + } +} + bool Instance::debugFilter(uint32_t funcIndex) const { return (debugFilter_[funcIndex / 32] >> funcIndex % 32) & 1; } diff --git a/js/src/wasm/WasmInstance.h b/js/src/wasm/WasmInstance.h index 0e4f9745b7..0f9960133a 100644 --- a/js/src/wasm/WasmInstance.h +++ b/js/src/wasm/WasmInstance.h @@ -217,6 +217,21 @@ class alignas(16) Instance { TableInstanceData& tableInstanceData(uint32_t tableIndex) const; TagInstanceData& tagInstanceData(uint32_t tagIndex) const; +#ifdef ENABLE_WASM_JSPI + public: + struct WasmJSPICallImportData { + Instance* instance; + int32_t funcImportIndex; + int32_t argc; + uint64_t* argv; + static bool Call(WasmJSPICallImportData* data); + }; + + private: + bool isImportAllowedOnSuspendableStack(JSContext* cx, + int32_t funcImportIndex); +#endif + // Only WasmInstanceObject can call the private trace function. friend class js::WasmInstanceObject; void tracePrivate(JSTracer* trc); @@ -342,6 +357,9 @@ class alignas(16) Instance { bool isInterrupted() const; void resetInterrupt(JSContext* cx); + void setTemporaryStackLimit(JS::NativeStackLimit limit); + void resetTemporaryStackLimit(JSContext* cx); + bool debugFilter(uint32_t funcIndex) const; void setDebugFilter(uint32_t funcIndex, bool value); diff --git a/js/src/wasm/WasmIonCompile.cpp b/js/src/wasm/WasmIonCompile.cpp index 0568a95804..b8039792ae 100644 --- a/js/src/wasm/WasmIonCompile.cpp +++ b/js/src/wasm/WasmIonCompile.cpp @@ -235,11 +235,18 @@ class FunctionCompiler { }; using ControlFlowPatchVector = Vector<ControlFlowPatch, 0, SystemAllocPolicy>; - using ControlFlowPatchVectorVector = - Vector<ControlFlowPatchVector, 0, SystemAllocPolicy>; + + struct PendingBlockTarget { + ControlFlowPatchVector patches; + BranchHint hint = BranchHint::Invalid; + }; + + using PendingBlockTargetVector = + Vector<PendingBlockTarget, 0, SystemAllocPolicy>; const ModuleEnvironment& moduleEnv_; IonOpIter iter_; + uint32_t functionBodyOffset_; const FuncCompileInput& func_; const ValTypeVector& locals_; size_t lastReadCallSite_; @@ -254,7 +261,7 @@ class FunctionCompiler { uint32_t loopDepth_; uint32_t blockDepth_; - ControlFlowPatchVectorVector blockPatches_; + PendingBlockTargetVector pendingBlocks_; // Control flow patches created by `delegate` instructions that target the // outermost label of this function. These will be bound to a pad that will // do a rethrow in `emitBodyDelegateThrowPad`. @@ -276,6 +283,7 @@ class FunctionCompiler { MIRGenerator& mirGen, TryNoteVector& tryNotes) : moduleEnv_(moduleEnv), iter_(moduleEnv, decoder), + functionBodyOffset_(decoder.beginOffset()), func_(func), locals_(locals), lastReadCallSite_(0), @@ -294,6 +302,9 @@ class FunctionCompiler { const ModuleEnvironment& moduleEnv() const { return moduleEnv_; } IonOpIter& iter() { return iter_; } + uint32_t relativeBytecodeOffset() { + return readBytecodeOffset() - functionBodyOffset_; + } TempAllocator& alloc() const { return alloc_; } // FIXME(1401675): Replace with BlockType. uint32_t funcIndex() const { return func_.index; } @@ -301,6 +312,7 @@ class FunctionCompiler { return *moduleEnv_.funcs[func_.index].type; } + MBasicBlock* getCurBlock() const { return curBlock_; } BytecodeOffset bytecodeOffset() const { return iter_.bytecodeOffset(); } BytecodeOffset bytecodeIfNotAsmJS() const { return moduleEnv_.isAsmJS() ? BytecodeOffset() : iter_.bytecodeOffset(); @@ -384,8 +396,8 @@ class FunctionCompiler { MOZ_ASSERT(loopDepth_ == 0); MOZ_ASSERT(blockDepth_ == 0); #ifdef DEBUG - for (ControlFlowPatchVector& patches : blockPatches_) { - MOZ_ASSERT(patches.empty()); + for (PendingBlockTarget& targets : pendingBlocks_) { + MOZ_ASSERT(targets.patches.empty()); } #endif MOZ_ASSERT(inDeadCode()); @@ -2447,6 +2459,31 @@ class FunctionCompiler { return collectUnaryCallResult(builtin.retType, def); } + [[nodiscard]] bool stackSwitch(MDefinition* suspender, MDefinition* fn, + MDefinition* data, StackSwitchKind kind) { + MOZ_ASSERT(!inDeadCode()); + + MInstruction* ins; + switch (kind) { + case StackSwitchKind::SwitchToMain: + ins = MWasmStackSwitchToMain::New(alloc(), suspender, fn, data); + break; + case StackSwitchKind::SwitchToSuspendable: + ins = MWasmStackSwitchToSuspendable::New(alloc(), suspender, fn, data); + break; + case StackSwitchKind::ContinueOnSuspendable: + ins = MWasmStackContinueOnSuspendable::New(alloc(), suspender); + break; + } + if (!ins) { + return false; + } + + curBlock_->add(ins); + + return true; + } + #ifdef ENABLE_WASM_GC [[nodiscard]] bool callRef(const FuncType& funcType, MDefinition* ref, uint32_t lineOrBytecode, @@ -2682,8 +2719,8 @@ class FunctionCompiler { } [[nodiscard]] bool startBlock() { - MOZ_ASSERT_IF(blockDepth_ < blockPatches_.length(), - blockPatches_[blockDepth_].empty()); + MOZ_ASSERT_IF(blockDepth_ < pendingBlocks_.length(), + pendingBlocks_[blockDepth_].patches.empty()); blockDepth_++; return true; } @@ -2769,8 +2806,8 @@ class FunctionCompiler { } // Fix up phis stored in the slots Vector of pending blocks. - for (ControlFlowPatchVector& patches : blockPatches_) { - for (ControlFlowPatch& p : patches) { + for (PendingBlockTarget& pendingBlockTarget : pendingBlocks_) { + for (ControlFlowPatch& p : pendingBlockTarget.patches) { MBasicBlock* block = p.ins->block(); if (block->loopDepth() >= loopEntry->loopDepth()) { fixupRedundantPhis(block); @@ -2836,8 +2873,8 @@ class FunctionCompiler { if (!loopHeader) { MOZ_ASSERT(inDeadCode()); - MOZ_ASSERT(headerLabel >= blockPatches_.length() || - blockPatches_[headerLabel].empty()); + MOZ_ASSERT(headerLabel >= pendingBlocks_.length() || + pendingBlocks_[headerLabel].patches.empty()); blockDepth_--; loopDepth_--; return true; @@ -2896,17 +2933,20 @@ class FunctionCompiler { return inDeadCode() || popPushedDefs(loopResults); } - [[nodiscard]] bool addControlFlowPatch(MControlInstruction* ins, - uint32_t relative, uint32_t index) { + [[nodiscard]] bool addControlFlowPatch( + MControlInstruction* ins, uint32_t relative, uint32_t index, + BranchHint branchHint = BranchHint::Invalid) { MOZ_ASSERT(relative < blockDepth_); uint32_t absolute = blockDepth_ - 1 - relative; - if (absolute >= blockPatches_.length() && - !blockPatches_.resize(absolute + 1)) { + if (absolute >= pendingBlocks_.length() && + !pendingBlocks_.resize(absolute + 1)) { return false; } - return blockPatches_[absolute].append(ControlFlowPatch(ins, index)); + pendingBlocks_[absolute].hint = branchHint; + return pendingBlocks_[absolute].patches.append( + ControlFlowPatch(ins, index)); } [[nodiscard]] bool br(uint32_t relativeDepth, const DefVector& values) { @@ -2929,7 +2969,7 @@ class FunctionCompiler { } [[nodiscard]] bool brIf(uint32_t relativeDepth, const DefVector& values, - MDefinition* condition) { + MDefinition* condition, BranchHint branchHint) { if (inDeadCode()) { return true; } @@ -2940,7 +2980,8 @@ class FunctionCompiler { } MTest* test = MTest::New(alloc(), condition, nullptr, joinBlock); - if (!addControlFlowPatch(test, relativeDepth, MTest::TrueBranchIndex)) { + if (!addControlFlowPatch(test, relativeDepth, MTest::TrueBranchIndex, + branchHint)) { return false; } @@ -2950,6 +2991,7 @@ class FunctionCompiler { curBlock_->end(test); curBlock_ = joinBlock; + return true; } @@ -4785,11 +4827,12 @@ class FunctionCompiler { } [[nodiscard]] bool bindBranches(uint32_t absolute, DefVector* defs) { - if (absolute >= blockPatches_.length() || blockPatches_[absolute].empty()) { + if (absolute >= pendingBlocks_.length() || + pendingBlocks_[absolute].patches.empty()) { return inDeadCode() || popPushedDefs(defs); } - ControlFlowPatchVector& patches = blockPatches_[absolute]; + ControlFlowPatchVector& patches = pendingBlocks_[absolute].patches; MControlInstruction* ins = patches[0].ins; MBasicBlock* pred = ins->block(); @@ -4798,6 +4841,11 @@ class FunctionCompiler { return false; } + // Use branch hinting information if any. + if (pendingBlocks_[absolute].hint != BranchHint::Invalid) { + join->setBranchHinting(pendingBlocks_[absolute].hint); + } + pred->mark(); ins->replaceSuccessor(patches[0].index, join); @@ -4942,6 +4990,9 @@ static bool EmitLoop(FunctionCompiler& f) { } static bool EmitIf(FunctionCompiler& f) { + BranchHint branchHint = + f.iter().getBranchHint(f.funcIndex(), f.relativeBytecodeOffset()); + ResultType params; MDefinition* condition = nullptr; if (!f.iter().readIf(¶ms, &condition)) { @@ -4953,6 +5004,11 @@ static bool EmitIf(FunctionCompiler& f) { return false; } + // Store the branch hint in the basic block. + if (branchHint != BranchHint::Invalid) { + f.getCurBlock()->setBranchHinting(branchHint); + } + f.iter().controlItem().block = elseBlock; return true; } @@ -5088,11 +5144,15 @@ static bool EmitBrIf(FunctionCompiler& f) { ResultType type; DefVector values; MDefinition* condition; + + BranchHint branchHint = + f.iter().getBranchHint(f.funcIndex(), f.relativeBytecodeOffset()); + if (!f.iter().readBrIf(&relativeDepth, &type, &values, &condition)) { return false; } - return f.brIf(relativeDepth, values, condition); + return f.brIf(relativeDepth, values, condition, branchHint); } static bool EmitBrTable(FunctionCompiler& f) { @@ -5372,6 +5432,22 @@ static bool EmitCallIndirect(FunctionCompiler& f, bool oldStyle) { return true; } +#ifdef ENABLE_WASM_JSPI +static bool EmitStackSwitch(FunctionCompiler& f) { + StackSwitchKind kind; + MDefinition* suspender; + MDefinition* fn; + MDefinition* data; + if (!f.iter().readStackSwitch(&kind, &suspender, &fn, &data)) { + return false; + } + if (!f.stackSwitch(suspender, fn, data, kind)) { + return false; + } + return true; +} +#endif + #ifdef ENABLE_WASM_TAIL_CALLS static bool EmitReturnCall(FunctionCompiler& f) { uint32_t lineOrBytecode = f.readCallSiteLineOrBytecode(); @@ -9153,6 +9229,15 @@ static bool EmitBodyExprs(FunctionCompiler& f) { } CHECK(EmitCallBuiltinModuleFunc(f)); } +#ifdef ENABLE_WASM_JSPI + if (op.b1 == uint32_t(MozOp::StackSwitch)) { + if (!f.moduleEnv().isBuiltinModule() || + !f.moduleEnv().jsPromiseIntegrationEnabled()) { + return f.iter().unrecognizedOpcode(&op); + } + CHECK(EmitStackSwitch(f)); + } +#endif if (!f.moduleEnv().isAsmJS()) { return f.iter().unrecognizedOpcode(&op); @@ -9326,6 +9411,12 @@ bool wasm::IonCompileFunctions(const ModuleEnvironment& moduleEnv, const JitCompileOptions options; MIRGraph graph(&alloc); CompileInfo compileInfo(locals.length()); + // Only activate branch hinting if the option is enabled and some hints were + // parsed. + if (moduleEnv.branchHintingEnabled() && !moduleEnv.branchHints.isEmpty()) { + compileInfo.setBranchHinting(true); + } + MIRGenerator mir(nullptr, options, &alloc, &graph, &compileInfo, IonOptimizations.get(OptimizationLevel::Wasm)); diff --git a/js/src/wasm/WasmJS.cpp b/js/src/wasm/WasmJS.cpp index d987ecec29..8a7e967a80 100644 --- a/js/src/wasm/WasmJS.cpp +++ b/js/src/wasm/WasmJS.cpp @@ -68,6 +68,7 @@ #include "wasm/WasmIonCompile.h" #include "wasm/WasmMemory.h" #include "wasm/WasmModule.h" +#include "wasm/WasmPI.h" #include "wasm/WasmProcess.h" #include "wasm/WasmSignalHandlers.h" #include "wasm/WasmStubs.h" @@ -139,6 +140,10 @@ static bool IsCallableNonCCW(const Value& v) { return IsCallable(v) && !IsCrossCompartmentWrapper(&v.toObject()); } +static bool IsWasmSuspendingWrapper(const Value& v) { + return v.isObject() && js::IsWasmSuspendingObject(&v.toObject()); +} + bool js::wasm::GetImports(JSContext* cx, const Module& module, HandleObject importObj, ImportValues* imports) { if (!module.imports().empty() && !importObj) { @@ -207,7 +212,8 @@ bool js::wasm::GetImports(JSContext* cx, const Module& module, switch (import.kind) { case DefinitionKind::Function: { - if (!IsCallableNonCCW(importFieldValue)) { + if (!IsCallableNonCCW(importFieldValue) && + !IsWasmSuspendingWrapper(importFieldValue)) { return ThrowBadImportType(cx, import.field, "Function"); } @@ -4225,6 +4231,66 @@ bool WasmFunctionConstruct(JSContext* cx, unsigned argc, Value* vp) { return false; } +# ifdef ENABLE_WASM_JSPI + // Check suspeding and promising + SuspenderArgPosition suspending = SuspenderArgPosition::None; + SuspenderArgPosition promising = SuspenderArgPosition::None; + if (wasm::JSPromiseIntegrationAvailable(cx) && args.length() > 2 && + args[2].isObject()) { + RootedObject usageObj(cx, &args[2].toObject()); + RootedValue val(cx); + if (!JS_GetProperty(cx, usageObj, "suspending", &val)) { + return false; + } + if (!ParseSuspendingPromisingString(cx, val, suspending)) { + return false; + } + if (!JS_GetProperty(cx, usageObj, "promising", &val)) { + return false; + } + if (!ParseSuspendingPromisingString(cx, val, promising)) { + return false; + } + } + + if (suspending > SuspenderArgPosition::None) { + if (!IsCallableNonCCW(args[1])) { + JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, + JSMSG_WASM_BAD_FUNCTION_VALUE); + return false; + } + + RootedObject func(cx, &args[1].toObject()); + RootedFunction suspend( + cx, WasmSuspendingFunctionCreate(cx, func, std::move(params), + std::move(results), suspending)); + if (!suspend) { + return false; + } + args.rval().setObject(*suspend); + + return true; + } + if (promising > SuspenderArgPosition::None) { + if (!IsWasmFunction(args[1])) { + JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, + JSMSG_WASM_BAD_FUNCTION_VALUE); + return false; + } + + RootedObject func(cx, &args[1].toObject()); + RootedFunction promise( + cx, WasmPromisingFunctionCreate(cx, func, std::move(params), + std::move(results), promising)); + if (!promise) { + return false; + } + args.rval().setObject(*promise); + + return true; + } +# endif // ENABLE_WASM_JSPI + // Get the target function if (!IsCallableNonCCW(args[1]) || IsWasmFunction(args[1])) { @@ -5291,6 +5357,91 @@ static bool WebAssembly_instantiateStreaming(JSContext* cx, unsigned argc, return true; } +#ifdef ENABLE_WASM_JSPI +const ClassSpec WasmSuspendingObject::classSpec_ = { + GenericCreateConstructor<construct, 1, gc::AllocKind::FUNCTION>, + GenericCreatePrototype<WasmSuspendingObject>, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + ClassSpec::DontDefineConstructor}; + +const JSClass WasmSuspendingObject::class_ = { + "Suspending", + JSCLASS_HAS_RESERVED_SLOTS(WasmSuspendingObject::RESERVED_SLOTS), + JS_NULL_CLASS_OPS, &classSpec_}; + +const JSClass& WasmSuspendingObject::protoClass_ = PlainObject::class_; + +/* static */ +bool WasmSuspendingObject::construct(JSContext* cx, unsigned argc, Value* vp) { + CallArgs args = CallArgsFromVp(argc, vp); + + if (!args.requireAtLeast(cx, "WebAssembly.Suspending", 1)) { + return false; + } + + if (!IsCallableNonCCW(args[0])) { + JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, + JSMSG_WASM_BAD_FUNCTION_VALUE); + return false; + } + + RootedObject callable(cx, &args[0].toObject()); + Rooted<WasmSuspendingObject*> suspending( + cx, NewBuiltinClassInstance<WasmSuspendingObject>(cx)); + if (!suspending) { + return false; + } + suspending->setWrappedFunction(callable); + args.rval().setObject(*suspending); + return true; +} + +static bool WebAssembly_promising(JSContext* cx, unsigned argc, Value* vp) { + CallArgs args = CallArgsFromVp(argc, vp); + + if (!args.requireAtLeast(cx, "WebAssembly.promising", 1)) { + return false; + } + + if (!IsWasmFunction(args[0])) { + JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, + JSMSG_WASM_BAD_FUNCTION_VALUE); + return false; + } + + RootedObject func(cx, &args[0].toObject()); + RootedFunction promise( + cx, WasmPromisingFunctionCreate(cx, func, wasm::ValTypeVector(), + wasm::ValTypeVector(), + SuspenderArgPosition::None)); + if (!promise) { + return false; + } + args.rval().setObject(*promise); + return true; +} + +static const JSFunctionSpec WebAssembly_jspi_methods[] = { + JS_FN("promising", WebAssembly_promising, 1, JSPROP_ENUMERATE), JS_FS_END}; + +bool js::IsWasmSuspendingObject(JSObject* obj) { + return obj->is<WasmSuspendingObject>(); +} + +JSObject* js::MaybeUnwrapSuspendingObject(JSObject* wrapper) { + if (!wrapper->is<WasmSuspendingObject>()) { + return nullptr; + } + return wrapper->as<WasmSuspendingObject>().wrappedFunction(); +} +#else +bool js::IsWasmSuspendingObject(JSObject* obj) { return false; } +#endif // ENABLE_WASM_JSPI + #ifdef ENABLE_WASM_MOZ_INTGEMM static bool WebAssembly_mozIntGemm(JSContext* cx, unsigned argc, Value* vp) { @@ -5410,6 +5561,31 @@ static bool WebAssemblyClassFinish(JSContext* cx, HandleObject object, wasm->setWrappedJSValueTag(wrappedJSValueTagObject); + if (ExnRefAvailable(cx)) { + RootedId jsTagName(cx, NameToId(cx->names().jsTag)); + RootedValue jsTagValue(cx, ObjectValue(*wrappedJSValueTagObject)); + if (!DefineDataProperty(cx, wasm, jsTagName, jsTagValue, + JSPROP_READONLY | JSPROP_ENUMERATE)) { + return false; + } + } + +#ifdef ENABLE_WASM_JSPI + constexpr NameAndProtoKey jspiEntries[] = { + {"Suspending", JSProto_WasmSuspending}, + }; + if (JSPromiseIntegrationAvailable(cx)) { + if (!JS_DefineFunctions(cx, wasm, WebAssembly_jspi_methods)) { + return false; + } + for (const auto& entry : jspiEntries) { + if (!WebAssemblyDefineConstructor(cx, wasm, entry, &ctorValue, &id)) { + return false; + } + } + } +#endif + #ifdef ENABLE_WASM_MOZ_INTGEMM if (MozIntGemmAvailable(cx) && !JS_DefineFunctions(cx, wasm, WebAssembly_mozIntGemm_methods)) { diff --git a/js/src/wasm/WasmJS.h b/js/src/wasm/WasmJS.h index 27d49701a9..3ebc2d9705 100644 --- a/js/src/wasm/WasmJS.h +++ b/js/src/wasm/WasmJS.h @@ -503,6 +503,30 @@ class WasmNamespaceObject : public NativeObject { extern const JSClass WasmFunctionClass; +bool IsWasmSuspendingObject(JSObject* obj); + +#ifdef ENABLE_WASM_JSPI + +class WasmSuspendingObject : public NativeObject { + public: + static const ClassSpec classSpec_; + static const JSClass class_; + static const JSClass& protoClass_; + static const unsigned WRAPPED_FN_SLOT = 0; + static const unsigned RESERVED_SLOTS = 1; + static bool construct(JSContext*, unsigned, Value*); + + JSObject* wrappedFunction() const { + return getReservedSlot(WRAPPED_FN_SLOT).toObjectOrNull(); + } + void setWrappedFunction(HandleObject fn) { + return setReservedSlot(WRAPPED_FN_SLOT, ObjectValue(*fn)); + } +}; + +JSObject* MaybeUnwrapSuspendingObject(JSObject* wrapper); +#endif + } // namespace js #endif // wasm_js_h diff --git a/js/src/wasm/WasmModule.cpp b/js/src/wasm/WasmModule.cpp index 406c16462b..3609eeaf6e 100644 --- a/js/src/wasm/WasmModule.cpp +++ b/js/src/wasm/WasmModule.cpp @@ -38,6 +38,7 @@ #include "wasm/WasmIonCompile.h" #include "wasm/WasmJS.h" #include "wasm/WasmModuleTypes.h" +#include "wasm/WasmPI.h" #include "wasm/WasmSerialize.h" #include "wasm/WasmUtility.h" diff --git a/js/src/wasm/WasmModuleTypes.cpp b/js/src/wasm/WasmModuleTypes.cpp index fdd968a614..8fc4effb5f 100644 --- a/js/src/wasm/WasmModuleTypes.cpp +++ b/js/src/wasm/WasmModuleTypes.cpp @@ -49,6 +49,8 @@ bool CacheableName::fromUTF8Chars(const char* utf8Chars, CacheableName* name) { return true; } +BranchHintVector BranchHintCollection::invalidVector; + JSAtom* CacheableName::toAtom(JSContext* cx) const { return AtomizeUTF8Chars(cx, begin(), length()); } diff --git a/js/src/wasm/WasmModuleTypes.h b/js/src/wasm/WasmModuleTypes.h index 091619f598..c6cfabaca5 100644 --- a/js/src/wasm/WasmModuleTypes.h +++ b/js/src/wasm/WasmModuleTypes.h @@ -23,6 +23,7 @@ #include "mozilla/Span.h" #include "js/AllocPolicy.h" +#include "js/HashTable.h" #include "js/RefCounted.h" #include "js/Utility.h" #include "js/Vector.h" @@ -220,6 +221,54 @@ struct FuncDesc { using FuncDescVector = Vector<FuncDesc, 0, SystemAllocPolicy>; +enum class BranchHint : uint8_t { Unlikely = 0, Likely = 1, Invalid = 2 }; + +// Stores pairs of <BranchOffset, BranchHint> +struct BranchHintEntry { + uint32_t branchOffset; + BranchHint value; + + BranchHintEntry() = default; + BranchHintEntry(uint32_t branchOffset, BranchHint value) + : branchOffset(branchOffset), value(value) {} +}; + +// Branch hint sorted vector for a function, +// stores tuples of <BranchOffset, BranchHint> +using BranchHintVector = Vector<BranchHintEntry, 0, SystemAllocPolicy>; + +struct BranchHintCollection { + private: + // Map from function index to their collection of branch hints + HashMap<uint32_t, BranchHintVector, DefaultHasher<uint32_t>, + SystemAllocPolicy> + branchHintsMap; + + public: + // Used for lookups into the collection if a function + // doesn't contain any hints. + static BranchHintVector invalidVector; + + // Add all the branch hints for a function + [[nodiscard]] bool addHintsForFunc(uint32_t functionIndex, + BranchHintVector&& branchHints) { + return branchHintsMap.put(functionIndex, std::move(branchHints)); + } + + // Return the vector with branch hints for a funcIndex. + // If this function doesn't contain any hints, return an empty vector. + BranchHintVector& getHintVector(uint32_t funcIndex) const { + if (auto hintsVector = branchHintsMap.readonlyThreadsafeLookup(funcIndex)) { + return hintsVector->value(); + } + + // If not found, return the empty invalid Vector + return invalidVector; + } + + bool isEmpty() const { return branchHintsMap.empty(); } +}; + enum class GlobalKind { Import, Constant, Variable }; // A GlobalDesc describes a single global variable. diff --git a/js/src/wasm/WasmOpIter.cpp b/js/src/wasm/WasmOpIter.cpp index d60a87dc12..e35c6ce578 100644 --- a/js/src/wasm/WasmOpIter.cpp +++ b/js/src/wasm/WasmOpIter.cpp @@ -811,6 +811,8 @@ OpKind wasm::Classify(OpBytes op) { return OpKind::OldCallIndirect; case MozOp::CallBuiltinModuleFunc: return OpKind::CallBuiltinModuleFunc; + case MozOp::StackSwitch: + return OpKind::StackSwitch; } break; } diff --git a/js/src/wasm/WasmOpIter.h b/js/src/wasm/WasmOpIter.h index 59d494bfbf..9ea44bac92 100644 --- a/js/src/wasm/WasmOpIter.h +++ b/js/src/wasm/WasmOpIter.h @@ -234,6 +234,7 @@ enum class OpKind { Try, TryTable, CallBuiltinModuleFunc, + StackSwitch, }; // Return the OpKind for a given Op. This is used for sanity-checking that @@ -431,6 +432,8 @@ class MOZ_STACK_CLASS OpIter : private Policy { // immutable globals are allowed. uint32_t maxInitializedGlobalsIndexPlus1_; FeatureUsage featureUsage_; + uint32_t lastBranchHintIndex_; + BranchHintVector* branchHintVector_; #ifdef DEBUG OpBytes op_; @@ -548,6 +551,7 @@ class MOZ_STACK_CLASS OpIter : private Policy { env_(env), maxInitializedGlobalsIndexPlus1_(0), featureUsage_(FeatureUsage::None), + branchHintVector_(nullptr), op_(OpBytes(Op::Limit)), offsetOfLastReadOp_(0) {} #else @@ -598,6 +602,32 @@ class MOZ_STACK_CLASS OpIter : private Policy { return !controlStack_.empty() && controlStack_.back().polymorphicBase(); } + // If it exists, return the BranchHint value from a function index and a + // branch offset. + // Branch hints are stored in a sorted vector. Because code in compiled in + // order, we keep track of the most recently accessed index. + // Retrieving branch hints is also done in order inside a function. + BranchHint getBranchHint(uint32_t funcIndex, uint32_t branchOffset) { + if (!env_.branchHintingEnabled()) { + return BranchHint::Invalid; + } + + // Get the next hint in the collection + while (lastBranchHintIndex_ < branchHintVector_->length() && + (*branchHintVector_)[lastBranchHintIndex_].branchOffset < + branchOffset) { + lastBranchHintIndex_++; + } + + // No hint found for this branch. + if (lastBranchHintIndex_ >= branchHintVector_->length()) { + return BranchHint::Invalid; + } + + // The last index is saved, now return the hint. + return (*branchHintVector_)[lastBranchHintIndex_].value; + } + // ------------------------------------------------------------------------ // Decoding and validation interface. @@ -828,6 +858,11 @@ class MOZ_STACK_CLASS OpIter : private Policy { [[nodiscard]] bool readCallBuiltinModuleFunc( const BuiltinModuleFunc** builtinModuleFunc, ValueVector* params); +#ifdef ENABLE_WASM_JSPI + [[nodiscard]] bool readStackSwitch(StackSwitchKind* kind, Value* suspender, + Value* fn, Value* data); +#endif + // At a location where readOp is allowed, peek at the next opcode // without consuming it or updating any internal state. // Never fails: returns uint16_t(Op::Limit) in op->b0 if it can't read. @@ -1270,6 +1305,12 @@ inline bool OpIter<Policy>::startFunction(uint32_t funcIndex, MOZ_ASSERT(maxInitializedGlobalsIndexPlus1_ == 0); BlockType type = BlockType::FuncResults(*env_.funcs[funcIndex].type); + // Initialize information related to branch hinting. + lastBranchHintIndex_ = 0; + if (env_.branchHintingEnabled()) { + branchHintVector_ = &env_.branchHints.getHintVector(funcIndex); + } + size_t numArgs = env_.funcs[funcIndex].type->args().length(); if (!unsetLocals_.init(locals, numArgs)) { return false; @@ -1304,6 +1345,7 @@ inline bool OpIter<Policy>::startInitExpr(ValType expected) { MOZ_ASSERT(valueStack_.empty()); MOZ_ASSERT(controlStack_.empty()); MOZ_ASSERT(op_.b0 == uint16_t(Op::Limit)); + lastBranchHintIndex_ = 0; // GC allows accessing any previously defined global, not just those that are // imported and immutable. @@ -4219,6 +4261,46 @@ inline bool OpIter<Policy>::readStoreLane(uint32_t byteSize, #endif // ENABLE_WASM_SIMD +#ifdef ENABLE_WASM_JSPI +template <typename Policy> +inline bool OpIter<Policy>::readStackSwitch(StackSwitchKind* kind, + Value* suspender, Value* fn, + Value* data) { + MOZ_ASSERT(Classify(op_) == OpKind::StackSwitch); + MOZ_ASSERT(env_.jsPromiseIntegrationEnabled()); + uint32_t kind_; + if (!d_.readVarU32(&kind_)) { + return false; + } + *kind = StackSwitchKind(kind_); + if (!popWithType(ValType(RefType::any()), data)) { + return false; + } + StackType stackType; + if (!popWithType(ValType(RefType::func()), fn, &stackType)) { + return false; + } +# if DEBUG + // Verify that the function takes suspender and data as parameters and + // returns no values. + MOZ_ASSERT((*kind == StackSwitchKind::ContinueOnSuspendable) == + stackType.isNullableAsOperand()); + if (!stackType.isNullableAsOperand()) { + ValType valType = stackType.valType(); + MOZ_ASSERT(valType.isRefType() && valType.typeDef()->isFuncType()); + const FuncType& func = valType.typeDef()->funcType(); + MOZ_ASSERT(func.args().length() == 2 && func.results().empty() && + func.arg(0).isExternRef() && + ValType::isSubTypeOf(func.arg(1), RefType::any())); + } +# endif + if (!popWithType(ValType(RefType::extern_()), suspender)) { + return false; + } + return true; +} +#endif + template <typename Policy> inline bool OpIter<Policy>::readCallBuiltinModuleFunc( const BuiltinModuleFunc** builtinModuleFunc, ValueVector* params) { diff --git a/js/src/wasm/WasmPI.cpp b/js/src/wasm/WasmPI.cpp new file mode 100644 index 0000000000..d11db9022d --- /dev/null +++ b/js/src/wasm/WasmPI.cpp @@ -0,0 +1,1743 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: set ts=8 sts=2 et sw=2 tw=80: + * + * Copyright 2016 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "wasm/WasmPI.h" + +#include "builtin/Promise.h" +#include "jit/MIRGenerator.h" +#include "js/CallAndConstruct.h" +#include "vm/JSContext.h" +#include "vm/JSObject.h" +#include "vm/NativeObject.h" +#include "vm/PromiseObject.h" +#include "wasm/WasmConstants.h" +#include "wasm/WasmContext.h" +#include "wasm/WasmFeatures.h" +#include "wasm/WasmGenerator.h" +#include "wasm/WasmValidate.h" + +#include "vm/JSObject-inl.h" +#include "wasm/WasmGcObject-inl.h" +#include "wasm/WasmInstance-inl.h" + +#ifdef XP_WIN +# include "util/WindowsWrapper.h" +#endif + +using namespace js; +using namespace js::jit; + +#ifdef ENABLE_WASM_JSPI +namespace js::wasm { + +SuspenderObjectData::SuspenderObjectData(void* stackMemory) + : stackMemory_(stackMemory), + suspendableFP_(nullptr), + suspendableSP_(static_cast<uint8_t*>(stackMemory) + + SuspendableStackPlusRedZoneSize), + state_(SuspenderState::Initial) {} + +# ifdef _WIN64 +// On WIN64, the Thread Information Block stack limits has to be modified to +// avoid failures on SP checks. +void SuspenderObjectData::updateTIBStackFields() { + _NT_TIB* tib = reinterpret_cast<_NT_TIB*>(::NtCurrentTeb()); + savedStackBase_ = tib->StackBase; + savedStackLimit_ = tib->StackLimit; + uintptr_t stack_limit = (uintptr_t)stackMemory_ + SuspendableRedZoneSize; + uintptr_t stack_base = stack_limit + SuspendableStackSize; + tib->StackBase = (void*)stack_base; + tib->StackLimit = (void*)stack_limit; +} + +void SuspenderObjectData::restoreTIBStackFields() { + _NT_TIB* tib = reinterpret_cast<_NT_TIB*>(::NtCurrentTeb()); + tib->StackBase = savedStackBase_; + tib->StackLimit = savedStackLimit_; +} +# endif + +// Slots that used in various JSFunctionExtended below. +const size_t SUSPENDER_SLOT = 0; +const size_t WRAPPED_FN_SLOT = 1; +const size_t CONTINUE_ON_SUSPENDABLE_SLOT = 1; + +SuspenderContext::SuspenderContext() + : activeSuspender_(nullptr), suspendedStacks_() {} + +SuspenderContext::~SuspenderContext() { + MOZ_ASSERT(activeSuspender_ == nullptr); +} + +SuspenderObject* SuspenderContext::activeSuspender() { + return activeSuspender_; +} + +void SuspenderContext::setActiveSuspender(SuspenderObject* obj) { + activeSuspender_.set(obj); +} + +void SuspenderContext::trace(JSTracer* trc) { + if (activeSuspender_) { + TraceEdge(trc, &activeSuspender_, "suspender"); + } +} + +void SuspenderContext::traceRoots(JSTracer* trc) { + for (const SuspenderObjectData& data : suspendedStacks_) { + void* startFP = data.suspendableFP(); + void* returnAddress = data.suspendedReturnAddress(); + void* exitFP = data.suspendableExitFP(); + MOZ_ASSERT(startFP != exitFP); + + WasmFrameIter iter(static_cast<FrameWithInstances*>(startFP), + returnAddress); + MOZ_ASSERT(iter.stackSwitched()); + uintptr_t highestByteVisitedInPrevWasmFrame = 0; + while (true) { + MOZ_ASSERT(!iter.done()); + uint8_t* nextPC = iter.resumePCinCurrentFrame(); + Instance* instance = iter.instance(); + TraceInstanceEdge(trc, instance, "WasmFrameIter instance"); + highestByteVisitedInPrevWasmFrame = instance->traceFrame( + trc, iter, nextPC, highestByteVisitedInPrevWasmFrame); + if (iter.frame() == exitFP) { + break; + } + ++iter; + if (iter.stackSwitched()) { + highestByteVisitedInPrevWasmFrame = 0; + } + } + } +} + +static_assert(JS_STACK_GROWTH_DIRECTION < 0, + "JS-PI implemented only for native stacks that grows towards 0"); + +static void DecrementSuspendableStacksCount(JSContext* cx) { + for (;;) { + uint32_t currentCount = cx->wasm().suspendableStacksCount; + MOZ_ASSERT(currentCount > 0); + if (cx->wasm().suspendableStacksCount.compareExchange(currentCount, + currentCount - 1)) { + break; + } + // Failed to decrement suspendableStacksCount, repeat. + } +} + +class SuspenderObject : public NativeObject { + public: + static const JSClass class_; + + enum { DataSlot, PromisingPromiseSlot, SuspendingPromiseSlot, SlotCount }; + + static SuspenderObject* create(JSContext* cx) { + for (;;) { + uint32_t currentCount = cx->wasm().suspendableStacksCount; + if (currentCount >= SuspendableStacksMaxCount) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_JSPI_SUSPENDER_LIMIT); + return nullptr; + } + if (cx->wasm().suspendableStacksCount.compareExchange(currentCount, + currentCount + 1)) { + break; + } + // Failed to increment suspendableStacksCount, repeat. + } + + Rooted<SuspenderObject*> suspender( + cx, NewBuiltinClassInstance<SuspenderObject>(cx)); + if (!suspender) { + DecrementSuspendableStacksCount(cx); + return nullptr; + } + + void* stackMemory = js_malloc(SuspendableStackPlusRedZoneSize); + if (!stackMemory) { + DecrementSuspendableStacksCount(cx); + ReportOutOfMemory(cx); + return nullptr; + } + + SuspenderObjectData* data = js_new<SuspenderObjectData>(stackMemory); + if (!data) { + js_free(stackMemory); + DecrementSuspendableStacksCount(cx); + ReportOutOfMemory(cx); + return nullptr; + } + MOZ_RELEASE_ASSERT(data->state() != SuspenderState::Moribund); + + suspender->initReservedSlot(DataSlot, PrivateValue(data)); + suspender->initReservedSlot(PromisingPromiseSlot, NullValue()); + suspender->initReservedSlot(SuspendingPromiseSlot, NullValue()); + return suspender; + } + + PromiseObject* promisingPromise() const { + return &getReservedSlot(PromisingPromiseSlot) + .toObject() + .as<PromiseObject>(); + } + + void setPromisingPromise(Handle<PromiseObject*> promise) { + setReservedSlot(PromisingPromiseSlot, ObjectOrNullValue(promise)); + } + + PromiseObject* suspendingPromise() const { + return &getReservedSlot(SuspendingPromiseSlot) + .toObject() + .as<PromiseObject>(); + } + + void setSuspendingPromise(Handle<PromiseObject*> promise) { + setReservedSlot(SuspendingPromiseSlot, ObjectOrNullValue(promise)); + } + + JS::NativeStackLimit getStackMemoryLimit() { + return JS::NativeStackLimit(data()->stackMemory()) + SuspendableRedZoneSize; + } + + SuspenderState state() { return data()->state(); } + + inline bool hasData() { return !getReservedSlot(DataSlot).isUndefined(); } + + inline SuspenderObjectData* data() { + return static_cast<SuspenderObjectData*>( + getReservedSlot(DataSlot).toPrivate()); + } + + void setMoribund(JSContext* cx); + void setActive(JSContext* cx); + void setSuspended(JSContext* cx); + + void enter(JSContext* cx); + void suspend(JSContext* cx); + void resume(JSContext* cx); + void leave(JSContext* cx); + + private: + static const JSClassOps classOps_; + + static void finalize(JS::GCContext* gcx, JSObject* obj); +}; + +static_assert(SuspenderObjectDataSlot == SuspenderObject::DataSlot); + +const JSClass SuspenderObject::class_ = { + "SuspenderObject", + JSCLASS_HAS_RESERVED_SLOTS(SlotCount) | JSCLASS_BACKGROUND_FINALIZE, + &SuspenderObject::classOps_}; + +const JSClassOps SuspenderObject::classOps_ = { + nullptr, // addProperty + nullptr, // delProperty + nullptr, // enumerate + nullptr, // newEnumerate + nullptr, // resolve + nullptr, // mayResolve + finalize, // finalize + nullptr, // call + nullptr, // construct + nullptr, // trace +}; + +/* static */ +void SuspenderObject::finalize(JS::GCContext* gcx, JSObject* obj) { + SuspenderObject& suspender = obj->as<SuspenderObject>(); + if (!suspender.hasData()) { + return; + } + SuspenderObjectData* data = suspender.data(); + MOZ_RELEASE_ASSERT(data->state() == SuspenderState::Moribund); + js_free(data->stackMemory()); + js_free(data); +} + +void SuspenderObject::setMoribund(JSContext* cx) { + // TODO make sense to free stackMemory at this point to reduce memory usage? + MOZ_ASSERT(state() == SuspenderState::Active); + ResetInstanceStackLimits(cx); +# ifdef _WIN64 + data()->restoreTIBStackFields(); +# endif + SuspenderObjectData* data = this->data(); + data->setState(SuspenderState::Moribund); + DecrementSuspendableStacksCount(cx); + MOZ_ASSERT( + !cx->wasm().promiseIntegration.suspendedStacks_.ElementProbablyInList( + data)); +} + +void SuspenderObject::setActive(JSContext* cx) { + data()->setState(SuspenderState::Active); + UpdateInstanceStackLimitsForSuspendableStack(cx, getStackMemoryLimit()); +# ifdef _WIN64 + data()->updateTIBStackFields(); +# endif +} + +void SuspenderObject::setSuspended(JSContext* cx) { + data()->setState(SuspenderState::Suspended); + ResetInstanceStackLimits(cx); +# ifdef _WIN64 + data()->restoreTIBStackFields(); +# endif +} + +void SuspenderObject::enter(JSContext* cx) { + MOZ_ASSERT(state() == SuspenderState::Initial); + cx->wasm().promiseIntegration.setActiveSuspender(this); + setActive(cx); +} + +void SuspenderObject::suspend(JSContext* cx) { + MOZ_ASSERT(state() == SuspenderState::Active); + setSuspended(cx); + cx->wasm().promiseIntegration.suspendedStacks_.pushFront(data()); + cx->wasm().promiseIntegration.setActiveSuspender(nullptr); +} + +void SuspenderObject::resume(JSContext* cx) { + MOZ_ASSERT(state() == SuspenderState::Suspended); + cx->wasm().promiseIntegration.setActiveSuspender(this); + setActive(cx); + cx->wasm().promiseIntegration.suspendedStacks_.remove(data()); +} + +void SuspenderObject::leave(JSContext* cx) { + cx->wasm().promiseIntegration.setActiveSuspender(nullptr); + // We are exiting alternative stack if state is active, + // otherwise the stack was just suspended. + switch (state()) { + case SuspenderState::Active: + setMoribund(cx); + break; + case SuspenderState::Suspended: + break; + case SuspenderState::Initial: + case SuspenderState::Moribund: + MOZ_CRASH(); + } +} + +bool ParseSuspendingPromisingString(JSContext* cx, HandleValue val, + SuspenderArgPosition& result) { + if (val.isNullOrUndefined()) { + result = SuspenderArgPosition::None; + return true; + } + + RootedString str(cx, ToString(cx, val)); + if (!str) { + return false; + } + Rooted<JSLinearString*> linear(cx, str->ensureLinear(cx)); + if (!linear) { + return false; + } + + if (StringEqualsLiteral(linear, "first")) { + result = SuspenderArgPosition::First; + } else if (StringEqualsLiteral(linear, "last")) { + result = SuspenderArgPosition::Last; + } else { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_JSPI_ARG_POSITION); + return false; + } + return true; +} + +using CallImportData = Instance::WasmJSPICallImportData; + +/*static*/ +bool CallImportData::Call(CallImportData* data) { + Instance* instance = data->instance; + JSContext* cx = instance->cx(); + return instance->callImport(cx, data->funcImportIndex, data->argc, + data->argv); +} + +bool CallImportOnMainThread(JSContext* cx, Instance* instance, + int32_t funcImportIndex, int32_t argc, + uint64_t* argv) { + CallImportData data = {instance, funcImportIndex, argc, argv}; + Rooted<SuspenderObject*> suspender( + cx, cx->wasm().promiseIntegration.activeSuspender()); + SuspenderObjectData* stacks = suspender->data(); + + cx->wasm().promiseIntegration.setActiveSuspender(nullptr); + + MOZ_ASSERT(suspender->state() == SuspenderState::Active); + suspender->setSuspended(cx); + + // The platform specific code below inserts offsets as strings into inline + // assembly. CHECK_OFFSETS verifies the specified literals in macros below. +# define CHECK_OFFSETS(MAIN_FP_OFFSET, MAIN_SP_OFFSET, SUSPENDABLE_FP_OFFSET, \ + SUSPENDABLE_SP_OFFSET) \ + static_assert((MAIN_FP_OFFSET) == SuspenderObjectData::offsetOfMainFP() && \ + (MAIN_SP_OFFSET) == SuspenderObjectData::offsetOfMainSP() && \ + (SUSPENDABLE_FP_OFFSET) == \ + SuspenderObjectData::offsetOfSuspendableFP() && \ + (SUSPENDABLE_SP_OFFSET) == \ + SuspenderObjectData::offsetOfSuspendableSP()); + + // The following assembly code temporarily switches FP/SP pointers to be on + // main stack, while maintaining frames linking. After + // `CallImportData::Call` execution suspendable stack FP/SP will be restored. + // + // Because the assembly sequences contain a call, the trashed-register list + // must contain all the caller saved registers. They must also contain "cc" + // and "memory" since both of those state elements could be modified by the + // call. They also need a "volatile" qualifier to ensure that the they don't + // get optimised out or otherwise messed with by clang/gcc. + // + // `Registers::VolatileMask` (in the assembler complex) is useful in that it + // lists the caller-saved registers. + + uintptr_t res; + + // clang-format off +#if defined(_M_ARM64) || defined(__aarch64__) +# define CALLER_SAVED_REGS \ + "x0", "x1", "x2", "x3","x4", "x5", "x6", "x7", "x8", "x9", "x10", \ + "x11", "x12", "x13", "x14", "x15", "x16", "x17", /* "x18", */ \ + "x19", "x20", /* it's unclear who saves these two, so be safe */ \ + /* claim that all the vector regs are caller-saved, for safety */ \ + "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", \ + "v11", "v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", \ + "v20", "v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", \ + "v29", "v30", "v31" +# define INLINED_ASM(MAIN_FP, MAIN_SP, SUSPENDABLE_FP, SUSPENDABLE_SP) \ + CHECK_OFFSETS(MAIN_FP, MAIN_SP, SUSPENDABLE_FP, SUSPENDABLE_SP); \ + asm volatile( \ + "\n mov x0, %1" \ + "\n mov x27, sp " \ + "\n str x29, [x0, #" #SUSPENDABLE_FP "] " \ + "\n str x27, [x0, #" #SUSPENDABLE_SP "] " \ + \ + "\n ldr x29, [x0, #" #MAIN_FP "] " \ + "\n ldr x27, [x0, #" #MAIN_SP "] " \ + "\n mov sp, x27 " \ + \ + "\n stp x0, x27, [sp, #-16]! " \ + \ + "\n mov x0, %3" \ + "\n blr %2 " \ + \ + "\n ldp x3, x27, [sp], #16 " \ + \ + "\n mov x27, sp " \ + "\n str x29, [x3, #" #MAIN_FP "] " \ + "\n str x27, [x3, #" #MAIN_SP "] " \ + \ + "\n ldr x29, [x3, #" #SUSPENDABLE_FP "] " \ + "\n ldr x27, [x3, #" #SUSPENDABLE_SP "] " \ + "\n mov sp, x27 " \ + "\n mov %0, x0" \ + : "=r"(res) \ + : "r"(stacks), "r"(CallImportData::Call), "r"(&data) \ + : "x0", "x3", "x27", CALLER_SAVED_REGS, "cc", "memory") + INLINED_ASM(24, 32, 40, 48); + +# elif defined(_WIN64) && defined(_M_X64) +# define INLINED_ASM(MAIN_FP, MAIN_SP, SUSPENDABLE_FP, SUSPENDABLE_SP) \ + CHECK_OFFSETS(MAIN_FP, MAIN_SP, SUSPENDABLE_FP, SUSPENDABLE_SP); \ + asm("\n mov %1, %%rcx" \ + "\n mov %%rbp, " #SUSPENDABLE_FP "(%%rcx)" \ + "\n mov %%rsp, " #SUSPENDABLE_SP "(%%rcx)" \ + \ + "\n mov " #MAIN_FP "(%%rcx), %%rbp" \ + "\n mov " #MAIN_SP "(%%rcx), %%rsp" \ + \ + "\n push %%rcx" \ + "\n push %%rdx" \ + \ + "\n mov %3, %%rcx" \ + "\n call *%2" \ + \ + "\n pop %%rdx" \ + "\n pop %%rcx" \ + \ + "\n mov %%rbp, " #MAIN_FP "(%%rcx)" \ + "\n mov %%rsp, " #MAIN_SP "(%%rcx)" \ + \ + "\n mov " #SUSPENDABLE_FP "(%%rcx), %%rbp" \ + "\n mov " #SUSPENDABLE_SP "(%%rcx), %%rsp" \ + \ + "\n movq %%rax, %0" \ + : "=r"(res) \ + : "r"(stacks), "r"(CallImportData::Call), "r"(&data) \ + : "rcx", "rax") + INLINED_ASM(24, 32, 40, 48); + +# elif defined(__x86_64__) +# define INLINED_ASM(MAIN_FP, MAIN_SP, SUSPENDABLE_FP, SUSPENDABLE_SP) \ + CHECK_OFFSETS(MAIN_FP, MAIN_SP, SUSPENDABLE_FP, SUSPENDABLE_SP); \ + asm("\n mov %1, %%rdi" \ + "\n mov %%rbp, " #SUSPENDABLE_FP "(%%rdi)" \ + "\n mov %%rsp, " #SUSPENDABLE_SP "(%%rdi)" \ + \ + "\n mov " #MAIN_FP "(%%rdi), %%rbp" \ + "\n mov " #MAIN_SP "(%%rdi), %%rsp" \ + \ + "\n push %%rdi" \ + "\n push %%rdx" \ + \ + "\n mov %3, %%rdi" \ + "\n call *%2" \ + \ + "\n pop %%rdx" \ + "\n pop %%rdi" \ + \ + "\n mov %%rbp, " #MAIN_FP "(%%rdi)" \ + "\n mov %%rsp, " #MAIN_SP "(%%rdi)" \ + \ + "\n mov " #SUSPENDABLE_FP "(%%rdi), %%rbp" \ + "\n mov " #SUSPENDABLE_SP "(%%rdi), %%rsp" \ + \ + "\n movq %%rax, %0" \ + : "=r"(res) \ + : "r"(stacks), "r"(CallImportData::Call), "r"(&data) \ + : "rdi", "rax") + INLINED_ASM(24, 32, 40, 48); + +# else + MOZ_CRASH("Not supported for this platform"); +# endif + // clang-format on + + bool ok = res; + suspender->setActive(cx); + cx->wasm().promiseIntegration.setActiveSuspender(suspender); + +# undef INLINED_ASM +# undef CHECK_OFFSETS +# undef CALLER_SAVED_REGS + + return ok; +} + +void UnwindStackSwitch(JSContext* cx) { + SuspenderObject* suspender = cx->wasm().promiseIntegration.activeSuspender(); + MOZ_ASSERT(suspender); + cx->wasm().promiseIntegration.setActiveSuspender(nullptr); + suspender->setMoribund(cx); +} + +// Suspending + +// Builds a wasm module with following structure: +// (module +// (type $params (struct (field ..)*))) +// (type $results (struct (field ..)*))) +// (import "" "" (func $suspending.wrappedfn ..)) +// (import "" "" (func $suspending.add-promise-reactions ..)) +// (import "" "" (func $suspending.get-suspending-promise-result ..)) +// (func $suspending.exported .. ) +// (func $suspending.trampoline ..) +// (func $suspending.continue-on-suspendable ..) +// (export "" (func $suspending.exported)) +// ) +class SuspendingFunctionModuleFactory { + public: + enum TypeIdx { + ParamsTypeIndex, + ResultsTypeIndex, + }; + + enum FnIdx { + WrappedFnIndex, + GetSuspendingResultsFnIndex, + ExportedFnIndex, + TrampolineFnIndex, + ContinueOnSuspendableFnIndex + }; + + private: + // Builds function that will be imported to wasm module: + // (func $suspending.exported + // (param $suspender externref)? (param ..)* (param $suspender externref)? + // (result ..)* + // (local $suspender externref)? + // (local $results (ref $results)) + // ;; #if checkSuspender + // local.get $suspender + // call $builtin.check-suspender + // ;; #else + // call $builtin.current-suspender + // local.tee $suspender + // ;; #endif + // ref.func $suspending.trampoline + // local.get $i* + // stuct.new $param-type + // stack-switch SwitchToMain ;; <- (suspender,fn,data) + // local.get $suspender + // call $builtin.get-suspending-promise-result + // ref.cast $results-type + // local.set $results + // (struct.get $results (local.get $results))* + // ) + bool encodeExportedFunction(ModuleEnvironment& moduleEnv, uint32_t paramsSize, + uint32_t resultSize, uint32_t paramsOffset, + uint32_t suspenderIndex, bool checkSuspender, + RefType resultType, Bytes& bytecode) { + Encoder encoder(bytecode, *moduleEnv.types); + ValTypeVector locals; + if (!checkSuspender && !locals.emplaceBack(RefType::extern_())) { + return false; + } + if (!locals.emplaceBack(resultType)) { + return false; + } + if (!EncodeLocalEntries(encoder, locals)) { + return false; + } + + if (checkSuspender) { + if (!encoder.writeOp(Op::LocalGet) || + !encoder.writeVarU32(suspenderIndex)) { + return false; + } + if (!encoder.writeOp(MozOp::CallBuiltinModuleFunc) || + !encoder.writeVarU32((uint32_t)BuiltinModuleFuncId::CheckSuspender)) { + return false; + } + } else { + if (!encoder.writeOp(Op::I32Const) || !encoder.writeVarU32(0)) { + return false; + } + if (!encoder.writeOp(MozOp::CallBuiltinModuleFunc) || + !encoder.writeVarU32( + (uint32_t)BuiltinModuleFuncId::CurrentSuspender)) { + return false; + } + if (!encoder.writeOp(Op::LocalTee) || + !encoder.writeVarU32(suspenderIndex)) { + return false; + } + } + + // Results local is located after all params and suspender. + // Adding 1 to paramSize for checkSuspender and ! cases. + int resultsIndex = paramsSize + 1; + + if (!encoder.writeOp(Op::RefFunc) || + !encoder.writeVarU32(TrampolineFnIndex)) { + return false; + } + for (uint32_t i = 0; i < paramsSize; i++) { + if (!encoder.writeOp(Op::LocalGet) || + !encoder.writeVarU32(i + paramsOffset)) { + return false; + } + } + if (!encoder.writeOp(GcOp::StructNew) || + !encoder.writeVarU32(ParamsTypeIndex)) { + return false; + } + + if (!encoder.writeOp(MozOp::StackSwitch) || + !encoder.writeVarU32(uint32_t(StackSwitchKind::SwitchToMain))) { + return false; + } + + if (!encoder.writeOp(Op::LocalGet) || + !encoder.writeVarU32(suspenderIndex)) { + return false; + } + if (!encoder.writeOp(MozOp::CallBuiltinModuleFunc) || + !encoder.writeVarU32( + (uint32_t)BuiltinModuleFuncId::GetSuspendingPromiseResult)) { + return false; + } + if (!encoder.writeOp(GcOp::RefCast) || + !encoder.writeVarU32(ResultsTypeIndex) || + !encoder.writeOp(Op::LocalSet) || !encoder.writeVarU32(resultsIndex)) { + return false; + } + for (uint32_t i = 0; i < resultSize; i++) { + if (!encoder.writeOp(Op::LocalGet) || + !encoder.writeVarU32(resultsIndex) || + !encoder.writeOp(GcOp::StructGet) || + !encoder.writeVarU32(ResultsTypeIndex) || !encoder.writeVarU32(i)) { + return false; + } + } + return encoder.writeOp(Op::End); + } + + // Builds function that is called on main stack: + // (func $suspending.trampoline + // (param $params (ref $suspender) (ref $param-type)) + // (result externref) + // local.get $suspender ;; for call $process-promise + // (struct.get $param-type $i (local.get $param))* + // call $suspending.wrappedfn + // ref.func $suspending.continue-on-suspendable + // call $suspending.add-promise-reactions + // ) + // The function calls suspending import and returns into the + // $promising.exported function because that was the top function + // on the main stack. + bool encodeTrampolineFunction(ModuleEnvironment& moduleEnv, + uint32_t paramsSize, Bytes& bytecode) { + Encoder encoder(bytecode, *moduleEnv.types); + if (!EncodeLocalEntries(encoder, ValTypeVector())) { + return false; + } + const uint32_t SuspenderIndex = 0; + const uint32_t ParamsIndex = 1; + + // For GetSuspendingResultsFnIndex call below. + if (!encoder.writeOp(Op::LocalGet) || + !encoder.writeVarU32(SuspenderIndex)) { + return false; + } + + for (uint32_t i = 0; i < paramsSize; i++) { + if (!encoder.writeOp(Op::LocalGet) || !encoder.writeVarU32(ParamsIndex)) { + return false; + } + if (!encoder.writeOp(GcOp::StructGet) || + !encoder.writeVarU32(ParamsTypeIndex) || !encoder.writeVarU32(i)) { + return false; + } + } + if (!encoder.writeOp(Op::Call) || !encoder.writeVarU32(WrappedFnIndex)) { + return false; + } + + if (!encoder.writeOp(Op::RefFunc) || + !encoder.writeVarU32(ContinueOnSuspendableFnIndex)) { + return false; + } + if (!encoder.writeOp(Op::Call) || + !encoder.writeVarU32(GetSuspendingResultsFnIndex)) { + return false; + } + + return encoder.writeOp(Op::End); + } + + // Builds function that is called on main stack: + // (func $suspending.continue-on-suspendable + // (param $params (ref $suspender)) + // (result externref) + // local.get $suspender + // ref.null funcref + // ref.null anyref + // stack-switch ContinueOnSuspendable + // ) + bool encodeContinueOnSuspendableFunction(ModuleEnvironment& moduleEnv, + uint32_t resultsSize, + Bytes& bytecode) { + Encoder encoder(bytecode, *moduleEnv.types); + if (!EncodeLocalEntries(encoder, ValTypeVector())) { + return false; + } + + const uint32_t SuspenderIndex = 0; + if (!encoder.writeOp(Op::LocalGet) || + !encoder.writeVarU32(SuspenderIndex)) { + return false; + } + if (!encoder.writeOp(Op::RefNull) || + !encoder.writeValType(ValType(RefType::func()))) { + return false; + } + if (!encoder.writeOp(Op::RefNull) || + !encoder.writeValType(ValType(RefType::any()))) { + return false; + } + + if (!encoder.writeOp(MozOp::StackSwitch) || + !encoder.writeVarU32( + uint32_t(StackSwitchKind::ContinueOnSuspendable))) { + return false; + } + + return encoder.writeOp(Op::End); + } + + public: + SharedModule build(JSContext* cx, HandleObject func, ValTypeVector&& params, + ValTypeVector&& results, + SuspenderArgPosition argPosition) { + FeatureOptions options; + options.isBuiltinModule = true; + options.requireGC = true; + options.requireTailCalls = true; + + ScriptedCaller scriptedCaller; + SharedCompileArgs compileArgs = + CompileArgs::buildAndReport(cx, std::move(scriptedCaller), options); + if (!compileArgs) { + return nullptr; + } + + ModuleEnvironment moduleEnv(compileArgs->features); + MOZ_ASSERT(IonAvailable(cx)); + CompilerEnvironment compilerEnv(CompileMode::Once, Tier::Optimized, + DebugEnabled::False); + compilerEnv.computeParameters(); + + if (!moduleEnv.init()) { + return nullptr; + } + + RefType suspenderType = RefType::extern_(); + RefType promiseType = RefType::extern_(); + + size_t paramsSize, paramsOffset, suspenderIndex; + size_t resultsSize = results.length(); + bool checkSuspender; + ValTypeVector paramsWithoutSuspender; + switch (argPosition) { + case SuspenderArgPosition::First: + paramsSize = params.length() - 1; + paramsOffset = 1; + suspenderIndex = 0; + if (!paramsWithoutSuspender.append(params.begin() + 1, params.end())) { + ReportOutOfMemory(cx); + return nullptr; + } + checkSuspender = true; + break; + case SuspenderArgPosition::Last: + paramsSize = params.length() - 1; + paramsOffset = 0; + suspenderIndex = paramsSize - 1; + if (!paramsWithoutSuspender.append(params.begin(), params.end() - 1)) { + ReportOutOfMemory(cx); + return nullptr; + } + checkSuspender = true; + break; + default: + paramsSize = params.length(); + paramsOffset = 0; + suspenderIndex = paramsSize; + if (!paramsWithoutSuspender.append(params.begin(), params.end())) { + ReportOutOfMemory(cx); + return nullptr; + } + checkSuspender = false; + break; + } + ValTypeVector resultsRef; + if (!resultsRef.emplaceBack(promiseType)) { + ReportOutOfMemory(cx); + return nullptr; + } + + StructType boxedParamsStruct; + if (!StructType::createImmutable(paramsWithoutSuspender, + &boxedParamsStruct)) { + ReportOutOfMemory(cx); + return nullptr; + } + MOZ_ASSERT(moduleEnv.types->length() == ParamsTypeIndex); + if (!moduleEnv.types->addType(std::move(boxedParamsStruct))) { + return nullptr; + } + + StructType boxedResultType; + if (!StructType::createImmutable(results, &boxedResultType)) { + ReportOutOfMemory(cx); + return nullptr; + } + MOZ_ASSERT(moduleEnv.types->length() == ResultsTypeIndex); + if (!moduleEnv.types->addType(std::move(boxedResultType))) { + return nullptr; + } + + MOZ_ASSERT(moduleEnv.funcs.length() == WrappedFnIndex); + if (!moduleEnv.addDefinedFunc(std::move(paramsWithoutSuspender), + std::move(resultsRef))) { + return nullptr; + } + + ValTypeVector paramsGetSuspendingResults, resultsGetSuspendingResults; + if (!paramsGetSuspendingResults.emplaceBack(suspenderType) || + !paramsGetSuspendingResults.emplaceBack(promiseType) || + !paramsGetSuspendingResults.emplaceBack(RefType::func())) { + ReportOutOfMemory(cx); + return nullptr; + } + MOZ_ASSERT(moduleEnv.funcs.length() == GetSuspendingResultsFnIndex); + if (!moduleEnv.addDefinedFunc(std::move(paramsGetSuspendingResults), + std::move(resultsGetSuspendingResults))) { + return nullptr; + } + + // Imports names are not important, declare functions above as imports. + moduleEnv.numFuncImports = moduleEnv.funcs.length(); + + // We will be looking up and using the exports function by index so + // the name doesn't matter. + MOZ_ASSERT(moduleEnv.funcs.length() == ExportedFnIndex); + if (!moduleEnv.addDefinedFunc(std::move(params), std::move(results), + /*declareForRef = */ true, + mozilla::Some(CacheableName()))) { + return nullptr; + } + + ValTypeVector paramsTrampoline, resultsTrampoline; + if (!paramsTrampoline.emplaceBack(suspenderType) || + !paramsTrampoline.emplaceBack(RefType::fromTypeDef( + &(*moduleEnv.types)[ParamsTypeIndex], false))) { + ReportOutOfMemory(cx); + return nullptr; + } + MOZ_ASSERT(moduleEnv.funcs.length() == TrampolineFnIndex); + if (!moduleEnv.addDefinedFunc(std::move(paramsTrampoline), + std::move(resultsTrampoline), + /*declareForRef = */ true)) { + return nullptr; + } + + ValTypeVector paramsContinueOnSuspendable, resultsContinueOnSuspendable; + if (!paramsContinueOnSuspendable.emplaceBack(suspenderType) || + !paramsContinueOnSuspendable.emplaceBack(RefType::extern_())) { + ReportOutOfMemory(cx); + return nullptr; + } + MOZ_ASSERT(moduleEnv.funcs.length() == ContinueOnSuspendableFnIndex); + if (!moduleEnv.addDefinedFunc(std::move(paramsContinueOnSuspendable), + std::move(resultsContinueOnSuspendable), + /*declareForRef = */ true)) { + return nullptr; + } + + ModuleGenerator mg(*compileArgs, &moduleEnv, &compilerEnv, nullptr, nullptr, + nullptr); + if (!mg.init(nullptr)) { + return nullptr; + } + // Build functions and keep bytecodes around until the end. + Bytes bytecode; + if (!encodeExportedFunction( + moduleEnv, paramsSize, resultsSize, paramsOffset, suspenderIndex, + checkSuspender, + RefType::fromTypeDef(&(*moduleEnv.types)[ResultsTypeIndex], false), + bytecode)) { + ReportOutOfMemory(cx); + return nullptr; + } + if (!mg.compileFuncDef(ExportedFnIndex, 0, bytecode.begin(), + bytecode.begin() + bytecode.length())) { + return nullptr; + } + Bytes bytecode2; + if (!encodeTrampolineFunction(moduleEnv, paramsSize, bytecode2)) { + ReportOutOfMemory(cx); + return nullptr; + } + if (!mg.compileFuncDef(TrampolineFnIndex, 0, bytecode2.begin(), + bytecode2.begin() + bytecode2.length())) { + return nullptr; + } + Bytes bytecode3; + if (!encodeContinueOnSuspendableFunction(moduleEnv, paramsSize, + bytecode3)) { + ReportOutOfMemory(cx); + return nullptr; + } + if (!mg.compileFuncDef(ContinueOnSuspendableFnIndex, 0, bytecode3.begin(), + bytecode3.begin() + bytecode3.length())) { + return nullptr; + } + if (!mg.finishFuncDefs()) { + return nullptr; + } + + SharedBytes shareableBytes = js_new<ShareableBytes>(); + if (!shareableBytes) { + ReportOutOfMemory(cx); + return nullptr; + } + return mg.finishModule(*shareableBytes); + } +}; + +// Reaction on resolved/rejected suspending promise. +static bool WasmPISuspendTaskContinue(JSContext* cx, unsigned argc, Value* vp) { + CallArgs args = CallArgsFromVp(argc, vp); + Rooted<JSFunction*> callee(cx, &args.callee().as<JSFunction>()); + RootedValue suspender(cx, callee->getExtendedSlot(SUSPENDER_SLOT)); + + // Convert result of the promise into the parameters/arguments for the + // $suspending.continue-on-suspendable. + RootedFunction continueOnSuspendable( + cx, &callee->getExtendedSlot(CONTINUE_ON_SUSPENDABLE_SLOT) + .toObject() + .as<JSFunction>()); + RootedValueVector argv(cx); + if (!argv.emplaceBack(suspender)) { + ReportOutOfMemory(cx); + return false; + } + MOZ_ASSERT(args.length() > 0); + if (!argv.emplaceBack(args[0])) { + ReportOutOfMemory(cx); + return false; + } + + JS::Rooted<JS::Value> rval(cx); + if (Call(cx, UndefinedHandleValue, continueOnSuspendable, argv, &rval)) { + return true; + } + + if (cx->isThrowingOutOfMemory()) { + return false; + } + Rooted<PromiseObject*> promise( + cx, suspender.toObject().as<SuspenderObject>().promisingPromise()); + return RejectPromiseWithPendingError(cx, promise); +} + +// Collects returned suspending promising, and registers callbacks to +// react on it using WasmPISuspendTaskContinue. +// Seen as $suspending.add-promise-reactions in wasm. +static bool WasmPIAddPromiseReactions(JSContext* cx, unsigned argc, Value* vp) { + CallArgs args = CallArgsFromVp(argc, vp); + + Rooted<SuspenderObject*> suspenderObject( + cx, &args[0].toObject().as<SuspenderObject>()); + RootedValue rval(cx, args[1]); + RootedFunction fn(cx, &args[2].toObject().as<JSFunction>()); + + MOZ_ASSERT(rval.toObject().is<PromiseObject>(), + "WasmPIWrapSuspendingImport always returning a promise"); + Rooted<PromiseObject*> promise(cx, &rval.toObject().as<PromiseObject>()); + suspenderObject->setSuspendingPromise(promise); + + // Pass fn here + RootedFunction then_( + cx, NewNativeFunction(cx, WasmPISuspendTaskContinue, 1, nullptr, + gc::AllocKind::FUNCTION_EXTENDED, GenericObject)); + then_->initExtendedSlot(SUSPENDER_SLOT, ObjectValue(*suspenderObject)); + then_->initExtendedSlot(CONTINUE_ON_SUSPENDABLE_SLOT, ObjectValue(*fn)); + return AddPromiseReactions(cx, promise, then_, then_); +} + +// Wraps original import to catch all exceptions and convert result to a +// promise. +// Seen as $suspending.wrappedfn in wasm. +static bool WasmPIWrapSuspendingImport(JSContext* cx, unsigned argc, + Value* vp) { + CallArgs args = CallArgsFromVp(argc, vp); + Rooted<JSFunction*> callee(cx, &args.callee().as<JSFunction>()); + RootedFunction originalImportFunc( + cx, + &callee->getExtendedSlot(WRAPPED_FN_SLOT).toObject().as<JSFunction>()); + + // Catching exceptions here. + RootedValue rval(cx); + if (Call(cx, UndefinedHandleValue, originalImportFunc, args, &rval)) { + // Convert the result to a resolved promise. + RootedObject promiseConstructor(cx, GetPromiseConstructor(cx)); + RootedObject promiseObj(cx, PromiseResolve(cx, promiseConstructor, rval)); + if (!promiseObj) { + return false; + } + args.rval().setObject(*promiseObj); + return true; + } + + if (cx->isThrowingOutOfMemory()) { + return false; + } + + // Convert failure to a rejected promise. + RootedObject promiseObject(cx, NewPromiseObject(cx, nullptr)); + if (!promiseObject) { + return false; + } + args.rval().setObject(*promiseObject); + + Rooted<PromiseObject*> promise(cx, &promiseObject->as<PromiseObject>()); + return RejectPromiseWithPendingError(cx, promise); +} + +JSFunction* WasmSuspendingFunctionCreate(JSContext* cx, HandleObject func, + ValTypeVector&& params, + ValTypeVector&& results, + SuspenderArgPosition argPosition) { + MOZ_ASSERT(IsCallable(ObjectValue(*func)) && + !IsCrossCompartmentWrapper(func)); + + if (argPosition != SuspenderArgPosition::None) { + if (params.length() < 1 || + params[argPosition == SuspenderArgPosition::Last ? params.length() - 1 + : 0] != + RefType::extern_()) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_JSPI_EXPECTED_SUSPENDER); + return nullptr; + } + } + + SuspendingFunctionModuleFactory moduleFactory; + SharedModule module = moduleFactory.build(cx, func, std::move(params), + std::move(results), argPosition); + if (!module) { + return nullptr; + } + + // Instantiate the module. + Rooted<ImportValues> imports(cx); + + // Add $suspending.wrappedfn to imports. + RootedFunction funcWrapper( + cx, NewNativeFunction(cx, WasmPIWrapSuspendingImport, 0, nullptr, + gc::AllocKind::FUNCTION_EXTENDED, GenericObject)); + if (!funcWrapper) { + return nullptr; + } + funcWrapper->initExtendedSlot(WRAPPED_FN_SLOT, ObjectValue(*func)); + if (!imports.get().funcs.append(funcWrapper)) { + ReportOutOfMemory(cx); + return nullptr; + } + + // Add $suspending.add-promise-reactions to imports. + RootedFunction addPromiseReactions( + cx, NewNativeFunction(cx, WasmPIAddPromiseReactions, 3, nullptr, + gc::AllocKind::FUNCTION_EXTENDED, GenericObject)); + if (!addPromiseReactions) { + return nullptr; + } + if (!imports.get().funcs.append(addPromiseReactions)) { + ReportOutOfMemory(cx); + return nullptr; + } + + Rooted<WasmInstanceObject*> instance(cx); + if (!module->instantiate(cx, imports.get(), nullptr, &instance)) { + // Can also trap on invalid input function. + return nullptr; + } + + // Returns the $suspending.exported function. + RootedFunction wasmFunc(cx); + if (!WasmInstanceObject::getExportedFunction( + cx, instance, SuspendingFunctionModuleFactory::ExportedFnIndex, + &wasmFunc)) { + return nullptr; + } + return wasmFunc; +} + +JSFunction* WasmSuspendingFunctionCreate(JSContext* cx, HandleObject func, + const FuncType& type) { + ValTypeVector params, results; + if (!params.append(type.args().begin(), type.args().end()) || + !results.append(type.results().begin(), type.results().end())) { + ReportOutOfMemory(cx); + return nullptr; + } + return WasmSuspendingFunctionCreate(cx, func, std::move(params), + std::move(results), + SuspenderArgPosition::None); +} + +// Promising + +// Builds a wasm module with following structure: +// (module +// (type $params (struct (field ..)*))) +// (type $results (struct (field ..)*))) +// (import "" "" (func $promising.wrappedfn ..)) +// (import "" "" (func $promising.create-suspender ..)) +// (func $promising.exported .. ) +// (func $promising.trampoline ..) +// (export "" (func $promising.exported)) +// ) +class PromisingFunctionModuleFactory { + public: + enum TypeIdx { + ParamsTypeIndex, + ResultsTypeIndex, + }; + + enum FnIdx { + WrappedFnIndex, + CreateSuspenderFnIndex, + ExportedFnIndex, + TrampolineFnIndex, + }; + + private: + // Builds function that will be exported for JS: + // (func $promising.exported + // (param ..)* (result externref) + // (local $promise externref) + // call $promising.create-suspender ;; -> (suspender,promise) + // local.set $promise + // ref.func $promising.trampoline + // local.get $i* + // stuct.new $param-type + // stack-switch SwitchToSuspendable ;; <- (suspender,fn,data) + // local.get $promise + // ) + bool encodeExportedFunction(ModuleEnvironment& moduleEnv, uint32_t paramsSize, + Bytes& bytecode) { + Encoder encoder(bytecode, *moduleEnv.types); + ValTypeVector locals; + if (!locals.emplaceBack(RefType::extern_())) { + return false; + } + if (!EncodeLocalEntries(encoder, locals)) { + return false; + } + + const uint32_t PromiseIndex = paramsSize; + if (!encoder.writeOp(Op::Call) || + !encoder.writeVarU32(CreateSuspenderFnIndex)) { + return false; + } + if (!encoder.writeOp(Op::LocalSet) || !encoder.writeVarU32(PromiseIndex)) { + return false; + } + + if (!encoder.writeOp(Op::RefFunc) || + !encoder.writeVarU32(TrampolineFnIndex)) { + return false; + } + for (uint32_t i = 0; i < paramsSize; i++) { + if (!encoder.writeOp(Op::LocalGet) || !encoder.writeVarU32(i)) { + return false; + } + } + if (!encoder.writeOp(GcOp::StructNew) || + !encoder.writeVarU32(ParamsTypeIndex)) { + return false; + } + if (!encoder.writeOp(MozOp::StackSwitch) || + !encoder.writeVarU32(uint32_t(StackSwitchKind::SwitchToSuspendable))) { + return false; + } + + if (!encoder.writeOp(Op::LocalGet) || !encoder.writeVarU32(PromiseIndex)) { + return false; + } + return encoder.writeOp(Op::End); + } + + // Builds function that is called on alternative stack: + // (func $promising.trampoline + // (param $suspender externref) (param $params (ref $param-type)) + // (result externref) + // local.get $suspender ;; for call $set-results + // (local.get $suspender)? + // (struct.get $param-type $i (local.get $param))* + // (local.get $suspender)? + // call $promising.wrappedfn + // struct.new $result-type + // call $builtin.set-promising-promise-results + // ) + bool encodeTrampolineFunction(ModuleEnvironment& moduleEnv, + uint32_t paramsSize, + SuspenderArgPosition argPosition, + Bytes& bytecode) { + Encoder encoder(bytecode, *moduleEnv.types); + if (!EncodeLocalEntries(encoder, ValTypeVector())) { + return false; + } + const uint32_t SuspenderIndex = 0; + const uint32_t ParamsIndex = 1; + + // Reserved for SetResultsFnIndex call at the end + if (!encoder.writeOp(Op::LocalGet) || + !encoder.writeVarU32(SuspenderIndex)) { + return false; + } + + if (argPosition == SuspenderArgPosition::First) { + if (!encoder.writeOp(Op::LocalGet) || + !encoder.writeVarU32(SuspenderIndex)) { + return false; + } + } + for (uint32_t i = 0; i < paramsSize; i++) { + if (!encoder.writeOp(Op::LocalGet) || !encoder.writeVarU32(ParamsIndex)) { + return false; + } + if (!encoder.writeOp(GcOp::StructGet) || + !encoder.writeVarU32(ParamsTypeIndex) || !encoder.writeVarU32(i)) { + return false; + } + } + if (argPosition == SuspenderArgPosition::Last) { + if (!encoder.writeOp(Op::LocalGet) || + !encoder.writeVarU32(SuspenderIndex)) { + return false; + } + } + if (!encoder.writeOp(Op::Call) || !encoder.writeVarU32(WrappedFnIndex)) { + return false; + } + + if (!encoder.writeOp(GcOp::StructNew) || + !encoder.writeVarU32(ResultsTypeIndex)) { + return false; + } + if (!encoder.writeOp(MozOp::CallBuiltinModuleFunc) || + !encoder.writeVarU32( + (uint32_t)BuiltinModuleFuncId::SetPromisingPromiseResults)) { + return false; + } + + return encoder.writeOp(Op::End); + } + + public: + SharedModule build(JSContext* cx, HandleFunction fn, ValTypeVector&& params, + ValTypeVector&& results, + SuspenderArgPosition argPosition) { + const FuncType& fnType = fn->wasmTypeDef()->funcType(); + size_t paramsSize = params.length(); + + RefType suspenderType = RefType::extern_(); + RefType promiseType = RefType::extern_(); + + FeatureOptions options; + options.isBuiltinModule = true; + options.requireGC = true; + options.requireTailCalls = true; + + ScriptedCaller scriptedCaller; + SharedCompileArgs compileArgs = + CompileArgs::buildAndReport(cx, std::move(scriptedCaller), options); + if (!compileArgs) { + return nullptr; + } + + ModuleEnvironment moduleEnv(compileArgs->features); + MOZ_ASSERT(IonAvailable(cx)); + CompilerEnvironment compilerEnv(CompileMode::Once, Tier::Optimized, + DebugEnabled::False); + compilerEnv.computeParameters(); + + if (!moduleEnv.init()) { + return nullptr; + } + + StructType boxedParamsStruct; + if (!StructType::createImmutable(params, &boxedParamsStruct)) { + ReportOutOfMemory(cx); + return nullptr; + } + MOZ_ASSERT(moduleEnv.types->length() == ParamsTypeIndex); + if (!moduleEnv.types->addType(std::move(boxedParamsStruct))) { + return nullptr; + } + + StructType boxedResultType; + if (!StructType::createImmutable(fnType.results(), &boxedResultType)) { + ReportOutOfMemory(cx); + return nullptr; + } + MOZ_ASSERT(moduleEnv.types->length() == ResultsTypeIndex); + if (!moduleEnv.types->addType(std::move(boxedResultType))) { + return nullptr; + } + + ValTypeVector paramsForWrapper, resultsForWrapper; + if (!paramsForWrapper.append(fnType.args().begin(), fnType.args().end()) || + !resultsForWrapper.append(fnType.results().begin(), + fnType.results().end())) { + ReportOutOfMemory(cx); + return nullptr; + } + MOZ_ASSERT(moduleEnv.funcs.length() == WrappedFnIndex); + if (!moduleEnv.addDefinedFunc(std::move(paramsForWrapper), + std::move(resultsForWrapper))) { + return nullptr; + } + + ValTypeVector paramsCreateSuspender, resultsCreateSuspender; + if (!resultsCreateSuspender.emplaceBack(suspenderType) || + !resultsCreateSuspender.emplaceBack(promiseType)) { + ReportOutOfMemory(cx); + return nullptr; + } + MOZ_ASSERT(moduleEnv.funcs.length() == CreateSuspenderFnIndex); + if (!moduleEnv.addDefinedFunc(std::move(paramsCreateSuspender), + std::move(resultsCreateSuspender))) { + return nullptr; + } + + // Imports names are not important, declare functions above as imports. + moduleEnv.numFuncImports = moduleEnv.funcs.length(); + + // We will be looking up and using the exports function by index so + // the name doesn't matter. + MOZ_ASSERT(moduleEnv.funcs.length() == ExportedFnIndex); + if (!moduleEnv.addDefinedFunc(std::move(params), std::move(results), + /* declareFoRef = */ true, + mozilla::Some(CacheableName()))) { + return nullptr; + } + + ValTypeVector paramsTrampoline, resultsTrampoline; + if (!paramsTrampoline.emplaceBack(suspenderType) || + !paramsTrampoline.emplaceBack(RefType::fromTypeDef( + &(*moduleEnv.types)[ParamsTypeIndex], false))) { + ReportOutOfMemory(cx); + return nullptr; + } + MOZ_ASSERT(moduleEnv.funcs.length() == TrampolineFnIndex); + if (!moduleEnv.addDefinedFunc(std::move(paramsTrampoline), + std::move(resultsTrampoline), + /* declareFoRef = */ true)) { + return nullptr; + } + + ModuleGenerator mg(*compileArgs, &moduleEnv, &compilerEnv, nullptr, nullptr, + nullptr); + if (!mg.init(nullptr)) { + return nullptr; + } + // Build functions and keep bytecodes around until the end. + Bytes bytecode; + if (!encodeExportedFunction(moduleEnv, paramsSize, bytecode)) { + ReportOutOfMemory(cx); + return nullptr; + } + if (!mg.compileFuncDef(ExportedFnIndex, 0, bytecode.begin(), + bytecode.begin() + bytecode.length())) { + return nullptr; + } + Bytes bytecode2; + if (!encodeTrampolineFunction(moduleEnv, paramsSize, argPosition, + bytecode2)) { + ReportOutOfMemory(cx); + return nullptr; + } + if (!mg.compileFuncDef(TrampolineFnIndex, 0, bytecode2.begin(), + bytecode2.begin() + bytecode2.length())) { + return nullptr; + } + if (!mg.finishFuncDefs()) { + return nullptr; + } + + SharedBytes shareableBytes = js_new<ShareableBytes>(); + if (!shareableBytes) { + ReportOutOfMemory(cx); + return nullptr; + } + return mg.finishModule(*shareableBytes); + } +}; + +// Creates a suspender and promise (that will be returned to JS code). +// Seen as $promising.create-suspender to wasm. +static bool WasmPICreateSuspender(JSContext* cx, unsigned argc, Value* vp) { + Rooted<SuspenderObject*> suspenderObject(cx, SuspenderObject::create(cx)); + RootedObject promiseObject(cx, NewPromiseObject(cx, nullptr)); + if (!promiseObject) { + return false; + } + + Rooted<PromiseObject*> promise(cx, &promiseObject->as<PromiseObject>()); + suspenderObject->setPromisingPromise(promise); + + CallArgs args = CallArgsFromVp(argc, vp); + Rooted<ArrayObject*> results(cx, NewDenseEmptyArray(cx)); + if (!NewbornArrayPush(cx, results, ObjectValue(*suspenderObject))) { + return false; + } + if (!NewbornArrayPush(cx, results, ObjectValue(*promise))) { + return false; + } + args.rval().setObject(*results); + return true; +} + +// Wraps call to wasm $promising.exported function to catch an exception and +// return a promise instead. +static bool WasmPIPromisingFunction(JSContext* cx, unsigned argc, Value* vp) { + CallArgs args = CallArgsFromVp(argc, vp); + Rooted<JSFunction*> callee(cx, &args.callee().as<JSFunction>()); + RootedFunction fn( + cx, + &callee->getExtendedSlot(WRAPPED_FN_SLOT).toObject().as<JSFunction>()); + + // Catching exceptions here. + if (Call(cx, UndefinedHandleValue, fn, args, args.rval())) { + return true; + } + + if (cx->isThrowingOutOfMemory()) { + return false; + } + + RootedObject promiseObject(cx, NewPromiseObject(cx, nullptr)); + if (!promiseObject) { + return false; + } + args.rval().setObject(*promiseObject); + + Rooted<PromiseObject*> promise(cx, &promiseObject->as<PromiseObject>()); + return RejectPromiseWithPendingError(cx, promise); +} + +JSFunction* WasmPromisingFunctionCreate(JSContext* cx, HandleObject func, + ValTypeVector&& params, + ValTypeVector&& results, + SuspenderArgPosition argPosition) { + RootedFunction wrappedWasmFunc(cx, &func->as<JSFunction>()); + MOZ_ASSERT(wrappedWasmFunc->isWasm()); + const FuncType& wrappedWasmFuncType = + wrappedWasmFunc->wasmTypeDef()->funcType(); + + if (argPosition != SuspenderArgPosition::None) { + if (results.length() != 1 || results[0] != RefType::extern_()) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_JSPI_EXPECTED_PROMISE); + return nullptr; + } + + size_t paramsOffset, suspenderIndex; + switch (argPosition) { + case SuspenderArgPosition::First: + paramsOffset = 1; + suspenderIndex = 0; + break; + case SuspenderArgPosition::Last: + paramsOffset = 0; + suspenderIndex = params.length(); + break; + default: + MOZ_CRASH(); + } + + if (wrappedWasmFuncType.args().length() != params.length() + 1 || + wrappedWasmFuncType.args()[suspenderIndex] != RefType::extern_()) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_JSPI_EXPECTED_SUSPENDER); + return nullptr; + } + for (size_t i = 0; i < params.length(); i++) { + if (params[i] != wrappedWasmFuncType.args()[i + paramsOffset]) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_JSPI_SIGNATURE_MISMATCH); + return nullptr; + } + } + } else { + MOZ_ASSERT(results.length() == 0 && params.length() == 0); + if (!results.append(RefType::extern_())) { + ReportOutOfMemory(cx); + return nullptr; + } + if (!params.append(wrappedWasmFuncType.args().begin(), + wrappedWasmFuncType.args().end())) { + ReportOutOfMemory(cx); + return nullptr; + } + } + + PromisingFunctionModuleFactory moduleFactory; + SharedModule module = moduleFactory.build( + cx, wrappedWasmFunc, std::move(params), std::move(results), argPosition); + // Instantiate the module. + Rooted<ImportValues> imports(cx); + + // Add wrapped function ($promising.wrappedfn) to imports. + if (!imports.get().funcs.append(func)) { + ReportOutOfMemory(cx); + return nullptr; + } + + // Add $promising.create-suspender to imports. + RootedFunction createSuspenderFunc( + cx, NewNativeFunction(cx, WasmPICreateSuspender, 0, nullptr, + gc::AllocKind::FUNCTION_EXTENDED, GenericObject)); + if (!createSuspenderFunc) { + return nullptr; + } + if (!imports.get().funcs.append(createSuspenderFunc)) { + ReportOutOfMemory(cx); + return nullptr; + } + + Rooted<WasmInstanceObject*> instance(cx); + if (!module->instantiate(cx, imports.get(), nullptr, &instance)) { + MOZ_ASSERT(cx->isThrowingOutOfMemory()); + return nullptr; + } + + // Wrap $promising.exported function for exceptions/traps handling. + RootedFunction wasmFunc(cx); + if (!WasmInstanceObject::getExportedFunction( + cx, instance, PromisingFunctionModuleFactory::ExportedFnIndex, + &wasmFunc)) { + return nullptr; + } + + RootedFunction wasmFuncWrapper( + cx, NewNativeFunction(cx, WasmPIPromisingFunction, 0, nullptr, + gc::AllocKind::FUNCTION_EXTENDED, GenericObject)); + if (!wasmFuncWrapper) { + return nullptr; + } + wasmFuncWrapper->initExtendedSlot(WRAPPED_FN_SLOT, ObjectValue(*wasmFunc)); + return wasmFuncWrapper; +} + +// Gets active suspender. +// The reserved parameter is a workaround for limitation in the +// WasmBuiltinModule.yaml generator to always have params. +SuspenderObject* CurrentSuspender(Instance* instance, int32_t reserved) { + MOZ_ASSERT(SASigCurrentSuspender.failureMode == FailureMode::FailOnNullPtr); + JSContext* cx = instance->cx(); + SuspenderObject* suspender = cx->wasm().promiseIntegration.activeSuspender(); + if (!suspender) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_JSPI_INVALID_STATE); + return nullptr; + } + return suspender; +} + +// Checks suspender value. +SuspenderObject* CheckSuspender(Instance* instance, JSObject* maybeSuspender) { + MOZ_ASSERT(SASigCheckSuspender.failureMode == FailureMode::FailOnNullPtr); + JSContext* cx = instance->cx(); + if (!maybeSuspender || !maybeSuspender->is<SuspenderObject>() || + &maybeSuspender->as<SuspenderObject>() != + cx->wasm().promiseIntegration.activeSuspender()) { + // Wrong suspender + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_JSPI_INVALID_SUSPENDER); + return nullptr; + } + SuspenderObject* suspenderObject = &maybeSuspender->as<SuspenderObject>(); + if (suspenderObject->state() != SuspenderState::Active) { + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_JSPI_INVALID_STATE); + return nullptr; + } + return suspenderObject; +} + +// Converts promise results into actual function result, or exception/trap +// if rejected. +JSObject* GetSuspendingPromiseResult(Instance* instance, + SuspenderObject* suspender) { + MOZ_ASSERT(SASigGetSuspendingPromiseResult.failureMode == + FailureMode::FailOnNullPtr); + JSContext* cx = instance->cx(); + Rooted<SuspenderObject*> suspenderObject(cx, suspender); + + Rooted<PromiseObject*> promise(cx, suspenderObject->suspendingPromise()); + + if (promise->state() == JS::PromiseState::Rejected) { + RootedValue reason(cx, promise->reason()); + // Result is also the reason of promise rejection. + cx->setPendingException(reason, ShouldCaptureStack::Maybe); + return nullptr; + } + + // Construct the results object. + Rooted<WasmStructObject*> results( + cx, instance->constantStructNewDefault( + cx, SuspendingFunctionModuleFactory::ResultsTypeIndex)); + const StructFieldVector& fields = results->typeDef().structType().fields_; + + MOZ_ASSERT(fields.length() <= 1); + if (fields.length() == 1) { + RootedValue jsValue(cx, promise->value()); + + // The struct object is constructed based on returns of exported function. + // It is the only way we can get ValType for Val::fromJSValue call. + auto bestTier = instance->code().bestTier(); + const wasm::FuncExport& funcExport = + instance->metadata(bestTier).lookupFuncExport( + SuspendingFunctionModuleFactory::ExportedFnIndex); + const wasm::FuncType& sig = + instance->metadata().getFuncExportType(funcExport); + + RootedVal val(cx); + MOZ_ASSERT(sig.result(0).storageType() == fields[0].type); + if (!Val::fromJSValue(cx, sig.result(0), jsValue, &val)) { + return nullptr; + } + results->storeVal(val, 0); + } + return results; +} + +// Resolves the promise using results packed by wasm. +int32_t SetPromisingPromiseResults(Instance* instance, + SuspenderObject* suspender, + WasmStructObject* results) { + MOZ_ASSERT(SASigSetPromisingPromiseResults.failureMode == + FailureMode::FailOnNegI32); + JSContext* cx = instance->cx(); + Rooted<WasmStructObject*> res(cx, results); + Rooted<SuspenderObject*> suspenderObject(cx, suspender); + RootedObject promise(cx, suspenderObject->promisingPromise()); + + const StructType& resultType = res->typeDef().structType(); + RootedValue val(cx); + // Unbox the result value from the struct, if any. + if (resultType.fields_.length() > 0) { + MOZ_RELEASE_ASSERT(resultType.fields_.length() == 1); + if (!res->getField(cx, /*index=*/0, &val)) { + return -1; + } + } + ResolvePromise(cx, promise, val); + return 0; +} + +void UpdateSuspenderState(Instance* instance, SuspenderObject* suspender, + UpdateSuspenderStateAction action) { + MOZ_ASSERT(SASigUpdateSuspenderState.failureMode == FailureMode::Infallible); + + JSContext* cx = instance->cx(); + switch (action) { + case UpdateSuspenderStateAction::Enter: + suspender->enter(cx); + break; + case UpdateSuspenderStateAction::Suspend: + suspender->suspend(cx); + break; + case UpdateSuspenderStateAction::Resume: + suspender->resume(cx); + break; + case UpdateSuspenderStateAction::Leave: + suspender->leave(cx); + break; + default: + MOZ_CRASH(); + } +} + +} // namespace js::wasm +#endif // ENABLE_WASM_JSPI diff --git a/js/src/wasm/WasmPI.h b/js/src/wasm/WasmPI.h new file mode 100644 index 0000000000..a26740d540 --- /dev/null +++ b/js/src/wasm/WasmPI.h @@ -0,0 +1,170 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: set ts=8 sts=2 et sw=2 tw=80: + * + * Copyright 2016 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef wasm_pi_h +#define wasm_pi_h + +#include "mozilla/DoublyLinkedList.h" // for DoublyLinkedListElement + +#include "js/TypeDecls.h" +#include "wasm/WasmTypeDef.h" + +namespace js { + +class WasmStructObject; + +namespace wasm { + +class SuspenderObject; + +static const uint32_t SuspenderObjectDataSlot = 0; + +enum SuspenderArgPosition { + None = -1, + First = 0, + Last = 1, +}; + +enum SuspenderState { + Initial, + Moribund, + Active, + Suspended, +}; + +class SuspenderObjectData + : public mozilla::DoublyLinkedListElement<SuspenderObjectData> { + void* stackMemory_; + + // Stored main stack FP register. + void* mainFP_; + + // Stored main stack SP register. + void* mainSP_; + + // Stored suspendable stack FP register. + void* suspendableFP_; + + // Stored suspendable stack SP register. + void* suspendableSP_; + + // Stored suspendable stack exit/bottom frame pointer. + void* suspendableExitFP_; + + // Stored return address for return to suspendable stack. + void* suspendedReturnAddress_; + + SuspenderState state_; + +#ifdef _WIN64 + // The storage of main stack limits during stack switching. + // See updateTibFields and restoreTibFields below. + void* savedStackBase_; + void* savedStackLimit_; +#endif + + public: + explicit SuspenderObjectData(void* stackMemory); + + inline SuspenderState state() const { return state_; } + void setState(SuspenderState state) { state_ = state; } + + inline void* stackMemory() const { return stackMemory_; } + inline void* mainFP() const { return mainFP_; } + inline void* mainSP() const { return mainSP_; } + inline void* suspendableFP() const { return suspendableFP_; } + inline void* suspendableSP() const { return suspendableSP_; } + inline void* suspendableExitFP() const { return suspendableExitFP_; } + inline void* suspendedReturnAddress() const { + return suspendedReturnAddress_; + } + +#ifdef _WIN64 + void updateTIBStackFields(); + void restoreTIBStackFields(); +#endif + + static constexpr size_t offsetOfMainFP() { + return offsetof(SuspenderObjectData, mainFP_); + } + + static constexpr size_t offsetOfMainSP() { + return offsetof(SuspenderObjectData, mainSP_); + } + + static constexpr size_t offsetOfSuspendableFP() { + return offsetof(SuspenderObjectData, suspendableFP_); + } + + static constexpr size_t offsetOfSuspendableSP() { + return offsetof(SuspenderObjectData, suspendableSP_); + } + + static constexpr size_t offsetOfSuspendableExitFP() { + return offsetof(SuspenderObjectData, suspendableExitFP_); + } + + static constexpr size_t offsetOfSuspendedReturnAddress() { + return offsetof(SuspenderObjectData, suspendedReturnAddress_); + } +}; + +#ifdef ENABLE_WASM_JSPI + +bool ParseSuspendingPromisingString(JSContext* cx, JS::HandleValue val, + SuspenderArgPosition& result); + +bool CallImportOnMainThread(JSContext* cx, Instance* instance, + int32_t funcImportIndex, int32_t argc, + uint64_t* argv); + +void UnwindStackSwitch(JSContext* cx); + +JSFunction* WasmSuspendingFunctionCreate(JSContext* cx, HandleObject func, + wasm::ValTypeVector&& params, + wasm::ValTypeVector&& results, + SuspenderArgPosition argPosition); + +JSFunction* WasmSuspendingFunctionCreate(JSContext* cx, HandleObject func, + const FuncType& type); + +JSFunction* WasmPromisingFunctionCreate(JSContext* cx, HandleObject func, + wasm::ValTypeVector&& params, + wasm::ValTypeVector&& results, + SuspenderArgPosition argPosition); + +SuspenderObject* CurrentSuspender(Instance* instance, int reserved); + +SuspenderObject* CheckSuspender(Instance* instance, JSObject* maybeSuspender); + +JSObject* GetSuspendingPromiseResult(Instance* instance, + SuspenderObject* suspender); + +int32_t SetPromisingPromiseResults(Instance* instance, + SuspenderObject* suspender, + WasmStructObject* results); + +void UpdateSuspenderState(Instance* instance, SuspenderObject* suspender, + UpdateSuspenderStateAction action); + +#endif // ENABLE_WASM_JSPI + +} // namespace wasm +} // namespace js + +#endif // wasm_pi_h diff --git a/js/src/wasm/WasmRealm.cpp b/js/src/wasm/WasmRealm.cpp index 8907715c8f..61d8b96a44 100644 --- a/js/src/wasm/WasmRealm.cpp +++ b/js/src/wasm/WasmRealm.cpp @@ -150,3 +150,22 @@ void wasm::ResetInterruptState(JSContext* cx) { instance->resetInterrupt(cx); } } + +#ifdef ENABLE_WASM_JSPI +void wasm::UpdateInstanceStackLimitsForSuspendableStack( + JSContext* cx, JS::NativeStackLimit limit) { + auto runtimeInstances = cx->runtime()->wasmInstances.lock(); + cx->wasm().suspendableStackLimit = limit; + for (Instance* instance : runtimeInstances.get()) { + instance->setTemporaryStackLimit(limit); + } +} + +void wasm::ResetInstanceStackLimits(JSContext* cx) { + auto runtimeInstances = cx->runtime()->wasmInstances.lock(); + cx->wasm().suspendableStackLimit = JS::NativeStackLimitMin; + for (Instance* instance : runtimeInstances.get()) { + instance->resetTemporaryStackLimit(cx); + } +} +#endif // ENABLE_WASM_JSPI diff --git a/js/src/wasm/WasmRealm.h b/js/src/wasm/WasmRealm.h index 6ad7c435b9..46267456f1 100644 --- a/js/src/wasm/WasmRealm.h +++ b/js/src/wasm/WasmRealm.h @@ -78,6 +78,12 @@ extern void InterruptRunningCode(JSContext* cx); void ResetInterruptState(JSContext* cx); +#ifdef ENABLE_WASM_JSPI +void UpdateInstanceStackLimitsForSuspendableStack(JSContext* cx, + JS::NativeStackLimit limit); +void ResetInstanceStackLimits(JSContext* cx); +#endif + } // namespace wasm } // namespace js diff --git a/js/src/wasm/WasmSerialize.cpp b/js/src/wasm/WasmSerialize.cpp index 35f437688c..e8cf904064 100644 --- a/js/src/wasm/WasmSerialize.cpp +++ b/js/src/wasm/WasmSerialize.cpp @@ -957,7 +957,10 @@ CoderResult CodeSymbolicLinkArray( template <CoderMode mode> CoderResult CodeLinkData(Coder<mode>& coder, CoderArg<mode, wasm::LinkData> item) { - WASM_VERIFY_SERIALIZATION_FOR_SIZE(wasm::LinkData, 8976); + // SymbolicLinkArray depends on SymbolicAddress::Limit, which is changed + // often. Exclude symbolicLinks field from trip wire value calculation. + WASM_VERIFY_SERIALIZATION_FOR_SIZE( + wasm::LinkData, 48 + sizeof(wasm::LinkData::SymbolicLinkArray)); if constexpr (mode == MODE_ENCODE) { MOZ_ASSERT(item->tier == Tier::Serialized); } diff --git a/js/src/wasm/WasmStubs.cpp b/js/src/wasm/WasmStubs.cpp index dfaa898744..76f015d34b 100644 --- a/js/src/wasm/WasmStubs.cpp +++ b/js/src/wasm/WasmStubs.cpp @@ -1862,6 +1862,39 @@ static void FillArgumentArrayForJitExit(MacroAssembler& masm, Register instance, GenPrintf(DebugChannel::Import, masm, "\n"); } +static bool AddStackCheckForImportFunctionEntry(jit::MacroAssembler& masm, + unsigned reserve, + const FuncType& funcType, + StackMaps* stackMaps) { + std::pair<CodeOffset, uint32_t> pair = + masm.wasmReserveStackChecked(reserve, BytecodeOffset(0)); + + // Attempt to create stack maps for masm.wasmReserveStackChecked. + ArgTypeVector argTypes(funcType); + RegisterOffsets trapExitLayout; + size_t trapExitLayoutNumWords; + GenerateTrapExitRegisterOffsets(&trapExitLayout, &trapExitLayoutNumWords); + CodeOffset trapInsnOffset = pair.first; + size_t nBytesReservedBeforeTrap = pair.second; + size_t nInboundStackArgBytes = StackArgAreaSizeUnaligned(argTypes); + wasm::StackMap* stackMap = nullptr; + if (!CreateStackMapForFunctionEntryTrap( + argTypes, trapExitLayout, trapExitLayoutNumWords, + nBytesReservedBeforeTrap, nInboundStackArgBytes, &stackMap)) { + return false; + } + + // In debug builds, we'll always have a stack map, even if there are no + // refs to track. + MOZ_ASSERT(stackMap); + if (stackMap && + !stackMaps->add((uint8_t*)(uintptr_t)trapInsnOffset.offset(), stackMap)) { + stackMap->destroy(); + return false; + } + return true; +} + // Generate a wrapper function with the standard intra-wasm call ABI which // simply calls an import. This wrapper function allows any import to be treated // like a normal wasm function for the purposes of exports and table calls. In @@ -1873,7 +1906,7 @@ static bool GenerateImportFunction(jit::MacroAssembler& masm, const FuncImport& fi, const FuncType& funcType, CallIndirectId callIndirectId, - FuncOffsets* offsets) { + FuncOffsets* offsets, StackMaps* stackMaps) { AutoCreatedBy acb(masm, "wasm::GenerateImportFunction"); AssertExpectedSP(masm); @@ -1886,7 +1919,12 @@ static bool GenerateImportFunction(jit::MacroAssembler& masm, WasmStackAlignment, sizeof(Frame), // pushed by prologue StackArgBytesForWasmABI(funcType) + sizeOfInstanceSlot); - masm.wasmReserveStackChecked(framePushed, BytecodeOffset(0)); + + if (!AddStackCheckForImportFunctionEntry(masm, framePushed, funcType, + stackMaps)) { + return false; + } + MOZ_ASSERT(masm.framePushed() == framePushed); masm.storePtr(InstanceReg, Address(masm.getStackPointer(), @@ -1950,7 +1988,8 @@ bool wasm::GenerateImportFunctions(const ModuleEnvironment& env, CallIndirectId callIndirectId = CallIndirectId::forFunc(env, funcIndex); FuncOffsets offsets; - if (!GenerateImportFunction(masm, fi, funcType, callIndirectId, &offsets)) { + if (!GenerateImportFunction(masm, fi, funcType, callIndirectId, &offsets, + &code->stackMaps)) { return false; } if (!code->codeRanges.emplaceBack(funcIndex, /* bytecodeOffset = */ 0, diff --git a/js/src/wasm/WasmTypeDef.h b/js/src/wasm/WasmTypeDef.h index a0d44e647b..135d58e613 100644 --- a/js/src/wasm/WasmTypeDef.h +++ b/js/src/wasm/WasmTypeDef.h @@ -1355,6 +1355,7 @@ inline RefTypeHierarchy RefType::hierarchy() const { case RefType::NoExtern: return RefTypeHierarchy::Extern; case RefType::Exn: + case RefType::NoExn: return RefTypeHierarchy::Exn; case RefType::Any: case RefType::None: @@ -1476,6 +1477,11 @@ inline bool RefType::isSubTypeOf(RefType subType, RefType superType) { return true; } + // No exn is the bottom type of the exn hierarchy + if (subType.isNoExn() && superType.hierarchy() == RefTypeHierarchy::Exn) { + return true; + } + return false; } diff --git a/js/src/wasm/WasmValType.cpp b/js/src/wasm/WasmValType.cpp index 64ef8ff85a..0d9e1b24fb 100644 --- a/js/src/wasm/WasmValType.cpp +++ b/js/src/wasm/WasmValType.cpp @@ -52,6 +52,7 @@ RefType RefType::topType() const { case RefType::NoExtern: return RefType::extern_(); case RefType::Exn: + case RefType::NoExn: return RefType::exn(); case RefType::TypeRef: switch (typeDef()->kind()) { @@ -94,14 +95,12 @@ static bool ToRefType(JSContext* cx, JSLinearString* typeLinearStr, *out = RefType::extern_(); return true; } -#ifdef ENABLE_WASM_EXNREF if (ExnRefAvailable(cx)) { if (StringEqualsLiteral(typeLinearStr, "exnref")) { *out = RefType::exn(); return true; } } -#endif #ifdef ENABLE_WASM_GC if (GcAvailable(cx)) { if (StringEqualsLiteral(typeLinearStr, "anyref")) { @@ -132,6 +131,10 @@ static bool ToRefType(JSContext* cx, JSLinearString* typeLinearStr, *out = RefType::noextern(); return true; } + if (StringEqualsLiteral(typeLinearStr, "nullexnref")) { + *out = RefType::noexn(); + return true; + } if (StringEqualsLiteral(typeLinearStr, "nullref")) { *out = RefType::none(); return true; @@ -220,6 +223,9 @@ UniqueChars wasm::ToString(RefType type, const TypeContext* types) { case RefType::NoFunc: literal = "nullfuncref"; break; + case RefType::NoExn: + literal = "nullexnref"; + break; case RefType::NoExtern: literal = "nullexternref"; break; @@ -263,6 +269,9 @@ UniqueChars wasm::ToString(RefType type, const TypeContext* types) { case RefType::NoFunc: heapType = "nofunc"; break; + case RefType::NoExn: + heapType = "noexn"; + break; case RefType::NoExtern: heapType = "noextern"; break; diff --git a/js/src/wasm/WasmValType.h b/js/src/wasm/WasmValType.h index c98eda28dd..b194b78113 100644 --- a/js/src/wasm/WasmValType.h +++ b/js/src/wasm/WasmValType.h @@ -316,6 +316,7 @@ class RefType { Any = uint8_t(TypeCode::AnyRef), NoFunc = uint8_t(TypeCode::NullFuncRef), NoExtern = uint8_t(TypeCode::NullExternRef), + NoExn = uint8_t(TypeCode::NullExnRef), None = uint8_t(TypeCode::NullAnyRef), Eq = uint8_t(TypeCode::EqRef), I31 = uint8_t(TypeCode::I31Ref), @@ -373,6 +374,7 @@ class RefType { case TypeCode::ArrayRef: case TypeCode::NullFuncRef: case TypeCode::NullExternRef: + case TypeCode::NullExnRef: case TypeCode::NullAnyRef: case AbstractTypeRefCode: return true; @@ -388,6 +390,7 @@ class RefType { static RefType any() { return RefType(Any, true); } static RefType nofunc() { return RefType(NoFunc, true); } static RefType noextern() { return RefType(NoExtern, true); } + static RefType noexn() { return RefType(NoExn, true); } static RefType none() { return RefType(None, true); } static RefType eq() { return RefType(Eq, true); } static RefType i31() { return RefType(I31, true); } @@ -399,6 +402,7 @@ class RefType { bool isAny() const { return kind() == RefType::Any; } bool isNoFunc() const { return kind() == RefType::NoFunc; } bool isNoExtern() const { return kind() == RefType::NoExtern; } + bool isNoExn() const { return kind() == RefType::NoExn; } bool isNone() const { return kind() == RefType::None; } bool isEq() const { return kind() == RefType::Eq; } bool isI31() const { return kind() == RefType::I31; } @@ -412,7 +416,9 @@ class RefType { return RefType(ptc_.withIsNullable(nullable)); } - bool isRefBottom() const { return isNone() || isNoFunc() || isNoExtern(); } + bool isRefBottom() const { + return isNone() || isNoFunc() || isNoExtern() || isNoExn(); + } // These methods are defined in WasmTypeDef.h to avoid a cycle while allowing // inlining. @@ -469,6 +475,7 @@ class StorageTypeTraits { case TypeCode::FuncRef: case TypeCode::ExternRef: case TypeCode::ExnRef: + case TypeCode::NullExnRef: #ifdef ENABLE_WASM_GC case TypeCode::AnyRef: case TypeCode::EqRef: @@ -547,6 +554,7 @@ class ValTypeTraits { case TypeCode::FuncRef: case TypeCode::ExternRef: case TypeCode::ExnRef: + case TypeCode::NullExnRef: #ifdef ENABLE_WASM_GC case TypeCode::AnyRef: case TypeCode::EqRef: @@ -725,6 +733,8 @@ class PackedType : public T { bool isNoExtern() const { return tc_.typeCode() == TypeCode::NullExternRef; } + bool isNoExn() const { return tc_.typeCode() == TypeCode::NullExnRef; } + bool isNone() const { return tc_.typeCode() == TypeCode::NullAnyRef; } bool isEqRef() const { return tc_.typeCode() == TypeCode::EqRef; } @@ -745,9 +755,9 @@ class PackedType : public T { // Returns whether the type has a representation in JS. bool isExposable() const { #if defined(ENABLE_WASM_SIMD) - return kind() != Kind::V128 && !isExnRef(); + return kind() != Kind::V128 && !isExnRef() && !isNoExn(); #else - return !isExnRef(); + return !isExnRef() && !isNoExn(); #endif } diff --git a/js/src/wasm/WasmValidate.cpp b/js/src/wasm/WasmValidate.cpp index d67967fa41..3a0f865d46 100644 --- a/js/src/wasm/WasmValidate.cpp +++ b/js/src/wasm/WasmValidate.cpp @@ -2929,6 +2929,92 @@ bool wasm::StartsCodeSection(const uint8_t* begin, const uint8_t* end, return false; } +#ifdef ENABLE_WASM_BRANCH_HINTING +static bool ParseBranchHintingSection(Decoder& d, ModuleEnvironment* env) { + uint32_t functionCount; + if (!d.readVarU32(&functionCount)) { + return d.fail("failed to read function count"); + } + + for (uint32_t i = 0; i < functionCount; i++) { + uint32_t functionIndex; + if (!d.readVarU32(&functionIndex)) { + return d.fail("failed to read function index"); + } + + // Disallow branch hints on imported functions. + if ((functionIndex >= env->funcs.length()) || + (functionIndex < env->numFuncImports)) { + return d.fail("invalid function index in branch hint"); + } + + uint32_t hintCount; + if (!d.readVarU32(&hintCount)) { + return d.fail("failed to read hint count"); + } + + BranchHintVector hintVector; + if (!hintVector.reserve(hintCount)) { + return false; + } + + // Branch hint offsets must appear in increasing byte offset order, at most + // once for each offset. + uint32_t prevOffsetPlus1 = 0; + for (uint32_t hintIndex = 0; hintIndex < hintCount; hintIndex++) { + uint32_t branchOffset; + if (!d.readVarU32(&branchOffset)) { + return d.fail("failed to read branch offset"); + } + if (branchOffset <= prevOffsetPlus1) { + return d.fail("Invalid offset in code hint"); + } + + uint32_t reserved; + if (!d.readVarU32(&reserved) || (reserved != 1)) { + return d.fail("Invalid reserved value for code hint"); + } + + uint32_t branchHintValue; + if (!d.readVarU32(&branchHintValue) || + (branchHintValue >= MaxBranchHintValue)) { + return d.fail("Invalid branch hint value"); + } + + BranchHint branchHint = static_cast<BranchHint>(branchHintValue); + BranchHintEntry entry(branchOffset, branchHint); + hintVector.infallibleAppend(entry); + + prevOffsetPlus1 = branchOffset; + } + + // Save this collection in the module + if (!env->branchHints.addHintsForFunc(functionIndex, + std::move(hintVector))) { + return false; + } + } + + return true; +} + +static bool DecodeBranchHintingSection(Decoder& d, ModuleEnvironment* env) { + MaybeSectionRange range; + if (!d.startCustomSection(BranchHintingSectionName, env, &range)) { + return false; + } + if (!range) { + return true; + } + + // Skip this custom section if errors are encountered during parsing. + env->parsedBranchHints = ParseBranchHintingSection(d, env); + + d.finishCustomSection(BranchHintingSectionName, *range); + return true; +} +#endif + bool wasm::DecodeModuleEnvironment(Decoder& d, ModuleEnvironment* env) { if (!DecodePreamble(d)) { return false; @@ -2984,6 +3070,12 @@ bool wasm::DecodeModuleEnvironment(Decoder& d, ModuleEnvironment* env) { return false; } +#ifdef ENABLE_WASM_BRANCH_HINTING + if (env->branchHintingEnabled() && !DecodeBranchHintingSection(d, env)) { + return false; + } +#endif + if (!d.startSection(SectionId::Code, env, &env->codeSection, "code")) { return false; } diff --git a/js/src/wasm/WasmValidate.h b/js/src/wasm/WasmValidate.h index f8d712b3b3..4dab19416c 100644 --- a/js/src/wasm/WasmValidate.h +++ b/js/src/wasm/WasmValidate.h @@ -58,6 +58,7 @@ struct ModuleEnvironment { MemoryDescVector memories; MutableTypeContext types; FuncDescVector funcs; + BranchHintCollection branchHints; uint32_t numFuncImports; uint32_t numGlobalImports; GlobalDescVector globals; @@ -93,6 +94,9 @@ struct ModuleEnvironment { Maybe<Name> moduleName; NameVector funcNames; + // Indicates whether the branch hint section was successfully parsed. + bool parsedBranchHints; + explicit ModuleEnvironment(FeatureArgs features, ModuleKind kind = ModuleKind::Wasm) : kind(kind), @@ -103,7 +107,8 @@ struct ModuleEnvironment { typeDefsOffsetStart(UINT32_MAX), memoriesOffsetStart(UINT32_MAX), tablesOffsetStart(UINT32_MAX), - tagsOffsetStart(UINT32_MAX) {} + tagsOffsetStart(UINT32_MAX), + parsedBranchHints(false) {} [[nodiscard]] bool init() { types = js_new<TypeContext>(features); diff --git a/js/src/wasm/WasmValue.cpp b/js/src/wasm/WasmValue.cpp index 6039b00517..824cc0e2cc 100644 --- a/js/src/wasm/WasmValue.cpp +++ b/js/src/wasm/WasmValue.cpp @@ -135,6 +135,8 @@ bool wasm::CheckRefType(JSContext* cx, RefType targetType, HandleValue v, return CheckAnyRefValue(cx, v, refval); case RefType::NoFunc: return CheckNullFuncRefValue(cx, v, fnval); + case RefType::NoExn: + return CheckNullExnRefValue(cx, v, refval); case RefType::NoExtern: return CheckNullExternRefValue(cx, v, refval); case RefType::None: @@ -200,6 +202,18 @@ bool wasm::CheckNullFuncRefValue(JSContext* cx, HandleValue v, return true; } +bool wasm::CheckNullExnRefValue(JSContext* cx, HandleValue v, + MutableHandleAnyRef vp) { + if (!v.isNull()) { + JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, + JSMSG_WASM_BAD_NULL_EXNREF_VALUE); + return false; + } + + vp.set(AnyRef::null()); + return true; +} + bool wasm::CheckNullExternRefValue(JSContext* cx, HandleValue v, MutableHandleAnyRef vp) { if (!v.isNull()) { @@ -436,6 +450,23 @@ bool ToWebAssemblyValue_externref(JSContext* cx, HandleValue val, void** loc, } template <typename Debug = NoDebug> +bool ToWebAssemblyValue_nullexnref(JSContext* cx, HandleValue val, void** loc, + bool mustWrite64) { + RootedAnyRef result(cx, AnyRef::null()); + if (!CheckNullExnRefValue(cx, val, &result)) { + return false; + } + loc[0] = result.get().forCompiledCode(); +#ifndef JS_64BIT + if (mustWrite64) { + loc[1] = nullptr; + } +#endif + Debug::print(*loc); + return true; +} + +template <typename Debug = NoDebug> bool ToWebAssemblyValue_nullexternref(JSContext* cx, HandleValue val, void** loc, bool mustWrite64) { RootedAnyRef result(cx, AnyRef::null()); @@ -667,6 +698,9 @@ bool wasm::ToWebAssemblyValue(JSContext* cx, HandleValue val, ValType type, case RefType::NoFunc: return ToWebAssemblyValue_nullfuncref<Debug>(cx, val, (void**)loc, mustWrite64); + case RefType::NoExn: + return ToWebAssemblyValue_nullexnref<Debug>(cx, val, (void**)loc, + mustWrite64); case RefType::NoExtern: return ToWebAssemblyValue_nullexternref<Debug>(cx, val, (void**)loc, mustWrite64); @@ -775,6 +809,9 @@ bool ToJSValue_lossless(JSContext* cx, const void* src, MutableHandleValue dst, cx, GlobalObject::getOrCreatePrototype(cx, JSProto_WasmGlobal)); Rooted<WasmGlobalObject*> srcGlobal( cx, WasmGlobalObject::create(cx, srcVal, false, prototype)); + if (!srcGlobal) { + return false; + } dst.set(ObjectValue(*srcGlobal.get())); return true; } diff --git a/js/src/wasm/WasmValue.h b/js/src/wasm/WasmValue.h index 9a5442fc75..ddb2463883 100644 --- a/js/src/wasm/WasmValue.h +++ b/js/src/wasm/WasmValue.h @@ -371,6 +371,10 @@ using RootedValVectorN = Rooted<ValVectorN<N>>; [[nodiscard]] extern bool CheckAnyRefValue(JSContext* cx, HandleValue v, MutableHandleAnyRef vp); +// The same as above for when the target type is 'nullexnref'. +[[nodiscard]] extern bool CheckNullExnRefValue(JSContext* cx, HandleValue v, + MutableHandleAnyRef vp); + // The same as above for when the target type is 'nullexternref'. [[nodiscard]] extern bool CheckNullExternRefValue(JSContext* cx, HandleValue v, MutableHandleAnyRef vp); diff --git a/js/src/wasm/moz.build b/js/src/wasm/moz.build index 83fea3b81b..e8bf00a9d6 100644 --- a/js/src/wasm/moz.build +++ b/js/src/wasm/moz.build @@ -41,6 +41,7 @@ UNIFIED_SOURCES += [ "WasmModule.cpp", "WasmModuleTypes.cpp", "WasmOpIter.cpp", + "WasmPI.cpp", "WasmProcess.cpp", "WasmRealm.cpp", "WasmSerialize.cpp", |