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: dcc350157573
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 58646493703e
Choose a head ref
  • 13 commits
  • 21 files changed
  • 1 contributor

Commits on Apr 2, 2016

  1. Copy the full SHA
    5030e43 View commit details
  2. Copy the full SHA
    8a9c48e View commit details
  3. Copy the full SHA
    b7f855c View commit details
  4. Copy the full SHA
    8f8cce1 View commit details
  5. Copy the full SHA
    d145a9e View commit details
  6. Copy the full SHA
    7b265a7 View commit details
  7. Copy the full SHA
    57d0812 View commit details
  8. Copy the full SHA
    547f698 View commit details
  9. Add a spec for string literal freeze magic comment, where the literal…

    …s are in different files.
    chrisseaton committed Apr 2, 2016
    Copy the full SHA
    abdeb10 View commit details
  10. [Truffle] Tag and mark as slow two string literals with freeze magic …

    …comment in different files spec.
    chrisseaton committed Apr 2, 2016
    Copy the full SHA
    86d3d5e View commit details
  11. Add a spec for string literal freeze magic comment, where the literal…

    …s are in different files but have different encodings.
    chrisseaton committed Apr 2, 2016
    Copy the full SHA
    c95880e View commit details
  12. Copy the full SHA
    417c3f0 View commit details
  13. Add a spec for string literal freeze magic comment, where there is th…

    …e same literal but in a file without the comment.
    chrisseaton committed Apr 2, 2016
    Copy the full SHA
    5864649 View commit details
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -224,7 +224,7 @@ public class Options {

public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE = bool(TRUFFLE, "truffle.platform.safe", false, "Disallow any unsafe access to the platform, such as IO, processes and so on.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_PROCESSES = bool(TRUFFLE, "truffle.platform.safe.processes", false, "Treat any methods that deal with processes as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_EXIT = bool(TRUFFLE, "truffle.platform.safe.exit", false, "Treat exiting the VM as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_EXIT = bool(TRUFFLE, "truffle.platform.safe.exit", false, "Treat #exit! (hard exiting the VM) as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_SAFE_PUTS = bool(TRUFFLE, "truffle.platform.safe_puts", true, "Treat Truffle::Primitive.safe_puts as safe.");
public static final Option<Boolean> TRUFFLE_PLATFORM_USE_JAVA = bool(TRUFFLE, "truffle.platform.use_java", false, "Use a pure-Java platform, so no native POSIX.");

3 changes: 3 additions & 0 deletions spec/ruby/command_line/fixtures/freeze_flag_across_files.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require_relative 'freeze_flag_required'

p "abc".freeze.object_id == $second_literal_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require_relative 'freeze_flag_required_diff_enc'

p "abc".freeze.object_id != $second_literal_id
2 changes: 2 additions & 0 deletions spec/ruby/command_line/fixtures/freeze_flag_one_literal.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ids = Array.new(2) { "abc".freeze.object_id }
p ids.first == ids.last
1 change: 1 addition & 0 deletions spec/ruby/command_line/fixtures/freeze_flag_required.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$second_literal_id = "abc".freeze.object_id
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
p "abc".freeze.object_id == "abc".freeze.object_id
21 changes: 21 additions & 0 deletions spec/ruby/command_line/frozen_strings_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require File.expand_path('../../spec_helper', __FILE__)

describe "The --enable-frozen-string-literal flag causes string literals to" do

it "produce the same object each time" do
ruby_exe(fixture(__FILE__, "freeze_flag_one_literal.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
end

it "produce the same object for literals with the same content" do
ruby_exe(fixture(__FILE__, "freeze_flag_two_literals.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
end

it "produce the same object for literals with the same content in different files" do
ruby_exe(fixture(__FILE__, "freeze_flag_across_files.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
end

it "produce different objects for literals with the same content in different files if they have different encodings" do
ruby_exe(fixture(__FILE__, "freeze_flag_across_files_diff_enc.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
end

end
14 changes: 14 additions & 0 deletions spec/ruby/core/string/freeze_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.expand_path('../../../spec_helper', __FILE__)

describe "String#freeze" do

it "produces the same object whenever called on an instance of a literal in the source" do
ids = Array.new(2) { "abc".freeze.object_id }
ids.first.should == ids.last
end

it "doesn't produce the same object for different instances of literals in the source" do
"abc".object_id.should_not == "abc".object_id
end

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

require_relative 'freeze_magic_comment_required'

p "abc".freeze.object_id == $second_literal_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

require_relative 'freeze_magic_comment_required_diff_enc'

p "abc".freeze.object_id != $second_literal_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

require_relative 'freeze_magic_comment_required_no_comment'

p "abc".freeze.object_id != $second_literal_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

ids = Array.new(2) { "abc".freeze.object_id }
p ids.first == ids.last
3 changes: 3 additions & 0 deletions spec/ruby/language/fixtures/freeze_magic_comment_required.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

$second_literal_id = "abc".freeze.object_id
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$second_literal_id = "abc".freeze.object_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

p "abc".freeze.object_id == "abc".freeze.object_id
21 changes: 21 additions & 0 deletions spec/ruby/language/string_spec.rb
Original file line number Diff line number Diff line change
@@ -284,6 +284,27 @@ def long_string_literals
it "on multiple lines with newlines and backslash in between are concatenated together" do
long_string_literals.should == "Beautiful is better than ugly.Explicit is better than implicit."
end

it "with a magic frozen comment produce the same object each time" do
ruby_exe(fixture(__FILE__, "freeze_magic_comment_one_literal.rb")).chomp.should == "true"
end

it "with a magic frozen comment produce the same object for literals with the same content" do
ruby_exe(fixture(__FILE__, "freeze_magic_comment_two_literals.rb")).chomp.should == "true"
end

it "with a magic frozen comment produce the same object for literals with the same content in different files" do
ruby_exe(fixture(__FILE__, "freeze_magic_comment_across_files.rb")).chomp.should == "true"
end

it "with a magic frozen comment produce different objects for literals with the same content in different files if the other file doesn't have the comment" do
ruby_exe(fixture(__FILE__, "freeze_magic_comment_across_files_no_comment.rb")).chomp.should == "true"
end

it "with a magic frozen comment produce different objects for literals with the same content in different files if they have different encodings" do
ruby_exe(fixture(__FILE__, "freeze_magic_comment_across_files_diff_enc.rb")).chomp.should == "true"
end

end

with_feature :encoding do
1 change: 1 addition & 0 deletions spec/truffle/tags/core/string/freeze_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:String#freeze produces the same object whenever called on an instance of a literal in the source
6 changes: 6 additions & 0 deletions spec/truffle/tags/language/string_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fails:Ruby String literals with a magic frozen comment produce the same object each time
slow:Ruby String literals with a magic frozen comment produce the same object each time
fails:Ruby String literals with a magic frozen comment produce the same object for literals with the same content
slow:Ruby String literals with a magic frozen comment produce the same object for literals with the same content
fails:Ruby String literals with a magic frozen comment produce the same object for literals with the same content in different files
slow:Ruby String literals with a magic frozen comment produce the same object for literals with the same content in different files
5 changes: 2 additions & 3 deletions test/truffle/integration/safe.sh
Original file line number Diff line number Diff line change
@@ -5,11 +5,11 @@ function run {
}

function safe {
run "$@" || ( echo "$@" was not safe ; exit 1 )
run "$@" || { echo "$@" was not safe ; exit 1; }
}

function unsafe {
run "$@" && ( echo "$@" was not unsafe ; exit 1 )
run "$@" && { echo "$@" was not unsafe ; exit ; }
}

# Things that are alway safe
@@ -28,7 +28,6 @@ unsafe -Xtruffle.platform.safe_puts=false -e "Truffle::Primitive.safe_puts 'hell

#unsafe -e "puts 'hello, world'"
unsafe -e '`echo foo`'
unsafe -e 'exit'
unsafe -e 'exit!'

# Check we can enable some unsafe operations if we want to