alpha-vary, generate-constraints, and unify testing

7 views
Skip to first unread message

Jake

unread,
Apr 11, 2011, 8:18:42 PM4/11/11
to byu-cs-330-Winter-2011
Is there a way to test alpha-vary, generate-constraints, and/or
unify? The test=? function Dr. Morse gave us seems to be for infer-
type, but I don't think we can use it for the other three. Do we just
include the testing for the other three in our testing of infer-type?

Thanks

Bryan Morse

unread,
Apr 11, 2011, 8:38:54 PM4/11/11
to byu-cs-330-...@googlegroups.com
The constraint-list=? function provided with the other testing functions will test to see if two constraint lists are the same other than renaming of type variables. This can be used to write tests explicitly for generate-constraints and unify, which will allow you to verify/demonstrate that each part is working before moving on to implementing the next.

Note: even though constraint-list=? handles differences in type variable naming, it still requires that the two constraint lists be in the same order.

James Fiala

unread,
Apr 12, 2011, 7:47:25 PM4/12/11
to byu-cs-330-...@googlegroups.com
So I asked explicitly about alpha-vary, but will we get any points for
testing generate-constraints and unify, or will all points come from
just testing infer-type and parse?

I ask because we have 40 some odd test cases for parse but we only
need 83 to get full credit, and it seems like testing all of these
with test cases could push us way over 400 points.

Bryan Morse

unread,
Apr 13, 2011, 10:38:16 AM4/13/11
to byu-cs-330-...@googlegroups.com
Yes, you need to test generate-constraints and unify separately, and these are given credit.

The assignment said you may assume syntactically valid input for the parser. You might have a handful of test cases there to verify that you get correct output for correct input, but 40 seems like a lot of redundancy if you're only testing valid input.

For generate-constraints you should probably have around one test case per production in the grammar to ensure code coverage and to verify that each produces the correct sets of constraints.

For unify you should make sure to include simple tests for each of the different branches in the algorithm, and you should have cases that make sure your substitution (in the constraint list and the substitution list) are working.

Most of the rest of the cases should be for infer-type to verify that the alpha-vary, generate-constraints, and unify functions all work together correctly to handle some fairly complex inference cases.

Reply all
Reply to author
Forward
0 new messages