mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-15 23:09:05 +00:00
LibJS: Implement Temporal.PlainMonthDay.prototype.valueOf
This commit is contained in:
parent
5389acc231
commit
64811ab7b6
Notes:
github-actions[bot]
2024-11-22 00:25:23 +00:00
Author: https://github.com/trflynn89
Commit: 64811ab7b6
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2471
3 changed files with 20 additions and 0 deletions
|
@ -40,6 +40,7 @@ void PlainMonthDayPrototype::initialize(Realm& realm)
|
||||||
define_native_function(realm, vm.names.toString, to_string, 0, attr);
|
define_native_function(realm, vm.names.toString, to_string, 0, attr);
|
||||||
define_native_function(realm, vm.names.toLocaleString, to_locale_string, 0, attr);
|
define_native_function(realm, vm.names.toLocaleString, to_locale_string, 0, attr);
|
||||||
define_native_function(realm, vm.names.toJSON, to_json, 0, attr);
|
define_native_function(realm, vm.names.toJSON, to_json, 0, attr);
|
||||||
|
define_native_function(realm, vm.names.valueOf, value_of, 0, attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10.3.3 get Temporal.PlainMonthDay.prototype.calendarId, https://tc39.es/proposal-temporal/#sec-get-temporal.plainmonthday.prototype.calendarid
|
// 10.3.3 get Temporal.PlainMonthDay.prototype.calendarId, https://tc39.es/proposal-temporal/#sec-get-temporal.plainmonthday.prototype.calendarid
|
||||||
|
@ -172,4 +173,11 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_json)
|
||||||
return PrimitiveString::create(vm, temporal_month_day_to_string(month_day, ShowCalendar::Auto));
|
return PrimitiveString::create(vm, temporal_month_day_to_string(month_day, ShowCalendar::Auto));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 10.3.11 Temporal.PlainMonthDay.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.valueof
|
||||||
|
JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::value_of)
|
||||||
|
{
|
||||||
|
// 1. Throw a TypeError exception.
|
||||||
|
return vm.throw_completion<TypeError>(ErrorType::Convert, "Temporal.PlainMonthDay", "a primitive value");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ private:
|
||||||
JS_DECLARE_NATIVE_FUNCTION(to_string);
|
JS_DECLARE_NATIVE_FUNCTION(to_string);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(to_locale_string);
|
JS_DECLARE_NATIVE_FUNCTION(to_locale_string);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(to_json);
|
JS_DECLARE_NATIVE_FUNCTION(to_json);
|
||||||
|
JS_DECLARE_NATIVE_FUNCTION(value_of);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
describe("errors", () => {
|
||||||
|
test("throws TypeError", () => {
|
||||||
|
const plainMonthDay = new Temporal.PlainMonthDay(7, 6);
|
||||||
|
expect(() => {
|
||||||
|
plainMonthDay.valueOf();
|
||||||
|
}).toThrowWithMessage(
|
||||||
|
TypeError,
|
||||||
|
"Cannot convert Temporal.PlainMonthDay to a primitive value"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue