Skip to content

Commit

Permalink
Fix tests for strain and other small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ingydotnet committed Oct 25, 2024
1 parent 80a3faa commit 6fa6d4f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
5 changes: 2 additions & 3 deletions exercises/practice/pangram/.meta/pangram.ys
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
!yamlscript/v0

defn is-pangram(sentence):
26 ==:
len: lc(sentence)
26 ==: lc(sentence)
.replace(/[^a-z]/)
.distinct()
.distinct():len
5 changes: 4 additions & 1 deletion exercises/practice/perfect-numbers/perfect-numbers-test.ys
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ test::
- name: Large perfect number is classified correctly
code: classify(33550336)
want: perfect
SKIP: true # SLOW

- name: Smallest abundant number is classified correctly
code: classify(12)
Expand All @@ -28,6 +29,7 @@ test::
- name: Large abundant number is classified correctly
code: classify(33550335)
want: abundant
SKIP: true # SLOW

- name: Smallest prime deficient number is classified correctly
code: classify(2)
Expand All @@ -44,6 +46,7 @@ test::
- name: Large deficient number is classified correctly
code: classify(33550337)
want: deficient
SKIP: true # SLOW

- name: Edge case (no factors other than itself) is classified correctly
code: classify(1)
Expand All @@ -59,4 +62,4 @@ test::
what: error
want: Classification is only possible for positive integers.

done: 13
done: 10 # 13
8 changes: 2 additions & 6 deletions exercises/practice/raindrops/.meta/raindrops.ys
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ defn convert(number):
ps =: M(3 'Pling' 5 'Plang' 7 'Plong')
words =:
mapcat _ [3 5 7]:
fn(n):
(number % n) == 0 &&&:
get ps: n
fn(n): number.rem(n).! &&& ps.$n

if words.?:
str(words*)
str(number)
if words.?: str(words*) str(number)
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ colors =:

defn value([c1 c2]):
colors.$c1 * 10 +: colors.$c2

28 changes: 14 additions & 14 deletions exercises/practice/strain/strain-test.ys
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ use: strain

test::
- name: Keep on empty list returns empty list
code: keep([] "fn([x] true)")
code: keep([] \(true))
want: []

- name: Keeps everything
code: keep([1 3 5] "fn(x):\ true")
code: keep([1 3 5] \(true))
want:
- 1
- 3
- 5

- name: Keeps nothing
code: keep([1 3 5] "fn(x):\ false")
code: keep([1 3 5] \(false))
want: []

- name: Keeps first and last
code: keep([1 2 3] "fn(x):\ (x % 2) == 1")
code: keep([1 2 3] \((_ % 2) == 1))
want:
- 1
- 3

- name: Keeps neither first nor last
code: keep([1 2 3] "fn(x):\ (x % 2) == 0")
code: keep([1 2 3] \((_ % 2) == 0))
want:
- 2

- name: Keeps strings
code: keep(
qw(apple zebra banana zombies cherimoya zealot)
"fn(x):\ starts?(x, 'z')")
\(starts?(_ 'z')))
want:
- zebra
- zombies
Expand All @@ -43,7 +43,7 @@ test::
- name: Keeps lists
code: keep(
[[1 2 3] [5 5 5] [5 1 2] [2 1 2] [1 5 2] [2 2 1] [1 2 5]]
"fn(x):\ has?(x, 5)")
\(has?(_ 5)))
want:
- - 5
- 5
Expand All @@ -59,35 +59,35 @@ test::
- 5

- name: Discard on empty list returns empty list
code: discard([] "fn(x):\ true")
code: discard([] \(true))
want: []

- name: Discards everything
code: discard([1 3 5] "fn(x):\ true")
code: discard([1 3 5] \(true))
want: []

- name: Discards nothing
code: discard([1 3 5] "fn(x):\ false")
code: discard([1 3 5] \(false))
want:
- 1
- 3
- 5

- name: Discards first and last
code: discard([1 2 3] "fn(x):\ (x % 2) == 1")
code: discard([1 2 3] \((_ % 2) == 1))
want:
- 2

- name: Discards neither first nor last
code: discard([1 2 3] "fn(x):\ (x % 2) == 0")
code: discard([1 2 3] \((_ % 2) == 0))
want:
- 1
- 3

- name: Discards strings
code: discard(
qw(apple zebra banana zombies cherimoya zealot)
"fn(x):\ starts?(x, 'z')")
\(starts?(_ 'z')))
want:
- apple
- banana
Expand All @@ -96,7 +96,7 @@ test::
- name: Discards lists
code: discard(
[[1 2 3] [5 5 5] [5 1 2] [2 1 2] [1 5 2] [2 2 1] [1 2 5]]
"fn(x):\ has?(x, 5)")
\(has?(_ 5)))
want:
- - 1
- 2
Expand Down

0 comments on commit 6fa6d4f

Please sign in to comment.