[svn:parrot] r46613 - in trunk: runtime/parrot/library t/library

fperrad at svn.parrot.org fperrad at svn.parrot.org
Fri May 14 15:57:02 UTC 2010


Author: fperrad
Date: Fri May 14 15:57:02 2010
New Revision: 46613
URL: https://trac.parrot.org/parrot/changeset/46613

Log:
[URI] add scheme 'file'

Modified:
   trunk/runtime/parrot/library/URI.pir
   trunk/t/library/uri.t

Modified: trunk/runtime/parrot/library/URI.pir
==============================================================================
--- trunk/runtime/parrot/library/URI.pir	Fri May 14 15:25:05 2010	(r46612)
+++ trunk/runtime/parrot/library/URI.pir	Fri May 14 15:57:02 2010	(r46613)
@@ -8,7 +8,7 @@
 =head2 DESCRIPTION
 
 Simplified port of URI (version 1.54)
-see http://search.cpan.org/~gaas/URI/
+see L<http://search.cpan.org/~gaas/URI/>
 
 =head3 Class URI
 
@@ -238,6 +238,36 @@
 
 =back
 
+=head3 Class URI,file
+
+=over 4
+
+=cut
+
+.namespace ['URI';'file']
+
+.sub '' :init :load :anon
+    $P0 = subclass ['URI';'_generic'], ['URI';'file']
+.end
+
+=item path
+
+=cut
+
+.sub 'path' :method
+    .tailcall self.'path_query'()
+.end
+
+=item host
+
+=cut
+
+.sub 'host' :method
+    .tailcall self.'authority'()
+.end
+
+=back
+
 =head3 Class URI,_server
 
 =over 4

Modified: trunk/t/library/uri.t
==============================================================================
--- trunk/t/library/uri.t	Fri May 14 15:25:05 2010	(r46612)
+++ trunk/t/library/uri.t	Fri May 14 15:57:02 2010	(r46613)
@@ -21,9 +21,10 @@
 
     load_bytecode 'URI.pir'
 
-    plan(40)
+    plan(47)
     test_new()
     test_uri()
+    test_file()
     test_http()
 .end
 
@@ -34,6 +35,12 @@
     $I0 = isa $P0, ['URI']
     ok($I0, "isa ['URI']")
 
+    $P0 = new ['URI';'file']
+    $I0 = isa $P0, ['URI';'file']
+    ok($I0, "new ['URI';'file']")
+    $I0 = isa $P0, ['URI';'_generic']
+    ok($I0, "isa ['URI';'_generic']")
+
     $P0 = new ['URI';'_server']
     $I0 = isa $P0, ['URI';'_server']
     ok($I0, "new ['URI';'_server']")
@@ -103,6 +110,22 @@
     is($S0, 'path?query', "path_query")
 .end
 
+.sub 'test_file'
+    .local pmc factory
+    factory = get_hll_global ['URI'], 'new_from_string'
+
+    $P0 = factory('file:/foo/bar')
+    ok($P0, "file:/foo/bar")
+    $I0 = isa $P0, ['URI';'file']
+    ok($I0, "isa ['URI';'file']")
+    $S0 = $P0.'scheme'()
+    is($S0, 'file', "scheme")
+    $S0 = $P0.'host'()
+    is($S0, '', 'no host')
+    $S0 = $P0.'path'()
+    is($S0, '/foo/bar', 'path')
+.end
+
 .sub 'test_http'
     .local pmc factory
     factory = get_hll_global ['URI'], 'new_from_string'


More information about the parrot-commits mailing list