Skip to content

Commit 369dfb1

Browse files
committed
Merge branch 'develop' with new tests
2 parents 0138919 + 1d0de5e commit 369dfb1

24 files changed

Lines changed: 1207 additions & 619 deletions

.github/workflows/cicd.yml

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
strategy:
4848
fail-fast: false
4949
matrix:
50-
otp-version: ['27', '26', '25', '24', '23', '22']
50+
otp-version: ['28', '27', '26', '25', '24', '23', '22']
5151
os: ['ubuntu-24.04']
5252

5353
container:
@@ -61,57 +61,3 @@ jobs:
6161
run: make compile
6262
- name: Install
6363
run: make install PREFIX=$(mktemp -d)
64-
65-
66-
older-builds:
67-
name: Erlang ${{ matrix.otp-version }} / ${{ matrix.os }} (build)
68-
runs-on: ubuntu-20.04
69-
70-
strategy:
71-
fail-fast: false
72-
matrix:
73-
#otp-version: ['21', '20', '19']
74-
otp-version: ['21', '20']
75-
os: ['ubuntu-20.04']
76-
77-
container:
78-
image: erlang:${{ matrix.otp-version }}
79-
80-
steps:
81-
- uses: actions/checkout@v4
82-
- name: Erlang version check
83-
run: erl -noshell -eval 'erlang:display(erlang:system_info(system_version))' -eval 'init:stop()'
84-
- name: Rebar version check
85-
run: rebar3 -v
86-
- name: Compile (with rebar3)
87-
run: rebar3 compile
88-
- name: Run eunit Tests
89-
run: make eunit
90-
- name: Run proper Tests
91-
run: make proper
92-
- name: CT Suite Tests
93-
run: make ct
94-
95-
older-installs:
96-
name: Erlang ${{ matrix.otp-version }} / ${{ matrix.os }} (install)
97-
needs: older-builds
98-
runs-on: ubuntu-20.04
99-
100-
strategy:
101-
fail-fast: false
102-
matrix:
103-
#otp-version: ['21', '20', '19']
104-
otp-version: ['21', '20']
105-
os: ['ubuntu-20.04']
106-
107-
container:
108-
image: erlang:${{ matrix.otp-version }}
109-
110-
steps:
111-
- uses: actions/checkout@v4
112-
- name: Erlang version check
113-
run: erl -noshell -eval 'erlang:display(erlang:system_info(system_version))' -eval 'init:stop()'
114-
- name: Compile (with make)
115-
run: make compile
116-
- name: Install
117-
run: make install PREFIX=$(mktemp -d)

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ CFLAGS ?= -Wall -Wextra
2828
ifeq ($(OS_NAME),linux)
2929
LDFLAGS ?= -Wl,--as-needed
3030
endif
31-
PREFIX ?= /usr/local
31+
DESTDIR ?= /usr/local
32+
PREFIX ?= $(DESTDIR)
3233
INSTALL = install
3334
INSTALL_DIR = $(INSTALL) -m755 -d
3435
INSTALL_DATA = $(INSTALL) -m644
3536
INSTALL_BIN = $(INSTALL) -m755
36-
DESTLIBDIR := $(PREFIX)/lib/lfe
37+
DESTLIBDIR := $(DESTDIR)/lib/lfe
3738
DESTINCDIR := $(DESTLIBDIR)/$(INCDIR)
3839
DESTEBINDIR := $(DESTLIBDIR)/$(EBINDIR)
3940
DESTBINDIR := $(DESTLIBDIR)/$(BINDIR)
@@ -151,7 +152,7 @@ install-bin:
151152
ln -sf $(DESTBINDIR)/* $(PREFIX)/bin/
152153

153154
clean:
154-
rm -rf $(EBINDIR)/*.beam erl_crash.dump comp_opts.mk
155+
rm -rf $(EBINDIR)/*.beam erl_crash.dump comp_opts.mk test/*.beam
155156

156157
clean-all: clean
157158
rm -rf _build
@@ -195,7 +196,7 @@ common-test:
195196

196197
ct: common-test
197198

198-
tests:
199+
tests: clean
199200
@rebar3 as test do compile,eunit,eunit,proper -n 20, ct
200201

201202
#####################

examples/church.lfe

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
;; 5
3838
;; lfe> (church->int2 (lambda () (get-church 25)))
3939
;; 25
40-
4140
(defmodule church
4241
(export all))
4342

examples/core-macros.lfe

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,22 @@
3131
;;
3232
;; lfe> (include-file "examples/core-macros.lfe")
3333
;; ()
34-
;; lfe> (:: init get_status)
34+
;; lfe> (:: init get_status)
3535
;; #(started started)
3636

37+
(defmodule core-macros
38+
"LFE core macros as they could have been implemented in LFE."
39+
;; List accessor macros
40+
(export-macro caar cadr cdar cddr)
41+
;; List and function macros
42+
(export-macro ++ : ? list*)
43+
;; Binding macros
44+
(export-macro let* flet*)
45+
;; Conditional macros
46+
(export-macro cond andalso orelse)
47+
;; Backquote macro
48+
(export-macro backquote))
49+
3750
(defmacro caar (x) `(car (car ,x)))
3851
(defmacro cadr (x) `(car (cdr ,x)))
3952
(defmacro cdar (x) `(cdr (car ,x)))
Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
;; See the License for the specific language governing permissions and
1313
;; limitations under the License.
1414

15-
;; File : ets_demo.lfe
15+
;; File : ets-demo.lfe
1616
;; Author : Robert Virding
1717
;; Purpose : A simple ETS demo file for LFE.
1818

@@ -22,64 +22,64 @@
2222
;; ets:select.
2323

2424
;; Here is some example usage:
25-
;;
25+
;;
2626
;; $ ./bin/lfe
2727
;;
28-
;; lfe> (c "examples/ets_demo.lfe")
29-
;; (#(module ets_demo))
30-
;; lfe> (set db (ets_demo:new))
28+
;; lfe> (c "examples/ets-demo.lfe")
29+
;; (#(module ets-demo))
30+
;; lfe> (set db (ets-demo:new))
3131
;; #Ref<0.2772763705.1333133315.72774>
32-
;; lfe> (ets_demo:by_place db 'london)
32+
;; lfe> (ets-demo:by_place db 'london)
3333
;; #(((paul driver) (fred waiter) (john painter) (bert waiter))
3434
;; (#(person paul london driver)
3535
;; #(person fred london waiter)
3636
;; #(person john london painter)
3737
;; #(person bert london waiter)))
3838

39-
(defmodule ets_demo
40-
(export
41-
(new 0)
42-
(by_place 2)
43-
(by_place_ms 2)
44-
(not_painter 2)))
39+
(defmodule ets-demo
40+
(export
41+
(new 0)
42+
(by_place 2)
43+
(by_place_ms 2)
44+
(not_painter 2)))
4545

4646
;; Define a simple person record to work on.
4747
(defrecord person name place job)
4848

4949
;; Create an initialse the ets table.
5050
(defun new ()
51-
(let ((db (ets:new 'ets_demo '(#(keypos 2) set))))
52-
(let ((people '(
53-
;; First some people in London.
54-
#(fred london waiter)
55-
#(bert london waiter)
56-
#(john london painter)
57-
#(paul london driver)
58-
;; Now some in Paris.
59-
#(jean paris waiter)
60-
#(gerard paris driver)
61-
#(claude paris painter)
62-
#(yves paris waiter)
63-
;; And some in Rome.
64-
#(roberto rome waiter)
65-
#(guiseppe rome driver)
66-
#(paulo rome painter)
67-
;; And some in Berlin.
68-
#(fritz berlin painter)
69-
#(kurt berlin driver)
70-
#(hans berlin waiter)
71-
#(franz berlin waiter))))
72-
(lists:foreach
73-
(match-lambda
74-
([(tuple n p j)]
75-
(ets:insert db (make-person name n place p job j))))
76-
people))
51+
(let ((db (ets:new 'ets-demo '(#(keypos 2) set))))
52+
(let ((people
53+
'(;; First some people in London.
54+
#(fred london waiter)
55+
#(bert london waiter)
56+
#(john london painter)
57+
#(paul london driver)
58+
;; Now some in Paris.
59+
#(jean paris waiter)
60+
#(gerard paris driver)
61+
#(claude paris painter)
62+
#(yves paris waiter)
63+
;; And some in Rome.
64+
#(roberto rome waiter)
65+
#(guiseppe rome driver)
66+
#(paulo rome painter)
67+
;; And some in Berlin.
68+
#(fritz berlin painter)
69+
#(kurt berlin driver)
70+
#(hans berlin waiter)
71+
#(franz berlin waiter))))
72+
(lists:foreach
73+
(match-lambda
74+
([(tuple n p j)]
75+
(ets:insert db (make-person name n place p job j))))
76+
people))
7777
db)) ;; Return the table
7878

79-
;; Match records by place using match, match_object and the emp-XXXX macro.
79+
;; Match records by place using match and match_object.
8080
(defun by_place (db place)
81-
(let ((s1 (ets:match db (emp-person name '$1 place place job '$2)))
82-
(s2 (ets:match_object db (emp-person place place))))
81+
(let ((s1 (ets:match db (match-person name '$1 place place job '$2)))
82+
(s2 (ets:match_object db (match-person name '_ place place job '_))))
8383
(tuple s1 s2)))
8484

8585
;; Use match specifications to match records

examples/fizzbuzz.lfe

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141

4242
(defmodule fizzbuzz
4343
(export
44-
(buzz 1)
45-
(buzz1 1)
46-
(buzz2 1)
47-
(buzz3 1)))
44+
(buzz 1)
45+
(buzz1 1)
46+
(buzz2 1)
47+
(buzz3 1)))
4848

4949
(defun get-fizz (n)
5050
;; Request a FizzBuzz result for a given number.
@@ -64,10 +64,10 @@
6464
;; This is the basic version, takes an argument
6565
;; and attempts to create result list of results.
6666
(lists:map
67-
;; Wrap our call to 'get-fizz in a lambda
68-
(lambda (x) (get-fizz x))
69-
;; Create a list of numbers from one to n
70-
(lists:seq 1 n)))
67+
;; Wrap our call to 'get-fizz in a lambda
68+
(lambda (x) (get-fizz x))
69+
;; Create a list of numbers from one to n
70+
(lists:seq 1 n)))
7171

7272
(defun buzz1
7373
;; This version utilises pattern matching and guard to

examples/gps1.lfe

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
;; lfe> (gps '(son-at-home) '(son-at-home) (school-ops))
4949
;; solved
5050
;;
51-
5251
(include-lib "lfe/include/scm.lfe")
5352

5453
;; Define macros for global variable access. This is a hack and very naughty!
@@ -64,19 +63,19 @@
6463
;; Module definition.
6564
(defmodule gps1
6665
(export
67-
(gps 2)
68-
(gps 3)
69-
(school-ops 0))
66+
(gps 2)
67+
(gps 3)
68+
(school-ops 0))
7069
(import
71-
(from lists
72-
(member 2)
73-
(all 2)
74-
(any 2))
75-
;; Rename lists functions to be more CL like.
76-
(rename lists
77-
((all 2) every)
78-
((any 2) some)
79-
((filter 2) find-all))))
70+
(from lists
71+
(member 2)
72+
(all 2)
73+
(any 2))
74+
;; Rename lists functions to be more CL like.
75+
(rename lists
76+
((all 2) every)
77+
((any 2) some)
78+
((filter 2) find-all))))
8079

8180
;; An operation.
8281
(defrecord op
@@ -98,9 +97,9 @@
9897
;; appropriate op for it that is applicable."
9998
(defun achieve (goal)
10099
(orelse (member goal (getvar *state*))
101-
(some (fun apply-op 1)
102-
(find-all (lambda (op) (appropriate-p goal op))
103-
(getvar *ops*)))))
100+
(some (fun apply-op 1)
101+
(find-all (lambda (op) (appropriate-p goal op))
102+
(getvar *ops*)))))
104103

105104
;; An op is appropriate to a goal if it is in its add list.
106105
(defun appropriate-p (goal op)
@@ -131,27 +130,27 @@
131130
;; Define a list of operations to use with GPS.
132131
(defun school-ops ()
133132
(list
134-
(make-op action 'drive-son-to-school
135-
preconds '(son-at-home car-works)
136-
add-list '(son-at-school)
137-
del-list '(son-at-home))
138-
(make-op action 'shop-installs-battery
139-
preconds '(car-needs-battery shop-knows-problem shop-has-money)
140-
add-list '(car-works)
141-
del-list ())
142-
(make-op action 'tell-shop-problem
143-
preconds '(in-communication-with-shop)
144-
add-list '(shop-knows-problem)
145-
del-list ())
146-
(make-op action 'telephone-shop
147-
preconds '(know-phone-number)
148-
add-list '(in-communication-with-shop)
149-
del-list ())
150-
(make-op action 'look-up-number
151-
preconds '(have-phone-book)
152-
add-list '(know-phone-number)
153-
del-list ())
154-
(make-op action 'give-shop-money
155-
preconds '(have-money)
156-
add-list '(shop-has-money)
157-
del-list '(have-money))))
133+
(make-op action 'drive-son-to-school
134+
preconds '(son-at-home car-works)
135+
add-list '(son-at-school)
136+
del-list '(son-at-home))
137+
(make-op action 'shop-installs-battery
138+
preconds '(car-needs-battery shop-knows-problem shop-has-money)
139+
add-list '(car-works)
140+
del-list ())
141+
(make-op action 'tell-shop-problem
142+
preconds '(in-communication-with-shop)
143+
add-list '(shop-knows-problem)
144+
del-list ())
145+
(make-op action 'telephone-shop
146+
preconds '(know-phone-number)
147+
add-list '(in-communication-with-shop)
148+
del-list ())
149+
(make-op action 'look-up-number
150+
preconds '(have-phone-book)
151+
add-list '(know-phone-number)
152+
del-list ())
153+
(make-op action 'give-shop-money
154+
preconds '(have-money)
155+
add-list '(shop-has-money)
156+
del-list '(have-money))))

0 commit comments

Comments
 (0)