Today I finally put the QuickCheck technology to use, having it generate a large number of PIL expressions and check that invariants hold.
For example, this property declares that untie()
accepts any lvalue arguments:
prop_untie :: LV -> Bool prop_untie x = try_ok (Untie x)
Based on the type signature, when I type test prop_untie
in the ghci prompt, QuickCheck will generate 100 of random expressions that can evaluate to a lvalue, run them through Untie
, and check that all of them succeeds.
I am gradually converting hand-crafted unit tests into this kind of invariant-based tests. This process prompted me to see the language in a different light: not as a black box with external expectations defined by individual unit tests, but rather a well-behaved system with invariant properties. Of course, such verifiable specification is still not as good as a proof -- but it is much more cheap and cheerful than other test methodologies that I know of.
During the quick checking, a question arises: what is the meaning of
iblech and I also noticed that function parameter binding and normal variable binding are symmetric:
Currently the
Finally, I have posted a preliminary solution to the dreaded The new smoke is online [r5930] (compare with r5904), showing that PIL2JS passes 57.07% of Pugs' testsuite, with 28 unexpected successes. You can also browse the testsuite, compiled to JS. FYI, compiling the whole suite to JS took 5min 40s; compiling and running using Spidermonkey's Test failures are mainly due to --Ingountie(&say)
? Perl 5 does not have this problem, as &say
is a function call there -- you cannot address a function by name. In Perl 6, it seems to me that my &foo
is merely a constrained version of scalar variable my Code $foo
, and &foo = sub { ... }
should work as usual. I have brought this to p6l for discussion.
sub f ($a, $b) {
return (c => $a, d => $b)
}
($c, $d) := f(a => $a, b => $b);
return
side is not specified to observe the same rich binding semantics as the parameter side; moreover, named return values are not expressible. We think that it makes sense to unify both representations into the same binding form.
$x = $x + my $x if $x;
problem that haunted us during the hackathon. Enjoy!
PIL2JS passes 57.07% of the testsuite :)
iblech on 2005-07-31T18:54:16
bin/js
took 29min (with -j1
).
&eval
, of course, not working,