Closed ahumenberger closed 5 days ago
For new transpilation tasks, there needs to be some small changes to how the eval figures out which languages are targeted. Cause right now if we have Go as transpilation source, it automatically assumes Java must be the target cause no other language existed yet.
mistakes
repositoryFor Java and Go we check for compilation errors with:
go build
mvn compile
Since Ruby is an interpreted language, there is no compilation step. I tried the following approaches.
Check Ruby's syntax with ruby -c lib/<ruby-file>
(see Command line options)
lib/end_keyword_missing.rb:9: syntax error, unexpected end-of-input, expecting keyword_end
Conclusion: only only error caught
Running rake test
at the root of the repository
Run options: --seed 64839
# Running:
EEE
Finished in 0.000889s, 3373.6712 runs/s, 0.0000 assertions/s.
1) Error:
TestArgumentMissing#test_argument_missing2:
ArgumentError: wrong number of arguments (given 1, expected 0)
/home/rui/dev/ruby/playground/mist/argumentMissing/lib/argument_missing.rb:1:in `argument_missing'
/home/rui/dev/ruby/playground/mist/argumentMissing/test/argument_missing_test.rb:15:in `test_argument_missing2'
2) Error:
TestArgumentMissing#test_argument_missing3:
ArgumentError: wrong number of arguments (given 1, expected 0)
/home/rui/dev/ruby/playground/mist/argumentMissing/lib/argument_missing.rb:1:in `argument_missing'
/home/rui/dev/ruby/playground/mist/argumentMissing/test/argument_missing_test.rb:22:in `test_argument_missing3'
3) Error:
TestArgumentMissing#test_argument_missing1:
ArgumentError: wrong number of arguments (given 1, expected 0)
/home/rui/dev/ruby/playground/mist/argumentMissing/lib/argument_missing.rb:1:in `argument_missing'
/home/rui/dev/ruby/playground/mist/argumentMissing/test/argument_missing_test.rb:8:in `test_argument_missing1'
3 runs, 0 assertions, 0 failures, 3 errors, 0 skips
rake aborted!
Command failed with status (1)
Tasks: TOP => test
(See full trace by running task with --trace)
/home/rui/dev/ruby/playground/mist/variableUnknown/lib/variable_unknown.rb:2: warning: possibly useless use of == in void context
Run options: --seed 59116
# Running:
EEE
Finished in 0.000951s, 3153.5992 runs/s, 0.0000 assertions/s.
1) Error:
TestVariableUnknown#test_variable_unknown2:
NameError: undefined local variable or method `y' for #<TestVariableUnknown:0x000055b56a9accf0>
/home/rui/dev/ruby/playground/mist/variableUnknown/lib/variable_unknown.rb:2:in `variable_unknown'
/home/rui/dev/ruby/playground/mist/variableUnknown/test/variable_unknown_test.rb:15:in `test_variable_unknown2'
2) Error:
TestVariableUnknown#test_variable_unknown1:
NameError: undefined local variable or method `y' for #<TestVariableUnknown:0x000055b56a9ac160>
/home/rui/dev/ruby/playground/mist/variableUnknown/lib/variable_unknown.rb:2:in `variable_unknown'
/home/rui/dev/ruby/playground/mist/variableUnknown/test/variable_unknown_test.rb:8:in `test_variable_unknown1'
3) Error:
TestVariableUnknown#test_variable_unknown3:
NameError: undefined local variable or method `y' for #<TestVariableUnknown:0x000055b56a6eddc0>
/home/rui/dev/ruby/playground/mist/variableUnknown/lib/variable_unknown.rb:2:in `variable_unknown'
/home/rui/dev/ruby/playground/mist/variableUnknown/test/variable_unknown_test.rb:22:in `test_variable_unknown3'
3 runs, 0 assertions, 0 failures, 3 errors, 0 skips
rake aborted!
Command failed with status (1)
Tasks: TOP => test
(See full trace by running task with --trace)
Conclusion: It catches all errors, but the structure of syntax errors are different from runtime errors.
Adding a call.rb
that calls the function defined in lib/<ruby-source-file
, then running ruby call.rb
and check the output
Example of call.rb
require_relative 'lib/end_keyword_missing'
end_keyword_missing(1)
Conclusion: better error messages. All errors have the same structure
ruby -c
only checks for syntax errors. We can only catch one error within 5 packagesrake test
call.rb
Claude suggested rubocop, it has JSON formatted output: https://docs.rubocop.org/rubocop/formatters.html#json-formatter
All PRs are merged so closing this one.
We want to add language support for Ruby.
ExecuteTests
method in the Ruby language #327symflower test
Mistakes
method in the Ruby languagetranspile-java
,transpile-ruby
, instead of justtranspile
so it is clear which language we are transpiling fromFollow-up