-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathspecifications.ss
11569 lines (11569 loc) · 449 KB
/
specifications.ss
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
((robot-simulator
(exercise . "robot-simulator")
(version . "3.2.0")
(comments
"Some tests have two expectations: one for the position, one for the direction"
"Optionally, you can also test"
" - An invalid direction throws an error"
" - An invalid instruction throws an error"
" - Default starting position and direction if none are provided")
(cases
((description . "Create robot")
(cases
((description . "at origin facing north")
(property . "create")
(input (position (x . 0) (y . 0)) (direction . "north"))
(expected (position (x . 0) (y . 0)) (direction . "north")))
((description . "at negative position facing south")
(property . "create")
(input (position (x . -1) (y . -1)) (direction . "south"))
(expected
(position (x . -1) (y . -1))
(direction . "south")))))
((description . "Rotating clockwise")
(cases
((description . "changes north to east")
(property . "move")
(input
(position (x . 0) (y . 0))
(direction . "north")
(instructions . "R"))
(expected (position (x . 0) (y . 0)) (direction . "east")))
((description . "changes east to south")
(property . "move")
(input
(position (x . 0) (y . 0))
(direction . "east")
(instructions . "R"))
(expected (position (x . 0) (y . 0)) (direction . "south")))
((description . "changes south to west")
(property . "move")
(input
(position (x . 0) (y . 0))
(direction . "south")
(instructions . "R"))
(expected (position (x . 0) (y . 0)) (direction . "west")))
((description . "changes west to north")
(property . "move")
(input
(position (x . 0) (y . 0))
(direction . "west")
(instructions . "R"))
(expected
(position (x . 0) (y . 0))
(direction . "north")))))
((description . "Rotating counter-clockwise")
(cases
((description . "changes north to west")
(property . "move")
(input
(position (x . 0) (y . 0))
(direction . "north")
(instructions . "L"))
(expected (position (x . 0) (y . 0)) (direction . "west")))
((description . "changes west to south")
(property . "move")
(input
(position (x . 0) (y . 0))
(direction . "west")
(instructions . "L"))
(expected (position (x . 0) (y . 0)) (direction . "south")))
((description . "changes south to east")
(property . "move")
(input
(position (x . 0) (y . 0))
(direction . "south")
(instructions . "L"))
(expected (position (x . 0) (y . 0)) (direction . "east")))
((description . "changes east to north")
(property . "move")
(input
(position (x . 0) (y . 0))
(direction . "east")
(instructions . "L"))
(expected
(position (x . 0) (y . 0))
(direction . "north")))))
((description . "Moving forward one")
(cases
((description . "facing north increments Y")
(property . "move")
(input
(position (x . 0) (y . 0))
(direction . "north")
(instructions . "A"))
(expected (position (x . 0) (y . 1)) (direction . "north")))
((description . "facing south decrements Y")
(property . "move")
(input
(position (x . 0) (y . 0))
(direction . "south")
(instructions . "A"))
(expected
(position (x . 0) (y . -1))
(direction . "south")))
((description . "facing east increments X")
(property . "move")
(input
(position (x . 0) (y . 0))
(direction . "east")
(instructions . "A"))
(expected (position (x . 1) (y . 0)) (direction . "east")))
((description . "facing west decrements X")
(property . "move")
(input
(position (x . 0) (y . 0))
(direction . "west")
(instructions . "A"))
(expected
(position (x . -1) (y . 0))
(direction . "west")))))
((description . "Follow series of instructions")
(comments
"The robot can follow a series of instructions and end up with the correct position and direction."
"Where R = Turn Right, L = Turn Left and A = Advance")
(cases
((description . "moving east and north from README")
(property . "move")
(input
(position (x . 7) (y . 3))
(direction . "north")
(instructions . "RAALAL"))
(expected (position (x . 9) (y . 4)) (direction . "west")))
((description . "moving west and north")
(property . "move")
(input
(position (x . 0) (y . 0))
(direction . "north")
(instructions . "LAAARALA"))
(expected (position (x . -4) (y . 1)) (direction . "west")))
((description . "moving west and south")
(property . "move")
(input
(position (x . 2) (y . -7))
(direction . "east")
(instructions . "RRAAAAALA"))
(expected
(position (x . -3) (y . -8))
(direction . "south")))
((description . "moving east and north")
(property . "move")
(input
(position (x . 8) (y . 4))
(direction . "south")
(instructions . "LAAARRRALLLL"))
(expected
(position (x . 11) (y . 5))
(direction . "north")))))))
(food-chain
(exercise . "food-chain")
(version . "2.1.0")
(comments
"JSON doesn't allow for multi-line strings, so all verses are presented "
"here as arrays of strings. It's up to the test generator to join the "
"lines together with line breaks."
"Some languages test for the verse() method, which takes a start verse "
"and optional end verse, but other languages have only tested for the full poem."
"For those languages in the latter category, you may wish to only "
"implement the full song test and leave the rest alone, ignoring the start "
"and end verse fields.")
(cases
((description
.
"Return specified verse or series of verses")
(cases
((description . "fly")
(property . "recite")
(input (startVerse . 1) (endVerse . 1))
(expected
"I know an old lady who swallowed a fly."
"I don't know why she swallowed the fly. Perhaps she'll die."))
((description . "spider")
(property . "recite")
(input (startVerse . 2) (endVerse . 2))
(expected
"I know an old lady who swallowed a spider."
"It wriggled and jiggled and tickled inside her."
"She swallowed the spider to catch the fly."
"I don't know why she swallowed the fly. Perhaps she'll die."))
((description . "bird")
(property . "recite")
(input (startVerse . 3) (endVerse . 3))
(expected "I know an old lady who swallowed a bird."
"How absurd to swallow a bird!"
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her."
"She swallowed the spider to catch the fly."
"I don't know why she swallowed the fly. Perhaps she'll die."))
((description . "cat")
(property . "recite")
(input (startVerse . 4) (endVerse . 4))
(expected "I know an old lady who swallowed a cat."
"Imagine that, to swallow a cat!"
"She swallowed the cat to catch the bird."
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her."
"She swallowed the spider to catch the fly."
"I don't know why she swallowed the fly. Perhaps she'll die."))
((description . "dog")
(property . "recite")
(input (startVerse . 5) (endVerse . 5))
(expected "I know an old lady who swallowed a dog."
"What a hog, to swallow a dog!"
"She swallowed the dog to catch the cat."
"She swallowed the cat to catch the bird."
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her."
"She swallowed the spider to catch the fly."
"I don't know why she swallowed the fly. Perhaps she'll die."))
((description . "goat")
(property . "recite")
(input (startVerse . 6) (endVerse . 6))
(expected "I know an old lady who swallowed a goat."
"Just opened her throat and swallowed a goat!"
"She swallowed the goat to catch the dog."
"She swallowed the dog to catch the cat."
"She swallowed the cat to catch the bird."
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her."
"She swallowed the spider to catch the fly."
"I don't know why she swallowed the fly. Perhaps she'll die."))
((description . "cow")
(property . "recite")
(input (startVerse . 7) (endVerse . 7))
(expected "I know an old lady who swallowed a cow."
"I don't know how she swallowed a cow!"
"She swallowed the cow to catch the goat."
"She swallowed the goat to catch the dog."
"She swallowed the dog to catch the cat."
"She swallowed the cat to catch the bird."
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her."
"She swallowed the spider to catch the fly."
"I don't know why she swallowed the fly. Perhaps she'll die."))
((description . "horse")
(property . "recite")
(input (startVerse . 8) (endVerse . 8))
(expected
"I know an old lady who swallowed a horse."
"She's dead, of course!"))
((description . "multiple verses")
(property . "recite")
(input (startVerse . 1) (endVerse . 3))
(expected "I know an old lady who swallowed a fly."
"I don't know why she swallowed the fly. Perhaps she'll die."
"" "I know an old lady who swallowed a spider."
"It wriggled and jiggled and tickled inside her."
"She swallowed the spider to catch the fly."
"I don't know why she swallowed the fly. Perhaps she'll die."
"" "I know an old lady who swallowed a bird."
"How absurd to swallow a bird!"
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her."
"She swallowed the spider to catch the fly."
"I don't know why she swallowed the fly. Perhaps she'll die."))
((description . "full song")
(property . "recite")
(input (startVerse . 1) (endVerse . 8))
(expected "I know an old lady who swallowed a fly."
"I don't know why she swallowed the fly. Perhaps she'll die."
"" "I know an old lady who swallowed a spider."
"It wriggled and jiggled and tickled inside her."
"She swallowed the spider to catch the fly."
"I don't know why she swallowed the fly. Perhaps she'll die."
"" "I know an old lady who swallowed a bird."
"How absurd to swallow a bird!"
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her."
"She swallowed the spider to catch the fly."
"I don't know why she swallowed the fly. Perhaps she'll die."
"" "I know an old lady who swallowed a cat."
"Imagine that, to swallow a cat!"
"She swallowed the cat to catch the bird."
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her."
"She swallowed the spider to catch the fly."
"I don't know why she swallowed the fly. Perhaps she'll die."
"" "I know an old lady who swallowed a dog."
"What a hog, to swallow a dog!"
"She swallowed the dog to catch the cat."
"She swallowed the cat to catch the bird."
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her."
"She swallowed the spider to catch the fly."
"I don't know why she swallowed the fly. Perhaps she'll die."
"" "I know an old lady who swallowed a goat."
"Just opened her throat and swallowed a goat!"
"She swallowed the goat to catch the dog."
"She swallowed the dog to catch the cat."
"She swallowed the cat to catch the bird."
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her."
"She swallowed the spider to catch the fly."
"I don't know why she swallowed the fly. Perhaps she'll die."
"" "I know an old lady who swallowed a cow."
"I don't know how she swallowed a cow!"
"She swallowed the cow to catch the goat."
"She swallowed the goat to catch the dog."
"She swallowed the dog to catch the cat."
"She swallowed the cat to catch the bird."
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her."
"She swallowed the spider to catch the fly."
"I don't know why she swallowed the fly. Perhaps she'll die."
"" "I know an old lady who swallowed a horse."
"She's dead, of course!"))))))
(word-search
(exercise . "word-search")
(version . "1.2.1")
(comments "Grid rows and columns are 1-indexed.")
(cases
((description
.
"Should accept an initial game grid and a target search word")
(property . "search")
(input (grid "jefblpepre") (wordsToSearchFor "clojure"))
(expected (clojure)))
((description
.
"Should locate one word written left to right")
(property . "search")
(input (grid "clojurermt") (wordsToSearchFor "clojure"))
(expected
(clojure
(start (column . 1) (row . 1))
(end (column . 7) (row . 1)))))
((description
.
"Should locate the same word written left to right in a different position")
(property . "search")
(input (grid "mtclojurer") (wordsToSearchFor "clojure"))
(expected
(clojure
(start (column . 3) (row . 1))
(end (column . 9) (row . 1)))))
((description
.
"Should locate a different left to right word")
(property . "search")
(input (grid "coffeelplx") (wordsToSearchFor "coffee"))
(expected
(coffee
(start (column . 1) (row . 1))
(end (column . 6) (row . 1)))))
((description
.
"Should locate that different left to right word in a different position")
(property . "search")
(input (grid "xcoffeezlp") (wordsToSearchFor "coffee"))
(expected
(coffee
(start (column . 2) (row . 1))
(end (column . 7) (row . 1)))))
((description
.
"Should locate a left to right word in two line grid")
(property . "search")
(input
(grid "jefblpepre" "tclojurerm")
(wordsToSearchFor "clojure"))
(expected
(clojure
(start (column . 2) (row . 2))
(end (column . 8) (row . 2)))))
((description
.
"Should locate a left to right word in three line grid")
(property . "search")
(input
(grid "camdcimgtc" "jefblpepre" "clojurermt")
(wordsToSearchFor "clojure"))
(expected
(clojure
(start (column . 1) (row . 3))
(end (column . 7) (row . 3)))))
((description
.
"Should locate a left to right word in ten line grid")
(property . "search")
(input
(grid "jefblpepre" "camdcimgtc" "oivokprjsm" "pbwasqroua"
"rixilelhrs" "wolcqlirpc" "screeaumgr" "alxhpburyi"
"jalaycalmp" "clojurermt")
(wordsToSearchFor "clojure"))
(expected
(clojure
(start (column . 1) (row . 10))
(end (column . 7) (row . 10)))))
((description
.
"Should locate that left to right word in a different position in a ten line grid")
(property . "search")
(input
(grid "jefblpepre" "camdcimgtc" "oivokprjsm" "pbwasqroua"
"rixilelhrs" "wolcqlirpc" "screeaumgr" "alxhpburyi"
"clojurermt" "jalaycalmp")
(wordsToSearchFor "clojure"))
(expected
(clojure
(start (column . 1) (row . 9))
(end (column . 7) (row . 9)))))
((description
.
"Should locate a different left to right word in a ten line grid")
(property . "search")
(input
(grid "jefblpepre" "camdcimgtc" "oivokprjsm" "pbwasqroua"
"rixilelhrs" "wolcqlirpc" "fortranftw" "alxhpburyi"
"clojurermt" "jalaycalmp")
(wordsToSearchFor "fortran"))
(expected
(fortran
(start (column . 1) (row . 7))
(end (column . 7) (row . 7)))))
((description . "Should locate multiple words")
(property . "search")
(input
(grid "jefblpepre" "camdcimgtc" "oivokprjsm" "pbwasqroua"
"rixilelhrs" "wolcqlirpc" "fortranftw" "alxhpburyi"
"jalaycalmp" "clojurermt")
(wordsToSearchFor "fortran" "clojure"))
(expected
(clojure
(start (column . 1) (row . 10))
(end (column . 7) (row . 10)))
(fortran
(start (column . 1) (row . 7))
(end (column . 7) (row . 7)))))
((description
.
"Should locate a single word written right to left")
(property . "search")
(input (grid "rixilelhrs") (wordsToSearchFor "elixir"))
(expected
(elixir
(start (column . 6) (row . 1))
(end (column . 1) (row . 1)))))
((description
.
"Should locate multiple words written in different horizontal directions")
(property . "search")
(input
(grid "jefblpepre" "camdcimgtc" "oivokprjsm" "pbwasqroua"
"rixilelhrs" "wolcqlirpc" "screeaumgr" "alxhpburyi"
"jalaycalmp" "clojurermt")
(wordsToSearchFor "elixir" "clojure"))
(expected
(clojure
(start (column . 1) (row . 10))
(end (column . 7) (row . 10)))
(elixir
(start (column . 6) (row . 5))
(end (column . 1) (row . 5)))))
((description . "Should locate words written top to bottom")
(property . "search")
(input
(grid "jefblpepre" "camdcimgtc" "oivokprjsm" "pbwasqroua"
"rixilelhrs" "wolcqlirpc" "screeaumgr" "alxhpburyi"
"jalaycalmp" "clojurermt")
(wordsToSearchFor "clojure" "elixir" "ecmascript"))
(expected
(clojure
(start (column . 1) (row . 10))
(end (column . 7) (row . 10)))
(elixir
(start (column . 6) (row . 5))
(end (column . 1) (row . 5)))
(ecmascript
(start (column . 10) (row . 1))
(end (column . 10) (row . 10)))))
((description . "Should locate words written bottom to top")
(property . "search")
(input
(grid "jefblpepre" "camdcimgtc" "oivokprjsm" "pbwasqroua"
"rixilelhrs" "wolcqlirpc" "screeaumgr" "alxhpburyi"
"jalaycalmp" "clojurermt")
(wordsToSearchFor "clojure" "elixir" "ecmascript" "rust"))
(expected
(clojure
(start (column . 1) (row . 10))
(end (column . 7) (row . 10)))
(elixir
(start (column . 6) (row . 5))
(end (column . 1) (row . 5)))
(ecmascript
(start (column . 10) (row . 1))
(end (column . 10) (row . 10)))
(rust
(start (column . 9) (row . 5))
(end (column . 9) (row . 2)))))
((description
.
"Should locate words written top left to bottom right")
(property . "search")
(input
(grid "jefblpepre" "camdcimgtc" "oivokprjsm" "pbwasqroua"
"rixilelhrs" "wolcqlirpc" "screeaumgr" "alxhpburyi"
"jalaycalmp" "clojurermt")
(wordsToSearchFor "clojure" "elixir" "ecmascript" "rust"
"java"))
(expected
(clojure
(start (column . 1) (row . 10))
(end (column . 7) (row . 10)))
(elixir
(start (column . 6) (row . 5))
(end (column . 1) (row . 5)))
(ecmascript
(start (column . 10) (row . 1))
(end (column . 10) (row . 10)))
(rust
(start (column . 9) (row . 5))
(end (column . 9) (row . 2)))
(java
(start (column . 1) (row . 1))
(end (column . 4) (row . 4)))))
((description
.
"Should locate words written bottom right to top left")
(property . "search")
(input
(grid "jefblpepre" "camdcimgtc" "oivokprjsm" "pbwasqroua"
"rixilelhrs" "wolcqlirpc" "screeaumgr" "alxhpburyi"
"jalaycalmp" "clojurermt")
(wordsToSearchFor "clojure" "elixir" "ecmascript" "rust"
"java" "lua"))
(expected
(clojure
(start (column . 1) (row . 10))
(end (column . 7) (row . 10)))
(elixir
(start (column . 6) (row . 5))
(end (column . 1) (row . 5)))
(ecmascript
(start (column . 10) (row . 1))
(end (column . 10) (row . 10)))
(rust
(start (column . 9) (row . 5))
(end (column . 9) (row . 2)))
(java
(start (column . 1) (row . 1))
(end (column . 4) (row . 4)))
(lua (start (column . 8) (row . 9))
(end (column . 6) (row . 7)))))
((description
.
"Should locate words written bottom left to top right")
(property . "search")
(input
(grid "jefblpepre" "camdcimgtc" "oivokprjsm" "pbwasqroua"
"rixilelhrs" "wolcqlirpc" "screeaumgr" "alxhpburyi"
"jalaycalmp" "clojurermt")
(wordsToSearchFor "clojure" "elixir" "ecmascript" "rust"
"java" "lua" "lisp"))
(expected
(clojure
(start (column . 1) (row . 10))
(end (column . 7) (row . 10)))
(elixir
(start (column . 6) (row . 5))
(end (column . 1) (row . 5)))
(ecmascript
(start (column . 10) (row . 1))
(end (column . 10) (row . 10)))
(rust
(start (column . 9) (row . 5))
(end (column . 9) (row . 2)))
(java
(start (column . 1) (row . 1))
(end (column . 4) (row . 4)))
(lua (start (column . 8) (row . 9))
(end (column . 6) (row . 7)))
(lisp
(start (column . 3) (row . 6))
(end (column . 6) (row . 3)))))
((description
.
"Should locate words written top right to bottom left")
(property . "search")
(input
(grid "jefblpepre" "camdcimgtc" "oivokprjsm" "pbwasqroua"
"rixilelhrs" "wolcqlirpc" "screeaumgr" "alxhpburyi"
"jalaycalmp" "clojurermt")
(wordsToSearchFor "clojure" "elixir" "ecmascript" "rust"
"java" "lua" "lisp" "ruby"))
(expected
(clojure
(start (column . 1) (row . 10))
(end (column . 7) (row . 10)))
(elixir
(start (column . 6) (row . 5))
(end (column . 1) (row . 5)))
(ecmascript
(start (column . 10) (row . 1))
(end (column . 10) (row . 10)))
(rust
(start (column . 9) (row . 5))
(end (column . 9) (row . 2)))
(java
(start (column . 1) (row . 1))
(end (column . 4) (row . 4)))
(lua (start (column . 8) (row . 9))
(end (column . 6) (row . 7)))
(lisp
(start (column . 3) (row . 6))
(end (column . 6) (row . 3)))
(ruby
(start (column . 8) (row . 6))
(end (column . 5) (row . 9)))))
((description
.
"Should fail to locate a word that is not in the puzzle")
(property . "search")
(input
(grid "jefblpepre" "camdcimgtc" "oivokprjsm" "pbwasqroua"
"rixilelhrs" "wolcqlirpc" "screeaumgr" "alxhpburyi"
"jalaycalmp" "clojurermt")
(wordsToSearchFor "clojure" "elixir" "ecmascript" "rust"
"java" "lua" "lisp" "ruby" "haskell"))
(expected
(clojure
(start (column . 1) (row . 10))
(end (column . 7) (row . 10)))
(elixir
(start (column . 6) (row . 5))
(end (column . 1) (row . 5)))
(ecmascript
(start (column . 10) (row . 1))
(end (column . 10) (row . 10)))
(rust
(start (column . 9) (row . 5))
(end (column . 9) (row . 2)))
(java
(start (column . 1) (row . 1))
(end (column . 4) (row . 4)))
(lua (start (column . 8) (row . 9))
(end (column . 6) (row . 7)))
(lisp
(start (column . 3) (row . 6))
(end (column . 6) (row . 3)))
(ruby
(start (column . 8) (row . 6))
(end (column . 5) (row . 9)))
(haskell)))))
(simple-cipher
(exercise . "simple-cipher")
(version . "2.0.0")
(comments
"Some of the strings used in this file are symbolic and do not represent their literal value. They are:"
"cipher.key - Represents the Cipher key"
"cipher.encode - Represents the output of the Cipher encode method"
"new - Represents the Cipher initialization"
"string.substring(start, length) - Represents a substring of 'string' that begins at index 'start' and is 'length' characters long")
(cases
((description . "Random key cipher")
(cases
((description . "Can encode")
(property . "encode")
(input (plaintext . "aaaaaaaaaa"))
(expected . "cipher.key.substring(0, plaintext.length)"))
((description . "Can decode")
(property . "decode")
(input
(ciphertext . "cipher.key.substring(0, expected.length)"))
(expected . "aaaaaaaaaa"))
((description
.
"Is reversible. I.e., if you apply decode in a encoded result, you must see the same plaintext encode parameter as a result of the decode method")
(property . "decode")
(input
(plaintext . "abcdefghij")
(ciphertext . "cipher.encode"))
(expected . "abcdefghij"))
((description . "Key is made only of lowercase letters")
(property . "key")
(input)
(expected (match . "^[a-z]+$")))))
((description . "Substitution cipher")
(cases
((description . "Can encode")
(property . "encode")
(input (key . "abcdefghij") (plaintext . "aaaaaaaaaa"))
(expected . "abcdefghij"))
((description . "Can decode")
(property . "decode")
(input (key . "abcdefghij") (ciphertext . "abcdefghij"))
(expected . "aaaaaaaaaa"))
((description
.
"Is reversible. I.e., if you apply decode in a encoded result, you must see the same plaintext encode parameter as a result of the decode method")
(property . "decode")
(input
(key . "abcdefghij")
(plaintext . "abcdefghij")
(ciphertext . "cipher.encode"))
(expected . "abcdefghij"))
((description . "Can double shift encode")
(property . "encode")
(input
(key . "iamapandabear")
(plaintext . "iamapandabear"))
(expected . "qayaeaagaciai"))
((description . "Can wrap on encode")
(property . "encode")
(input (key . "abcdefghij") (plaintext . "zzzzzzzzzz"))
(expected . "zabcdefghi"))
((description . "Can wrap on decode")
(property . "decode")
(input (key . "abcdefghij") (ciphertext . "zabcdefghi"))
(expected . "zzzzzzzzzz"))
((description . "Can encode messages longer than the key")
(property . "encode")
(input (key . "abc") (plaintext . "iamapandabear"))
(expected . "iboaqcnecbfcr"))
((description . "Can decode messages longer than the key")
(property . "decode")
(input (key . "abc") (ciphertext . "iboaqcnecbfcr"))
(expected . "iamapandabear"))))))
(nth-prime
(exercise . "nth-prime")
(version . "2.1.0")
(cases
((description . "first prime")
(property . "prime")
(input (number . 1))
(expected . 2))
((description . "second prime")
(property . "prime")
(input (number . 2))
(expected . 3))
((description . "sixth prime")
(property . "prime")
(input (number . 6))
(expected . 13))
((description . "big prime")
(property . "prime")
(input (number . 10001))
(expected . 104743))
((description . "there is no zeroth prime")
(property . "prime")
(input (number . 0))
(expected (error . "there is no zeroth prime")))))
(ocr-numbers
(exercise . "ocr-numbers")
(version . "1.2.0")
(cases
((description
.
"Converts lines of OCR Numbers to a string of integers")
(cases
((description . "Recognizes 0")
(property . "convert")
(input (rows " _ " "| |" "|_|" " "))
(expected . "0"))
((description . "Recognizes 1")
(property . "convert")
(input (rows " " " |" " |" " "))
(expected . "1"))
((description
.
"Unreadable but correctly sized inputs return ?")
(property . "convert")
(input (rows " " " _" " |" " "))
(expected . "?"))
((description
.
"Input with a number of lines that is not a multiple of four raises an error")
(property . "convert")
(input (rows " _ " "| |" " "))
(expected
(error .
"Number of input lines is not a multiple of four")))
((description
.
"Input with a number of columns that is not a multiple of three raises an error")
(property . "convert")
(input (rows " " " |" " |" " "))
(expected
(error .
"Number of input columns is not a multiple of three")))
((description . "Recognizes 110101100")
(property . "convert")
(input
(rows
" _ _ _ _ "
" | || | || | | || || |"
" | ||_| ||_| | ||_||_|"
" "))
(expected . "110101100"))
((description
.
"Garbled numbers in a string are replaced with ?")
(property . "convert")
(input
(rows
" _ _ _ "
" | || | || | || || |"
" | | _| ||_| | ||_||_|"
" "))
(expected . "11?10?1?0"))
((description . "Recognizes 2")
(property . "convert")
(input (rows " _ " " _|" "|_ " " "))
(expected . "2"))
((description . "Recognizes 3")
(property . "convert")
(input (rows " _ " " _|" " _|" " "))
(expected . "3"))
((description . "Recognizes 4")
(property . "convert")
(input (rows " " "|_|" " |" " "))
(expected . "4"))
((description . "Recognizes 5")
(property . "convert")
(input (rows " _ " "|_ " " _|" " "))
(expected . "5"))
((description . "Recognizes 6")
(property . "convert")
(input (rows " _ " "|_ " "|_|" " "))
(expected . "6"))
((description . "Recognizes 7")
(property . "convert")
(input (rows " _ " " |" " |" " "))
(expected . "7"))
((description . "Recognizes 8")
(property . "convert")
(input (rows " _ " "|_|" "|_|" " "))
(expected . "8"))
((description . "Recognizes 9")
(property . "convert")
(input (rows " _ " "|_|" " _|" " "))
(expected . "9"))
((description . "Recognizes string of decimal numbers")
(property . "convert")
(input
(rows
" _ _ _ _ _ _ _ _ "
" | _| _||_||_ |_ ||_||_|| |"
" ||_ _| | _||_| ||_| _||_|"
" "))
(expected . "1234567890"))
((description
.
"Numbers separated by empty lines are recognized. Lines are joined by commas.")
(property . "convert")
(input
(rows " _ _ " " | _| _|" " ||_ _|" " " " _ _ "
"|_||_ |_ " " | _||_|" " " " _ _ _ " " ||_||_|"
" ||_| _|" " "))
(expected . "123,456,789"))))))
(zebra-puzzle
(exercise . "zebra-puzzle")
(version . "1.1.0")
(cases
((description . "resident who drinks water")
(property . "drinksWater")
(input)
(expected . "Norwegian"))
((description . "resident who owns zebra")
(property . "ownsZebra")
(input)
(expected . "Japanese"))))
(clock
(exercise . "clock")
(version . "2.4.0")
(comments
"Most languages require constructing a clock with initial values,"
"adding or subtracting some number of minutes, and testing equality"
"in some language-native way. Negative and out of range values are"
"generally expected to wrap around rather than represent errors.")
(cases
((description . "Create a new clock with an initial time")
(cases
((description . "on the hour")
(property . "create")
(input (hour . 8) (minute . 0))
(expected . "08:00"))
((description . "past the hour")
(property . "create")
(input (hour . 11) (minute . 9))
(expected . "11:09"))
((description . "midnight is zero hours")
(property . "create")
(input (hour . 24) (minute . 0))
(expected . "00:00"))
((description . "hour rolls over")
(property . "create")
(input (hour . 25) (minute . 0))
(expected . "01:00"))
((description . "hour rolls over continuously")
(property . "create")
(input (hour . 100) (minute . 0))
(expected . "04:00"))
((description . "sixty minutes is next hour")
(property . "create")
(input (hour . 1) (minute . 60))
(expected . "02:00"))
((description . "minutes roll over")
(property . "create")
(input (hour . 0) (minute . 160))
(expected . "02:40"))
((description . "minutes roll over continuously")
(property . "create")
(input (hour . 0) (minute . 1723))
(expected . "04:43"))
((description . "hour and minutes roll over")
(property . "create")
(input (hour . 25) (minute . 160))
(expected . "03:40"))
((description . "hour and minutes roll over continuously")
(property . "create")
(input (hour . 201) (minute . 3001))
(expected . "11:01"))
((description
.
"hour and minutes roll over to exactly midnight")
(property . "create")
(input (hour . 72) (minute . 8640))
(expected . "00:00"))
((description . "negative hour")
(property . "create")
(input (hour . -1) (minute . 15))
(expected . "23:15"))
((description . "negative hour rolls over")
(property . "create")
(input (hour . -25) (minute . 0))
(expected . "23:00"))
((description . "negative hour rolls over continuously")
(property . "create")
(input (hour . -91) (minute . 0))
(expected . "05:00"))
((description . "negative minutes")
(property . "create")
(input (hour . 1) (minute . -40))
(expected . "00:20"))
((description . "negative minutes roll over")
(property . "create")
(input (hour . 1) (minute . -160))
(expected . "22:20"))
((description . "negative minutes roll over continuously")
(property . "create")
(input (hour . 1) (minute . -4820))
(expected . "16:40"))
((description . "negative sixty minutes is previous hour")
(property . "create")
(input (hour . 2) (minute . -60))
(expected . "01:00"))
((description . "negative hour and minutes both roll over")
(property . "create")
(input (hour . -25) (minute . -160))
(expected . "20:20"))
((description
.
"negative hour and minutes both roll over continuously")
(property . "create")
(input (hour . -121) (minute . -5810))
(expected . "22:10"))))
((description . "Add minutes")
(cases
((description . "add minutes")
(property . "add")
(input (hour . 10) (minute . 0) (value . 3))
(expected . "10:03"))
((description . "add no minutes")
(property . "add")
(input (hour . 6) (minute . 41) (value . 0))
(expected . "06:41"))
((description . "add to next hour")
(property . "add")
(input (hour . 0) (minute . 45) (value . 40))
(expected . "01:25"))
((description . "add more than one hour")
(property . "add")
(input (hour . 10) (minute . 0) (value . 61))
(expected . "11:01"))
((description . "add more than two hours with carry")
(property . "add")
(input (hour . 0) (minute . 45) (value . 160))
(expected . "03:25"))
((description . "add across midnight")
(property . "add")
(input (hour . 23) (minute . 59) (value . 2))
(expected . "00:01"))
((description . "add more than one day (1500 min = 25 hrs)")
(property . "add")
(input (hour . 5) (minute . 32) (value . 1500))
(expected . "06:32"))
((description . "add more than two days")
(property . "add")
(input (hour . 1) (minute . 1) (value . 3500))
(expected . "11:21"))))
((description . "Subtract minutes")
(cases
((description . "subtract minutes")
(property . "subtract")
(input (hour . 10) (minute . 3) (value . 3))
(expected . "10:00"))
((description . "subtract to previous hour")
(property . "subtract")
(input (hour . 10) (minute . 3) (value . 30))
(expected . "09:33"))
((description . "subtract more than an hour")