Changeset 4832

Show
Ignore:
Timestamp:
06/19/05 07:28:00 (4 years ago)
Author:
chromatic
svk:copy_cache_prev:
6641
Message:

r4832@windwheel: chromatic | 2005-06-18 18:24:08 -0700
attribute fixing
r4835@windwheel: chromatic | 2005-06-18 22:12:48 -0700
Fix argument passing to object attributes in methods by attempting to bind

named values regardless of sigil and twigil.

r4836@windwheel: chromatic | 2005-06-18 22:14:04 -0700
Untodo some tests that now work.
Unfortunately, test 40 now fails (and I'm not what should go in :todo<???>).
r4837@windwheel: chromatic | 2005-06-18 22:15:47 -0700
Untodo several attribute-passing tests that now pass.
r4838@windwheel: chromatic | 2005-06-18 22:16:53 -0700
Fix a handful of typos and thinkos, and now this test completely passes!
r4839@windwheel: chromatic | 2005-06-18 22:17:40 -0700
Unskip the whole test file, fix the test number, untodo some passes, and clean

up the rest and all of this test file passes too.

Files:
9 modified

Legend:

Unmodified
Added
Removed
  • ext/Test-Builder/t/021_Test_Builder_Test_Pass.t

    r4597 r4832  
    1717    'new() should return a Test::Builder::Test::Pass instance' ); 
    1818 
    19 is( $pass_test.number(), 1, 'number() should return the provided test number', :todo<bug> ); 
    20 ok( $pass_test.passed(),    'passed() should report the right passed value', :todo<bug> ); 
     19is( $pass_test.number(), 1, 'number() should return the provided test number' ); 
     20ok( $pass_test.passed(),    'passed() should report the right passed value'  ); 
    2121is( $pass_test.description(), 'first test description', 
    22     'description() should report the test description', :todo<bug> ); 
     22    'description() should report the test description' ); 
    2323is( $pass_test.diagnostic(), '???', 
    2424    'diagnostic() should report the default diagnostic if needed' ); 
     
    3232 
    3333is( $pass_diag.diagnostic(), 'some reason this passed', 
    34     '... or the provided diagnostic', :todo<bug> ); 
     34    '... or the provided diagnostic' ); 
    3535 
    3636is( $pass_test.report(), 'ok 1 - first test description', 
    37     'report() should produce the correct TAP line', :todo<bug> ); 
     37    'report() should produce the correct TAP line' ); 
    3838 
    3939my %status = $pass_test.status(); 
    4040is( +( keys %status ), 2, 'status() should return a hash' ); 
    41 is( %status<passed>,   1, '... with a passed key set to true', :todo<bug> ); 
     41is( %status<passed>,   1, '... with a passed key set to true' ); 
    4242is( %status<description>, 'first test description', 
    43     '... and the correct test description', :todo<bug> ); 
     43    '... and the correct test description' ); 
  • ext/Test-Builder/t/022_Test_Builder_Test_Fail.t

    r4597 r4832  
    1717        'new() should return a Test::Builder::Test::Fail instance' ); 
    1818 
    19 is( $fail_test.number(), 1, 'number() should return the provided test number', :todo<bug> ); 
     19is( $fail_test.number(), 1, 'number() should return the provided test number' ); 
    2020ok(!$fail_test.passed(),    'passed() should report the right passed value' ); 
    2121is( $fail_test.description(), 'first test description', 
    22         'description() should report the test description', :todo<bug> ); 
     22        'description() should report the test description' ); 
    2323is( $fail_test.diagnostic(), '???', 
    2424        'diagnostic() should report the default diagnostic if needed' ); 
     
    3232 
    3333is( $fail_diag.diagnostic(), 'some reason this failed', 
    34         '... or the provided diagnostic', :todo<bug> ); 
     34        '... or the provided diagnostic' ); 
    3535 
    3636is( $fail_test.report(), 'not ok 1 - first test description', 
    37         'report() should produce the correct TAP line', :todo<bug> ); 
     37        'report() should produce the correct TAP line' ); 
    3838 
    3939my %status = $fail_test.status(); 
    4040is( +( keys %status ), 2, 'status() should return a hash' ); 
    41 is( %status<passed>, 0, '... with a passed key set to false', :todo<bug> ); 
     41is( %status<passed>, 0, '... with a passed key set to false' ); 
    4242is( %status<description>, 'first test description', 
    43         '... and the correct test description', :todo<bug> ); 
     43        '... and the correct test description' ); 
  • ext/Test-Builder/t/023_Test_Builder_Test_Skip.t

    r4604 r4832  
    1818    'new() should return a Test::Builder::Test::Skip instance' ); 
    1919 
    20 is( $skip_test.number(), 1, 'number() should return the test number', :todo<bug> ); 
    21 ok( $skip_test.passed(), 'passed() should return the passed value', :todo<bug> ); 
     20is( $skip_test.number(), 1, 'number() should return the test number' ); 
     21ok( $skip_test.passed(), 'passed() should return the passed value' ); 
    2222is( $skip_test.description(), 'first test description', 
    23     'description() should return the test description', :todo<bug> ); 
     23    'description() should return the test description' ); 
    2424is( $skip_test.diagnostic(), '???', 
    2525    'diagnostic() should return the default diagnostic if needed' ); 
     
    3434 
    3535is( $skip_diag.diagnostic(), 'some diagnostic message', 
    36     '... but should return diagnostic if set', :todo<bug> ); 
     36    '... but should return diagnostic if set' ); 
    3737 
    3838is( $skip_test.reason(), 'reason for skipping', 
    39     'reason() should return the test reason', :todo<bug> ); 
     39    'reason() should return the test reason' ); 
    4040 
    4141is( $skip_test.report(), 'not ok 1 #skip reason for skipping', 
    42     'report() should return a TAP-formatted skip message', :todo<bug> ); 
     42    'report() should return a TAP-formatted skip message' ); 
    4343 
    4444my %status = $skip_test.status(); 
    4545 
    4646is( +( keys %status ), 4, 'status() should return a hash') 
    47 is( %status<passed>,   1, '... with a passed key set to true', :todo<bug>); 
     47is( %status<passed>,   1, '... with a passed key set to true'); 
    4848is( %status<skip>,     1, '... a skip key set to true'                 ); 
    4949 
    50 is( %status<reason>,      'reason for skipping', '... the skip reason', :todo<bug> ); 
     50is( %status<reason>,      'reason for skipping', '... the skip reason' ); 
    5151is( %status<description>, 'first test description', 
    52     '... and the correct test description', :todo<bug>); 
     52    '... and the correct test description'); 
  • ext/Test-Builder/t/024_Test_Builder_Test_TODO.t

    r4597 r4832  
    1818    'new() should return a Test::Builder::Test::TODO instance' ); 
    1919 
    20 is( $todo_test.number(), 1, 'number() should return the right test number', :todo<bug> ); 
    21 ok( $todo_test.passed(),    'passed() should always be true', :todo<bug> ); 
     20is( $todo_test.number(), 1, 'number() should return the right test number' ); 
     21ok( $todo_test.passed(),    'passed() should always be true' ); 
    2222is( $todo_test.description(), 'first test description', 
    23     'description() should return the test description', :todo<bug> ); 
     23    'description() should return the test description' ); 
    2424is( $todo_test.diagnostic(), '???', 
    2525    'diagnostic() should return the default diagnostic if needed' ); 
     
    3333); 
    3434 
    35 is( $todo_test.diagnostic(), 'some test diagnostic', 
    36     '... or the provided diagnostic', 
    37     :todo<feature> ); 
     35is( $todo_diag.diagnostic(), 'some test diagnostic', 
     36    '... or the provided diagnostic' ); 
    3837 
    3938is( $todo_test.reason(), 'reason for TODO-ing', 
    40     'reason() should return the test reason', :todo<bug> ); 
     39    'reason() should return the test reason' ); 
    4140 
    4241my %status = $todo_diag.status(); 
     
    4746 
    4847is( %status<really_passed>, 0, 
    49     '... the really_passed key set to the passed value', :todo<bug> ); 
     48    '... the really_passed key set to the passed value' ); 
    5049is( %status<description>, 'first test description', 
    51     '... and the correct test description', :todo<bug> ); 
     50    '... and the correct test description' ); 
  • ext/Test-Builder/t/030_Test_Builder_Output.t

    r4401 r4832  
    88use Test::Builder::Output; 
    99 
    10 my $output = open("output", :w); 
    11 my $error_output = open("error_output", :w); 
     10my $output       = open('output',      :w); 
     11my $error_output = open('error_output', :w); 
    1212 
    13 my $output = Test::Builder::Output.new( 
     13my $tbo = Test::Builder::Output.new( 
    1414    output       => $output, 
    1515    error_output => $error_output,     
    16     ); 
    17 is($output.ref, 'Test::Builder::Output', '... this is a Test::Builder::Output instance'); 
     16); 
    1817 
    19 # NOTE: 
    20 # the # needs to be removed, but right now 
    21 # it messed up Test::Harness too much 
    22 $output.write('#ok 1'); 
    23 $output.write('#ok 2'); 
    24 $output.write("#ok 3\ntesting"); 
     18is( $tbo.ref, 'Test::Builder::Output', 
     19    'new() should return a Test::Builder::Output instance' ); 
     20 
     21$tbo.write('ok 1'); 
     22$tbo.write('ok 2'); 
     23$tbo.write("ok 3\ntesting"); 
     24 
     25$output.close(); 
    2526 
    2627my $output_output = slurp('output'); 
    27 is($output_output,  
    28 "ok 1 
    29 ok 2 
    30 ok 3 
    31 #testing 
    32 ", '... got the right output', :todo<feature>); 
     28is( $output_output, "ok 1\nok 2\nok 3\n#testing\n", 
     29        'write() should write to normal output, escaping newlines' ); 
    3330 
    34 $output.diag('this is error output'); 
    35 $output.diag("this is error output\nover two lines"); 
     31$tbo.diag('this is error output'); 
     32$tbo.diag("this is error output\nover two lines"); 
     33 
     34$error_output.close(); 
    3635 
    3736my $error_output_output = slurp('error_output'); 
     
    3938"#this is error output 
    4039#this is error output 
    41 #over two lines 
    42 ", '... got the right error output', :todo<feature>); 
     40#over two lines\n", 
     41        'diag() should write to error output, escaping all output' ); 
    4342 
    44 END { 
    45     unlink("output"); 
    46     unlink("error_output");     
     43END 
     44{ 
     45    unlink( 'output' ); 
     46    unlink( 'error_output' ); 
    4747} 
  • ext/Test-Builder/t/040_Test_Builder_TestPlan.t

    r4597 r4832  
    44use Test; 
    55 
    6 plan 10; 
     6plan 9; 
    77 
    88use Test::Builder::TestPlan; 
    9  
    10 skip_rest; # XXX - just to get the test parsing for now 
    11 exit; 
    129 
    1310my $test_plan = Test::Builder::TestPlan.new(:expect(10)); 
    1411 
    1512# NOTE: replace this with proper isa_ok() when that works 
    16 isa_ok($test_plan, Test::Builder::TestPlan, '... this is a Test::Builder::TestPlan instance'); 
     13isa_ok( $test_plan, Test::Builder::TestPlan, 
     14        'new() should return a Test::Builder::TestPlan instance' ); 
    1715 
    18 dies_ok { 
    19     $test_plan.expect(); 
    20 }, '... this property is private, so this should die'; 
     16dies_ok { $test_plan.expect() }, 
     17    '$:expect is a private property, so expect() should die'; 
    2118 
    22 dies_ok { 
    23     $test_plan.expect(100); 
    24 }, '... this property is private, so this should die'; 
     19dies_ok { $test_plan.expect(100) }, '... as should expect( value )'; 
    2520 
    26 is($test_plan.header(), '1..10', '... got the header we expected', :todo<bug>); 
    27 is($test_plan.footer(:run(10)), '', '... got the footer we expected :run(10)', :todo<bug>); 
    28 is($test_plan.footer(:run(8)), 'Expected 10 but ran 8', '... got the footer we expected :run(8)', :todo<bug>); 
     21is( $test_plan.header(), '1..10', 'header() should return a valid header' ); 
     22is( $test_plan.footer( :run(10) ), '', 
     23        'footer() should return nothing for running all expected tests' ); 
     24is( $test_plan.footer( :run(8) ), 'Expected 10 but ran 8', 
     25        '... or a missing tests warning for running fewer' ); 
    2926 
    3027my $null_test_plan = Test::Builder::NullPlan.new(); 
    3128 
    32 is($null_test_plan.ref, 'Test::Builder::NullPlan', '... this is a Test::Builder::NullPlan instance'); 
     29isa_ok( $null_test_plan, 'Test::Builder::NullPlan', 
     30        'new() should return a Test::Builder::NullPlan instance'); 
    3331 
    34 is($null_test_plan.header(), '', '... null plans have no header'); 
    35 is($null_test_plan.footer(:run(50)), '1..50', '... got the footer we expected :run(50)'); 
     32is( $null_test_plan.header(), '', 
     33        'header() should return an empty string for a null plan' ); 
     34 
     35is( $null_test_plan.footer(:run(50)), '1..50', 
     36        'footer() should return the test header for a null plan'); 
  • src/Pugs/Bind.hs

    r4158 r4832  
    3939    (bound, exps') = foldr doBind ([], []) (map unPair exps) 
    4040    doBind (name, exp) (bound, exps)  
    41         | Just prm <- find ((name ==) . tail . paramName) prms 
     41        | Just prm <- find ((matchNamedAttribute name) . paramName) prms 
    4242        = ( ((prm, exp) : bound), exps ) 
    4343        | otherwise 
    4444        = ( bound, (Syn "=>" [Val (VStr name), exp]:exps) ) 
    4545 
     46matchNamedAttribute :: String -> String -> Bool 
     47matchNamedAttribute arg (_:'.':param) = param == arg 
     48matchNamedAttribute arg (_:':':param) = param == arg 
     49matchNamedAttribute arg     (_:param) = param == arg 
     50matchNamedAttribute   _             _ = False 
     51 
    4652emptyHashExp :: Exp 
    4753emptyHashExp  = Val $ VList [] -- VHash $ vCast $ VList [] 
     54 
    4855emptyArrayExp :: Exp 
    4956emptyArrayExp = Val $ VList [] -- VArray $ vCast $ VList [] 
  • src/Pugs/Eval.hs

    r4573 r4832  
    827827    f [ argValue arg | arg <- bound, (argName arg) /= "%_" ] 
    828828applyExp styp bound body = do 
    829     sequence_ [ evalExp 
    830         (Syn "=" [Syn "{}" [Val (argValue $ head bound), Val (VStr key)], Val val]) | 
    831         ApplyArg{ argName = (_:twigil:key), argValue = val } 
    832         <- bound, (twigil ==) `any` ".:" ] 
    833     applyThunk styp bound (MkThunk $ evalExp body) 
     829    let invocant         = head bound 
     830    let (attrib, normal) = partition isAttrib bound 
     831    ret <- applyThunk styp normal (MkThunk $ evalExp body) 
     832    sequence_ [ evalExp (Syn "=" [Syn "{}" [Val (argValue invocant), Val (VStr key)], Val val]) | 
     833        ApplyArg{ argName = (_:_:key), argValue = val } <- attrib ] 
     834    return ret 
     835 
     836isAttrib :: ApplyArg -> Bool 
     837isAttrib ApplyArg{ argName = (_:'.':_) } = True 
     838isAttrib ApplyArg{ argName = (_:':':_) } = True 
     839isAttrib _ = False 
    834840 
    835841applyThunk :: SubType -> [ApplyArg] -> VThunk -> Eval Val 
  • t/oo/attributes/instance.t

    r4821 r4832  
    144144    ok($foo ~~ Foo6, '... our Foo6 instance was created'); 
    145145         
    146     is($foo.bar,        1, "getting a public rw attribute (1)", :todo<bug>); 
    147     is($foo.baz,        2, "getting a public rw attribute (2)", :todo<bug>); 
    148     is($foo.get_hidden, 3, "getting a private ro attribute (3)", :todo<bug>); 
     146    is($foo.bar,        1, "getting a public rw attribute (1)"  ); 
     147    is($foo.baz,        2, "getting a public rw attribute (2)"  ); 
     148    is($foo.get_hidden, 3, "getting a private ro attribute (3)" ); 
    149149} 
    150150 
     
    165165    ok($foo ~~ Foo6a, '... our Foo6a instance was created'); 
    166166         
    167     is($foo.bar,        1, "getting a public rw attribute (1)", :todo<bug>); 
    168     is($foo.baz,        5, "getting a public rw attribute (2)"); 
    169     is($foo.get_hidden, 3, "getting a private ro attribute (3)", :todo<bug>); 
     167    is($foo.bar,        1, "getting a public rw attribute (1)"  ); 
     168    is($foo.baz,        5, "getting a public rw attribute (2)"  ); 
     169    is($foo.get_hidden, 3, "getting a private ro attribute (3)" ); 
    170170} 
    171171 
     
    226226$foo7    = Foo7.new( :bar(4), :baz(5) ); 
    227227is( $foo7.bar, 4, 
    228     'optional attribute should take passed-in value over default', :todo<bug> ); 
     228    'optional attribute should take passed-in value over default' ); 
    229229is( $foo7.baz, 10, 
    230230    '... optional non-attribute should too' );