[svn:parrot] r42397 - in trunk: runtime/parrot/library t/library
fperrad at svn.parrot.org
fperrad at svn.parrot.org
Tue Nov 10 06:35:02 UTC 2009
Author: fperrad
Date: Tue Nov 10 06:35:02 2009
New Revision: 42397
URL: https://trac.parrot.org/parrot/changeset/42397
Log:
[library] improve variable interpolation
Modified:
trunk/runtime/parrot/library/Configure.pir
trunk/t/library/configure.t
Modified: trunk/runtime/parrot/library/Configure.pir
==============================================================================
--- trunk/runtime/parrot/library/Configure.pir Tue Nov 10 06:28:36 2009 (r42396)
+++ trunk/runtime/parrot/library/Configure.pir Tue Nov 10 06:35:02 2009 (r42397)
@@ -367,6 +367,7 @@
L3:
$I1 = index line, '@', $I0
if $I1 < 0 goto L4
+ L8:
$I2 = $I1 - $I0
inc $I1
$I3 = index line, '@', $I1
@@ -381,6 +382,13 @@
$S0 .= $S2
goto L6
L5:
+ $I8 = $I3 + 1
+ $I9 = index line, '@', $I8
+ if $I9 < 0 goto L7
+ $I0 = $I1 - 1
+ $I1 = $I3
+ goto L8
+ L7:
printerr "\tunknown config: "
printerr $S1
printerr "\n"
Modified: trunk/t/library/configure.t
==============================================================================
--- trunk/t/library/configure.t Tue Nov 10 06:28:36 2009 (r42396)
+++ trunk/t/library/configure.t Tue Nov 10 06:35:02 2009 (r42397)
@@ -17,7 +17,7 @@
load_bytecode 'Configure.pbc'
- plan(39)
+ plan(40)
test_conditioned_line()
test_eval_expr()
test_interpolate_var()
@@ -113,12 +113,18 @@
config['foo'] = 'bar'
$S0 = interpolate_var("# plain text", config)
is($S0, "# plain text\n", "plain text")
+
$S0 = interpolate_var("\t at echo foo", config)
is($S0, "\t at echo foo\n", "@ alone")
+
$S0 = interpolate_var("here @foo@ variable", config)
is($S0, "here bar variable\n", "variable")
+
$S0 = interpolate_var("here @foo@ variable, and here @foo at .", config)
is($S0, "here bar variable, and here bar.\n", "variable")
+
+ $S0 = interpolate_var("\t at echo var @foo at .", config)
+ is($S0, "\t at echo var bar.\n", "gives a second change")
.end
.sub 'test_replace_slash'
More information about the parrot-commits
mailing list