Commit b77b1513

b77b151344b6Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 2 files · +1 added · ~1 modified

Description

test: cover float_array shuffle and String#% str_array form

Extend bm_shuffle.rb with FloatArray cases plus empty/single-element edges (the latter two regression-test the loop bounds in sp_*_shuffle_bang). New bm_str_format_arr.rb covers sp_str_format_strarr on the cases the runtime supports cleanly: single placeholder, multiple placeholders, %% literal, surrounding text, extra-args-ignored, and no-placeholders-args-ignored. Strict CRuby semantics (ArgumentError on too-few args) are intentionally not tested — the helper currently fills missing slots with the empty string, and matching CRuby's error would be a separate behavioural change.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
b77b151344b6
Parent
c0c0d0b0a12c

test/bm_shuffle.rbmodifiedView file

@@ -17,3 +17,19 @@
1717 nums.shuffle!
1818 puts nums.length
1919 puts nums.sort.join(",")
20+
21+# FloatArray
22+floats = [1.5, 2.5, 3.5, 4.5]
23+fs = floats.shuffle
24+puts fs.length # 4
25+puts floats.length # 4 (original unchanged)
26+floats.shuffle!
27+puts floats.length # 4 (in-place, length stable)
28+
29+# Empty / single-element edge cases stay stable.
30+empty = []
31+empty.shuffle!
32+puts empty.length # 0
33+one = [42]
34+one.shuffle!
35+puts one[0] # 42