Changeset 6658
- Timestamp:
- 09/02/05 16:11:15 (3 years ago)
- Files:
-
- 3 added
- 4 modified
- 1 moved
-
lib/pugs/hack.pod (modified) (2 diffs)
-
perl5/PIL2JS/lib6/Prelude/JS/Array.pm (modified) (1 diff)
-
perl5/PIL2JS/lib6/Prelude/JS/Hash.pm (modified) (1 diff)
-
t/operators/binding (added)
-
t/operators/binding/arrays.t (added)
-
t/operators/binding/hashes.t (added)
-
t/operators/binding/scalars.t (moved) (moved from t/operators/binding.t) (2 diffs)
-
t/statements/for_with_only_one_item.t (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lib/pugs/hack.pod
r6655 r6658 266 266 267 267 Where applicable, conventions documented in Damian Conway's "Perl Best 268 Practices" book (O reilly, 2005) should be followed by default. At the very268 Practices" book (O'Reilly, 2005) should be followed by default. At the very 269 269 least, all indenting should be done with spaces (4 per indent level) rather than 270 270 tabs, so the code and documentation looks the same to everyone. … … 279 279 $ export PERL6LIB=blib6/lib 280 280 281 You can also just say F<./pugs -Iblib6/lib t/.../mumble.t>.281 You can also just say C<./pugs -Iblib6/lib t/.../mumble.t>. 282 282 283 283 =head3 Regex testing -
perl5/PIL2JS/lib6/Prelude/JS/Array.pm
r6623 r6658 321 321 ret.BINDTO = function (other) { 322 322 if(array[idx] == undefined) 323 PIL2JS.die("Can\'t rebind non-existant array container!");323 array[idx] = new PIL2JS.Box(undefined); 324 324 325 325 return array[idx].BINDTO(other); -
perl5/PIL2JS/lib6/Prelude/JS/Hash.pm
r6623 r6658 73 73 ret.BINDTO = function (other) { 74 74 if(!hash.exists(key)) 75 PIL2JS.die("Can\'t rebind non-existant hash container!"); 75 hash.add_pair(new PIL2JS.Pair( 76 new PIL2JS.Box.ReadOnly(key), 77 new PIL2JS.Box(undefined) 78 )); 76 79 77 80 return hash.get_value(key).BINDTO(other); -
t/operators/binding/scalars.t
r6520 r6658 17 17 18 18 # L<S03/"Binding" /replaces the container itself. For instance:/> 19 # Basic scalar binding tests 20 { 21 my $x = 'Just Another'; 22 is($x, 'Just Another', 'normal assignment works'); 19 23 20 my $x = 'Just Another';21 is($x, 'Just Another', 'normal assignment works');24 my $y := $x; 25 is($y, 'Just Another', 'y is now bound to x'); 22 26 23 my $y := $x; 24 is($y, 'Just Another', 'y is now bound to x'); 27 ok($y =:= $x, 'y is bound to x (we checked with the =:= identity op)'); 25 28 26 ok($y =:= $x, 'y is bound to x (we checked with the =:= identity op)'); 29 my $z = $x; 30 is($z, 'Just Another', 'z is not bound to x'); 27 31 28 my $z = $x; 29 is($z, 'Just Another', 'z is not bound to x'); 32 ok(!($z =:= $x), 'z is not bound to x (we checked with the =:= identity op)', :todo); 30 33 31 ok(!($z =:= $x), 'z is not bound to x (we checked with the =:= identity op)', :todo); 34 $y = 'Perl Hacker'; 35 is($y, 'Perl Hacker', 'y has been changed to "Perl Hacker"'); 36 is($x, 'Perl Hacker', 'x has also been changed to "Perl Hacker"'); 32 37 33 $y = 'Perl Hacker'; 34 is($y, 'Perl Hacker', 'y has been changed to "Perl Hacker"'); 35 is($x, 'Perl Hacker', 'x has also been changed to "Perl Hacker"'); 36 37 is($z, 'Just Another', 'z is still "Just Another" because it was not bound to x'); 38 39 sub bar { 40 return $CALLER::a eq $CALLER::b; 38 is($z, 'Just Another', 'z is still "Just Another" because it was not bound to x'); 41 39 } 42 40 43 sub foo { 44 my $a = "foo"; 45 my $b := $a; 46 return bar(); # && bar2(); 41 # Binding and $CALLER:: 42 { 43 sub bar { 44 return $CALLER::a eq $CALLER::b; 45 } 46 47 sub foo { 48 my $a = "foo"; 49 my $b := $a; 50 return bar(); # && bar2(); 51 } 52 53 ok(foo(), "CALLER resolves bindings in caller's dynamic scope"); 47 54 } 48 49 ok(foo(), "CALLER resolves bindings in caller's dynamic scope");50 55 51 56 # Binding to swap … … 112 117 } 113 118 114 # := actually takes functionparameter list119 # := actually takes subroutine parameter list 115 120 { 116 121 my $a; -
t/statements/for_with_only_one_item.t
r6639 r6658 6 6 # Test primarily aimed at PIL2JS 7 7 8 plan 5;8 plan 8; 9 9 10 # sanity tests 10 11 { 11 12 my $res; … … 22 23 } 23 24 25 # for with only one item, a constant 24 26 { 25 27 my $res; … … 42 44 is $res, "a", "for works with \"a_single_constant\""; 43 45 } 46 47 # for with only one item, an arrayref 48 # See thread "for $arrayref {...}" on p6l started by Ingo Blechschmidt, 49 # http://www.nntp.perl.org/group/perl.perl6.language/22970. 50 { 51 my $arrayref = [1,2,3]; 52 53 my $count; 54 for ($arrayref,) { $count++ } 55 56 is $count, 1, 'for ($arrayref,) {...} executes the loop body only once'; 57 } 58 59 { 60 my $arrayref = [1,2,3]; 61 62 my $count; 63 for ($arrayref) { $count++ } 64 65 is $count, 1, 'for ($arrayref) {...} executes the loop body only once'; 66 } 67 68 { 69 my $arrayref = [1,2,3]; 70 71 my $count; 72 for $arrayref { $count++ } 73 74 is $count, 1, 'for $arrayref {...} executes the loop body only once'; 75 }
