From: Chris W. <la...@us...> - 2005-02-26 23:22:55
|
Update of /cvsroot/openinteract/OpenInteract2/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32729/t Modified Files: url.t Log Message: OIN-135: modify URL parsing to deal with additional parameters and return from parse() methods Index: url.t =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/t/url.t,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** url.t 27 Nov 2004 18:27:33 -0000 1.14 --- url.t 26 Feb 2005 23:22:45 -0000 1.15 *************** *** 7,11 **** require 'utils.pl'; use OpenInteract2::Context qw( CTX ); ! use Test::More tests => 112; initialize_context(); --- 7,11 ---- require 'utils.pl'; use OpenInteract2::Context qw( CTX ); ! use Test::More tests => 135; initialize_context(); *************** *** 24,77 **** { my ( $action_name, $task ); ! ( $action_name, $task ) = $UCL->parse( 'http://www.infocom.com/games/explore/' ); is( $action_name, 'games', 'Action name from full URL (relative)' ); is( $task, 'explore', 'Task from full URL (relative)' ); ! ( $action_name, $task ) = $UCL->parse_absolute( 'http://www.infocom.com/games/explore/' ); is( $action_name, 'games', 'Action name from full URL (absolute)' ); is( $task, 'explore', 'Task from full URL (absolute)' ); ! ( $action_name, $task ) = $UCL->parse( 'http://www.infocom.com/games/explore/?name=zork' ); is( $action_name, 'games', 'Action name from full URL with query (relative)' ); is( $task, 'explore', 'Task from full URL with query (relative)' ); ! ( $action_name, $task ) = $UCL->parse_absolute( 'http://www.infocom.com/games/explore/?name=zork' ); is( $action_name, 'games', 'Action name from full URL with query (absolute)' ); is( $task, 'explore', 'Task from full URL with query (absolute)' ); ! ( $action_name, $task ) = $UCL->parse( '/foo/bar/baz/' ); is( $action_name, 'foo', 'Action name from relative URL path (relative)' ); is( $task, 'bar', 'Task from relative URL path (relative)' ); } { my ( $action_name, $task ); ! ( $action_name, $task ) = $UCL->parse_absolute( '/foo/bar/baz/' ); is( $action_name, 'foo', 'Action name from URL path (absolute)' ); is( $task, 'bar', 'Task from relative URL path (absolute)' ); ! ( $action_name, $task ) = $UCL->parse( '/foo/bar/baz/?blah=blech' ); is( $action_name, 'foo', 'Action name from URL path with query (relative)' ); is( $task, 'bar', ! 'Task from URL path with query (relative)' ); ! ( $action_name, $task ) = $UCL->parse_absolute( '/foo/bar/baz/?blah=blech' ); is( $action_name, 'foo', 'Action name from URL path with query (absolute)' ); is( $task, 'bar', 'Task from URL path with query (absolute)' ); ( $action_name, $task ) = $UCL->parse( '/foo/?bar=baz' ); --- 24,103 ---- { my ( $action_name, $task ); ! my ( @params ); ! ( $action_name, $task, @params ) = $UCL->parse( 'http://www.infocom.com/games/explore/5/2' ); is( $action_name, 'games', 'Action name from full URL (relative)' ); is( $task, 'explore', 'Task from full URL (relative)' ); + is( $params[0], '5', + 'REST 1 from full URL (relative)' ); + is( $params[1], '2', + 'REST 2 from full URL (relative)' ); ! ( $action_name, $task, @params ) = $UCL->parse_absolute( 'http://www.infocom.com/games/explore/6/8' ); is( $action_name, 'games', 'Action name from full URL (absolute)' ); is( $task, 'explore', 'Task from full URL (absolute)' ); + is( $params[0], '6', + 'REST 1 from full URL (absolute)' ); + is( $params[1], '8', + 'REST 2 from full URL (absolute)' ); ! ( $action_name, $task, @params ) = $UCL->parse( 'http://www.infocom.com/games/explore/infocom/?name=zork' ); is( $action_name, 'games', 'Action name from full URL with query (relative)' ); is( $task, 'explore', 'Task from full URL with query (relative)' ); + is( $params[0], 'infocom', + 'REST 1 from full URL with query (relative)' ); ! ( $action_name, $task, @params ) = $UCL->parse_absolute( 'http://www.infocom.com/games/explore/frobozz//?name=zork' ); is( $action_name, 'games', 'Action name from full URL with query (absolute)' ); is( $task, 'explore', 'Task from full URL with query (absolute)' ); + is( $params[0], 'frobozz', + 'REST 1 from full URL with query (absolute)' ); ! ( $action_name, $task, @params ) = $UCL->parse( '/foo/bar/baz/' ); is( $action_name, 'foo', 'Action name from relative URL path (relative)' ); is( $task, 'bar', 'Task from relative URL path (relative)' ); + is( $params[0], 'baz', + 'REST 1 from relative URL path (relative)' ); } { my ( $action_name, $task ); ! my ( @params ); ! ( $action_name, $task, @params ) = $UCL->parse_absolute( '/foo/bar/baz/' ); is( $action_name, 'foo', 'Action name from URL path (absolute)' ); is( $task, 'bar', 'Task from relative URL path (absolute)' ); + is( $params[0], 'baz', + 'REST 1 from relative URL path (absolute)' ); ! ( $action_name, $task, @params ) = $UCL->parse( '/foo/bar/baz/quux?blah=blech' ); is( $action_name, 'foo', 'Action name from URL path with query (relative)' ); is( $task, 'bar', ! 'Task from URL path with query (relative)' ); ! is( $params[0], 'baz', ! 'REST 1 from URL path with query (relative)' ); ! is( $params[1], 'quux', ! 'REST 2 from URL path with query (relative)' ); ! ( $action_name, $task, @params ) = $UCL->parse_absolute( '/foo/bar/goo/gle/?blah=blech' ); is( $action_name, 'foo', 'Action name from URL path with query (absolute)' ); is( $task, 'bar', 'Task from URL path with query (absolute)' ); + is( $params[0], 'goo', + 'REST 1 from URL path with query (absolute)' ); + is( $params[1], 'gle', + 'REST 2 from URL path with query (absolute)' ); ( $action_name, $task ) = $UCL->parse( '/foo/?bar=baz' ); *************** *** 195,252 **** { my ( $action_name, $task ); ! ( $action_name, $task ) = $UCL->parse( 'http://www.infocom.com/games/explore/' ); is( $action_name, 'games', 'Action name from full URL not under context, with context set (relative)' ); is( $task, 'explore', 'Task from full URL not under context, with context set (relative)' ); ! ( $action_name, $task ) = $UCL->parse_absolute( 'http://www.infocom.com/games/explore/' ); is( $action_name, undef, 'Action name from full URL not under context, with context set (absolute)' ); is( $task, undef, 'Task from full URL not under context, with context set (absolute)' ); ! ( $action_name, $task ) = $UCL->parse( '/foo/bar/baz/' ); is( $action_name, 'foo', 'Action name from URL path not under context, with context set (relative)' ); is( $task, 'bar', 'Task from URL path not under context, with context set (relative)' ); ! ( $action_name, $task ) = $UCL->parse_absolute( '/foo/bar/baz/' ); is( $action_name, undef, 'Action name from URL path not under context, with context set (absolute)' ); is( $task, undef, 'Task from URL path not under context, with context set (absolute)' ); ! ( $action_name, $task ) = $UCL->parse( 'http://www.infocom.com/OpenInteract/games/explore/' ); is( $action_name, 'OpenInteract', 'Action name from full URL, with context set (relative)' ); is( $task, 'games', 'Task from full URL, with context set (relative)' ); ! ( $action_name, $task ) = $UCL->parse_absolute( 'http://www.infocom.com/OpenInteract/games/explore/' ); is( $action_name, 'games', 'Action name from full URL, with context set (absolute)' ); is( $task, 'explore', 'Task from full URL, with context set (absolute)' ); ! ( $action_name, $task ) = $UCL->parse( 'http://www.infocom.com/OpenInteract/games/explore/?name=zork' ); is( $action_name, 'OpenInteract', 'Action name from full URL with query, with context set (relative)' ); is( $task, 'games', 'Task from full URL with query, with context set (relative)' ); ! ( $action_name, $task ) = $UCL->parse_absolute( 'http://www.infocom.com/OpenInteract/games/explore/?name=zork' ); is( $action_name, 'games', 'Action name from full absolute URL with query, with context set (absolute)' ); is( $task, 'explore', 'Task from full URL with query, with context set (absolute)' ); ! ( $action_name, $task ) = $UCL->parse( '/OpenInteract/foo/bar/baz/' ); is( $action_name, 'OpenInteract', 'Action name from URL path under context, with context set (relative)' ); is( $task, 'foo', 'Task from URL path under context, with context set (relative)' ); ( $action_name, $task ) = $UCL->parse_absolute( '/OpenInteract/foo/bar/baz/' ); --- 221,302 ---- { my ( $action_name, $task ); + my ( @params ); ! ( $action_name, $task, @params ) = $UCL->parse( 'http://www.infocom.com/games/explore/foo' ); is( $action_name, 'games', 'Action name from full URL not under context, with context set (relative)' ); is( $task, 'explore', 'Task from full URL not under context, with context set (relative)' ); + is( $params[0], 'foo', + 'REST 1 from full URL not under context, with context set (relative)' ); ! ( $action_name, $task, @params ) = $UCL->parse_absolute( 'http://www.infocom.com/games/explore/' ); is( $action_name, undef, 'Action name from full URL not under context, with context set (absolute)' ); is( $task, undef, 'Task from full URL not under context, with context set (absolute)' ); + is( scalar @params, 0, + 'No REST from full URL not under context, with context set (absolute)' ); ! ( $action_name, $task, @params ) = $UCL->parse( '/foo/bar/baz/' ); is( $action_name, 'foo', 'Action name from URL path not under context, with context set (relative)' ); is( $task, 'bar', 'Task from URL path not under context, with context set (relative)' ); + is( $params[0], 'baz', + 'REST 1 from URL path not under context, with context set (relative)' ); ! ( $action_name, $task, @params ) = $UCL->parse_absolute( '/foo/bar/baz/' ); is( $action_name, undef, 'Action name from URL path not under context, with context set (absolute)' ); is( $task, undef, 'Task from URL path not under context, with context set (absolute)' ); + is( scalar @params, 0, + 'No REST from URL path not under context, with context set (absolute)' ); ! ( $action_name, $task, @params ) = $UCL->parse( 'http://www.infocom.com/OpenInteract/games/explore/' ); is( $action_name, 'OpenInteract', 'Action name from full URL, with context set (relative)' ); is( $task, 'games', 'Task from full URL, with context set (relative)' ); + is( $task, 'explore', + 'REST 1 from full URL, with context set (relative)' ); ! ( $action_name, $task, @params ) = ! $UCL->parse_absolute( 'http://www.infocom.com/OpenInteract/games/explore/textbased/sf' ); is( $action_name, 'games', 'Action name from full URL, with context set (absolute)' ); is( $task, 'explore', 'Task from full URL, with context set (absolute)' ); + is( $params[0], 'textbased', + 'REST 1 from full URL, with context set (absolute)' ); + is( $params[1], 'sf', + 'REST 2 from full URL, with context set (absolute)' ); ! ( $action_name, $task, @params ) = $UCL->parse( 'http://www.infocom.com/OpenInteract/games/explore/classic?name=zork' ); is( $action_name, 'OpenInteract', 'Action name from full URL with query, with context set (relative)' ); is( $task, 'games', 'Task from full URL with query, with context set (relative)' ); + is( $params[0], 'classic', + 'REST 1 from full URL with query, with context set (relative)' ); ! ( $action_name, $task, @params ) = $UCL->parse_absolute( 'http://www.infocom.com/OpenInteract/games/explore/classic/?name=zork' ); is( $action_name, 'games', 'Action name from full absolute URL with query, with context set (absolute)' ); is( $task, 'explore', 'Task from full URL with query, with context set (absolute)' ); + is( $params[0], 'classic', + 'REST 1 from full URL with query, with context set (absolute)' ); ! ( $action_name, $task, @params ) = $UCL->parse( '/OpenInteract/foo/bar/baz/' ); is( $action_name, 'OpenInteract', 'Action name from URL path under context, with context set (relative)' ); is( $task, 'foo', 'Task from URL path under context, with context set (relative)' ); + is( $params[0], 'bar', + 'REST 1 from URL path under context, with context set (relative)' ); + is( $params[1], 'baz', + 'REST 2 from URL path under context, with context set (relative)' ); ( $action_name, $task ) = $UCL->parse_absolute( '/OpenInteract/foo/bar/baz/' ); |