forked from B-Lang-org/bsc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# for "make clean" to work everywhere | ||
|
||
CONFDIR = $(realpath ../..) | ||
|
||
include $(CONFDIR)/clean.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
# tests for elaboration-time classic-syntax show library | ||
|
||
compile_verilog_pass TestSShow.bs sysTestSShow | ||
|
||
compare_file sysTestSShow.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package TestSShow where | ||
|
||
import SShow | ||
import ListN | ||
import Vector | ||
import BuildVector | ||
import BuildList | ||
|
||
data Foo = A (UInt 8) Bool Bar | ||
| B (Int 16) | ||
| C | ||
| D {a :: (Bit 8); b :: Foo} | ||
deriving (FShow) | ||
|
||
struct Bar = | ||
foo :: Foo | ||
x :: (UInt 8) | ||
deriving (FShow) | ||
|
||
data Baz a = Baz a a | ||
deriving (FShow) | ||
|
||
struct Qux = | ||
x :: a -> a -- Higher rank | ||
y :: Int 8 | ||
|
||
sysTestSShow :: Module Empty | ||
sysTestSShow = module | ||
out <- openFile "sysTestSShow.out" WriteMode | ||
|
||
hPutStrLn out (sshow (42 :: UInt 8)) | ||
hPutStrLn out (sshow (321 :: Integer)) | ||
hPutStrLn out (sshow (3.14 :: Real)) | ||
hPutStrLn out (sshow '*') | ||
hPutStrLn out (sshow "Hello") | ||
hPutStrLn out (sshow ()) | ||
hPutStrLn out (sshow (Bar {x=42; foo=C})) | ||
hPutStrLn out (sshow (A 12 True (Bar {foo=D {a=34; b=C}; x=42}))) | ||
hPutStrLn out (sshow (Baz C (A 12 True (Bar {foo=D {a=34; b=C}; x=42})))) | ||
hPutStrLn out (sshow ((vec (Bar {x=42; foo=C}) (Bar {x=3; foo=B 2323})) :: Vector 2 Bar)) | ||
hPutStrLn out (sshow $ vectorToArray ((vec (Bar {x=42; foo=C}) (Bar {x=3; foo=B 2323})) :: Vector 2 Bar)) | ||
hPutStrLn out (sshow ((lst (Bar {x=42; foo=C}) (Bar {x=3; foo=B 2323})) :: List Bar)) | ||
hPutStrLn out (sshow ((Bar {x=42; foo=C}) :> (Bar {x=3; foo=B 2323}) :> ListN.nil)) | ||
hPutStrLn out (sshow ("x", ((Left 123) :: Either (UInt 8) Bar, False))) | ||
hPutStrLn out (sshow $ Qux {x = id; y = 42;}) | ||
|
||
hClose out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
42 | ||
321 | ||
3.14 | ||
'*' | ||
"Hello" | ||
() | ||
Bar {foo=C; x=42} | ||
A 12 True (Bar {foo=D {a=34; b=C}; x=42}) | ||
Baz C (A 12 True (Bar {foo=D {a=34; b=C}; x=42})) | ||
[Bar {foo=C; x=42}, Bar {foo=B 2323; x=3}] | ||
[Bar {foo=C; x=42}, Bar {foo=B 2323; x=3}] | ||
[Bar {foo=C; x=42}, Bar {foo=B 2323; x=3}] | ||
[Bar {foo=C; x=42}, Bar {foo=B 2323; x=3}] | ||
("x", Left 123, False) | ||
Qux {x=<polymorphic value>; y=42} |