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 {} socket :srv1 {} socket :srv2 {} socket :cli1 {} socket :cli2 {} socket "postman-echo.com" 80 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 send cli1 recv-line :line (response line) => "\n" join @response (line "HTTP/1.1 200 OK" == not) ( cli1 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 clear-stack srv1 close srv2 close cli1 close cli2 close |