Download odp - Small eigen collider

Transcript

Small Eigen Collider

Creating random ruby programs

Andrew Grimm

Rationale

Unit tests of existing projects failed on Rubinius because of bugs in things like String#split or StringIO#gets

If I could generate random programs, I could see whether less popular implementations did the same thing as more popular implementations

Producing random code

result = @receiver.send(@method, @parameter_objects, &:inspect)

Where @receiver and @parameter_objects are randomly chosen objects, and @method is a randomly chosen method name.

Logging the results

Currently printing the receiver, method, parameter objects and the result

Receiver object: aMethod: casecmpParameters: [b]Result: -1

Comparing the results

Run the script under different ruby versions

Do a diff on the outputs

Example of a diff

Lines above were running a.casecmp(b)

diff MRI_output.txt rubinius_output.txt 180c180< Result: -1---> Result: 1

Contents of the two files

MRI_output.txt

Receiver object: "a"Method: "casecmp"Parameters: ["b"]Result: -1

rubinius_output.txt

Receiver object: aMethod: casecmpParameters: [b]Result: 1

Manual confirmation

rvm ruby -e 'puts [RUBY_ENGINE, a.casecmpb].join(\t)jruby -1 macruby -1 ruby -1 rbx 1


Recommended