all repos — min @ 1ee08fd0de6b063d5bb0db373ed3abdbd2d0f307

A small but practical concatenative programming language.

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
'test load
'test import

"net" 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) assert

  (srv1 srv2 ==) assert
  (cli1 cli2 !=) assert

  report
  clear-stack
  srv1 close
  srv2 close
  cli1 close
  cli2 close