all repos — min @ 19ce2215dd6f3183eaaedda5b7151cc5bb6b2dc3

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
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
'test load
'test import

"net" describe

  () socket =srv1
  () socket =srv2
  () socket =cli1
  () socket =cli2

  
  () socket "httpbin.org" 80 connect #cli1
  "min v$1" (version) => % :user-agent

  "GET /user-agent HTTP/1.1\r\nHost: httpbin.org\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 "}" !=) 
  (
    cli1 recv-line @line
    (response line) => "\n" join @response 
  ) while

  ;HTTP/1.1 200 OK
  ;Connection: keep-alive
  ;Server: meinheld/0.6.1
  ;Date: Sun, 19 Nov 2017 13:37:15 GMT
  ;Content-Type: application/json
  ;Access-Control-Allow-Origin: *
  ;Access-Control-Allow-Credentials: true
  ;X-Powered-By: Flask
  ;X-Processed-Time: 0.00111794471741
  ;Content-Length: 34
  ;Via: 1.1 vegur
  ;
  ;{ 
  ;  "user-agent": "min v0.12.0"
  ;}

  (response "\n\n" split 1 get from-json /user-agent user-agent ==) assert

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

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