Skip to content

Commit

Permalink
[Truffle] Re-enable ARGF specs by providing a more flexible implement…
Browse files Browse the repository at this point in the history
…ation

* Take an arbitrary array of strings as input.
* ARGV is treated specially to make sure it is passed by reference
  (since calling with * and receiving with * might create a copy).
eregon committed Jun 15, 2015
1 parent 7eb5d7f commit f51b89f
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions spec/truffle/tags/core/argf/binmode_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
fails:ARGF.binmode does not raise an error
fails:ARGF.binmode puts reading into binmode
fails:ARGF.binmode puts alls subsequent stream reading through ARGF into binmode
slow:ARGF.binmode returns self
slow:ARGF.binmode sets the file's encoding to ASCII-8BIT
3 changes: 0 additions & 3 deletions spec/truffle/truffle.mspec
Original file line number Diff line number Diff line change
@@ -14,9 +14,6 @@ class MSpecScript
core = [
"spec/ruby/core",

# Specs are incompatible with the current implementation
"^spec/ruby/core/argf",

# Can't load these - so tags aren't enough to exclude them. The problem is
# either fixtures or syntax. Some of them are probably easy fixes.

14 changes: 9 additions & 5 deletions truffle/src/main/ruby/core/rubinius/common/argf.rb
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ module Rubinius
#
class ARGFClass
include Enumerable
attr_reader :argv # Truffle

# :internal:
#
@@ -46,7 +47,9 @@ class ARGFClass
#
# @see #advance!
#
def initialize
# Truffle: adapted to take argv as input
def initialize(argv = ARGV, *others)
@argv = argv.equal?(ARGV) ? ARGV : [argv, *others]
@lineno = 0
@advance = true
@init = false
@@ -512,12 +515,13 @@ def to_s
# there are further file names in ARGV, tries to open
# the next one as the current stream.
#
# Truffle: adapted to take argv as input
def advance!
return true unless @advance

unless @init

if ARGV.empty?
if @argv.empty?
@advance = false
@stream = STDIN
@filename = "-"
@@ -529,11 +533,11 @@ def advance!

File.unlink(@backup_filename) if @backup_filename && $-i == ""

return false if @use_stdin_only || ARGV.empty?
return false if @use_stdin_only || @argv.empty?

@advance = false

file = ARGV.shift
file = @argv.shift
@stream = stream(file)
@filename = file

@@ -555,4 +559,4 @@ def advance!
# The virtual concatenation file of the files given on command line (or
# from $stdin if no files were given.) Usable like an IO.
#
ARGF = Rubinius::ARGFClass.new
ARGF = Rubinius::ARGFClass.new(ARGV) # Truffle

0 comments on commit f51b89f

Please sign in to comment.