Skip to content

Commit

Permalink
Merge branch 'master' into truffle-head
Browse files Browse the repository at this point in the history
Conflicts:
	truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
	truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
  • Loading branch information
chrisseaton committed Mar 14, 2015
2 parents 86858cc + 44ab7cc commit 62c76ac
Show file tree
Hide file tree
Showing 105 changed files with 317 additions and 357 deletions.
24 changes: 2 additions & 22 deletions core/src/main/java/org/jruby/RubyString.java
Expand Up @@ -4148,39 +4148,19 @@ public IRubyObject chop_bang(ThreadContext context) {
public IRubyObject chop19(ThreadContext context) {
Ruby runtime = context.runtime;
if (value.getRealSize() == 0) return newEmptyString(runtime, getMetaClass(), value.getEncoding()).infectBy(this);
return makeShared19(runtime, 0, choppedLength19(runtime));
return makeShared19(runtime, 0, StringSupport.choppedLength19(this, runtime));
}

@JRubyMethod(name = "chop!")
public IRubyObject chop_bang19(ThreadContext context) {
modifyCheck();
Ruby runtime = context.runtime;
if (value.getRealSize() == 0) return runtime.getNil();
view(0, choppedLength19(runtime));
view(0, StringSupport.choppedLength19(this, runtime));
if (getCodeRange() != CR_7BIT) clearCodeRange();
return this;
}

private int choppedLength19(Ruby runtime) {
int p = value.getBegin();
int end = p + value.getRealSize();

if (p > end) return 0;
byte bytes[] = value.getUnsafeBytes();
Encoding enc = value.getEncoding();

int s = enc.prevCharHead(bytes, p, end, end);
if (s == -1) return 0;
if (s > p && codePoint(runtime, enc, bytes, s, end) == '\n') {
int s2 = enc.prevCharHead(bytes, p, s, end);
if (s2 != -1 && codePoint(runtime, enc, bytes, s2, end) == '\r') s = s2;
}
return s - p;
}

/** rb_str_chop
*
*/
public RubyString chomp(ThreadContext context) {
return chomp19(context);
}
Expand Down
21 changes: 21 additions & 0 deletions core/src/main/java/org/jruby/util/StringSupport.java
Expand Up @@ -1324,4 +1324,25 @@ public static CodeRangeable delete_bangCommon19(CodeRangeable rubyString, Ruby r

return modify ? rubyString : null;
}

/**
* rb_str_chop
*/
public static int choppedLength19(CodeRangeable rubyString, Ruby runtime) {
final ByteList value = rubyString.getByteList();
int p = value.getBegin();
int end = p + value.getRealSize();

if (p > end) return 0;
byte bytes[] = value.getUnsafeBytes();
Encoding enc = value.getEncoding();

int s = enc.prevCharHead(bytes, p, end, end);
if (s == -1) return 0;
if (s > p && codePoint(runtime, enc, bytes, s, end) == '\n') {
int s2 = enc.prevCharHead(bytes, p, s, end);
if (s2 != -1 && codePoint(runtime, enc, bytes, s2, end) == '\r') s = s2;
}
return s - p;
}
}
4 changes: 2 additions & 2 deletions lib/ruby/truffle/shims/stringio.rb
Expand Up @@ -10,8 +10,8 @@

class StringIO

def initialize(string, mode)
@lines = string.split(/\n/).reject { |line| line.empty? }
def initialize(string=nil, mode=nil)
@lines = (string || '').split(/\n/).reject { |line| line.empty? }
end

def gets
Expand Down
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/array/delete_at_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/array/hash_tags.txt
@@ -1,6 +1,4 @@
fails:Array#hash returns the same hash for equal recursive arrays
fails:Array#hash returns the same hash for equal recursive arrays through hashes
fails:Array#hash calls to_int on result of calling hash on each element
fails:Array#hash returns same hash code for arrays with the same content
fails:Array#hash returns the same value if arrays are #eql?
fails:Array#hash properly handles recursive arrays
1 change: 0 additions & 1 deletion spec/truffle/tags/core/array/sort_tags.txt
@@ -1,4 +1,3 @@
fails:Array#sort sorts reverse-sorted Arrays
fails:Array#sort may take a block which is used to determine the order of objects a and b described as -1, 0 or +1
fails:Array#sort raises an error when a given block returns nil
fails:Array#sort completes when supplied a block that always returns the same result
Expand Down
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/array/to_h_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/basicobject/instance_exec_tags.txt
@@ -1,3 +1,2 @@
fails:BasicObject#instance_exec is a public instance method
fails:BasicObject#instance_exec sets self to the receiver in the context of the passed block
fails:BasicObject#instance_exec passes arguments to the block
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/enumerable/collect_concat_tags.txt

This file was deleted.

4 changes: 0 additions & 4 deletions spec/truffle/tags/core/enumerable/flat_map_tags.txt

This file was deleted.

5 changes: 0 additions & 5 deletions spec/truffle/tags/core/enumerable/grep_tags.txt

This file was deleted.

5 changes: 0 additions & 5 deletions spec/truffle/tags/core/enumerable/to_h_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/enumerator/each_tags.txt

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/enumerator/initialize_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/enumerator/inject_tags.txt
@@ -1,2 +1 @@
fails:Enumerator#inject requires multiple arguments
fails:Enumerator#inject works when chained against each_with_index
1 change: 0 additions & 1 deletion spec/truffle/tags/core/enumerator/with_object_tags.txt

This file was deleted.

7 changes: 0 additions & 7 deletions spec/truffle/tags/core/marshal/dump_tags.txt
@@ -1,13 +1,6 @@
fails:Marshal.dump dumps an extended_object
fails:Marshal.dump dumps an object that has had an ivar added and removed as though the ivar never was set
fails:Marshal.dump Hash returns a binary string
fails:Marshal.dump Hash subclass returns a binary string
fails:Marshal.dump raises an ArgumentError when the recursion limit is exceeded
fails:Marshal.dump raises a TypeError if dumping a IO/File instance
fails:Marshal.dump returns a tainted string if object is tainted
fails:Marshal.dump returns a tainted string if nested object is tainted
fails:Marshal.dump returns an untrusted string if object is untrusted
fails:Marshal.dump returns an untrusted string if nested object is untrusted
fails:Marshal.dump with a Fixnum dumps a positive Fixnum > 31 bits as a Bignum
fails:Marshal.dump with a Fixnum dumps a negative Fixnum > 31 bits as a Bignum
fails:Marshal.dump with a Symbol dumps an encoded Symbol
Expand Down
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/marshal/load_tags.txt
@@ -1,4 +1,3 @@
fails:Marshal.load raises an ArgumentError when the dumped data is truncated
fails:Marshal.load raises an ArgumentError when the dumped class is missing
fails:Marshal.load returns the value of the proc when called with a proc
fails:Marshal.load calls the proc for recursively visited data
Expand Down Expand Up @@ -36,7 +35,6 @@ fails:Marshal.load loads a Float 8323434.342
fails:Marshal.load loads a Random
fails:Marshal.load raises an ArgumentError with full constant name when the dumped constant is missing
fails:Marshal.load when source is tainted returns a tainted object
fails:Marshal.load when source is tainted does not taint Symbols
fails:Marshal.load for an Array loads an array containing the same objects
fails:Marshal.load for a Hash loads an extended_user_hash with a parameter to initialize
fails:Marshal.load for a Hash preserves hash ivars when hash contains a string having ivar
Expand Down
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/marshal/restore_tags.txt
@@ -1,4 +1,3 @@
fails:Marshal.restore raises an ArgumentError when the dumped data is truncated
fails:Marshal.restore raises an ArgumentError when the dumped class is missing
fails:Marshal.restore returns the value of the proc when called with a proc
fails:Marshal.restore calls the proc for recursively visited data
Expand Down Expand Up @@ -36,7 +35,6 @@ fails:Marshal.restore loads a Float 8323434.342
fails:Marshal.restore loads a Random
fails:Marshal.restore raises an ArgumentError with full constant name when the dumped constant is missing
fails:Marshal.restore when source is tainted returns a tainted object
fails:Marshal.restore when source is tainted does not taint Symbols
fails:Marshal.restore for an Array loads an array containing the same objects
fails:Marshal.restore for a Hash loads an extended_user_hash with a parameter to initialize
fails:Marshal.restore for a Hash preserves hash ivars when hash contains a string having ivar
Expand Down
1 change: 0 additions & 1 deletion spec/truffle/tags/core/module/class_variable_get_tags.txt
@@ -1,7 +1,6 @@
fails:Module#class_variable_get returns the value of the class variable with the given name
fails:Module#class_variable_get raises a NameError for a class variable named '@@'
fails:Module#class_variable_get raises a NameError for a class variables with the given name defined in an extended module
fails:Module#class_variable_get returns class variables defined in the class body and accessed in the metaclass
fails:Module#class_variable_get returns class variables defined in the metaclass and accessed by class methods
fails:Module#class_variable_get returns class variables defined in the metaclass and accessed by instance methods
fails:Module#class_variable_get returns a class variable defined in a metaclass
Expand Down
1 change: 0 additions & 1 deletion spec/truffle/tags/core/module/define_method_tags.txt
Expand Up @@ -7,7 +7,6 @@ fails:Module#define_method raises an ArgumentError when no block is given
fails:Module#define_method is private
fails:Module#define_method method body is an UnboundMethod allows methods defined on a different object
fails:Module#define_method when name is :initialize given an UnboundMethod sets the visibility to private when method is named :initialize
fails:Method#define_method when passed a Method object defines a method with the same #arity as the original
fails:Method#define_method when passed a Method object defines a method with the same #parameters as the original
fails:Method#define_method when passed an UnboundMethod object defines a method with the same #arity as the original
fails:Method#define_method when passed an UnboundMethod object defines a method with the same #parameters as the original
1 change: 0 additions & 1 deletion spec/truffle/tags/core/module/instance_method_tags.txt
@@ -1,4 +1,3 @@
fails:Module#instance_method requires an argument
fails:Module#instance_method raises a NameError if the method has been undefined
fails:Module#instance_method raises a NameError if the method does not exist
fails:Module#instance_method sets the NameError#name attribute to the name of the missing method
1 change: 0 additions & 1 deletion spec/truffle/tags/core/module/protected_tags.txt
@@ -1,5 +1,4 @@
fails:Module#protected is a private method
fails:Module#protected makes a public Object instance method protected in a new module
fails:Module#protected makes a public Object instance method protected in Kernel
fails:Module#protected raises a NameError when given an undefined name
fails:Module#protected without arguments sets visibility to following method definitions
Expand Down
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/object/instance_exec_tags.txt
@@ -1,7 +1,4 @@
fails:Object#instance_exec raises a LocalJumpError unless given a block
fails:Object#instance_exec has an arity of -1
fails:Object#instance_exec accepts arguments with a block
fails:Object#instance_exec doesn't pass self to the block as an argument
fails:Object#instance_exec passes any arguments to the block
fails:Object#instance_exec only binds the exec to the receiver
fails:Object#instance_exec binds self to the receiver
Expand Down
1 change: 0 additions & 1 deletion spec/truffle/tags/core/proc/inspect_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/proc/to_s_tags.txt

This file was deleted.

6 changes: 0 additions & 6 deletions spec/truffle/tags/core/process/daemon_tags.txt
Expand Up @@ -8,16 +8,10 @@ fails:Process.daemon changes directory to the root directory if the first argume
fails:Process.daemon changes directory to the root directory if the first argument is nil
fails:Process.daemon does not change to the root directory if the first argument is true
fails:Process.daemon does not change to the root directory if the first argument is non-false
fails:Process.daemon when the second argument is not given redirects stdout to /dev/null
fails:Process.daemon when the second argument is not given redirects stderr to /dev/null
fails:Process.daemon when the second argument is not given redirects stdin to /dev/null
fails:Process.daemon when the second argument is not given does not close open files
fails:Process.daemon when the second argument is false redirects stdout to /dev/null
fails:Process.daemon when the second argument is false redirects stderr to /dev/null
fails:Process.daemon when the second argument is false redirects stdin to /dev/null
fails:Process.daemon when the second argument is false does not close open files
fails:Process.daemon when the second argument is nil redirects stdout to /dev/null
fails:Process.daemon when the second argument is nil redirects stderr to /dev/null
fails:Process.daemon when the second argument is nil redirects stdin to /dev/null
fails:Process.daemon when the second argument is nil does not close open files
fails:Process.daemon when the second argument is true does not redirect stdout to /dev/null
Expand Down
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/random/bytes_tags.txt
@@ -1,7 +1,3 @@
fails:Random#bytes returns a String
fails:Random#bytes returns a String of the length given as argument
fails:Random#bytes returns an ASCII-8BIT String
fails:Random#bytes returns the same output for a given seed
fails:Random#bytes returns the same numeric output for a given seed accross all implementations and platforms
fails:Random#bytes returns the same numeric output for a given huge seed accross all implementations and platforms
fails:Random#bytes returns a random binary String
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/random/rand_tags.txt
Expand Up @@ -7,13 +7,11 @@ fails:Random.rand returns an Integer >= 0 if an Integer argument is passed
fails:Random.rand returns an Integer < the max argument if an Integer argument is passed
fails:Random.rand returns the same sequence for a given seed if an Integer argument is passed
fails:Random.rand coerces arguments to Integers with #to_int
fails:Random#rand with Fixnum returns a Fixnum less than the argument
fails:Random#rand with Fixnum eventually returns all possible values
fails:Random#rand with Bignum typically returns a Bignum
fails:Random#rand with Bignum returns the same sequence for a given seed
fails:Random#rand with Float returns the same sequence for a given seed
fails:Random#rand with Fixnum returns the same sequence for a given seed
fails:Random#rand with Range returns an object that is a member of the Range
fails:Random#rand with Range works with inclusive ranges
fails:Random#rand with Range works with exclusive ranges
fails:Random#rand with Range returns the same sequence for a given seed
Expand Down
1 change: 0 additions & 1 deletion spec/truffle/tags/core/regexp/compile_tags.txt
Expand Up @@ -3,7 +3,6 @@ fails:Regexp.compile given a String ignores the third argument if it is 'e' or '
fails:Regexp.compile given a String ignores the third argument if it is 's' or 'sjis' (case-insensitive)
fails:Regexp.compile given a String ignores the third argument if it is 'u' or 'utf8' (case-insensitive)
fails:Regexp.compile given a String uses US_ASCII encoding if third argument is 'n' or 'none' (case insensitive) and only ascii characters
fails:Regexp.compile given a String uses ASCII_8BIT encoding if third argument is 'n' or 'none' (case insensitive) and non-ascii characters
fails:Regexp.compile given a String with escaped characters raises a RegexpError if \x is not followed by any hexadecimal digits
fails:Regexp.compile given a String with escaped characters raises a RegexpError if less than four digits are given for \uHHHH
fails:Regexp.compile given a String with escaped characters raises a RegexpError if the \u{} escape is empty
Expand Down
24 changes: 0 additions & 24 deletions spec/truffle/tags/core/string/chop_tags.txt
@@ -1,27 +1,3 @@
fails:String#chop removes the final character
fails:String#chop removes the final carriage return
fails:String#chop removes the final newline
fails:String#chop removes the final carriage return, newline
fails:String#chop removes the carrige return, newline if they are the only characters
fails:String#chop does not remove more than the final carriage return, newline
fails:String#chop removes a multi-byte character
fails:String#chop removes the final carriage return, newline from a multibyte String
fails:String#chop removes the final carriage return, newline from a non-ASCII String
fails:String#chop returns an empty string when applied to an empty string
fails:String#chop returns a new string when applied to an empty string
fails:String#chop taints result when self is tainted
fails:String#chop untrusts result when self is untrusted
fails:String#chop returns subclass instances when called on a subclass
fails:String#chop! removes the final character
fails:String#chop! removes the final carriage return
fails:String#chop! removes the final newline
fails:String#chop! removes the final carriage return, newline
fails:String#chop! removes the carrige return, newline if they are the only characters
fails:String#chop! does not remove more than the final carriage return, newline
fails:String#chop! removes a multi-byte character
fails:String#chop! removes the final carriage return, newline from a multibyte String
fails:String#chop! removes the final carriage return, newline from a non-ASCII String
fails:String#chop! returns self if modifications were made
fails:String#chop! returns nil when called on an empty string
fails:String#chop! raises a RuntimeError on a frozen instance that is modified
fails:String#chop! raises a RuntimeError on a frozen instance that would not be modified
1 change: 0 additions & 1 deletion spec/truffle/tags/core/string/split_tags.txt
@@ -1,4 +1,3 @@
fails:String#split with String throws an ArgumentError if the pattern is not a valid string
fails:String#split with String splits on multibyte characters
fails:String#split with String returns subclass instances based on self
fails:String#split with String taints the resulting strings if self is tainted
Expand Down
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/symbol/element_reference_tags.txt
Expand Up @@ -12,8 +12,6 @@ fails:Symbol#[] with a Range slice that is out of bounds returns nil if the firs
fails:Symbol#[] with a Range slice with Float values converts the first value to an Integer
fails:Symbol#[] with a Range slice with Float values converts the last value to an Integer
fails:Symbol#[] with a Range subclass slice returns a slice
fails:Symbol#[] with a Regex slice without a capture index returns a tainted string if the regexp is tainted
fails:Symbol#[] with a Regex slice without a capture index returns an untrusted string if the regexp is untrusted
fails:Symbol#[] with a String slice does not set $~
fails:Symbol#[] with a String slice returns a string if there is match
fails:Symbol#[] with a String slice returns nil if there is not a match
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/symbol/slice_tags.txt
Expand Up @@ -12,8 +12,6 @@ fails:Symbol#slice with a Range slice that is out of bounds returns nil if the f
fails:Symbol#slice with a Range slice with Float values converts the first value to an Integer
fails:Symbol#slice with a Range slice with Float values converts the last value to an Integer
fails:Symbol#slice with a Range subclass slice returns a slice
fails:Symbol#slice with a Regex slice without a capture index returns a tainted string if the regexp is tainted
fails:Symbol#slice with a Regex slice without a capture index returns an untrusted string if the regexp is untrusted
fails:Symbol#slice with a String slice does not set $~
fails:Symbol#slice with a String slice returns a string if there is match
fails:Symbol#slice with a String slice returns nil if there is not a match
Expand Up @@ -81,7 +81,7 @@ public Object isDefined(VirtualFrame frame) {
*/

if (e.getRubyException().getLogicalClass() == context.getCoreLibrary().getNameErrorClass()) {
return getContext().getCoreLibrary().getNilObject();
return nil();
}

throw e;
Expand All @@ -91,7 +91,7 @@ public Object isDefined(VirtualFrame frame) {
RubyConstant constant = ModuleOperations.lookupConstant(context, dispatch.getLexicalScope(), module, name);

if (constant == null || !constant.isVisibleTo(context, dispatch.getLexicalScope(), module)) {
return getContext().getCoreLibrary().getNilObject();
return nil();
} else {
return context.makeString("constant");
}
Expand Down

0 comments on commit 62c76ac

Please sign in to comment.