🕷 zenspider.com

by ryan davis

Looking for the Ruby Quickref?

Better way to test multi-layered code?

Published 2008-08-06 @ 09:22

Tagged ruby, ruby2c, zentest, minitest

add_tests(“lasgn_call”, “Rewriter” => :same, “TypeChecker” => t(:lasgn, :c, t(:call, t(:lit, 2, Type.long), :+, t(:arglist, t(:lit, 3, Type.long)), Type.long), Type.long), “CRewriter” => :same, “RubyToAnsiC” => “c = 2 + 3”, # FIX: probably not “c = …” “RubyToRubyC” => ‘c = rb_funcall(LONG2NUM(2), rb_intern(“+”), 1, LONG2NUM(3))’)

Can you think of a better / cleaner way? This generates 5 test_lasgn_call methods in 5 different test classes. :same says “use previous output as my input”, and Rewriter gets its input from ParseTree’s test suite.

I’ve got 297 of these add_tests method calls. Gah. Just seems a bit much, but I can’t really think of a better way ATM.