Skip to content

Commit cc6333d

Browse files
committed
Use Enum#toString() in Truffle::Boot.get_option
1 parent 9b62401 commit cc6333d

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

spec/truffle/options/parsing_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
end
2323

2424
it "enum values" do
25-
ruby_exe("p Truffle::Boot.get_option('verbose')").should_not == ":NIL\n"
26-
ruby_exe("p Truffle::Boot.get_option('verbose')", options: "--verbose=NIL").should == ":NIL\n"
27-
ruby_exe("p Truffle::Boot.get_option('verbose')", options: "--verbose").should == ":TRUE\n"
25+
ruby_exe("p Truffle::Boot.get_option('verbose')").should_not == ":nil\n"
26+
ruby_exe("p Truffle::Boot.get_option('verbose')", options: "--verbose=nil").should == ":nil\n" # TODO
27+
ruby_exe("p Truffle::Boot.get_option('verbose')", options: "--verbose").should == ":true\n"
2828
end
2929

3030
it "strings" do
@@ -49,7 +49,7 @@
4949
end
5050

5151
it "enum values" do
52-
ruby_exe("14", options: "--verbose=foo", args: "2>&1", exit_status: 1).should.include?("Invalid argument --verbose=foo specified. No enum constant org.truffleruby.shared.options.Verbosity.FOO")
52+
ruby_exe("14", options: "--verbose=foo", args: "2>&1", exit_status: 1).should.include?("ERROR: Invalid argument --verbose=foo specified. Invalid option value 'foo'. Valid options values are: 'nil', 'false', 'true'")
5353
end
5454
end
5555
end

src/main/java/org/truffleruby/language/TruffleBootNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ protected Object getOption(Object optionName,
343343
if (value instanceof Boolean || value instanceof Integer) {
344344
return value;
345345
} else if (value instanceof Enum) {
346-
return getSymbol(((Enum<?>) value).name());
346+
return getSymbol(value.toString());
347347
} else if (value instanceof String) {
348348
return makeStringNode.executeMake(value, Encodings.UTF_8, CodeRange.CR_UNKNOWN);
349349
} else if (value instanceof String[]) {

src/main/ruby/truffleruby/core/truffle/kernel_operations.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ def $LOAD_PATH.resolve_feature_path(file_name)
134134
Truffle::Boot.redo do
135135
$DEBUG = Truffle::Boot.get_option_or_default('debug', false)
136136
$VERBOSE = case Truffle::Boot.get_option_or_default('verbose', false)
137-
when :TRUE
137+
when :true
138138
true
139-
when :FALSE
139+
when :false
140140
false
141-
when :NIL
141+
when :nil
142142
nil
143143
end
144144
end

src/main/ruby/truffleruby/core/truffle/regexp_operations.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def self.match_stats(joni_matches:)
175175
def self.print_stats
176176
output_format = Truffle::Boot.get_option('regexp-instrumentation-output-format')
177177

178-
if output_format == :TEXT
178+
if output_format == :text
179179
puts '--------------------'
180180
puts 'Regular expression statistics'
181181
puts '--------------------'
@@ -204,7 +204,7 @@ def self.print_stats
204204

205205
puts '--------------------'
206206
end
207-
elsif output_format == :JSON
207+
elsif output_format == :json
208208
ret = {}
209209

210210
if Truffle::Boot.get_option('regexp-instrument-creation')

0 commit comments

Comments
 (0)