Project

General

Profile

Actions

Bug #6814

closed

Test failures in test_win32ole_variant.rb

Added by h.shirosaki (Hiroshi Shirosaki) over 11 years ago. Updated over 11 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 2.0.0dev (2012-07-30 trunk 36577) [x64-mswin64_100]
Backport:
[ruby-core:46873]

Description

Originally this was reported on RubyInstaller-list by dmajkic.
https://groups.google.com/d/msg/rubyinstaller/a4TS9XAsia0/NkZZOzG6n4wJ

Quote:

This one is about 3 failures I have in "test_win32ole_variant.rb".
Those are:

test_s_array
test_conversion_str2num
test_conversion_ole_variant2ole_variant

After looking at the win32ole.c, I see that the default locale
is LOCALE_SYSTEM_DEFAULT. That means that the locale
is from the Windows, and is not affected by the console settings.

Since I am using "Serbian Latin", which sets coma as decimal
separator (eg. 123456,78), all three tests fail simply because
Windows API tires to convert string to number using wrong locale.
String is in US locale, but conversion API uses system default.

Since WIN32OLE.locale= exists, setting it to 1033 (US English),
solves all three tests as "pass". It looks like this:

def test_conversion_str2num
WIN32OLE.locale = 1033 # set US-Eng locale - number with decimal point
obj = WIN32OLE_VARIANT.new("12.345", WIN32OLE::VARIANT::VT_R8)
assert_equal(12.345, obj.value)
end


I've created the following patch based on above analysis.
It seems to work fine.

https://gist.github.com/3202976

Updated by usa (Usaku NAKAMURA) over 11 years ago

  • Category set to test
  • Status changed from Open to Assigned
  • Assignee changed from luislavena (Luis Lavena) to suke (Masaki Suketa)
  • Target version set to 2.0.0
Actions #2

Updated by suke (Masaki Suketa) over 11 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r36641.
Hiroshi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • test/win32ole/test_win32ole_variant.rb: setting WIN32OLE.locale
    to pass some assertion. Thanks to Hiroshi Shirosaki.
    [ruby-core:46873][Bug #6814]
Actions

Also available in: Atom PDF

Like0
Like0Like0