Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into truffle-head
Browse files Browse the repository at this point in the history
* Do not go to SNAPSHOT versions:
  jnr-ffi:2.1.0-SNAPSHOT
  'jffi.version' => '1.2.13-SNAPSHOT'
  • Loading branch information
eregon committed Sep 27, 2016
2 parents 883bf29 + f6c16b9 commit 7789b7c
Show file tree
Hide file tree
Showing 47 changed files with 425 additions and 273 deletions.
9 changes: 0 additions & 9 deletions core/src/main/java/org/jruby/ast/ArgsNode.java
Expand Up @@ -61,7 +61,6 @@ public class ArgsNode extends Node {
protected final ArgumentNode restArgNode;
private final KeywordRestArgNode keyRest;
private final BlockArgNode blockArgNode;
private ListNode blockLocalVariables = null;

private static final Node[] NO_ARGS = new Node[] {};
/**
Expand Down Expand Up @@ -272,12 +271,4 @@ public int getRequiredKeywordCount() {
}
return count;
}

public ListNode getBlockLocalVariables() {
return blockLocalVariables;
}

public void setBlockLocalVariables(ListNode blockLocalVariables) {
this.blockLocalVariables = blockLocalVariables;
}
}
Expand Up @@ -102,7 +102,8 @@ protected void updateByJavaObject(final Ruby runtime, Object... values) {
} else if (values.length > 1) {
javaType = (Class) values[1];
} else {
javaType = javaObject.getClass();
// When a new object comes in without a target type, clear out cached type
javaType = null;
}
irubyObject = JavaEmbedUtils.javaToRuby(runtime, javaObject);
fromRuby = false;
Expand Down Expand Up @@ -141,9 +142,6 @@ public Object getJavaObject() {
}
else { // Ruby originated variables
javaObject = irubyObject.toJava(Object.class);
if (javaObject != null) {
javaType = javaObject.getClass();
}
}
return javaObject;
}
Expand Down
16 changes: 16 additions & 0 deletions core/src/main/java/org/jruby/ext/ripper/RubyRipper.java
Expand Up @@ -33,11 +33,13 @@
import org.jruby.RubyHash;
import org.jruby.RubyNumeric;
import org.jruby.RubyObject;
import org.jruby.RubyString;
import org.jruby.anno.JRubyMethod;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.lexer.ByteListLexerSource;
import org.jruby.lexer.GetsLexerSource;
import org.jruby.lexer.LexerSource;
import org.jruby.lexer.LexingCommon;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.Visibility;
Expand Down Expand Up @@ -340,6 +342,20 @@ public IRubyObject yydebug_set(ThreadContext context, IRubyObject arg) {
parser.setYYDebug(arg.isTrue());
return arg;
}

@JRubyMethod(meta = true)
public static IRubyObject dedent_string(ThreadContext context, IRubyObject self, IRubyObject _input, IRubyObject _width) {
RubyString input = _input.convertToString();
int wid = _width.convertToInteger().getIntValue();
input.modify19();
int col = LexingCommon.dedent_string(input.getByteList(), wid);
return context.runtime.newFixnum(col);
}

@JRubyMethod
public IRubyObject dedent_string(ThreadContext context, IRubyObject _input, IRubyObject _width) {
return dedent_string(context, this, _input, _width);
}

private LexerSource source(ThreadContext context, IRubyObject src, String filename, int lineno) {
// FIXME: respond_to? returns private methods
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/lexer/LexingCommon.java
Expand Up @@ -122,7 +122,7 @@ public String createTokenString() {
return createTokenString(tokp);
}

protected int dedent_string(ByteList string, int width) {
public static int dedent_string(ByteList string, int width) {
long len = string.realSize();
int i, col = 0;
byte[] str = string.unsafeBytes();
Expand Down
1 change: 0 additions & 1 deletion spec/mspec/bin/mspec-ci
Expand Up @@ -3,6 +3,5 @@
$:.unshift File.expand_path('../../lib', __FILE__)

require 'mspec/commands/mspec-ci'
require 'mspec'

MSpecCI.main
1 change: 0 additions & 1 deletion spec/mspec/bin/mspec-run
Expand Up @@ -3,6 +3,5 @@
$:.unshift File.expand_path('../../lib', __FILE__)

require 'mspec/commands/mspec-run'
require 'mspec'

MSpecRun.main
1 change: 0 additions & 1 deletion spec/mspec/bin/mspec-tag
Expand Up @@ -3,6 +3,5 @@
$:.unshift File.expand_path('../../lib', __FILE__)

require 'mspec/commands/mspec-tag'
require 'mspec'

MSpecTag.main
9 changes: 8 additions & 1 deletion spec/mspec/lib/mspec.rb
Expand Up @@ -4,8 +4,15 @@
require 'mspec/runner'
require 'mspec/guards'
require 'mspec/helpers'
require 'mspec/version'

# If the implementation on which the specs are run cannot
# load pp from the standard library, add a pp.rb file that
# defines the #pretty_inspect method on Object or Kernel.
require 'pp'
begin
require 'pp'
rescue LoadError
module Kernel
alias pretty_inspect inspect
end
end
1 change: 1 addition & 0 deletions spec/mspec/lib/mspec/commands/mspec-ci.rb
Expand Up @@ -70,6 +70,7 @@ def run
tags = ["fails", "critical", "unstable", "incomplete", "unsupported"]
tags += Array(config[:ci_xtags])

require 'mspec/runner/filters/tag'
filter = TagFilter.new(:exclude, *tags)
filter.register

Expand Down
19 changes: 13 additions & 6 deletions spec/mspec/lib/mspec/commands/mspec-run.rb
Expand Up @@ -75,12 +75,19 @@ def options(argv=ARGV)
options.doc ""

patterns = options.parse argv
patterns = config[:files] if patterns.empty?
patterns = ["spec/"] if patterns.empty? and File.directory? "./spec"
if patterns.empty?
puts options
puts "No files specified."
exit 1

unless $0.end_with?("_spec.rb")
if patterns.empty?
patterns = config[:files]
end
if patterns.empty? and File.directory? "./spec"
patterns = ["spec/"]
end
if patterns.empty?
puts options
puts "No files specified."
exit 1
end
end
@files = files patterns
end
Expand Down
2 changes: 2 additions & 0 deletions spec/mspec/lib/mspec/commands/mspec-tag.rb
Expand Up @@ -98,6 +98,8 @@ def options(argv=ARGV)
end

def register
require 'mspec/runner/actions'

case config[:tagger]
when :add, :del
tag = SpecTag.new config[:tag]
Expand Down
4 changes: 0 additions & 4 deletions spec/mspec/lib/mspec/commands/mspec.rb
Expand Up @@ -137,10 +137,6 @@ def multi_exec(argv)
end

def run
ENV['MSPEC_RUNNER'] = '1'
ENV['RUBY_EXE'] = config[:target]
ENV['RUBY_FLAGS'] = config[:flags].join " "

argv = []

argv.concat config[:launch]
Expand Down
28 changes: 14 additions & 14 deletions spec/mspec/lib/mspec/guards/guard.rb
@@ -1,7 +1,6 @@
require 'mspec/runner/mspec'
require 'mspec/runner/actions/tally'

require 'rbconfig'
require 'mspec/utils/ruby_name'

class SpecGuard
def self.report
Expand Down Expand Up @@ -42,29 +41,25 @@ def self.ruby_version_override
@@ruby_version_override
end

# Returns a partial Ruby version string based on +which+. For example,
# if RUBY_VERSION = 8.2.3 and RUBY_PATCHLEVEL = 71:
# Returns a partial Ruby version string based on +which+.
# For example, if RUBY_VERSION = 8.2.3:
#
# :major => "8"
# :minor => "8.2"
# :tiny => "8.2.3"
# :teeny => "8.2.3"
# :full => "8.2.3.71"
# :full => "8.2.3"
def self.ruby_version(which = :minor)
case which
when :major
n = 1
when :minor
n = 2
when :tiny, :teeny
when :tiny, :teeny, :full
n = 3
else
n = 4
end

patch = RUBY_PATCHLEVEL.to_i
patch = 0 if patch < 0
version = "#{ruby_version_override || RUBY_VERSION}.#{patch}"
version = ruby_version_override || RUBY_VERSION
version.split('.')[0,n].join('.')
end

Expand Down Expand Up @@ -165,11 +160,16 @@ def wordsize?(size)
size == 8 * 1.size
end

HOST_OS = begin
require 'rbconfig'
RbConfig::CONFIG['host_os'] || RUBY_PLATFORM
rescue LoadError
RUBY_PLATFORM
end.downcase

def os?(*oses)
oses.any? do |os|
host_os = RbConfig::CONFIG['host_os'] || RUBY_PLATFORM
host_os.downcase!
host_os.match(os.to_s) || windows?(os, host_os)
HOST_OS.match(os.to_s) || windows?(os, HOST_OS)
end
end

Expand Down
5 changes: 2 additions & 3 deletions spec/mspec/lib/mspec/helpers/argf.rb
Expand Up @@ -18,9 +18,8 @@ def argf(argv)
if argv.empty? or argv.length > 2
raise "Only 1 or 2 filenames are allowed for the argf helper so files can be properly closed: #{argv.inspect}"
end
if defined?(@argf) and (@argf || @__mspec_saved_argf_file__)
raise "Cannot nest calls to the argf helper"
end
@argf ||= nil
raise "Cannot nest calls to the argf helper" if @argf

@argf = ARGF.class.new(*argv)
@__mspec_saved_argf_file__ = @argf.file
Expand Down
50 changes: 14 additions & 36 deletions spec/mspec/lib/mspec/helpers/numeric.rb
@@ -1,3 +1,5 @@
require 'mspec/guards/guard'

class Object
def nan_value
0/0.0
Expand All @@ -20,77 +22,53 @@ def bignum_value(plus=0)

if guard.standard? or guard.implementation? :topaz
if guard.wordsize? 32
def fixnum_max()
def fixnum_max
(2**30) - 1
end

def fixnum_min()
def fixnum_min
-(2**30)
end
elsif guard.wordsize? 64
def fixnum_max()
def fixnum_max
(2**62) - 1
end

def fixnum_min()
def fixnum_min
-(2**62)
end
end
elsif guard.implementation? :opal
def fixnum_max()
def fixnum_max
Integer::MAX
end

def fixnum_min()
def fixnum_min
Integer::MIN
end
elsif guard.implementation? :rubinius
def fixnum_max()
def fixnum_max
Fixnum::MAX
end

def fixnum_min()
def fixnum_min
Fixnum::MIN
end
elsif guard.implementation? :jruby
# Values from jruby/test/testFixnumBignumAutoconversion.rb
def fixnum_max()
def fixnum_max
9223372036854775807
end

def fixnum_min()
def fixnum_min
-9223372036854775808
end
elsif guard.implementation? :ironruby
def fixnum_max()
raise "fixnum_max() helper not implemented"
end

def fixnum_min()
raise "fixnum_min() helper not implemented"
end
elsif guard.implementation? :maglev
def fixnum_max()
raise "fixnum_max() helper not implemented"
end

def fixnum_min()
raise "fixnum_min() helper not implemented"
end
elsif guard.implementation? :macruby
def fixnum_max()
raise "fixnum_max() helper not implemented"
end

def fixnum_min()
raise "fixnum_min() helper not implemented"
end
else
def fixnum_max()
def fixnum_max
raise "unknown implementation for fixnum_max() helper"
end

def fixnum_min()
def fixnum_min
raise "unknown implementation for fixnum_min() helper"
end
end
Expand Down
3 changes: 2 additions & 1 deletion spec/mspec/lib/mspec/helpers/ruby_exe.rb
Expand Up @@ -95,9 +95,11 @@ def ruby_exe_options(option)
"ir"
end
when :name
require 'rbconfig'
bin = RUBY_NAME + (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
File.join(".", bin)
when :install_name
require 'rbconfig'
bin = RbConfig::CONFIG["RUBY_INSTALL_NAME"] || RbConfig::CONFIG["ruby_install_name"]
bin << (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
File.join(RbConfig::CONFIG['bindir'], bin)
Expand Down Expand Up @@ -170,7 +172,6 @@ def ruby_cmd(code, opts = {})
end

unless Object.const_defined?(:RUBY_EXE) and RUBY_EXE
require 'rbconfig'
RUBY_EXE = resolve_ruby_exe
end
end
6 changes: 3 additions & 3 deletions spec/mspec/lib/mspec/mocks/mock.rb
Expand Up @@ -108,7 +108,7 @@ def self.verify_count
end
unless pass
SpecExpectation.fail_with(
"Mock '#{name_or_inspect obj}' expected to receive '#{key.last}' " \
"Mock '#{name_or_inspect obj}' expected to receive '#{key.last}' " + \
"#{qualifier.to_s.sub('_', ' ')} #{count} times",
"but received it #{proxy.calls} times")
end
Expand Down Expand Up @@ -142,14 +142,14 @@ def self.verify_call(obj, sym, *args, &block)
block.call(*args_to_yield)
else
SpecExpectation.fail_with(
"Mock '#{name_or_inspect obj}' asked to yield " \
"Mock '#{name_or_inspect obj}' asked to yield " + \
"|#{proxy.yielding.join(', ')}| on #{sym}\n",
"but a block with arity #{block.arity} was passed")
end
end
else
SpecExpectation.fail_with(
"Mock '#{name_or_inspect obj}' asked to yield " \
"Mock '#{name_or_inspect obj}' asked to yield " + \
"|[#{proxy.yielding.join('], [')}]| on #{sym}\n",
"but no block was passed")
end
Expand Down

0 comments on commit 7789b7c

Please sign in to comment.