From 5176b270d2239ff0c6c2cc63459a2c5930e78993 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Fri, 14 Aug 2020 13:22:34 -0700 Subject: [PATCH] misc: more syntax tests. --- misc/syntax-test.factor | 44 ++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/misc/syntax-test.factor b/misc/syntax-test.factor index 6e9223770a..01c6f39b02 100644 --- a/misc/syntax-test.factor +++ b/misc/syntax-test.factor @@ -29,6 +29,7 @@ DEFER: word FORGET: word POSTPONE: word + SLOT: name ! Classes @@ -84,8 +85,8 @@ drop ! wrong GENERIC#: word 1 ! comment drop ! wrong MATH: + ( x y -- z ) foldable flushable - SLOT: name C: foo + CONSTRUCTOR: circle ( radius -- obj ) ; ! Private definitions @@ -103,7 +104,6 @@ drop ! wrong HOOK: word variable ( stack -- effect ) GENERIC#: word 1 ( stack -- effect ) MATH: + ( x y -- z ) foldable flushable - SLOT: name C: foo PRIVATE> @@ -128,8 +128,6 @@ PRIVATE> SYMBOL: word SYMBOLS: words ... ; - C: foo - ! Math 1 2 + @@ -227,16 +225,35 @@ PRIVATE> { CHAR: c CHAR: H } { CHAR: d CHAR: C } -! New number literals: +! Bin - 0xCAFEBABE - 0o432 0b10101 + 0B10101 + +! Oct + + 0o432 + 0O1234567 + 0o1234567 + 0o7 + +! Hex + + 0xCAFEBABE + 0XCAFEBABE + 0x1AB4p30 + +! Dec + 1,000 10,000 + +! Float + 1e10 -1.5e-5 + ! Weird numbers 1,234+56/78 @@ -250,17 +267,12 @@ PRIVATE> -1.5e30 1.5e-30 1,000.1,2 - 0XCAFEBABE - 0x1AB4p30 - 0B10101 - 0O1234567 NAN: CAFE1234 0,. ! third token wrong 0,. ! wrong, next line also wrong 0,. NAN: ! ff 0xff comment xCAFE1234 ! wrong ff ! shouldn't match as a hex number - 0o7 NAN: 0 drop NAN: ! @@ -269,9 +281,13 @@ PRIVATE> NAN: f, + NAN: ALKSJDflKJ ! XXX: should error ! Not numbers + ,0.1 + . + -. 1foo 1.5bar +foo @@ -321,7 +337,6 @@ boolean -- q: boolean ) flushablething flushable > 1 @@ -335,7 +350,6 @@ pair? tail? 0.1 -,0.1 ! wrong 10,0.1 1.23 .1 @@ -343,8 +357,6 @@ tail? -0.1 -0,1.1 1. -. ! other --. ! other ! Numeral comma separator parsing (!: wrong, ~: other): ! int -- 2.34.1