Skip to content

Commit c1ccf46

Browse files
committed
Complete exercise 10.1.
1 parent 66dd3d9 commit c1ccf46

File tree

4 files changed

+51
-2
lines changed

4 files changed

+51
-2
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Solutions to the exercises in Joe Armstrong's book *Programming Erlang* 2nd Edit
1515
* Chapter 6 - [exercises 1 and 2 in the chapter_6 directory](chapter_6/)
1616
* Chapter 7 - [exercises 1, 2, 3, 4, and 5 in the chapter_7 directory](chapter_7/)
1717
* Chapter 8 - [exercises 1 and 2 in the chapter_8 directory](chapter_8/)
18-
* Chapter 9 - [WIP](chapter_9/)
19-
* Chapter 10 - WIP
18+
* Chapter 9 - [exercises 1, 2, 3, and 4 in the chapter_9 directory](chapter_9/)
19+
* Chapter 10 - [exercise 1 in the chapter_10 directory](chapter_10/)
2020
* Chapter 11 - no exercises
2121
* Chapter 12 - WIP
2222
* Chapter 13 - [WIP](chapter_13/)

chapter_10/exercise_1/Makefile

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.PHONY: tests
2+
3+
.SUFFIXES: .erl .beam .yrl
4+
5+
.erl.beam:
6+
erlc -W $<
7+
8+
.yrl.erl:
9+
erlc -W $<
10+
11+
ERL = erl -boot start_clean
12+
13+
MODS = sample_app
14+
15+
# List of all the test modules. test:start/0 is our entry point
16+
TEST_MODS = test
17+
18+
all: compile
19+
${ERL} -s sample_app start
20+
21+
compile: ${MODS:%=%.beam}
22+
23+
# Compile all the modules in the test directory, then run test:start/0, which
24+
# should start the tests
25+
tests: ${TEST_MODS:%=test/%.beam}
26+
${ERL} -s test start
27+
28+
clean:
29+
# Clean source
30+
rm -rf *.beam erl_crash.dump
31+
# Clean tests
32+
rm -rf test/*.beam

chapter_10/exercise_1/sample_app.erl

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-module(sample_app).
2+
3+
-export([start/0]).
4+
5+
start() ->
6+
% Dummy start function
7+
ok.

chapter_10/exercise_1/test/test.erl

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-module(test).
2+
3+
-export([start/0]).
4+
5+
start() ->
6+
io:format("Running tests...~n"),
7+
% Run tests here...
8+
io:format("Tests finished.~n"),
9+
init:stop(),
10+
ok.

0 commit comments

Comments
 (0)