Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Acronym practice exercise #187

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions exercises/practice/acronym/.gitignore
kephas marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## -*- conf -*-
.rebar3
.docs/
.meta/
_build/
ebin/
erl_crash.dump
rebar3.crashdump

tmp
bin/configlet
bin/configlet.exe
CHECKLIST
21 changes: 21 additions & 0 deletions exercises/practice/acronym/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ERL := $(shell which erl)
REBAR3 := $(shell which rebar3)

null :=
space := $(null) #
comma := ,

ifeq ($(ERL),)
$(error Can't find Erlang executable 'erl')
else ifeq ($(REBAR3),)
$(error Can't find rebar3)
endif

compile: ; $(REBAR3) compile

clean: ; $(REBAR3) clean

.PHONY: test
test:
$(REBAR3) eunit \
-m $(subst $(space),$(comma),$(basename $(notdir $(wildcard test/*.lfe))))
11 changes: 11 additions & 0 deletions exercises/practice/acronym/rebar.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{plugins, [{rebar3_lfe, "0.4.3"}]}.

{provider_hooks, [{post, [{compile, {lfe, compile}}]}]}.

{deps, [{lfe, "2.1.1"}]}.

{profiles,
[{test,
[{eunit_compile_opts, [{src_dirs, ["src", "test"]}]},
{deps,
[{ltest, "0.13.3"}]}]}]}.
8 changes: 8 additions & 0 deletions exercises/practice/acronym/rebar.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{"1.2.0",
[{<<"lfe">>,{pkg,<<"lfe">>,<<"2.1.1">>},0}]}.
[
{pkg_hash,[
{<<"lfe">>, <<"4A888B26172D198DC7A5AFEB897E8248AF7D56E1638D9C8249AAF933AE811B96">>}]},
{pkg_hash_ext,[
{<<"lfe">>, <<"C484D3B655D40DED58BC41B17B22F173711C681BF36063A234A9BAA9506947E1">>}]}
].
11 changes: 11 additions & 0 deletions exercises/practice/acronym/src/acronym.app.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
%% -*- erlang -*-
{application, 'acronym',
[{description, ""},
{vsn, "0.0.1"},
{modules,
['acronym']},
{registered, []},
{applications,
[kernel, stdlib]},
{included_applications, []},
{env, []}]}.
5 changes: 5 additions & 0 deletions exercises/practice/acronym/src/acronym.lfe
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(defmodule acronym
(export (abbreviate 1)))

(defun abbreviate (str)
(throw "You need to implement abbreviate"))
kephas marked this conversation as resolved.
Show resolved Hide resolved
26 changes: 26 additions & 0 deletions exercises/practice/acronym/test/acronym-tests.lfe
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(defmodule acronym-tests
(behaviour ltest-unit)
(export all))

(include-lib "ltest/include/ltest-macros.lfe")

(deftest no-allergies-at-all (is-equal () (allergies:allergies 0)))
kephas marked this conversation as resolved.
Show resolved Hide resolved

(defun acronyms_test_ ()
(lists:map #'make-test/1 (cases)))

(defun make-test
(((tuple description input expected))
(tuple description (lambda () (is-equal expected (acronym:abbreviate input))))))

(defun cases ()
(list
(tuple "basic" "Portable Network Graphics" "PNG")
(tuple "lowercase words" "Ruby on Rails" "ROR")
(tuple "punctuation" "First In, First Out" "FIFO")
(tuple "all caps word" "GNU Image Manipulation Program" "GIMP")
(tuple "punctuation without whitespace" "Complementary metal-oxide semiconductor" "CMOS")
(tuple "very long abbreviation" "Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me" "ROTFLSHTMDCOALM")
(tuple "consecutive delimiters" "Something - I made up from thin air" "SIMUFTA")
(tuple "apostrophes" "Halley's Comet" "HC")
(tuple "underscore emphasis" "The Road _Not_ Taken" "TRNT")))