]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/http/http-tests.factor
Revert "factor: rename [ ] [ ] unit-test -> { } [ ] unit-test using a refactoring...
[factor.git] / basis / http / http-tests.factor
index 1b82e787bcfc96d5f76c8a6465d695728436586a..fda88dd42aad8dad040de89a4e64b530308a2406 100644 (file)
@@ -6,24 +6,24 @@ db.sqlite make continuations urls hashtables accessors namespaces xml.data
 io.encodings.8-bit.latin1 random combinators.short-circuit ;
 IN: http.tests
 
-{ "text/plain" "UTF-8" } [ "text/plain" parse-content-type ] unit-test
+[ "text/plain" "UTF-8" ] [ "text/plain" parse-content-type ] unit-test
 
-{ "text/html" "ASCII" } [ "text/html;  charset=ASCII" parse-content-type ] unit-test
+[ "text/html" "ASCII" ] [ "text/html;  charset=ASCII" parse-content-type ] unit-test
 
-{ "text/html" "utf-8" } [ "text/html; charset=\"utf-8\"" parse-content-type ] unit-test
+[ "text/html" "utf-8" ] [ "text/html; charset=\"utf-8\"" parse-content-type ] unit-test
 
-{ "application/octet-stream" f } [ "application/octet-stream" parse-content-type ] unit-test
+[ "application/octet-stream" f ] [ "application/octet-stream" parse-content-type ] unit-test
 
-{ "localhost" f } [ "localhost" parse-host ] unit-test
-{ "localhost" 8888 } [ "localhost:8888" parse-host ] unit-test
-{ "::1" 8888 } [ "::1:8888" parse-host ] unit-test
-{ "127.0.0.1" 8888 } [ "127.0.0.1:8888" parse-host ] unit-test
+[ "localhost" f ] [ "localhost" parse-host ] unit-test
+[ "localhost" 8888 ] [ "localhost:8888" parse-host ] unit-test
+[ "::1" 8888 ] [ "::1:8888" parse-host ] unit-test
+[ "127.0.0.1" 8888 ] [ "127.0.0.1:8888" parse-host ] unit-test
 
-{ "localhost" } [ T{ url { protocol "http" } { host "localhost" } } unparse-host ] unit-test
-{ "localhost" } [ T{ url { protocol "http" } { host "localhost" } { port 80 } } unparse-host ] unit-test
-{ "localhost" } [ T{ url { protocol "https" } { host "localhost" } { port 443 } } unparse-host ] unit-test
-{ "localhost:8080" } [ T{ url { protocol "http" } { host "localhost" } { port 8080 } } unparse-host ] unit-test
-{ "localhost:8443" } [ T{ url { protocol "https" } { host "localhost" } { port 8443 } } unparse-host ] unit-test
+[ "localhost" ] [ T{ url { protocol "http" } { host "localhost" } } unparse-host ] unit-test
+[ "localhost" ] [ T{ url { protocol "http" } { host "localhost" } { port 80 } } unparse-host ] unit-test
+[ "localhost" ] [ T{ url { protocol "https" } { host "localhost" } { port 443 } } unparse-host ] unit-test
+[ "localhost:8080" ] [ T{ url { protocol "http" } { host "localhost" } { port 8080 } } unparse-host ] unit-test
+[ "localhost:8443" ] [ T{ url { protocol "https" } { host "localhost" } { port 8443 } } unparse-host ] unit-test
 
 STRING: read-request-test-1
 POST /bar HTTP/1.1
@@ -35,7 +35,7 @@ Content-type: application/octet-stream
 blah
 ;
 
-{
+[
     T{ request
         { url T{ url { path "/bar" } } }
         { method "POST" }
@@ -45,7 +45,7 @@ blah
         { cookies V{ } }
         { redirects 10 }
     }
-} [
+] [
     read-request-test-1 lf>crlf [
         read-request
     ] with-string-reader
@@ -60,7 +60,7 @@ some-header: 1; 2
 blah
 ;
 
-read-request-test-1' }      [
+read-request-test-1' 1array [
     read-request-test-1 lf>crlf
     [ read-request ] with-string-reader
     [ write-request ] with-string-writer
@@ -74,7 +74,7 @@ Host: www.sex.com
 
 ;
 
-{
+[
     T{ request
         { url T{ url { host "www.sex.com" } { path "/bar" } } }
         { method "HEAD" }
@@ -83,7 +83,7 @@ Host: www.sex.com
         { cookies V{ } }
         { redirects 10 }
     }
-} [
+] [
     read-request-test-2 lf>crlf [
         read-request
     ] with-string-reader
@@ -95,7 +95,7 @@ Host: www.sex.com:101
 
 ;
 
-{
+[
     T{ request
         { url T{ url { host "www.sex.com" } { port 101 } { path "/bar" } } }
         { method "HEAD" }
@@ -104,7 +104,7 @@ Host: www.sex.com:101
         { cookies V{ } }
         { redirects 10 }
     }
-} [
+] [
     read-request-test-2' lf>crlf [
         read-request
     ] with-string-reader
@@ -120,7 +120,7 @@ GET /blah HTTP/1.0
 Host: "www.amazon.com"
 ;
 
-{ "www.amazon.com" }
+[ "www.amazon.com" ]
 [
     read-request-test-4 lf>crlf [ read-request ] with-string-reader
     "host" header
@@ -133,7 +133,7 @@ Content-Type: text/html; charset=UTF-8
 blah
 ;
 
-{
+[
     T{ response
         { version "1.1" }
         { code 404 }
@@ -144,7 +144,7 @@ blah
         { content-charset "UTF-8" }
         { content-encoding utf8 }
     }
-} [
+] [
     read-response-test-1 lf>crlf
     [ read-response ] with-string-reader
 ] unit-test
@@ -157,7 +157,7 @@ content-type: text/html; charset=UTF-8
 
 ;
 
-read-response-test-1' }      [
+read-response-test-1' 1array [
     URL" http://localhost/" url set
     read-response-test-1 lf>crlf
     [ read-response ] with-string-reader
@@ -166,12 +166,12 @@ read-response-test-1' }      [
     string-lines "\n" join
 ] unit-test
 
-{ t } [
+[ t ] [
     "rmid=732423sdfs73242; path=/; domain=.example.net; expires=Fri, 31-Dec-2010 23:59:59 GMT"
     dup parse-set-cookie first unparse-set-cookie =
 ] unit-test
 
-{ t } [
+[ t ] [
     "a="
     dup parse-set-cookie first unparse-set-cookie =
 ] unit-test
@@ -183,7 +183,7 @@ Set-Cookie: oo="bar; a=b"; httponly=yes; sid=123456
 
 ;
 
-{ 2 } [
+[ 2 ] [
     read-response-test-2 lf>crlf
     [ read-response ] with-string-reader
     cookies>> length
@@ -196,7 +196,7 @@ Set-Cookie: oo="bar; a=b"; comment="your mom"; httponly=yes
 
 ;
 
-{ 1 } [
+[ 1 ] [
     read-response-test-3 lf>crlf
     [ read-response ] with-string-reader
     cookies>> length
@@ -226,7 +226,7 @@ http.server.dispatchers db.tuples ;
     "http://localhost/quit" add-addr http-get nip
     "Goodbye" assert= ;
 
-{ } [
+[ ] [
     [ test-db-file delete-file ] ignore-errors
 
     test-db [
@@ -391,11 +391,11 @@ test-db <db-persistence> [
 ] test-with-db-persistence
 
 ! Test cloning
-{ f } [ <404> dup clone "b" "a" set-header drop "a" header ] unit-test
-{ f } [ <404> dup clone "b" "a" <cookie> put-cookie drop "a" get-cookie ] unit-test
+[ f ] [ <404> dup clone "b" "a" set-header drop "a" header ] unit-test
+[ f ] [ <404> dup clone "b" "a" <cookie> put-cookie drop "a" get-cookie ] unit-test
 
 ! Test basic auth
-{ "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" } [
+[ "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" ] [
     <request> "Aladdin" "open sesame" set-basic-auth "Authorization" header
 ] unit-test