Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fix some error message in Struct#[] #278

Merged
merged 1 commit into from

3 participants

Kenichi Kamiya Don't Add Me To Your Organization a.k.a The Travis Bot Charles Oliver Nutter
Kenichi Kamiya

For below case.

Foo = Struct.new :foo
foo = Foo.new true

MRI/YARV

ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]

foo[-2]   #=> offset -1 too small for struct(size:1) (IndexError)
foo[:bar] #=> no member 'bar' in struct (NameError)

JRuby

jruby 1.7.0.preview2 (1.9.3p203) 2012-08-31 aeef1b8 on Java HotSpot(TM) 64-Bit Server VM 1.6.0_33-b03-424-11M3720 [darwin-x86_64]

foo[-2]   #=> IndexError: offset -1 too large for struct (size:1)
foo[:bar] #=> NameError: bar is not struct member
Don't Add Me To Your Organization a.k.a The Travis Bot

This pull request fails (merged 17fa907 into b247119).

Charles Oliver Nutter headius merged commit 5e1ea4a into from
Kenichi Kamiya kachick deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 31, 2012
  1. Kenichi Kamiya
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 5 deletions.
  1. +5 −5 src/org/jruby/RubyStruct.java
10 src/org/jruby/RubyStruct.java
View
@@ -471,7 +471,7 @@ public IRubyObject set(IRubyObject value, int index) {
}
private RaiseException notStructMemberError(String name) {
- return getRuntime().newNameError(name + " is not struct member", name);
+ return getRuntime().newNameError("no member '" + name + "' in struct", name);
}
public IRubyObject get(int index) {
@@ -624,9 +624,9 @@ public IRubyObject aref(IRubyObject key) {
idx = idx < 0 ? values.length + idx : idx;
if (idx < 0) {
- throw getRuntime().newIndexError("offset " + idx + " too large for struct (size:" + values.length + ")");
+ throw getRuntime().newIndexError("offset " + idx + " too small for struct(size:" + values.length + ")");
} else if (idx >= values.length) {
- throw getRuntime().newIndexError("offset " + idx + " too large for struct (size:" + values.length + ")");
+ throw getRuntime().newIndexError("offset " + idx + " too large for struct(size:" + values.length + ")");
}
return values[idx];
@@ -643,9 +643,9 @@ public IRubyObject aset(IRubyObject key, IRubyObject value) {
idx = idx < 0 ? values.length + idx : idx;
if (idx < 0) {
- throw getRuntime().newIndexError("offset " + idx + " too large for struct (size:" + values.length + ")");
+ throw getRuntime().newIndexError("offset " + idx + " too small for struct(size:" + values.length + ")");
} else if (idx >= values.length) {
- throw getRuntime().newIndexError("offset " + idx + " too large for struct (size:" + values.length + ")");
+ throw getRuntime().newIndexError("offset " + idx + " too large for struct(size:" + values.length + ")");
}
modify();
Something went wrong with that request. Please try again.