diff --git a/pkg/stdlib/datetime/date_test.go b/pkg/stdlib/datetime/date_test.go index 221fcbb3..ab4298e3 100644 --- a/pkg/stdlib/datetime/date_test.go +++ b/pkg/stdlib/datetime/date_test.go @@ -26,6 +26,12 @@ func TestDate(t *testing.T) { Args: []core.Value{}, ShouldErr: true, }, + &testCase{ + Name: "When argument isn't DateTime", + Expected: values.None, + Args: []core.Value{values.NewInt(0)}, + ShouldErr: true, + }, &testCase{ Name: "When incorrect timeStrings", Expected: values.None, diff --git a/pkg/stdlib/datetime/day_test.go b/pkg/stdlib/datetime/day_test.go index bb7ded3d..192ad8c0 100644 --- a/pkg/stdlib/datetime/day_test.go +++ b/pkg/stdlib/datetime/day_test.go @@ -25,6 +25,12 @@ func TestDateDay(t *testing.T) { Args: []core.Value{}, ShouldErr: true, }, + &testCase{ + Name: "When argument isn't DateTime", + Expected: values.None, + Args: []core.Value{values.NewInt(0)}, + ShouldErr: true, + }, &testCase{ Name: "When 7th day", Expected: values.NewInt(7), diff --git a/pkg/stdlib/datetime/dayofweek_test.go b/pkg/stdlib/datetime/dayofweek_test.go index 617cfef6..dcef7588 100644 --- a/pkg/stdlib/datetime/dayofweek_test.go +++ b/pkg/stdlib/datetime/dayofweek_test.go @@ -25,6 +25,12 @@ func TestDateDayOfWeek(t *testing.T) { Args: []core.Value{}, ShouldErr: true, }, + &testCase{ + Name: "When argument isn't DateTime", + Expected: values.None, + Args: []core.Value{values.NewInt(0)}, + ShouldErr: true, + }, &testCase{ Name: "When Sunday (0th day)", Expected: values.NewInt(0), diff --git a/pkg/stdlib/datetime/dayofyear_test.go b/pkg/stdlib/datetime/dayofyear_test.go index a847befb..50c16f3f 100644 --- a/pkg/stdlib/datetime/dayofyear_test.go +++ b/pkg/stdlib/datetime/dayofyear_test.go @@ -26,6 +26,12 @@ func TestDateDayOfYear(t *testing.T) { Args: []core.Value{}, ShouldErr: true, }, + &testCase{ + Name: "When argument isn't DateTime", + Expected: values.None, + Args: []core.Value{values.NewInt(0)}, + ShouldErr: true, + }, &testCase{ Name: "When 38th day of the year", Expected: values.NewInt(38), diff --git a/pkg/stdlib/datetime/daysinmonth_test.go b/pkg/stdlib/datetime/daysinmonth_test.go index 8b05a3d1..ac5ab7d2 100644 --- a/pkg/stdlib/datetime/daysinmonth_test.go +++ b/pkg/stdlib/datetime/daysinmonth_test.go @@ -26,6 +26,12 @@ func TestDateDateDaysInMonth(t *testing.T) { Args: []core.Value{}, ShouldErr: true, }, + &testCase{ + Name: "When argument isn't DateTime", + Expected: values.None, + Args: []core.Value{values.NewInt(0)}, + ShouldErr: true, + }, &testCase{ Name: "When Feb and a leap year", Expected: values.NewInt(29), diff --git a/pkg/stdlib/datetime/hour_test.go b/pkg/stdlib/datetime/hour_test.go index 1118c1ea..f1206415 100644 --- a/pkg/stdlib/datetime/hour_test.go +++ b/pkg/stdlib/datetime/hour_test.go @@ -25,6 +25,12 @@ func TestDateHour(t *testing.T) { Args: []core.Value{}, ShouldErr: true, }, + &testCase{ + Name: "When argument isn't DateTime", + Expected: values.None, + Args: []core.Value{values.NewInt(0)}, + ShouldErr: true, + }, &testCase{ Name: "When 7th hour", Expected: values.NewInt(7), diff --git a/pkg/stdlib/datetime/leapyear_test.go b/pkg/stdlib/datetime/leapyear_test.go index d25f2984..5ffaea54 100644 --- a/pkg/stdlib/datetime/leapyear_test.go +++ b/pkg/stdlib/datetime/leapyear_test.go @@ -25,6 +25,12 @@ func TestDateLeapYear(t *testing.T) { Args: []core.Value{}, ShouldErr: true, }, + &testCase{ + Name: "When argument isn't DateTime", + Expected: values.None, + Args: []core.Value{values.NewInt(0)}, + ShouldErr: true, + }, &testCase{ Name: "When not a leap year", Expected: values.NewBoolean(false), diff --git a/pkg/stdlib/datetime/millisecond_test.go b/pkg/stdlib/datetime/millisecond_test.go index b8d42bf4..02ee66c0 100644 --- a/pkg/stdlib/datetime/millisecond_test.go +++ b/pkg/stdlib/datetime/millisecond_test.go @@ -26,6 +26,12 @@ func TestDateMillisecond(t *testing.T) { Args: []core.Value{}, ShouldErr: true, }, + &testCase{ + Name: "When argument isn't DateTime", + Expected: values.None, + Args: []core.Value{values.NewInt(0)}, + ShouldErr: true, + }, &testCase{ Name: "When 129 millisecond", Expected: values.NewInt(129), diff --git a/pkg/stdlib/datetime/minute_test.go b/pkg/stdlib/datetime/minute_test.go index f2fbbffd..46a6eff3 100644 --- a/pkg/stdlib/datetime/minute_test.go +++ b/pkg/stdlib/datetime/minute_test.go @@ -25,6 +25,12 @@ func TestDateMinute(t *testing.T) { Args: []core.Value{}, ShouldErr: true, }, + &testCase{ + Name: "When argument isn't DateTime", + Expected: values.None, + Args: []core.Value{values.NewInt(0)}, + ShouldErr: true, + }, &testCase{ Name: "When 4th minute", Expected: values.NewInt(4), diff --git a/pkg/stdlib/datetime/month_test.go b/pkg/stdlib/datetime/month_test.go index 56927880..c49e138e 100644 --- a/pkg/stdlib/datetime/month_test.go +++ b/pkg/stdlib/datetime/month_test.go @@ -25,6 +25,12 @@ func TestDateMonth(t *testing.T) { Args: []core.Value{}, ShouldErr: true, }, + &testCase{ + Name: "When argument isn't DateTime", + Expected: values.None, + Args: []core.Value{values.NewInt(0)}, + ShouldErr: true, + }, &testCase{ Name: "When 2th month", Expected: values.NewInt(2), diff --git a/pkg/stdlib/datetime/quarter_test.go b/pkg/stdlib/datetime/quarter_test.go index 3b29c7f2..96aca870 100644 --- a/pkg/stdlib/datetime/quarter_test.go +++ b/pkg/stdlib/datetime/quarter_test.go @@ -26,6 +26,12 @@ func TestDateQuarter(t *testing.T) { Args: []core.Value{}, ShouldErr: true, }, + &testCase{ + Name: "When argument isn't DateTime", + Expected: values.None, + Args: []core.Value{values.NewInt(0)}, + ShouldErr: true, + }, } for month := time.January; month <= time.December; month++ { diff --git a/pkg/stdlib/datetime/second_test.go b/pkg/stdlib/datetime/second_test.go index 64f194b4..c7e596c8 100644 --- a/pkg/stdlib/datetime/second_test.go +++ b/pkg/stdlib/datetime/second_test.go @@ -25,6 +25,12 @@ func TestDateSecond(t *testing.T) { Args: []core.Value{}, ShouldErr: true, }, + &testCase{ + Name: "When argument isn't DateTime", + Expected: values.None, + Args: []core.Value{values.NewInt(0)}, + ShouldErr: true, + }, &testCase{ Name: "When 5th second", Expected: values.NewInt(5), diff --git a/pkg/stdlib/datetime/year_test.go b/pkg/stdlib/datetime/year_test.go index 29b9ab0b..fbddcaa9 100644 --- a/pkg/stdlib/datetime/year_test.go +++ b/pkg/stdlib/datetime/year_test.go @@ -25,6 +25,12 @@ func TestDateYear(t *testing.T) { Args: []core.Value{}, ShouldErr: true, }, + &testCase{ + Name: "When argument isn't DateTime", + Expected: values.None, + Args: []core.Value{values.NewInt(0)}, + ShouldErr: true, + }, &testCase{ Name: "When 1999th year", Expected: values.NewInt(1999),