github.com/NeowayLabs/nash@v0.2.2-0.20200127205349-a227041ffd50/stdlib/io_test.sh (about) 1 2 fn run_example(args...) { 3 var got, status <= ./cmd/nash/nash ./stdlib/io_example.sh $args 4 return $got, $status 5 } 6 7 fn assert_success(expected, got, status) { 8 if $status != "0" { 9 print("expected success, but got status code: %s\n", $status) 10 exit("1") 11 } 12 if $got != $expected { 13 print("expected [%s] got [%s]\n", $expected, $got) 14 exit("1") 15 } 16 } 17 18 fn test_println_format() { 19 var got, status <= run_example("hello %s", "world") 20 21 assert_success("hello world", $got, $status) 22 } 23 24 fn test_println() { 25 var expected = "pazu" 26 var got, status <= run_example($expected) 27 28 assert_success($expected, $got, $status) 29 } 30 31 test_println_format() 32 test_println()