Skip to content

Commit a986766

Browse files
committed
[GR-16397] Implement rb_enc_sprintf.
PullRequest: truffleruby/887
2 parents 00b0956 + 603ed94 commit a986766

File tree

4 files changed

+15
-19
lines changed

4 files changed

+15
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Compatibility:
1111
* `Integer#{ceil,floor,truncate}` now accept a precision and `Integer#round` accepts a rounding mode.
1212
* Added missing `Enumerable#filter` and `Enumerator::Lazy#filter` aliases to the respective `select` method (#1610).
1313
* Implement more `Ripper` methods as no-ops (#1694).
14+
* Implemented `rb_enc_sprintf` (#1702).
1415

1516
# 20.0.0 beta 1
1617

src/main/c/cext/ruby.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,14 @@ void rb_enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...) {
13091309
}
13101310

13111311
VALUE rb_enc_sprintf(rb_encoding *enc, const char *format, ...) {
1312-
rb_tr_error("rb_enc_sprintf not implemented");
1312+
VALUE result;
1313+
va_list ap;
1314+
1315+
va_start(ap, format);
1316+
result = rb_enc_vsprintf(enc, format, ap);
1317+
va_end(ap);
1318+
1319+
return result;
13131320
}
13141321

13151322
int rb_enc_to_index(rb_encoding *enc) {

test/mri/excludes/Test_SPrintf.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,16 @@
22
exclude :"test_format_integer(% #+-00.d)", "needs investigation"
33
exclude :"test_format_integer(% #+-020d)", "needs investigation"
44
exclude :"test_format_integer(% #-00.d)", "needs investigation"
5-
exclude :"test_format_integer(% #-00d)", "needs investigation"
65
exclude :"test_format_integer(% #-020.d)", "needs investigation"
76
exclude :"test_format_integer(% #-020d)", "needs investigation"
87
exclude :"test_format_integer(% #0.d)", "needs investigation"
9-
exclude :"test_format_integer(% #20d)", "needs investigation"
108
exclude :"test_format_integer(% +-0.0d)", "needs investigation"
11-
exclude :"test_format_integer(% +-0d)", "needs investigation"
129
exclude :"test_format_integer(% +-20.0d)", "needs investigation"
13-
exclude :"test_format_integer(% +-20d)", "needs investigation"
1410
exclude :"test_format_integer(%#+0.d)", "needs investigation"
1511
exclude :"test_format_integer(%#+05.d)", "needs investigation"
16-
exclude :"test_format_integer(%#+05d)", "needs investigation"
17-
exclude :"test_format_integer(%#+0d)", "needs investigation"
1812
exclude :"test_format_integer(%+-05.0d)", "needs investigation"
19-
exclude :"test_format_integer(%+-0d)", "needs investigation"
2013
exclude :"test_format_integer(%.0d)", "needs investigation"
2114
exclude :"test_format_integer(%5.0d)", "needs investigation"
22-
exclude :"test_format_integer(%5d)", "needs investigation"
23-
exclude :"test_format_integer(%d)", "needs investigation"
24-
exclude :test_inspect, "needs investigation"
2515
exclude :test_quote, "needs investigation"
26-
exclude :test_string_prec, "needs investigation"
2716
exclude :test_taint, "needs investigation"
28-
exclude :test_to_str, "needs investigation"
2917
exclude :test_snprintf_count, "needs investigation"

tool/parse_mri_errors.rb

100644100755
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
## Expirimental MRI test tagging script
2-
## Needs to be run from the jruby/test/mri directory
3-
## Error console output read from stdin or the first argument
1+
#!/usr/bin/env ruby
2+
## Experimental MRI test tagging script from a test run log
3+
## The input is read from stdin or the first argument
44

55
# Usage:
6-
# ruby tool/parse_mri_errors.rb output.txt
6+
# tool/parse_mri_errors.rb output.txt
77
# or
8-
# jt test test/mri/tests/rdoc/test_rdoc_token_stream.rb | ruby tool/parse_mri_errors.rb
8+
# jt test mri test/mri/tests/rdoc/test_rdoc_token_stream.rb | tool/parse_mri_errors.rb
99

1010
REASON = ENV.fetch('REASON', 'needs investigation')
1111

@@ -47,7 +47,7 @@
4747
repo_root = File.expand_path("../..", __FILE__)
4848
excludes = "#{repo_root}/test/mri/excludes"
4949

50-
t = /((?:\w+::)?\w+)#(\S+)(?:\s*\[.+\])?:$/
50+
t = /((?:\w+::)?\w+)#(.+?)(?:\s*\[(?:[^\]])+\])?:$/
5151
contents.scan(t) do |class_name, test_method, result|
5252
file = excludes + "/" + class_name.split("::").join('/') + ".rb"
5353
unless result == "."

0 commit comments

Comments
 (0)