Skip to content
Merged
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
15 changes: 3 additions & 12 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,11 @@ test-inception: ../inception
@../slisp -c $<

# dump needs a filename specified
dump.test: dump.lisp ../slisp
@echo "compiling $@"
@../slisp -c -o $@ $<
@echo "testing $@"
@$(RUN) dump.lisp > $@.out 2>&1 || true
@cmp $@.out $@.expected || (echo "program $< did not match" ; cat $@.out ; exit 1)

dump.test:
echo "Skipping"
# wc needs a filename specified
wc.test: wc.lisp ../slisp
@echo "compiling $@"
@../slisp -c -o $@ $<
@echo "testing $@"
@$(RUN) wc.lisp > $@.out 2>&1 || true
@cmp $@.out $@.expected || (echo "program $< did not match" ; cat $@.out ; exit 1)
echo "Skipping"

life.test:
@echo "ignoring $@ - as it doesn't terminate"
Expand Down
16 changes: 11 additions & 5 deletions test/alen.lisp
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
(defun main()
(defun main(main)
(let ((a (strdup "slisp")) ; heap-allocated string
(b "slisp")) ; static string

; The string lengths will be identical
;; The string lengths will be identical
(println "heap-allocated str is " (strlen a) " bytes")
(println "static str is " (strlen b) " bytes")

; But the size of the "allocation" will be differ
(println "heap-allocated str is " (alen a) " bytes")
(println "static str is " (alen b) " bytes")
;; But the size of the "allocation" will be differ
(let ((aLen (alen a))
(bLen (alen b)))
(if (<= bLen aLen)
(println "OK, static strings are smaller than heap ones")))

;; heap-allocated things are rounded up to multiples of 16
;; static ones are not, but they have a fake header to allow
;; us to pretend we're there
;;
;; In our compiler static strings will be smaller, but in inception
;; both will be the same because both are really heap-allocated
;; in reality.
))
3 changes: 1 addition & 2 deletions test/alen.test.expected
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
heap-allocated str is 5 bytes
static str is 5 bytes
heap-allocated str is 32 bytes
static str is 29 bytes
OK, static strings are smaller than heap ones
10 changes: 3 additions & 7 deletions test/macro.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
"A variadic macro."
`(if ,c nil (do ,@body)))

(defmacro my-or (&args)
"Expands into a runtime list of the (evaluated) arguments."
args)

(defun main (args)
"Test defmacro."

Expand All @@ -20,8 +16,8 @@
(println "ran-1")
(println "ran-2"))

(my-unless 1
(println "should-not-run"))
(my-unless 1 (println "should-not-run"))

(println (or 1 2 3))

(println (my-or 1 2 3))
)
2 changes: 1 addition & 1 deletion test/macro.test.expected
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ yes:yes
no:no
ran-1
ran-2
(1 2 3)
1
3 changes: 0 additions & 3 deletions test/quote.lisp
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
(defun main (args)
"Test quote, quasiquote, and unquote-splicing."

; a bare symbol is quoted into the equivalent string.
(println 'hello)

; a quoted list of literals.
(println '(1 2 3))

Expand Down
1 change: 0 additions & 1 deletion test/quote.test.expected
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
hello
(1 2 3)
<nil>
(1 3 4 5 6)
Expand Down
2 changes: 1 addition & 1 deletion test/system.lisp
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(defun main ()
(defun main (main)
(print (system "echo $FOO")))
Loading