[svn:mod_parrot] r290 - mod_parrot/trunk/t/response/TestAPI

[email protected]
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Sat Dec 22 07:51:47 2007
New Revision: 290

Added:
   mod_parrot/trunk/t/response/TestAPI/request_rec.pir

Log:
start converting API tests to server-side tests


Added: mod_parrot/trunk/t/response/TestAPI/request_rec.pir
==============================================================================
--- (empty file)
+++ mod_parrot/trunk/t/response/TestAPI/request_rec.pir	Sat Dec 22 07:51:47 2007
@@ -0,0 +1,146 @@
+.namespace [ 'TestAPI::request_rec' ]
+
+.sub handler
+    .param pmc r
+    .local pmc ap_const
+    .local string results
+
+    ap_const = get_root_global [ 'Apache'; 'Constants' ], 'ap_constants'
+
+    r.'puts'("1..16\n")
+
+  START_1:
+    $S0 = typeof r
+    if $S0 == "Apache;RequestRec" goto OK_1
+    r.'puts'("not ")
+  OK_1:
+    r.'puts'("ok 1 - object\n")
+
+  START_2:
+  OK_2:
+    r.'puts'("ok 2 - puts()\n")
+
+  START_3:
+    $I0 = r.'write'("testing 123\n", 12)
+    if $I0 == 12 goto OK_3
+    r.'puts'("not ")
+  OK_3:
+    r.'puts'("ok 3 - write()\n")
+
+  START_4:
+    $S0 = r.'content_type'()
+    # text/html is mod_parrot's default content type
+    if $S0 == "text/html" goto OK_4
+    r.'puts'("not ")
+  OK_4:
+    r.'puts'("ok 4 - content_type get\n")
+
+  START_5:
+    r.'content_type'("text/html")
+  OK_5:
+    r.'puts'("ok 5 - content_type set\n")
+
+  START_6:
+    r.'args'("testing")
+    $S0 = r.'args'()
+    if $S0 == "testing" goto OK_6
+    r.'puts'("not ")
+  OK_6:
+    r.'puts'("ok 6 - args()\n")
+    
+  START_7:
+    r.'path_info'("/my/test/path")
+    $S0 = r.'path_info'()
+    if $S0 == "/my/test/path" goto OK_7
+    r.'puts'("not ")
+  OK_7:
+    r.'puts'("ok 7 - pathinfo()\n")
+    
+  START_8:
+    r.'hostname'("modparrot.example.com")
+    $S0 = r.'hostname'()
+    if $S0 == "modparrot.example.com" goto OK_8
+    r.'puts'("not ")
+  OK_8:
+    r.'puts'("ok 8 - hostname()\n")
+    
+  START_9:
+    $I0 = ap_const['APLOG_EMERG']
+    r.'log_rerror'("test", 0, $I0, "mod_parrot test log")
+  OK_9:
+    r.'puts'("ok 9 - log_rerror()\n")
+
+  START_10:
+    # save original status -- we need it for the test client!
+    $I0 = r.'status'()
+    r.'status'(123)
+    $I1 = r.'status'()
+    if $I1 == 123 goto OK_10
+    r.'puts'("not ")
+  OK_10:
+    r.'puts'("ok 10 - status()\n")
+    r.'status'($I0)
+
+  START_11:
+    $P0 = r.'notes'()
+    $P0.'set'("modparrot_test", "test note")
+    $P0 = r.'notes'()
+    $S0 = $P0.'get'("modparrot_test")
+    if $S0 == "test note" goto OK_11
+    r.'puts'("not ")
+  OK_11:
+    r.'puts'("ok 11 - notes()\n")
+
+  START_12:
+    r.'uri'("/my/test/uri")
+    $S0 = r.'uri'()
+    if $S0 == "/my/test/uri" goto OK_12
+    r.'puts'("not ")
+  OK_12:
+    r.'puts'("ok 12 - uri()\n")
+
+  START_13:
+    # save original handler
+    $S0 = r.'handler'()
+    r.'handler'("test-handler")
+    $S1 = r.'handler'()
+    if $S1 == "test-handler" goto OK_13
+    r.'puts'("not ")
+  OK_13:
+    r.'puts'("ok 13 - handler()\n")
+    r.'handler'($S0)
+
+  START_14:
+    r.'user'("testuser")
+    $S0 = r.'user'()
+    if $S0 == "testuser" goto OK_14
+    r.'puts'("not ")
+  OK_14:
+    r.'puts'("ok 14 - user()\n")
+
+  START_15:
+    $P0 = new 'String'
+    $P0 = "test PMC note"
+    r.'pmc_notes'('modparrot_test_pmcnote_string', 'test PMC note')
+    $P1 = r.'pmc_notes'('modparrot_test_pmcnote_string')
+    if $P1 == 'test PMC note' goto OK_15
+    r.'puts'("not ")
+  OK_15:
+    r.'puts'("ok 15 - pmc_notes() string value\n")
+
+  START_16:
+    $P0 = new 'Hash'
+    $P1 = new 'String'
+    $P1 = "test PMC note in a hash"
+    $P0['test'] = $P1
+    r.'pmc_notes'('modparrot_test_pmcnote_hash', $P0)
+    $P1 = r.'pmc_notes'('modparrot_test_pmcnote_hash')
+    $P2 = $P1['test']
+    if $P2 == 'test PMC note in a hash' goto OK_16
+    r.'puts'("not ")
+  OK_16:
+    r.'puts'("ok 16 - pmc_notes() hash value\n")
+
+    $I0 = ap_const['OK']
+    .return($I0)
+.end
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.