From 748df6f7bdc08d1594a2a065ca0a581ba4806059 Mon Sep 17 00:00:00 2001 From: Dov Murik Date: Tue, 23 Jul 2019 10:21:27 +0300 Subject: [PATCH] io: Fix unneeded escaping of forward slash Instead of using Io's `asJson` method which escapes forward slashes, implement our own string escaping code so it fits the Mal requirements. The relevant step1 test was modified from soft to hard. --- io/MalTypes.io | 4 +++- tests/step1_read_print.mal | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/io/MalTypes.io b/io/MalTypes.io index afe0a750..a5b7c0c6 100644 --- a/io/MalTypes.io +++ b/io/MalTypes.io @@ -7,7 +7,9 @@ Number malPrint := method(readable, self asString) // Io strings are of type Sequence Sequence malPrint := method(readable, - if(readable, self asString asJson, self asString) + if(readable, + "\"" .. (self asString asMutable replaceSeq("\\", "\\\\") replaceSeq("\"", "\\\"") replaceSeq("\n", "\\n")) .. "\"", + self asString) ) MalMeta := Object clone do( diff --git a/tests/step1_read_print.mal b/tests/step1_read_print.mal index 913a412d..11dc4bfb 100644 --- a/tests/step1_read_print.mal +++ b/tests/step1_read_print.mal @@ -98,6 +98,8 @@ false ;=>"," "-" ;=>"-" +"/" +;=>"/" ":" ;=>":" ";" @@ -275,6 +277,3 @@ false ;; fantom fails this one "!" ;=>"!" -;; io fails this one -"/" -;=>"/"