@@ -444,6 +444,14 @@
|
||||
"practices": [],
|
||||
"prerequisites": [],
|
||||
"difficulty": 4
|
||||
},
|
||||
{
|
||||
"slug": "meetup",
|
||||
"name": "Meetup",
|
||||
"uuid": "970df031-46b3-45d4-9cb8-74d3cbbc9d83",
|
||||
"practices": [],
|
||||
"prerequisites": [],
|
||||
"difficulty": 6
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
7
exercises/practice/meetup/.docs/instructions.append.md
Normal file
7
exercises/practice/meetup/.docs/instructions.append.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Instructions append
|
||||
|
||||
# Date words
|
||||
|
||||
~~~~exercism/note
|
||||
The `d` namespace contains date and time related words, some of which will be really useful to solve this exercise.
|
||||
~~~~
|
||||
51
exercises/practice/meetup/.docs/instructions.md
Normal file
51
exercises/practice/meetup/.docs/instructions.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# Instructions
|
||||
|
||||
Recurring monthly meetups are generally scheduled on the given weekday of a given week each month.
|
||||
In this exercise you will be given the recurring schedule, along with a month and year, and then asked to find the exact date of the meetup.
|
||||
|
||||
For example a meetup might be scheduled on the _first Monday_ of every month.
|
||||
You might then be asked to find the date that this meetup will happen in January 2018.
|
||||
In other words, you need to determine the date of the first Monday of January 2018.
|
||||
|
||||
Similarly, you might be asked to find:
|
||||
|
||||
- the third Tuesday of August 2019 (August 20, 2019)
|
||||
- the teenth Wednesday of May 2020 (May 13, 2020)
|
||||
- the fourth Sunday of July 2021 (July 25, 2021)
|
||||
- the last Thursday of November 2022 (November 24, 2022)
|
||||
|
||||
The descriptors you are expected to process are: `first`, `second`, `third`, `fourth`, `last`, `teenth`.
|
||||
|
||||
Note that descriptor `teenth` is a made-up word.
|
||||
|
||||
It refers to the seven numbers that end in '-teen' in English: 13, 14, 15, 16, 17, 18, and 19.
|
||||
But general descriptions of dates use ordinal numbers, e.g. the _first_ Monday, the _third_ Tuesday.
|
||||
|
||||
For the numbers ending in '-teen', that becomes:
|
||||
|
||||
- 13th (thirteenth)
|
||||
- 14th (fourteenth)
|
||||
- 15th (fifteenth)
|
||||
- 16th (sixteenth)
|
||||
- 17th (seventeenth)
|
||||
- 18th (eighteenth)
|
||||
- 19th (nineteenth)
|
||||
|
||||
So there are seven numbers ending in '-teen'.
|
||||
And there are also seven weekdays (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday).
|
||||
Therefore, it is guaranteed that each day of the week (Monday, Tuesday, ...) will have exactly one numbered day ending with "teen" each month.
|
||||
|
||||
If asked to find the teenth Saturday of August, 1953 (or, alternately the "Saturteenth" of August, 1953), we need to look at the calendar for August 1953:
|
||||
|
||||
```plaintext
|
||||
August 1953
|
||||
Su Mo Tu We Th Fr Sa
|
||||
1
|
||||
2 3 4 5 6 7 8
|
||||
9 10 11 12 13 14 15
|
||||
16 17 18 19 20 21 22
|
||||
23 24 25 26 27 28 29
|
||||
30 31
|
||||
```
|
||||
|
||||
The Saturday that has a number ending in '-teen' is August 15, 1953.
|
||||
18
exercises/practice/meetup/.meta/config.json
Normal file
18
exercises/practice/meetup/.meta/config.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"authors": [
|
||||
"erikschierboom"
|
||||
],
|
||||
"files": {
|
||||
"solution": [
|
||||
"meetup.8th"
|
||||
],
|
||||
"test": [
|
||||
"test.8th"
|
||||
],
|
||||
"example": [
|
||||
".meta/example.8th"
|
||||
]
|
||||
},
|
||||
"blurb": "Calculate the date of meetups.",
|
||||
"source": "Jeremy Hinegardner mentioned a Boulder meetup that happens on the Wednesteenth of every month"
|
||||
}
|
||||
56
exercises/practice/meetup/.meta/example.8th
Normal file
56
exercises/practice/meetup/.meta/example.8th
Normal file
@@ -0,0 +1,56 @@
|
||||
needs date/utils
|
||||
|
||||
: >dow \ s -- n
|
||||
{
|
||||
"Monday": ' d:Mon,
|
||||
"Tuesday": ' d:Tue,
|
||||
"Wednesday": ' d:Wed,
|
||||
"Thursday": ' d:Thu,
|
||||
"Friday": ' d:Fri,
|
||||
"Saturday": ' d:Sat,
|
||||
"Sunday": ' d:Sun
|
||||
} swap caseof
|
||||
;
|
||||
|
||||
: >day \ d -- n
|
||||
d:/ 2 a:_@
|
||||
;
|
||||
|
||||
: first-day-of-month \ n n -- d
|
||||
1 0 0 0 6 a:close d:join
|
||||
;
|
||||
|
||||
: first-of-month \ n n s -- n
|
||||
-rot first-day-of-month swap >dow d:first-dow
|
||||
;
|
||||
|
||||
: second-of-month \ n n s -- n
|
||||
first-of-month 7 d:+
|
||||
;
|
||||
|
||||
: third-of-month \ n n s -- n
|
||||
first-of-month 14 d:+
|
||||
;
|
||||
|
||||
: fourth-of-month \ n n s -- n
|
||||
first-of-month 21 d:+
|
||||
;
|
||||
|
||||
: last-of-month \ n n s -- n
|
||||
-rot first-day-of-month swap >dow d:last-dow
|
||||
;
|
||||
|
||||
: teenth-of-month \ n n s -- n
|
||||
first-of-month dup >day 5 n:> if 7 d:+ else 14 d:+ then
|
||||
;
|
||||
|
||||
: meetup \ n n s s -- d
|
||||
{
|
||||
"first": ' first-of-month,
|
||||
"second": ' second-of-month,
|
||||
"third": ' third-of-month,
|
||||
"fourth": ' fourth-of-month,
|
||||
"last": ' last-of-month,
|
||||
"teenth": ' teenth-of-month
|
||||
} swap caseof
|
||||
;
|
||||
295
exercises/practice/meetup/.meta/tests.toml
Normal file
295
exercises/practice/meetup/.meta/tests.toml
Normal file
@@ -0,0 +1,295 @@
|
||||
# This is an auto-generated file.
|
||||
#
|
||||
# Regenerating this file via `configlet sync` will:
|
||||
# - Recreate every `description` key/value pair
|
||||
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
|
||||
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
|
||||
# - Preserve any other key/value pair
|
||||
#
|
||||
# As user-added comments (using the # character) will be removed when this file
|
||||
# is regenerated, comments can be added via a `comment` key.
|
||||
|
||||
[d7f8eadd-d4fc-46ee-8a20-e97bd3fd01c8]
|
||||
description = "when teenth Monday is the 13th, the first day of the teenth week"
|
||||
|
||||
[f78373d1-cd53-4a7f-9d37-e15bf8a456b4]
|
||||
description = "when teenth Monday is the 19th, the last day of the teenth week"
|
||||
|
||||
[8c78bea7-a116-425b-9c6b-c9898266d92a]
|
||||
description = "when teenth Monday is some day in the middle of the teenth week"
|
||||
|
||||
[cfef881b-9dc9-4d0b-8de4-82d0f39fc271]
|
||||
description = "when teenth Tuesday is the 19th, the last day of the teenth week"
|
||||
|
||||
[69048961-3b00-41f9-97ee-eb6d83a8e92b]
|
||||
description = "when teenth Tuesday is some day in the middle of the teenth week"
|
||||
|
||||
[d30bade8-3622-466a-b7be-587414e0caa6]
|
||||
description = "when teenth Tuesday is the 13th, the first day of the teenth week"
|
||||
|
||||
[8db4b58b-92f3-4687-867b-82ee1a04f851]
|
||||
description = "when teenth Wednesday is some day in the middle of the teenth week"
|
||||
|
||||
[6c27a2a2-28f8-487f-ae81-35d08c4664f7]
|
||||
description = "when teenth Wednesday is the 13th, the first day of the teenth week"
|
||||
|
||||
[008a8674-1958-45b5-b8e6-c2c9960d973a]
|
||||
description = "when teenth Wednesday is the 19th, the last day of the teenth week"
|
||||
|
||||
[e4abd5e3-57cb-4091-8420-d97e955c0dbd]
|
||||
description = "when teenth Thursday is some day in the middle of the teenth week"
|
||||
|
||||
[85da0b0f-eace-4297-a6dd-63588d5055b4]
|
||||
description = "when teenth Thursday is the 13th, the first day of the teenth week"
|
||||
|
||||
[ecf64f9b-8413-489b-bf6e-128045f70bcc]
|
||||
description = "when teenth Thursday is the 19th, the last day of the teenth week"
|
||||
|
||||
[ac4e180c-7d0a-4d3d-b05f-f564ebb584ca]
|
||||
description = "when teenth Friday is the 19th, the last day of the teenth week"
|
||||
|
||||
[b79101c7-83ad-4f8f-8ec8-591683296315]
|
||||
description = "when teenth Friday is some day in the middle of the teenth week"
|
||||
|
||||
[6ed38b9f-0072-4901-bd97-7c8b8b0ef1b8]
|
||||
description = "when teenth Friday is the 13th, the first day of the teenth week"
|
||||
|
||||
[dfae03ed-9610-47de-a632-655ab01e1e7c]
|
||||
description = "when teenth Saturday is some day in the middle of the teenth week"
|
||||
|
||||
[ec02e3e1-fc72-4a3c-872f-a53fa8ab358e]
|
||||
description = "when teenth Saturday is the 13th, the first day of the teenth week"
|
||||
|
||||
[d983094b-7259-4195-b84e-5d09578c89d9]
|
||||
description = "when teenth Saturday is the 19th, the last day of the teenth week"
|
||||
|
||||
[d84a2a2e-f745-443a-9368-30051be60c2e]
|
||||
description = "when teenth Sunday is the 19th, the last day of the teenth week"
|
||||
|
||||
[0e64bc53-92a3-4f61-85b2-0b7168c7ce5a]
|
||||
description = "when teenth Sunday is some day in the middle of the teenth week"
|
||||
|
||||
[de87652c-185e-4854-b3ae-04cf6150eead]
|
||||
description = "when teenth Sunday is the 13th, the first day of the teenth week"
|
||||
|
||||
[2cbfd0f5-ba3a-46da-a8cc-0fe4966d3411]
|
||||
description = "when first Monday is some day in the middle of the first week"
|
||||
|
||||
[a6168c7c-ed95-4bb3-8f92-c72575fc64b0]
|
||||
description = "when first Monday is the 1st, the first day of the first week"
|
||||
|
||||
[1bfc620f-1c54-4bbd-931f-4a1cd1036c20]
|
||||
description = "when first Tuesday is the 7th, the last day of the first week"
|
||||
|
||||
[12959c10-7362-4ca0-a048-50cf1c06e3e2]
|
||||
description = "when first Tuesday is some day in the middle of the first week"
|
||||
|
||||
[1033dc66-8d0b-48a1-90cb-270703d59d1d]
|
||||
description = "when first Wednesday is some day in the middle of the first week"
|
||||
|
||||
[b89185b9-2f32-46f4-a602-de20b09058f6]
|
||||
description = "when first Wednesday is the 7th, the last day of the first week"
|
||||
|
||||
[53aedc4d-b2c8-4dfb-abf7-a8dc9cdceed5]
|
||||
description = "when first Thursday is some day in the middle of the first week"
|
||||
|
||||
[b420a7e3-a94c-4226-870a-9eb3a92647f0]
|
||||
description = "when first Thursday is another day in the middle of the first week"
|
||||
|
||||
[61df3270-28b4-4713-bee2-566fa27302ca]
|
||||
description = "when first Friday is the 1st, the first day of the first week"
|
||||
|
||||
[cad33d4d-595c-412f-85cf-3874c6e07abf]
|
||||
description = "when first Friday is some day in the middle of the first week"
|
||||
|
||||
[a2869b52-5bba-44f0-a863-07bd1f67eadb]
|
||||
description = "when first Saturday is some day in the middle of the first week"
|
||||
|
||||
[3585315a-d0db-4ea1-822e-0f22e2a645f5]
|
||||
description = "when first Saturday is another day in the middle of the first week"
|
||||
|
||||
[c49e9bd9-8ccf-4cf2-947a-0ccd4e4f10b1]
|
||||
description = "when first Sunday is some day in the middle of the first week"
|
||||
|
||||
[1513328b-df53-4714-8677-df68c4f9366c]
|
||||
description = "when first Sunday is the 7th, the last day of the first week"
|
||||
|
||||
[49e083af-47ec-4018-b807-62ef411efed7]
|
||||
description = "when second Monday is some day in the middle of the second week"
|
||||
|
||||
[6cb79a73-38fe-4475-9101-9eec36cf79e5]
|
||||
description = "when second Monday is the 8th, the first day of the second week"
|
||||
|
||||
[4c39b594-af7e-4445-aa03-bf4f8effd9a1]
|
||||
description = "when second Tuesday is the 14th, the last day of the second week"
|
||||
|
||||
[41b32c34-2e39-40e3-b790-93539aaeb6dd]
|
||||
description = "when second Tuesday is some day in the middle of the second week"
|
||||
|
||||
[90a160c5-b5d9-4831-927f-63a78b17843d]
|
||||
description = "when second Wednesday is some day in the middle of the second week"
|
||||
|
||||
[23b98ce7-8dd5-41a1-9310-ef27209741cb]
|
||||
description = "when second Wednesday is the 14th, the last day of the second week"
|
||||
|
||||
[447f1960-27ca-4729-bc3f-f36043f43ed0]
|
||||
description = "when second Thursday is some day in the middle of the second week"
|
||||
|
||||
[c9aa2687-300c-4e79-86ca-077849a81bde]
|
||||
description = "when second Thursday is another day in the middle of the second week"
|
||||
|
||||
[a7e11ef3-6625-4134-acda-3e7195421c09]
|
||||
description = "when second Friday is the 8th, the first day of the second week"
|
||||
|
||||
[8b420e5f-9290-4106-b5ae-022f3e2a3e41]
|
||||
description = "when second Friday is some day in the middle of the second week"
|
||||
|
||||
[80631afc-fc11-4546-8b5f-c12aaeb72b4f]
|
||||
description = "when second Saturday is some day in the middle of the second week"
|
||||
|
||||
[e34d43ac-f470-44c2-aa5f-e97b78ecaf83]
|
||||
description = "when second Saturday is another day in the middle of the second week"
|
||||
|
||||
[a57d59fd-1023-47ad-b0df-a6feb21b44fc]
|
||||
description = "when second Sunday is some day in the middle of the second week"
|
||||
|
||||
[a829a8b0-abdd-4ad1-b66c-5560d843c91a]
|
||||
description = "when second Sunday is the 14th, the last day of the second week"
|
||||
|
||||
[501a8a77-6038-4fc0-b74c-33634906c29d]
|
||||
description = "when third Monday is some day in the middle of the third week"
|
||||
|
||||
[49e4516e-cf32-4a58-8bbc-494b7e851c92]
|
||||
description = "when third Monday is the 15th, the first day of the third week"
|
||||
|
||||
[4db61095-f7c7-493c-85f1-9996ad3012c7]
|
||||
description = "when third Tuesday is the 21st, the last day of the third week"
|
||||
|
||||
[714fc2e3-58d0-4b91-90fd-61eefd2892c0]
|
||||
description = "when third Tuesday is some day in the middle of the third week"
|
||||
|
||||
[b08a051a-2c80-445b-9b0e-524171a166d1]
|
||||
description = "when third Wednesday is some day in the middle of the third week"
|
||||
|
||||
[80bb9eff-3905-4c61-8dc9-bb03016d8ff8]
|
||||
description = "when third Wednesday is the 21st, the last day of the third week"
|
||||
|
||||
[fa52a299-f77f-4784-b290-ba9189fbd9c9]
|
||||
description = "when third Thursday is some day in the middle of the third week"
|
||||
|
||||
[f74b1bc6-cc5c-4bf1-ba69-c554a969eb38]
|
||||
description = "when third Thursday is another day in the middle of the third week"
|
||||
|
||||
[8900f3b0-801a-466b-a866-f42d64667abd]
|
||||
description = "when third Friday is the 15th, the first day of the third week"
|
||||
|
||||
[538ac405-a091-4314-9ccd-920c4e38e85e]
|
||||
description = "when third Friday is some day in the middle of the third week"
|
||||
|
||||
[244db35c-2716-4fa0-88ce-afd58e5cf910]
|
||||
description = "when third Saturday is some day in the middle of the third week"
|
||||
|
||||
[dd28544f-f8fa-4f06-9bcd-0ad46ce68e9e]
|
||||
description = "when third Saturday is another day in the middle of the third week"
|
||||
|
||||
[be71dcc6-00d2-4b53-a369-cbfae55b312f]
|
||||
description = "when third Sunday is some day in the middle of the third week"
|
||||
|
||||
[b7d2da84-4290-4ee6-a618-ee124ae78be7]
|
||||
description = "when third Sunday is the 21st, the last day of the third week"
|
||||
|
||||
[4276dc06-a1bd-4fc2-b6c2-625fee90bc88]
|
||||
description = "when fourth Monday is some day in the middle of the fourth week"
|
||||
|
||||
[ddbd7976-2deb-4250-8a38-925ac1a8e9a2]
|
||||
description = "when fourth Monday is the 22nd, the first day of the fourth week"
|
||||
|
||||
[eb714ef4-1656-47cc-913c-844dba4ebddd]
|
||||
description = "when fourth Tuesday is the 28th, the last day of the fourth week"
|
||||
|
||||
[16648435-7937-4d2d-b118-c3e38fd084bd]
|
||||
description = "when fourth Tuesday is some day in the middle of the fourth week"
|
||||
|
||||
[de062bdc-9484-437a-a8c5-5253c6f6785a]
|
||||
description = "when fourth Wednesday is some day in the middle of the fourth week"
|
||||
|
||||
[c2ce6821-169c-4832-8d37-690ef5d9514a]
|
||||
description = "when fourth Wednesday is the 28th, the last day of the fourth week"
|
||||
|
||||
[d462c631-2894-4391-a8e3-dbb98b7a7303]
|
||||
description = "when fourth Thursday is some day in the middle of the fourth week"
|
||||
|
||||
[9ff1f7b6-1b72-427d-9ee9-82b5bb08b835]
|
||||
description = "when fourth Thursday is another day in the middle of the fourth week"
|
||||
|
||||
[83bae8ba-1c49-49bc-b632-b7c7e1d7e35f]
|
||||
description = "when fourth Friday is the 22nd, the first day of the fourth week"
|
||||
|
||||
[de752d2a-a95e-48d2-835b-93363dac3710]
|
||||
description = "when fourth Friday is some day in the middle of the fourth week"
|
||||
|
||||
[eedd90ad-d581-45db-8312-4c6dcf9cf560]
|
||||
description = "when fourth Saturday is some day in the middle of the fourth week"
|
||||
|
||||
[669fedcd-912e-48c7-a0a1-228b34af91d0]
|
||||
description = "when fourth Saturday is another day in the middle of the fourth week"
|
||||
|
||||
[648e3849-ea49-44a5-a8a3-9f2a43b3bf1b]
|
||||
description = "when fourth Sunday is some day in the middle of the fourth week"
|
||||
|
||||
[f81321b3-99ab-4db6-9267-69c5da5a7823]
|
||||
description = "when fourth Sunday is the 28th, the last day of the fourth week"
|
||||
|
||||
[1af5e51f-5488-4548-aee8-11d7d4a730dc]
|
||||
description = "last Monday in a month with four Mondays"
|
||||
|
||||
[f29999f2-235e-4ec7-9dab-26f137146526]
|
||||
description = "last Monday in a month with five Mondays"
|
||||
|
||||
[31b097a0-508e-48ac-bf8a-f63cdcf6dc41]
|
||||
description = "last Tuesday in a month with four Tuesdays"
|
||||
|
||||
[8c022150-0bb5-4a1f-80f9-88b2e2abcba4]
|
||||
description = "last Tuesday in another month with four Tuesdays"
|
||||
|
||||
[0e762194-672a-4bdf-8a37-1e59fdacef12]
|
||||
description = "last Wednesday in a month with five Wednesdays"
|
||||
|
||||
[5016386a-f24e-4bd7-b439-95358f491b66]
|
||||
description = "last Wednesday in a month with four Wednesdays"
|
||||
|
||||
[12ead1a5-cdf9-4192-9a56-2229e93dd149]
|
||||
description = "last Thursday in a month with four Thursdays"
|
||||
|
||||
[7db89e11-7fbe-4e57-ae3c-0f327fbd7cc7]
|
||||
description = "last Thursday in a month with five Thursdays"
|
||||
|
||||
[e47a739e-b979-460d-9c8a-75c35ca2290b]
|
||||
description = "last Friday in a month with five Fridays"
|
||||
|
||||
[5bed5aa9-a57a-4e5d-8997-2cc796a5b0ec]
|
||||
description = "last Friday in a month with four Fridays"
|
||||
|
||||
[61e54cba-76f3-4772-a2b1-bf443fda2137]
|
||||
description = "last Saturday in a month with four Saturdays"
|
||||
|
||||
[8b6a737b-2fa9-444c-b1a2-80ce7a2ec72f]
|
||||
description = "last Saturday in another month with four Saturdays"
|
||||
|
||||
[0b63e682-f429-4d19-9809-4a45bd0242dc]
|
||||
description = "last Sunday in a month with five Sundays"
|
||||
|
||||
[5232307e-d3e3-4afc-8ba6-4084ad987c00]
|
||||
description = "last Sunday in a month with four Sundays"
|
||||
|
||||
[0bbd48e8-9773-4e81-8e71-b9a51711e3c5]
|
||||
description = "when last Wednesday in February in a leap year is the 29th"
|
||||
|
||||
[fe0936de-7eee-4a48-88dd-66c07ab1fefc]
|
||||
description = "last Wednesday in December that is also the last day of the year"
|
||||
|
||||
[2ccf2488-aafc-4671-a24e-2b6effe1b0e2]
|
||||
description = "when last Sunday in February in a non-leap year is not the 29th"
|
||||
|
||||
[00c3ce9f-cf36-4b70-90d8-92b32be6830e]
|
||||
description = "when first Friday is the 7th, the last day of the first week"
|
||||
173
exercises/practice/meetup/libs/exercism/test
Normal file
173
exercises/practice/meetup/libs/exercism/test
Normal file
@@ -0,0 +1,173 @@
|
||||
needs console/loaded
|
||||
|
||||
\ -----------------------------------------------------------------
|
||||
|
||||
ns: test
|
||||
|
||||
-1 var, test-count
|
||||
var tests-passed
|
||||
var tests-failed
|
||||
var tests-skipped
|
||||
true var, run-test
|
||||
|
||||
\ Some utility words
|
||||
|
||||
|
||||
: test-passed \ s x x -- \\ test name, expected value, actual value
|
||||
2drop
|
||||
1 tests-passed n:+!
|
||||
con:green con:onBlack . space " ... OK" . con:white con:onBlack cr
|
||||
;
|
||||
|
||||
: test-skipped \ s --
|
||||
1 tests-skipped n:+!
|
||||
con:cyan con:onBlack . space " ... SKIPPED" . con:white con:onBlack cr
|
||||
;
|
||||
|
||||
: test-failed \ s x x -- \\ test name, expected value, actual value
|
||||
1 tests-failed n:+!
|
||||
rot
|
||||
con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr
|
||||
" Actual: «" . . "»" . cr
|
||||
" Expected: «" . . "»" . cr cr
|
||||
;
|
||||
|
||||
: isword? \ x -- x f
|
||||
dup >kind ns:w n:=
|
||||
;
|
||||
|
||||
: run-test? \ -- T
|
||||
run-test @ if true else "RUN_ALL_TESTS" getenv n:>bool then
|
||||
;
|
||||
|
||||
\ Num passed + num skipped + num failed should == num tests
|
||||
: all-tests-run? \ -- T
|
||||
tests-passed @ tests-skipped @ tests-failed @ n:+ n:+
|
||||
test-count @ n:=
|
||||
;
|
||||
|
||||
\ returns true if x is a date, false otherwise
|
||||
: date? \ x -- x T
|
||||
dup >kind ns:d n:=
|
||||
;
|
||||
|
||||
\ adapted from 8th forum -- https://8th-dev.com/forum/index.php/topic,2745.0.html
|
||||
: eq? \ x x -- T
|
||||
\ are the items the same kind?
|
||||
2dup >kind swap >kind n:=
|
||||
!if 2drop false ;then
|
||||
|
||||
\ same kind: try different comparators
|
||||
number? if n:= ;then
|
||||
string? if s:= ;then
|
||||
array? if ' eq? a:= 2nip ;then
|
||||
map? if ' eq? m:= 2nip ;then
|
||||
date? if d:= ;then
|
||||
|
||||
\ otherwise fall back to 'lazy evaluation'
|
||||
l: =
|
||||
;
|
||||
|
||||
: eps_eq? \ n x x -- T
|
||||
\ are the items the same kind?
|
||||
2dup >kind swap >kind n:=
|
||||
!if 2drop false ;then
|
||||
number? !if 2drop false ;then
|
||||
rot n:~=
|
||||
;
|
||||
|
||||
: check-depth \ ... n -- ...
|
||||
dup>r
|
||||
n:1+ depth n:=
|
||||
!if
|
||||
con:red con:onBlack
|
||||
"PANIC: expected stack depth to be " . r> . cr
|
||||
"Stack is:" . cr
|
||||
.s cr
|
||||
255 die
|
||||
then
|
||||
rdrop
|
||||
;
|
||||
|
||||
\ -----------------------------------------------------------------
|
||||
|
||||
\ status report at end of run
|
||||
( all-tests-run?
|
||||
!if con:red con:onBlack "... FAIL - not all tests completed" . con:white con:onBlack cr then
|
||||
) onexit
|
||||
|
||||
\ Print a summary of the tests run
|
||||
( con:white con:onBlack
|
||||
test-count @ . space "tests planned - " .
|
||||
tests-passed @ . space "passed - " .
|
||||
tests-skipped @ . space "skipped - " .
|
||||
tests-failed @ . space "failed" . cr
|
||||
) onexit
|
||||
|
||||
\ -----------------------------------------------------------------
|
||||
\ The public-facing words
|
||||
\ -----------------------------------------------------------------
|
||||
|
||||
: equal? \ s x w -- | s w x --
|
||||
run-test? !if 2drop test-skipped ;; then
|
||||
isword? !if swap then
|
||||
w:exec
|
||||
3 check-depth
|
||||
2dup \ so test-failed can show actual and expected
|
||||
eq? if test-passed else test-failed then
|
||||
;
|
||||
|
||||
: approx_equal? \ s x w n -- | s w x n --
|
||||
run-test? !if 3drop test-skipped ;; then
|
||||
-rot isword? !if swap then
|
||||
w:exec
|
||||
4 check-depth
|
||||
3dup \ so test-failed can show actual and expected
|
||||
eps_eq?
|
||||
if rot drop test-passed else rot drop test-failed then
|
||||
;
|
||||
|
||||
: true? \ s w --
|
||||
run-test? !if drop test-skipped ;; then
|
||||
w:exec
|
||||
2 check-depth
|
||||
true swap dup \ so test-failed can show actual and expected
|
||||
if test-passed else test-failed then
|
||||
;
|
||||
|
||||
: false? \ s w --
|
||||
run-test? !if drop test-skipped ;; then
|
||||
w:exec
|
||||
2 check-depth
|
||||
false swap dup \ so test-failed can show actual and expected
|
||||
!if test-passed else test-failed then
|
||||
;
|
||||
|
||||
: null? \ s w --
|
||||
run-test? !if drop test-skipped ;; then
|
||||
w:exec
|
||||
2 check-depth
|
||||
null swap dup \ so test-failed can show actual and expected
|
||||
G:null? nip if test-passed else test-failed then
|
||||
;
|
||||
|
||||
: SKIP-REST-OF-TESTS false run-test ! ;
|
||||
|
||||
: tests \ n --
|
||||
test-count !
|
||||
;
|
||||
|
||||
\ Set the exit status:
|
||||
\ 0 = all OK
|
||||
\ 1 = not all tests were run (some error occurred)
|
||||
\ 2 = some tests failed
|
||||
: end-of-tests \ --
|
||||
all-tests-run?
|
||||
if
|
||||
tests-failed @ 0 n:= if 0 else 2 then
|
||||
else
|
||||
1
|
||||
then
|
||||
die
|
||||
;
|
||||
|
||||
3
exercises/practice/meetup/meetup.8th
Normal file
3
exercises/practice/meetup/meetup.8th
Normal file
@@ -0,0 +1,3 @@
|
||||
: meetup \ n n s s -- d
|
||||
|
||||
;
|
||||
488
exercises/practice/meetup/test.8th
Normal file
488
exercises/practice/meetup/test.8th
Normal file
@@ -0,0 +1,488 @@
|
||||
"meetup.8th" f:include
|
||||
needs exercism/test
|
||||
with: test
|
||||
95 tests
|
||||
|
||||
: >date-only \ d -- d
|
||||
d:/ 0 3 a:slice [0, 0, 0, 0, 0, 0, 0] a:+ d:join
|
||||
;
|
||||
|
||||
"when teenth Monday is the 13th, the first day of the teenth week"
|
||||
( 2013 5 "Monday" "teenth" meetup >date-only )
|
||||
[2013, 05, 13, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
SKIP-REST-OF-TESTS
|
||||
|
||||
"when teenth Monday is the 19th, the last day of the teenth week"
|
||||
( 2013 8 "Monday" "teenth" meetup >date-only )
|
||||
[2013, 08, 19, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Monday is some day in the middle of the teenth week"
|
||||
( 2013 9 "Monday" "teenth" meetup >date-only )
|
||||
[2013, 09, 16, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Tuesday is the 19th, the last day of the teenth week"
|
||||
( 2013 3 "Tuesday" "teenth" meetup >date-only )
|
||||
[2013, 03, 19, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Tuesday is some day in the middle of the teenth week"
|
||||
( 2013 4 "Tuesday" "teenth" meetup >date-only )
|
||||
[2013, 04, 16, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Tuesday is the 13th, the first day of the teenth week"
|
||||
( 2013 8 "Tuesday" "teenth" meetup >date-only )
|
||||
[2013, 08, 13, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Wednesday is some day in the middle of the teenth week"
|
||||
( 2013 1 "Wednesday" "teenth" meetup >date-only )
|
||||
[2013, 01, 16, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Wednesday is the 13th, the first day of the teenth week"
|
||||
( 2013 2 "Wednesday" "teenth" meetup >date-only )
|
||||
[2013, 02, 13, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Wednesday is the 19th, the last day of the teenth week"
|
||||
( 2013 6 "Wednesday" "teenth" meetup >date-only )
|
||||
[2013, 06, 19, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Thursday is some day in the middle of the teenth week"
|
||||
( 2013 5 "Thursday" "teenth" meetup >date-only )
|
||||
[2013, 05, 16, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Thursday is the 13th, the first day of the teenth week"
|
||||
( 2013 6 "Thursday" "teenth" meetup >date-only )
|
||||
[2013, 06, 13, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Thursday is the 19th, the last day of the teenth week"
|
||||
( 2013 9 "Thursday" "teenth" meetup >date-only )
|
||||
[2013, 09, 19, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Friday is the 19th, the last day of the teenth week"
|
||||
( 2013 4 "Friday" "teenth" meetup >date-only )
|
||||
[2013, 04, 19, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Friday is some day in the middle of the teenth week"
|
||||
( 2013 8 "Friday" "teenth" meetup >date-only )
|
||||
[2013, 08, 16, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Friday is the 13th, the first day of the teenth week"
|
||||
( 2013 9 "Friday" "teenth" meetup >date-only )
|
||||
[2013, 09, 13, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Saturday is some day in the middle of the teenth week"
|
||||
( 2013 2 "Saturday" "teenth" meetup >date-only )
|
||||
[2013, 02, 16, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Saturday is the 13th, the first day of the teenth week"
|
||||
( 2013 4 "Saturday" "teenth" meetup >date-only )
|
||||
[2013, 04, 13, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Saturday is the 19th, the last day of the teenth week"
|
||||
( 2013 10 "Saturday" "teenth" meetup >date-only )
|
||||
[2013, 10, 19, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Sunday is the 19th, the last day of the teenth week"
|
||||
( 2013 5 "Sunday" "teenth" meetup >date-only )
|
||||
[2013, 05, 19, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Sunday is some day in the middle of the teenth week"
|
||||
( 2013 6 "Sunday" "teenth" meetup >date-only )
|
||||
[2013, 06, 16, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when teenth Sunday is the 13th, the first day of the teenth week"
|
||||
( 2013 10 "Sunday" "teenth" meetup >date-only )
|
||||
[2013, 10, 13, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when first Monday is some day in the middle of the first week"
|
||||
( 2013 3 "Monday" "first" meetup >date-only )
|
||||
[2013, 03, 04, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when first Monday is the 1st, the first day of the first week"
|
||||
( 2013 4 "Monday" "first" meetup >date-only )
|
||||
[2013, 04, 01, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when first Tuesday is the 7th, the last day of the first week"
|
||||
( 2013 5 "Tuesday" "first" meetup >date-only )
|
||||
[2013, 05, 07, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when first Tuesday is some day in the middle of the first week"
|
||||
( 2013 6 "Tuesday" "first" meetup >date-only )
|
||||
[2013, 06, 04, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when first Wednesday is some day in the middle of the first week"
|
||||
( 2013 7 "Wednesday" "first" meetup >date-only )
|
||||
[2013, 07, 03, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when first Wednesday is the 7th, the last day of the first week"
|
||||
( 2013 8 "Wednesday" "first" meetup >date-only )
|
||||
[2013, 08, 07, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when first Thursday is some day in the middle of the first week"
|
||||
( 2013 9 "Thursday" "first" meetup >date-only )
|
||||
[2013, 09, 05, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when first Thursday is another day in the middle of the first week"
|
||||
( 2013 10 "Thursday" "first" meetup >date-only )
|
||||
[2013, 10, 03, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when first Friday is the 1st, the first day of the first week"
|
||||
( 2013 11 "Friday" "first" meetup >date-only )
|
||||
[2013, 11, 01, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when first Friday is some day in the middle of the first week"
|
||||
( 2013 12 "Friday" "first" meetup >date-only )
|
||||
[2013, 12, 06, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when first Saturday is some day in the middle of the first week"
|
||||
( 2013 1 "Saturday" "first" meetup >date-only )
|
||||
[2013, 01, 05, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when first Saturday is another day in the middle of the first week"
|
||||
( 2013 2 "Saturday" "first" meetup >date-only )
|
||||
[2013, 02, 02, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when first Sunday is some day in the middle of the first week"
|
||||
( 2013 3 "Sunday" "first" meetup >date-only )
|
||||
[2013, 03, 03, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when first Sunday is the 7th, the last day of the first week"
|
||||
( 2013 4 "Sunday" "first" meetup >date-only )
|
||||
[2013, 04, 07, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when second Monday is some day in the middle of the second week"
|
||||
( 2013 3 "Monday" "second" meetup >date-only )
|
||||
[2013, 03, 11, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when second Monday is the 8th, the first day of the second week"
|
||||
( 2013 4 "Monday" "second" meetup >date-only )
|
||||
[2013, 04, 08, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when second Tuesday is the 14th, the last day of the second week"
|
||||
( 2013 5 "Tuesday" "second" meetup >date-only )
|
||||
[2013, 05, 14, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when second Tuesday is some day in the middle of the second week"
|
||||
( 2013 6 "Tuesday" "second" meetup >date-only )
|
||||
[2013, 06, 11, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when second Wednesday is some day in the middle of the second week"
|
||||
( 2013 7 "Wednesday" "second" meetup >date-only )
|
||||
[2013, 07, 10, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when second Wednesday is the 14th, the last day of the second week"
|
||||
( 2013 8 "Wednesday" "second" meetup >date-only )
|
||||
[2013, 08, 14, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when second Thursday is some day in the middle of the second week"
|
||||
( 2013 9 "Thursday" "second" meetup >date-only )
|
||||
[2013, 09, 12, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when second Thursday is another day in the middle of the second week"
|
||||
( 2013 10 "Thursday" "second" meetup >date-only )
|
||||
[2013, 10, 10, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when second Friday is the 8th, the first day of the second week"
|
||||
( 2013 11 "Friday" "second" meetup >date-only )
|
||||
[2013, 11, 08, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when second Friday is some day in the middle of the second week"
|
||||
( 2013 12 "Friday" "second" meetup >date-only )
|
||||
[2013, 12, 13, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when second Saturday is some day in the middle of the second week"
|
||||
( 2013 1 "Saturday" "second" meetup >date-only )
|
||||
[2013, 01, 12, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when second Saturday is another day in the middle of the second week"
|
||||
( 2013 2 "Saturday" "second" meetup >date-only )
|
||||
[2013, 02, 09, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when second Sunday is some day in the middle of the second week"
|
||||
( 2013 3 "Sunday" "second" meetup >date-only )
|
||||
[2013, 03, 10, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when second Sunday is the 14th, the last day of the second week"
|
||||
( 2013 4 "Sunday" "second" meetup >date-only )
|
||||
[2013, 04, 14, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when third Monday is some day in the middle of the third week"
|
||||
( 2013 3 "Monday" "third" meetup >date-only )
|
||||
[2013, 03, 18, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when third Monday is the 15th, the first day of the third week"
|
||||
( 2013 4 "Monday" "third" meetup >date-only )
|
||||
[2013, 04, 15, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when third Tuesday is the 21st, the last day of the third week"
|
||||
( 2013 5 "Tuesday" "third" meetup >date-only )
|
||||
[2013, 05, 21, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when third Tuesday is some day in the middle of the third week"
|
||||
( 2013 6 "Tuesday" "third" meetup >date-only )
|
||||
[2013, 06, 18, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when third Wednesday is some day in the middle of the third week"
|
||||
( 2013 7 "Wednesday" "third" meetup >date-only )
|
||||
[2013, 07, 17, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when third Wednesday is the 21st, the last day of the third week"
|
||||
( 2013 8 "Wednesday" "third" meetup >date-only )
|
||||
[2013, 08, 21, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when third Thursday is some day in the middle of the third week"
|
||||
( 2013 9 "Thursday" "third" meetup >date-only )
|
||||
[2013, 09, 19, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when third Thursday is another day in the middle of the third week"
|
||||
( 2013 10 "Thursday" "third" meetup >date-only )
|
||||
[2013, 10, 17, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when third Friday is the 15th, the first day of the third week"
|
||||
( 2013 11 "Friday" "third" meetup >date-only )
|
||||
[2013, 11, 15, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when third Friday is some day in the middle of the third week"
|
||||
( 2013 12 "Friday" "third" meetup >date-only )
|
||||
[2013, 12, 20, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when third Saturday is some day in the middle of the third week"
|
||||
( 2013 1 "Saturday" "third" meetup >date-only )
|
||||
[2013, 01, 19, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when third Saturday is another day in the middle of the third week"
|
||||
( 2013 2 "Saturday" "third" meetup >date-only )
|
||||
[2013, 02, 16, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when third Sunday is some day in the middle of the third week"
|
||||
( 2013 3 "Sunday" "third" meetup >date-only )
|
||||
[2013, 03, 17, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when third Sunday is the 21st, the last day of the third week"
|
||||
( 2013 4 "Sunday" "third" meetup >date-only )
|
||||
[2013, 04, 21, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when fourth Monday is some day in the middle of the fourth week"
|
||||
( 2013 3 "Monday" "fourth" meetup >date-only )
|
||||
[2013, 03, 25, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when fourth Monday is the 22nd, the first day of the fourth week"
|
||||
( 2013 4 "Monday" "fourth" meetup >date-only )
|
||||
[2013, 04, 22, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when fourth Tuesday is the 28th, the last day of the fourth week"
|
||||
( 2013 5 "Tuesday" "fourth" meetup >date-only )
|
||||
[2013, 05, 28, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when fourth Tuesday is some day in the middle of the fourth week"
|
||||
( 2013 6 "Tuesday" "fourth" meetup >date-only )
|
||||
[2013, 06, 25, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when fourth Wednesday is some day in the middle of the fourth week"
|
||||
( 2013 7 "Wednesday" "fourth" meetup >date-only )
|
||||
[2013, 07, 24, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when fourth Wednesday is the 28th, the last day of the fourth week"
|
||||
( 2013 8 "Wednesday" "fourth" meetup >date-only )
|
||||
[2013, 08, 28, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when fourth Thursday is some day in the middle of the fourth week"
|
||||
( 2013 9 "Thursday" "fourth" meetup >date-only )
|
||||
[2013, 09, 26, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when fourth Thursday is another day in the middle of the fourth week"
|
||||
( 2013 10 "Thursday" "fourth" meetup >date-only )
|
||||
[2013, 10, 24, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when fourth Friday is the 22nd, the first day of the fourth week"
|
||||
( 2013 11 "Friday" "fourth" meetup >date-only )
|
||||
[2013, 11, 22, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when fourth Friday is some day in the middle of the fourth week"
|
||||
( 2013 12 "Friday" "fourth" meetup >date-only )
|
||||
[2013, 12, 27, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when fourth Saturday is some day in the middle of the fourth week"
|
||||
( 2013 1 "Saturday" "fourth" meetup >date-only )
|
||||
[2013, 01, 26, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when fourth Saturday is another day in the middle of the fourth week"
|
||||
( 2013 2 "Saturday" "fourth" meetup >date-only )
|
||||
[2013, 02, 23, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when fourth Sunday is some day in the middle of the fourth week"
|
||||
( 2013 3 "Sunday" "fourth" meetup >date-only )
|
||||
[2013, 03, 24, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when fourth Sunday is the 28th, the last day of the fourth week"
|
||||
( 2013 4 "Sunday" "fourth" meetup >date-only )
|
||||
[2013, 04, 28, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"last Monday in a month with four Mondays"
|
||||
( 2013 3 "Monday" "last" meetup >date-only )
|
||||
[2013, 03, 25, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"last Monday in a month with five Mondays"
|
||||
( 2013 4 "Monday" "last" meetup >date-only )
|
||||
[2013, 04, 29, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"last Tuesday in a month with four Tuesdays"
|
||||
( 2013 5 "Tuesday" "last" meetup >date-only )
|
||||
[2013, 05, 28, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"last Tuesday in another month with four Tuesdays"
|
||||
( 2013 6 "Tuesday" "last" meetup >date-only )
|
||||
[2013, 06, 25, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"last Wednesday in a month with five Wednesdays"
|
||||
( 2013 7 "Wednesday" "last" meetup >date-only )
|
||||
[2013, 07, 31, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"last Wednesday in a month with four Wednesdays"
|
||||
( 2013 8 "Wednesday" "last" meetup >date-only )
|
||||
[2013, 08, 28, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"last Thursday in a month with four Thursdays"
|
||||
( 2013 9 "Thursday" "last" meetup >date-only )
|
||||
[2013, 09, 26, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"last Thursday in a month with five Thursdays"
|
||||
( 2013 10 "Thursday" "last" meetup >date-only )
|
||||
[2013, 10, 31, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"last Friday in a month with five Fridays"
|
||||
( 2013 11 "Friday" "last" meetup >date-only )
|
||||
[2013, 11, 29, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"last Friday in a month with four Fridays"
|
||||
( 2013 12 "Friday" "last" meetup >date-only )
|
||||
[2013, 12, 27, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"last Saturday in a month with four Saturdays"
|
||||
( 2013 1 "Saturday" "last" meetup >date-only )
|
||||
[2013, 01, 26, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"last Saturday in another month with four Saturdays"
|
||||
( 2013 2 "Saturday" "last" meetup >date-only )
|
||||
[2013, 02, 23, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"last Sunday in a month with five Sundays"
|
||||
( 2013 3 "Sunday" "last" meetup >date-only )
|
||||
[2013, 03, 31, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"last Sunday in a month with four Sundays"
|
||||
( 2013 4 "Sunday" "last" meetup >date-only )
|
||||
[2013, 04, 28, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when last Wednesday in February in a leap year is the 29th"
|
||||
( 2012 2 "Wednesday" "last" meetup >date-only )
|
||||
[2012, 02, 29, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"last Wednesday in December that is also the last day of the year"
|
||||
( 2014 12 "Wednesday" "last" meetup >date-only )
|
||||
[2014, 12, 31, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when last Sunday in February in a non-leap year is not the 29th"
|
||||
( 2015 2 "Sunday" "last" meetup >date-only )
|
||||
[2015, 02, 22, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
"when first Friday is the 7th, the last day of the first week"
|
||||
( 2012 12 "Friday" "first" meetup >date-only )
|
||||
[2012, 12, 07, 0, 0, 0, 0, 0, 0, 0] d:join
|
||||
equal?
|
||||
|
||||
end-of-tests
|
||||
;with
|
||||
Reference in New Issue
Block a user