Skip to content

Commit

Permalink
fix ToTemporalCalendarSlot on to differentiate builtins
Browse files Browse the repository at this point in the history
  • Loading branch information
nekevss committed Feb 3, 2024
1 parent 89bfd01 commit 02528e7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
12 changes: 6 additions & 6 deletions core/engine/src/builtins/temporal/calendar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ use boa_temporal::{

mod object;

/*
#[doc(inline)]
pub(crate) use object::JsObject;
*/

#[cfg(test)]
mod tests;
/// The `Temporal.Calendar` object.
Expand Down Expand Up @@ -1079,7 +1074,12 @@ pub(crate) fn to_temporal_calendar_slot_value(
}

// c. Return temporalCalendarLike.
return Ok(CalendarSlot::Protocol(calendar_like.clone()));
match calendar_like.clone().downcast::<Calendar>() {
Ok(cal) => return Ok(cal.borrow().data().slot.clone()),
Err(custom) => {
return Ok(CalendarSlot::Protocol(custom.clone()));
}
}
}

// 3. If temporalCalendarLike is not a String, throw a TypeError exception.
Expand Down
3 changes: 3 additions & 0 deletions core/engine/src/builtins/temporal/plain_date_time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ use crate::{
use boa_gc::{Finalize, Trace};
use boa_profiler::Profiler;

#[cfg(test)]
mod tests;

use boa_temporal::{
components::{
calendar::{CalendarSlot, GetCalendarSlot},
Expand Down
10 changes: 10 additions & 0 deletions core/engine/src/builtins/temporal/plain_date_time/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use crate::{run_test_actions, TestAction};

#[test]
fn pdt_year_of_week_basic() {
run_test_actions([
TestAction::run("let calendar = Temporal.Calendar.from('iso8601')"),
TestAction::run("let pdt = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar)"),
TestAction::assert_eq("pdt.yearOfWeek", 1976),
]);
}

0 comments on commit 02528e7

Please sign in to comment.