From e5c80a22c35a5745ae957b8e84da42abd0c41d4d Mon Sep 17 00:00:00 2001 From: historia Date: Sun, 11 Aug 2024 06:09:42 -0400 Subject: Feature: One-sided conditions like -(Aug 15 2025) --- tests/tconditionchecker.nim | 16 ++++++++++++++++ tests/tconditions.nim | 16 ---------------- tests/tests.nim | 2 +- tests/ttypechecker.nim | 18 ++++++++++++++++++ 4 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 tests/tconditionchecker.nim delete mode 100644 tests/tconditions.nim (limited to 'tests') diff --git a/tests/tconditionchecker.nim b/tests/tconditionchecker.nim new file mode 100644 index 0000000..f7909b2 --- /dev/null +++ b/tests/tconditionchecker.nim @@ -0,0 +1,16 @@ +import soon/conditionchecker +import std/[unittest] +import std/[times] + +let date1 = dateTime(2025, mJan, 01, 00, 00, 00, 00, utc()) +let date2 = dateTime(2025, mJan, 01, 00, 00, 00, 00, local()) +let date3 = dateTime(2025, mDec, 31, 00, 00, 00, 00, utc()) +let date4 = dateTime(2024, mFeb, 29, 00, 00, 00, 00, local()) +let date5 = dateTime(0001, mJan, 01, 00, 00, 00, 00, local()) +let date6 = dateTime(9999, mDec, 31, 00, 00, 00, 00, local()) + + +test "Time (always true)": + check checkCond("00:00", date1) == true + check checkCond("23:59", date2) == true + check checkCond("25:00", date3) == true diff --git a/tests/tconditions.nim b/tests/tconditions.nim deleted file mode 100644 index a0298e4..0000000 --- a/tests/tconditions.nim +++ /dev/null @@ -1,16 +0,0 @@ -import soon/conditions -import std/[unittest] -import std/[times] - -let date1 = dateTime(2025, mJan, 01, 00, 00, 00, 00, utc()) -let date2 = dateTime(2025, mJan, 01, 00, 00, 00, 00, local()) -let date3 = dateTime(2025, mDec, 31, 00, 00, 00, 00, utc()) -let date4 = dateTime(2024, mFeb, 29, 00, 00, 00, 00, local()) -let date5 = dateTime(0001, mJan, 01, 00, 00, 00, 00, local()) -let date6 = dateTime(9999, mDec, 31, 00, 00, 00, 00, local()) - - -test "Time (always true)": - check checkCond("00:00", date1) == true - check checkCond("23:59", date2) == true - check checkCond("25:00", date3) == true diff --git a/tests/tests.nim b/tests/tests.nim index 5b7f865..45134c0 100644 --- a/tests/tests.nim +++ b/tests/tests.nim @@ -1 +1 @@ -include "tconditions.nim" +include tconditionchecker, ttypechecker diff --git a/tests/ttypechecker.nim b/tests/ttypechecker.nim index 5e76c2f..c0fc057 100644 --- a/tests/ttypechecker.nim +++ b/tests/ttypechecker.nim @@ -75,3 +75,21 @@ test "Testing typechecker": for t in ["!@#$","foo",""]: check checkType(t) == "unknown" + + for t in ["-1", "15-", "-30"]: + check checkType(t) == "onesidedday" + + for t in ["-mon", "WED-"]: + check checkType(t) == "onesidedweekday" + + for t in ["jan-", "-JUN"]: + check checkType(t) == "onesidedmonth" + + for t in ["1984-", "-2025"]: + check checkType(t) == "onesidedyear" + + for t in [ + "(Jan 15)-", + "-(January 15 2025)" + ]: + check checkType(t) == "onesideddategroup" -- cgit v1.2.3