diff --git a/.travis.yml b/.travis.yml index d9ab35ad..38f0ae90 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,7 +53,10 @@ matrix: - {env: IMPL=logo NO_SELF_HOST=1, services: [docker]} # step4 timeout - {env: IMPL=lua, services: [docker]} - {env: IMPL=make NO_SELF_HOST=1, services: [docker]} # step4 timeout - - {env: IMPL=mal BUILD_IMPL=js NO_SELF_HOST=1, services: [docker]} + - {env: IMPL=mal MAL_IMPL=js BUILD_IMPL=js NO_SELF_HOST=1, services: [docker]} + - {env: IMPL=mal MAL_IMPL=js-mal BUILD_IMPL=js NO_SELF_HOST=1, services: [docker]} + - {env: IMPL=mal MAL_IMPL=nim BUILD_IMPL=nim NO_SELF_HOST=1, services: [docker]} + - {env: IMPL=mal MAL_IMPL=nim-mal BUILD_IMPL=nim NO_SELF_HOST=1, services: [docker]} - {env: IMPL=matlab NO_SELF_HOST_PERF=1, services: [docker]} # Octave, perf timeout - {env: IMPL=miniMAL NO_SELF_HOST_PERF=1, services: [docker]} # perf timeout - {env: IMPL=nasm NO_SELF_HOST_PERF=1, services: [docker]} # perf OOM diff --git a/.travis_test.sh b/.travis_test.sh index c41cf6b6..2c063fa0 100755 --- a/.travis_test.sh +++ b/.travis_test.sh @@ -44,7 +44,7 @@ if [ -z "${NO_DOCKER}" ]; then img_impl=$(echo "${MAL_IMPL:-${IMPL}}" | tr '[:upper:]' '[:lower:]') # We could just use make DOCKERIZE=1 instead but that does add # non-trivial startup overhead for each step. - MAKE="docker run -it -u $(id -u) -v `pwd`:/mal kanaka/mal-test-${img_impl} ${MAKE}" + MAKE="docker run -it -u $(id -u) -v `pwd`:/mal kanaka/mal-test-${img_impl%%-mal} ${MAKE}" fi case "${ACTION}" in diff --git a/Makefile b/Makefile index cdbaa7c3..44e1ad8f 100644 --- a/Makefile +++ b/Makefile @@ -291,7 +291,7 @@ STEP_TEST_FILES = $(strip $(wildcard \ lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1)))))))))))))))))))))))))) impl_to_image = kanaka/mal-test-$(call lc,$(1)) -actual_impl = $(if $(filter mal,$(1)),$(MAL_IMPL),$(1)) +actual_impl = $(if $(filter mal,$(1)),$(patsubst %-mal,%,$(MAL_IMPL)),$(1)) # Takes impl # Returns nothing if DOCKERIZE is not set, otherwise returns the @@ -400,7 +400,7 @@ $(foreach i,$(DO_IMPLS),$(foreach s,$(STEPS),build^$(i)^$(s))): $$(call $$(word $(ALL_TESTS): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(subst ^, ,$$(@)))) @$(foreach impl,$(word 2,$(subst ^, ,$(@))),\ $(foreach step,$(word 3,$(subst ^, ,$(@))),\ - cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)) && \ + cd $(call actual_impl,$(impl)) && \ $(foreach test,$(call STEP_TEST_FILES,$(impl),$(step)),\ echo '----------------------------------------------' && \ echo 'Testing $@; step file: $+, test file: $(test)' && \ @@ -455,7 +455,7 @@ perf: $(IMPL_PERF) $(IMPL_PERF): @echo "----------------------------------------------"; \ $(foreach impl,$(word 2,$(subst ^, ,$(@))),\ - cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \ + cd $(call actual_impl,$(impl)); \ echo "Performance test for $(impl):"; \ echo 'Running: $(call get_run_prefix,$(impl),stepA) ../$(impl)/run ../tests/perf1.mal'; \ $(call get_run_prefix,$(impl),stepA) ../$(impl)/run ../tests/perf1.mal; \ @@ -472,7 +472,7 @@ $(IMPL_PERF): $(ALL_REPL): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(subst ^, ,$$(@)))) @$(foreach impl,$(word 2,$(subst ^, ,$(@))),\ $(foreach step,$(word 3,$(subst ^, ,$(@))),\ - cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \ + cd $(call actual_impl,$(impl)); \ echo 'REPL implementation $(impl), step file: $+'; \ echo 'Running: $(call get_run_prefix,$(impl),$(step)) ../$(impl)/run $(RUN_ARGS)'; \ $(call get_run_prefix,$(impl),$(step)) ../$(impl)/run $(RUN_ARGS);)) diff --git a/mal/core.mal b/mal/core.mal index 5137f502..b7200bff 100644 --- a/mal/core.mal +++ b/mal/core.mal @@ -1,8 +1,3 @@ -(def! _map? (fn* [x] - (if (map? x) - (not (contains? x :__MAL_MACRO__)) - false))) - (def! _macro? (fn* [x] (if (map? x) (contains? x :__MAL_MACRO__) @@ -45,7 +40,7 @@ ['vector vector] ['vector? vector?] ['hash-map hash-map] - ['map? _map?] + ['map? map?] ['assoc assoc] ['dissoc dissoc] ['get get] diff --git a/mal/run b/mal/run index 32be705a..119ef194 100755 --- a/mal/run +++ b/mal/run @@ -1,4 +1,9 @@ #!/bin/bash MAL_FILE=../mal/${STEP:-stepA_mal}.mal export STEP=stepA_mal # force MAL_IMPL to use stepA +case ${MAL_IMPL} in +*-mal) + MAL_IMPL=${MAL_IMPL%%-mal} + MAL_FILE="../mal/stepA_mal.mal ${MAL_FILE}" ;; +esac exec ./../${MAL_IMPL:-js}/run ${MAL_FILE} "${@}" diff --git a/mal/step8_macros.mal b/mal/step8_macros.mal index d109f06f..36871c18 100644 --- a/mal/step8_macros.mal +++ b/mal/step8_macros.mal @@ -48,10 +48,10 @@ (vector? ast) (apply vector (map (fn* [exp] (EVAL exp env)) ast)) - (_map? ast) (apply hash-map - (apply concat - (map (fn* [k] [k (EVAL (get ast k) env)]) - (keys ast)))) + (map? ast) (apply hash-map + (apply concat + (map (fn* [k] [k (EVAL (get ast k) env)]) + (keys ast)))) "else" ast))) @@ -87,7 +87,8 @@ (EVAL (QUASIQUOTE (nth ast 1)) env) (= 'defmacro! a0) - (env-set env (nth ast 1) {:__MAL_MACRO__ (EVAL (nth ast 2) env)}) + (env-set env (nth ast 1) (hash-map :__MAL_MACRO__ + (EVAL (nth ast 2) env))) (= 'macroexpand a0) (MACROEXPAND (nth ast 1) env) diff --git a/mal/step9_try.mal b/mal/step9_try.mal index 89d697af..76abf84e 100644 --- a/mal/step9_try.mal +++ b/mal/step9_try.mal @@ -48,10 +48,10 @@ (vector? ast) (apply vector (map (fn* [exp] (EVAL exp env)) ast)) - (_map? ast) (apply hash-map - (apply concat - (map (fn* [k] [k (EVAL (get ast k) env)]) - (keys ast)))) + (map? ast) (apply hash-map + (apply concat + (map (fn* [k] [k (EVAL (get ast k) env)]) + (keys ast)))) "else" ast))) @@ -87,7 +87,8 @@ (EVAL (QUASIQUOTE (nth ast 1)) env) (= 'defmacro! a0) - (env-set env (nth ast 1) {:__MAL_MACRO__ (EVAL (nth ast 2) env)}) + (env-set env (nth ast 1) (hash-map :__MAL_MACRO__ + (EVAL (nth ast 2) env))) (= 'macroexpand a0) (MACROEXPAND (nth ast 1) env) diff --git a/mal/stepA_mal.mal b/mal/stepA_mal.mal index 35db404c..294046e6 100644 --- a/mal/stepA_mal.mal +++ b/mal/stepA_mal.mal @@ -48,10 +48,10 @@ (vector? ast) (apply vector (map (fn* [exp] (EVAL exp env)) ast)) - (_map? ast) (apply hash-map - (apply concat - (map (fn* [k] [k (EVAL (get ast k) env)]) - (keys ast)))) + (map? ast) (apply hash-map + (apply concat + (map (fn* [k] [k (EVAL (get ast k) env)]) + (keys ast)))) "else" ast))) @@ -87,7 +87,8 @@ (EVAL (QUASIQUOTE (nth ast 1)) env) (= 'defmacro! a0) - (env-set env (nth ast 1) {:__MAL_MACRO__ (EVAL (nth ast 2) env)}) + (env-set env (nth ast 1) (hash-map :__MAL_MACRO__ + (EVAL (nth ast 2) env))) (= 'macroexpand a0) (MACROEXPAND (nth ast 1) env) diff --git a/tests/step9_try.mal b/tests/step9_try.mal index ce6c9e17..d231b7fc 100644 --- a/tests/step9_try.mal +++ b/tests/step9_try.mal @@ -372,9 +372,6 @@ (= [] {}) ;=>false -(map? cond) -;=>false - (keyword :abc) ;=>:abc (keyword? (first (keys {":abc" 123 ":def" 456})))