tests/net.min
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
'min-test require :test ;;; "net" test.describe {} net.socket :srv1 {} net.socket :srv2 {} net.socket :cli1 {} net.socket :cli2 {} net.socket "postman-echo.com" 80 net.connect @cli1 "min v$1" (version) => % :user-agent "GET /get HTTP/1.1\r\nHost: postman-echo.com\r\nUser-Agent: $1\r\n\r\n" (user-agent) => % :req "" :response cli1 req net.send cli1 net.recv-line :line (response line) => "\n" join @response (line "HTTP/1.1 200 OK" == not) ( cli1 net.recv-line @line (response line) => "\n" join puts @response ) while (response "200 OK" match?) test.assert (srv1 srv2 ==) test.assert (cli1 cli2 !=) test.assert test.report stack.clear srv1 net.close srv2 net.close cli1 net.close cli2 net.close |