2023-02-18 18:43:05 +01:00
|
|
|
|
2023-02-25 11:37:07 +01:00
|
|
|
"stream.spl" import
|
2023-03-06 03:45:16 +01:00
|
|
|
"http.spl" import
|
2023-02-25 11:37:07 +01:00
|
|
|
|
2023-02-19 04:57:32 +01:00
|
|
|
func main { int | with args ;
|
|
|
|
def thing
|
2023-02-18 18:43:05 +01:00
|
|
|
|
2023-02-19 04:57:32 +01:00
|
|
|
1 anew =thing
|
2023-02-18 18:43:05 +01:00
|
|
|
|
2023-02-19 04:57:32 +01:00
|
|
|
"hi" 0 thing:unwrap:set;
|
2023-02-18 18:43:05 +01:00
|
|
|
|
2023-03-06 03:45:16 +01:00
|
|
|
def thing2 thing:unwrap List:new:from =thing2
|
2023-02-18 18:43:05 +01:00
|
|
|
|
2023-02-19 04:57:32 +01:00
|
|
|
"world" thing2:unwrap:push
|
2023-02-19 19:34:25 +01:00
|
|
|
"hello" 0 thing2:unwrap:insert
|
2023-02-18 18:43:05 +01:00
|
|
|
|
2023-02-19 19:34:25 +01:00
|
|
|
"printing first two words of 'hello hi world' (should be 'hello hi')" println
|
|
|
|
" " print
|
|
|
|
0 thing2:unwrap:get print " " print
|
|
|
|
1 thing2:unwrap:get println
|
|
|
|
"removing hello" println
|
|
|
|
thing2:pop-front;
|
|
|
|
"printing first two words again" println
|
|
|
|
" " print
|
|
|
|
0 thing2:unwrap:get print " " print
|
|
|
|
1 thing2:unwrap:get println
|
2023-02-18 18:43:05 +01:00
|
|
|
|
2023-02-19 19:34:25 +01:00
|
|
|
"" println
|
|
|
|
"testing closures and func-ptrs" println
|
2023-02-18 18:43:05 +01:00
|
|
|
|
2023-02-19 04:57:32 +01:00
|
|
|
def thingy
|
|
|
|
"heya1" =thingy
|
|
|
|
"thingy println" dyn-read call
|
2023-02-18 18:43:05 +01:00
|
|
|
|
2023-02-19 04:57:32 +01:00
|
|
|
"heya2" =thingy
|
|
|
|
{ |
|
|
|
|
thingy println
|
|
|
|
} call
|
2023-02-18 18:43:05 +01:00
|
|
|
|
2023-02-19 19:34:25 +01:00
|
|
|
def ptr
|
|
|
|
&println =ptr
|
|
|
|
"ptr works" ptr call
|
|
|
|
&&println =ptr
|
|
|
|
"ptr-ptr works" ptr call call
|
|
|
|
thingy:&unwrap =ptr
|
|
|
|
"unwrap-ptr works" ptr call println
|
|
|
|
thingy:&&unwrap =ptr
|
|
|
|
"unwrap-ptr-ptr works" ptr call call println
|
|
|
|
|
|
|
|
|
|
|
|
"" println
|
|
|
|
"testing if" println
|
|
|
|
|
|
|
|
def a "test" =a
|
|
|
|
def b "test" =b
|
|
|
|
a b eq dup if {
|
|
|
|
a " is equal to " b concat concat println
|
|
|
|
} not if {
|
|
|
|
a " is not equal to " b concat concat panic
|
|
|
|
}
|
|
|
|
|
|
|
|
a b assert-eq;
|
|
|
|
|
|
|
|
"" println
|
|
|
|
"testing ranges & iterators: (0..30@5) + 1" println
|
|
|
|
|
|
|
|
def range 5 (0 30 Range:new):set-step =range
|
|
|
|
|
|
|
|
range:iter
|
|
|
|
{ | 1 + } swap:map
|
|
|
|
{ | _str println } swap:foreach
|
|
|
|
|
|
|
|
"" println
|
|
|
|
"testing Iter:sum of 5 10s" println
|
|
|
|
|
|
|
|
0 5 Range:new:iter
|
|
|
|
{ | pop 10 } swap:map
|
|
|
|
_:sum
|
|
|
|
_str println
|
|
|
|
|
|
|
|
"" println
|
|
|
|
"testing MicroMap" println
|
|
|
|
|
2023-03-06 03:45:16 +01:00
|
|
|
def map MicroMap:new =map
|
2023-02-19 19:34:25 +01:00
|
|
|
"hey" "hello" map:set;
|
|
|
|
"helloworld" "Hello, World" map:set;
|
|
|
|
"{ " print
|
2023-03-06 03:45:16 +01:00
|
|
|
{ | with item ;
|
|
|
|
"'" print
|
|
|
|
0 item:get print
|
|
|
|
"': '" print
|
|
|
|
1 item:get print
|
|
|
|
"', " print
|
|
|
|
} map:foreach
|
2023-02-19 19:34:25 +01:00
|
|
|
"}" println
|
|
|
|
|
|
|
|
"" println
|
2023-02-20 14:33:30 +01:00
|
|
|
"Running with args: " print
|
|
|
|
argv:iter
|
|
|
|
{ str | " " concat } swap:map
|
|
|
|
&print swap:foreach
|
2023-02-25 11:37:07 +01:00
|
|
|
|
|
|
|
"" println
|
|
|
|
"testing stream" println
|
|
|
|
|
|
|
|
def file "test.txt" 1 StreamTypes:file:create =file
|
2023-02-25 12:41:02 +01:00
|
|
|
"hi\n" _:to-bytes file:write-exact;
|
2023-02-25 11:37:07 +01:00
|
|
|
file:close null =file
|
|
|
|
|
2023-03-06 14:56:49 +01:00
|
|
|
"" println
|
|
|
|
"testing split" println
|
|
|
|
{ | println } (" " "hello how are you" _:split):foreach
|
2023-02-20 14:33:30 +01:00
|
|
|
"" println
|
2023-02-19 19:34:25 +01:00
|
|
|
|
2023-03-06 14:56:49 +01:00
|
|
|
use net:http:Request
|
2023-03-06 03:45:16 +01:00
|
|
|
"testing http" println
|
2023-03-06 14:56:49 +01:00
|
|
|
def req "tudbut.de" 81 "GET" "/" Request:new =req
|
|
|
|
req:send:body _str println
|
2023-03-06 03:45:16 +01:00
|
|
|
"" println
|
|
|
|
|
2023-02-19 04:57:32 +01:00
|
|
|
100
|
2023-02-19 02:03:06 +01:00
|
|
|
}
|