Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ba40478f9cba
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 793d175bf266
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Oct 15, 2015

  1. Copy the full SHA
    51cd5fe View commit details
  2. Copy the full SHA
    793d175 View commit details
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -5251,6 +5251,7 @@ public IRubyObject force_encoding(ThreadContext context, IRubyObject enc) {
}

private IRubyObject force_encoding(Encoding encoding) {
modifyCheck();
modify19();
associateEncoding(encoding);
clearCodeRange();
5 changes: 5 additions & 0 deletions spec/ruby/core/string/force_encoding_spec.rb
Original file line number Diff line number Diff line change
@@ -44,5 +44,10 @@
str = "\u{8612}"
str.dup.force_encoding('utf-16le').should_not == str.encode('utf-16le')
end

it "raises a RuntimeError if self is frozen" do
str = "abcd".freeze
lambda { str.force_encoding(str.encoding) }.should raise_error(RuntimeError)
end
end
end
Original file line number Diff line number Diff line change
@@ -1140,7 +1140,7 @@ public DynamicObject encoding(DynamicObject string) {
}
}

@CoreMethod(names = "force_encoding", required = 1)
@CoreMethod(names = "force_encoding", required = 1, raiseIfFrozenSelf = true)
public abstract static class ForceEncodingNode extends CoreMethodArrayArgumentsNode {

@Child private ToStrNode toStrNode;