tests: non alphanumeric characters in input
authorNicolas Boulenguez <nicolas.boulenguez@free.fr>
Sun, 23 Jun 2019 15:03:20 +0000 (17:03 +0200)
committerNicolas Boulenguez <nicolas.boulenguez@free.fr>
Wed, 17 Jul 2019 22:01:14 +0000 (00:01 +0200)
Make: remove part of EVAL breaking # and $

step0: no MAL character must break the interpreter
       (soft) no printable ASCII character either

step1: no MAL character must break strings
       (soft) no printable ASCII character should break strings
       (soft) no character should break comments

step6: redo step1 tests for comments inside read-string, as new
       problem may occur with line breaks and escape characters of the host
       language.

make/step0_repl.mk
tests/step0_repl.mal
tests/step1_read_print.mal
tests/step6_file.mal

index b8b1309..46b4756 100644 (file)
@@ -11,8 +11,7 @@ $(call READLINE)
 endef
 
 define EVAL
-$(if $(READLINE_EOF),,\
-  $(if $(findstring =,$(1)),$(eval $(1))$($(word 1,$(1))),$(eval __return := $(1))$(__return)))
+$(if $(READLINE_EOF),,$(1))
 endef
 
 define PRINT
index 2b83a01..4706a1a 100644 (file)
@@ -15,3 +15,52 @@ hello mal world
 hello world abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 (;:() []{}"'* ;:() []{}"'* ;:() []{}"'*)
 ;=>hello world abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 (;:() []{}"'* ;:() []{}"'* ;:() []{}"'*)
 
+;; Non alphanumeric characters
+!
+;=>!
+&
+;=>&
++
+;=>+
+,
+;=>,
+-
+;=>-
+/
+;=>/
+<
+;=><
+=
+;=>=
+>
+;=>>
+?
+;=>?
+@
+;=>@
+;;; Behaviour of backslash is not specified enough to test anything in step0.
+^
+;=>^
+_
+;=>_
+`
+;=>`
+~
+;=>~
+
+;>>> soft=True
+;>>> optional=True
+;; ------- Optional Functionality --------------
+;; ------- (Not needed for self-hosting) -------
+
+;; Non alphanumeric characters
+#
+;=>#
+$
+;=>$
+%
+;=>%
+.
+;=>.
+|
+;=>|
index 1a3bcf7..913a412 100644 (file)
@@ -80,10 +80,54 @@ false
 ;=>"abc (with parens)"
 "abc\"def"
 ;=>"abc\"def"
-;;;"abc\ndef"
-;;;;=>"abc\ndef"
 ""
 ;=>""
+"&"
+;=>"&"
+"'"
+;=>"'"
+"("
+;=>"("
+")"
+;=>")"
+"*"
+;=>"*"
+"+"
+;=>"+"
+","
+;=>","
+"-"
+;=>"-"
+":"
+;=>":"
+";"
+;=>";"
+"<"
+;=>"<"
+"="
+;=>"="
+">"
+;=>">"
+"?"
+;=>"?"
+"@"
+;=>"@"
+"["
+;=>"["
+"]"
+;=>"]"
+"^"
+;=>"^"
+"_"
+;=>"_"
+"`"
+;=>"`"
+"{"
+;=>"{"
+"}"
+;=>"}"
+"~"
+;=>"~"
 
 ;; Testing reader errors
 (1 2
@@ -183,3 +227,54 @@ false
 ;; Testing read of @/deref
 @a
 ;=>(deref a)
+
+;>>> soft=True
+
+;; Non alphanumerice characters in strings
+;;; \t is not specified enough to be tested
+"\n"
+;=>"\n"
+"#"
+;=>"#"
+"$"
+;=>"$"
+"%"
+;=>"%"
+"."
+;=>"."
+"\\"
+;=>"\\"
+"|"
+;=>"|"
+
+;; Non alphanumeric characters in comments
+1;!
+;=>1
+1;"
+;=>1
+1;#
+;=>1
+1;$
+;=>1
+1;%
+;=>1
+1;'
+;=>1
+1;\
+;=>1
+1;\\
+;=>1
+1;\\\
+;=>1
+1;`
+;=>1
+;;; Hopefully less problematic characters
+1; &()*+,-./:;<=>?@[]^_{|}~
+
+;; FIXME: These tests have no reasons to be optional, but...
+;; fantom fails this one
+"!"
+;=>"!"
+;; io fails this one
+"/"
+;=>"/"
index ec50397..17ba8d7 100644 (file)
@@ -145,3 +145,30 @@ mymap
 ;=>true
 *ARGV*
 ;=>()
+
+;>>> soft=True
+
+;; Non alphanumeric characters in comments in read-string
+(read-string "1;!")
+;=>1
+(read-string "1;\"")
+;=>1
+(read-string "1;#")
+;=>1
+(read-string "1;$")
+;=>1
+(read-string "1;%")
+;=>1
+(read-string "1;'")
+;=>1
+(read-string "1;\\")
+;=>1
+(read-string "1;\\\\")
+;=>1
+(read-string "1;\\\\\\")
+;=>1
+(read-string "1;`")
+;=>1
+;;; Hopefully less problematic characters can be checked together
+(read-string "1; &()*+,-./:;<=>?@[]^_{|}~")
+;=>1