Skip to content

Instantly share code, notes, and snippets.

@bjfish
bjfish / test_workarounds.patch
Created April 14, 2015 13:45
Cleaned up Fixes and Workarounds to run `jt test mri test_set.rb`
diff --git a/lib/ruby/stdlib/optparse.rb b/lib/ruby/stdlib/optparse.rb
index 4ec891e..5a27f8e 100644
--- a/lib/ruby/stdlib/optparse.rb
+++ b/lib/ruby/stdlib/optparse.rb
@@ -264,6 +264,8 @@ class OptionParser
end
def self.candidate(key, icase = false, pat = nil, &block)
+ return [[:never, [:never], "never"]] if key == "never"
+ return [[:no, [:no], "no"]] if key == "no"
echo 'jt test mri ruby/test_alias.rb' && jt test mri ruby/test_alias.rb || echo 'jt test mri ruby/test_array.rb' && jt test mri ruby/test_array.rb || echo 'jt test mri ruby/test_assignment.rb' && jt test mri ruby/test_assignment.rb || echo 'jt test mri ruby/test_autoload.rb' && jt test mri ruby/test_autoload.rb || echo 'jt test mri ruby/test_basicinstructions.rb' && jt test mri ruby/test_basicinstructions.rb || echo 'jt test mri ruby/test_beginendblock.rb' && jt test mri ruby/test_beginendblock.rb || echo 'jt test mri ruby/test_bignum.rb' && jt test mri ruby/test_bignum.rb || echo 'jt test mri ruby/test_call.rb' && jt test mri ruby/test_call.rb || echo 'jt test mri ruby/test_case.rb' && jt test mri ruby/test_case.rb || echo 'jt test mri ruby/test_class.rb' && jt test mri ruby/test_class.rb || echo 'jt test mri ruby/test_clone.rb' && jt test mri ruby/test_clone.rb || echo 'jt test mri ruby/test_comparable.rb' && jt test mri ruby/test_comparable.rb || echo 'jt test mri ruby/test_complex.rb' && jt test mri ruby/
@bjfish
bjfish / mktmpdir.patch
Created April 16, 2015 13:25
Dir.mktmpdir workarounds - you may need to adjust tmp dir path to `echo $TMPDIR`
diff --git a/lib/ruby/stdlib/tmpdir.rb b/lib/ruby/stdlib/tmpdir.rb
index 9ba06d5..5b4b143 100644
--- a/lib/ruby/stdlib/tmpdir.rb
+++ b/lib/ruby/stdlib/tmpdir.rb
@@ -30,11 +30,11 @@ class Dir
for dir in [ENV['TMPDIR'], ENV['TMP'], ENV['TEMP'], @@systmpdir, '/tmp', '.']
next if !dir
dir = File.expand_path(dir)
- if stat = File.stat(dir) and stat.directory? and stat.writable? and
- (!(@@using_19 && stat.world_writable?) || stat.sticky?)
@Specialization
public Object stringByteSubstring(RubyString string, long index, int length) {
return stringByteSubstring(string, (int) index, length);
}
@Specialization
public Object stringByteSubstring(RubyString string, int index, long length) {
return stringByteSubstring(string, index, (int) length);
}
@bjfish
bjfish / running_rake.rb
Last active August 29, 2015 14:19
Run a small Rakefile Tutorial with ruby/rake
# Add a small Rakefile to current directory
task :default => [:test]
task :test do
puts "Hello Rake"
end
# Rake's file_utils.rb needs the following small workaround/change:
RUBY = '/Users/brandonfish/Documents/jruby-mine/bin/jruby'
# ENV['RUBY'] || File.join(
@bjfish
bjfish / parse_mri_errors.rb
Created April 20, 2015 13:45
Parse Test Output to generate index and exclude files.
file = File.open("../../../jruby-patches/test_output_more.txt", "rb")
contents = file.read
# sep = "TEST_SEPARATOR"
# results = contents.split(sep)
load_error_output = "0 tests, 0 assertions, 0 failures, 0 errors, 0 skips"
@bjfish
bjfish / pack_test.rb
Created April 21, 2015 16:27
Some pack usage found in the wild.
Infinity = Float::INFINITY
NaN = Float::NAN
def assert_equal(one, two)
raise "Expected: `#{one.b}` Actual: `#{two}`" if one.b != two
end
assert_equal("z",([] << 122).pack('C*'))
assert_equal("\x12",([] << 18).pack('C*'))
assert_equal("\x04",([] << 4).pack('C*'))
assert_equal("\x06",([] << 6).pack('C*'))
assert_equal("\b",([] << 8).pack('C*'))
@CoreMethod(names = "home_directory", onSingleton = true)
public abstract static class HomeDirectoryNode extends CoreMethodNode {
public HomeDirectoryNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
public HomeDirectoryNode(HomeDirectoryNode prev) {
super(prev);
}
@bjfish
bjfish / gist:92d734fa34c96171b5f3
Created April 30, 2015 13:59
Tried some Gem commands
./bin/jruby -X+T -S gem -v
2.4.6
./bin/jruby -X+T -S gem -h
RubyGems is a sophisticated package manager for Ruby. This is a
basic help message containing pointers to more information.
Usage:
gem -h/--help
gem -v/--version
1) Failure:
TC_Set#test_eq [ from /Users/brandonfish/Documents/jruby/test/mri/test_set.rb:522]:
<#<Set: {"a", "b", #<: {"a", "b", #<: {"a", "b"}>}>}>> expected but was
<#<Set: {"a", "b", #<: {"a", "b", #<: {"a", "b"}>}>}>>.