aboutsummaryrefslogtreecommitdiff
path: root/challenge-081/tyler-wardhaugh/lua/test.lua
diff options
context:
space:
mode:
authorTyler Wardhaugh <tyler.wardhaugh@gmail.com>2020-10-10 22:58:01 -0700
committerTyler Wardhaugh <tyler.wardhaugh@gmail.com>2020-10-10 23:06:08 -0700
commitafec5a7e05a9960b1f60be44a77fda8f771c9504 (patch)
tree3fafe080fa150259349558c92e08bf57fc51332e /challenge-081/tyler-wardhaugh/lua/test.lua
parentf5e4a7bc97c2642cf5cc3650a062c37bb8b4dbc7 (diff)
downloadperlweeklychallenge-club-afec5a7e05a9960b1f60be44a77fda8f771c9504.tar.gz
perlweeklychallenge-club-afec5a7e05a9960b1f60be44a77fda8f771c9504.tar.bz2
perlweeklychallenge-club-afec5a7e05a9960b1f60be44a77fda8f771c9504.zip
Ch81 [Lua]: Tasks 1 & 2
I used LPeg for both of these solutions, which is surely overkill. But I wanted to experiment with it.
Diffstat (limited to 'challenge-081/tyler-wardhaugh/lua/test.lua')
-rwxr-xr-xchallenge-081/tyler-wardhaugh/lua/test.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-081/tyler-wardhaugh/lua/test.lua b/challenge-081/tyler-wardhaugh/lua/test.lua
new file mode 100755
index 0000000000..0874b984cc
--- /dev/null
+++ b/challenge-081/tyler-wardhaugh/lua/test.lua
@@ -0,0 +1,25 @@
+#!/usr/bin/env lua
+
+require 'busted.runner'()
+
+describe("Task 1, Common Base String", function()
+ local t1 = require'ch-1'
+ it("produces correct results for the examples", function()
+ assert.are.same(t1.common_base_string("abcdabcd", "abcdabcdabcdabcd"), {"abcdabcd", "abcd"})
+ assert.are.same(t1.common_base_string("aaa", "aa"), {"a"})
+ end)
+end)
+
+describe("Task 2, Frequency Sort", function()
+ local t2 = require'ch-2'
+ it("produces correct results for the examples", function()
+ local expected = {
+ [1]={"But", "City", "It", "Jet", "Juliet", "Latino", "New", "Romeo", "Side", "Story", "Their", "Then", "West", "York", "adaptation", "any", "anything", "at", "award-winning", "away", "become", "before", "begin", "best", "classic", "climactic", "coexist", "control", "dance", "do", "doesn't", "end", "ending", "escalates", "families", "feuding", "form", "former", "friend", "gains", "gangs", "goes", "happened", "hatred", "heartbreaking", "highway", "hoping", "in", "know", "love", "lovers", "meet", "meeting", "neither", "no", "one", "plan", "planning", "point", "romantic", "rumble", "run", "secret", "sends", "sister", "streets", "strikes", "terribly", "their", "two", "under", "understanding", "until", "violence", "warring", "what", "when", "where", "white", "whoever", "wins", "with", "wrong", "younger"},
+ [2]={"Bernardo", "Jets", "Riff", "Sharks", "The", "by", "it", "led", "tragedy"},
+ [3]={"Maria", "Tony", "a", "can", "of", "stop"},
+ [4]={"to"},
+ [9]={"and", "the"}
+ }
+ assert.are.same(t2.frequency_sort(t2.slurp("resources/input")), expected)
+ end)
+end)