enso: Init repo
This commit is contained in:
1
tests/config.nims
Normal file
1
tests/config.nims
Normal file
@ -0,0 +1 @@
|
||||
switch("path", "$projectDir/../src")
|
||||
34
tests/test.nim
Normal file
34
tests/test.nim
Normal file
@ -0,0 +1,34 @@
|
||||
import enso
|
||||
import std/strformat
|
||||
|
||||
proc unsafe_void(str: string) =
|
||||
echo str
|
||||
|
||||
proc unsafe_int(str: string): int =
|
||||
echo str
|
||||
result = 1
|
||||
|
||||
func add_two(x: int): int = x + 2
|
||||
|
||||
func main() =
|
||||
run strput("Hello from Enso!")
|
||||
|
||||
let
|
||||
out_void: IO[void] = lift do(): unsafe_void("void")
|
||||
out_int: IO[int] = lift proc(): int = unsafe_int("int")
|
||||
|
||||
out_void()
|
||||
run strput(fmt"{out_int()}")
|
||||
|
||||
let
|
||||
num_list: IO[seq[int]] = to_IO @[1, 2, 3, 4, 5]
|
||||
list_added: IO[seq[int]] = num_list.map(add_two)
|
||||
|
||||
run strput(fmt"{list_added()}")
|
||||
|
||||
run strput("Enter a string")
|
||||
let read: IO[string] = readstr(STDIN)
|
||||
run strput(read())
|
||||
|
||||
when isMainModule:
|
||||
main()
|
||||
Reference in New Issue
Block a user