Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67d23f1
commit 3063622
Showing
22 changed files
with
1,268 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
fails:File includes File::Constants | ||
windows:File.file? returns true if the named file exists and is a regular file. | ||
windows:File.file? raises an ArgumentError if not passed one argument | ||
windows:File.file? raises a TypeError if not passed a String type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,23 @@ | ||
fails:File.fnmatch matches entire strings | ||
fails:File.fnmatch does not match partial strings | ||
fails:File.fnmatch does not support { } patterns by default | ||
fails:File.fnmatch supports some { } patterns when File::FNM_EXTGLOB is passed | ||
fails:File.fnmatch doesn't support some { } patterns even when File::FNM_EXTGLOB is passed | ||
fails:File.fnmatch doesn't match an extra } when File::FNM_EXTGLOB is passed | ||
fails:File.fnmatch matches when both FNM_EXTGLOB and FNM_PATHNAME are passed | ||
fails:File.fnmatch matches a single character for each ? character | ||
fails:File.fnmatch matches zero or more characters for each * character | ||
fails:File.fnmatch matches ranges of characters using bracket expresions (e.g. [a-z]) | ||
fails:File.fnmatch matches ranges of characters using bracket expresions, taking case into account | ||
fails:File.fnmatch does not match characters outside of the range of the bracket expresion | ||
fails:File.fnmatch matches ranges of characters using exclusive bracket expresions (e.g. [^t] or [!t]) | ||
fails:File.fnmatch matches characters with a case sensitive comparison | ||
fails:File.fnmatch matches characters with case insensitive comparison when flags includes FNM_CASEFOLD | ||
fails:File.fnmatch doesn't match case sensitive characters on platfroms with case sensitive paths, when flags include FNM_SYSCASE | ||
fails:File.fnmatch does not match '/' characters with ? or * when flags includes FNM_PATHNAME | ||
fails:File.fnmatch does not match '/' characters inside bracket expressions when flags includes FNM_PATHNAME | ||
fails:File.fnmatch matches literal ? or * in path when pattern includes \? or \* | ||
fails:File.fnmatch matches literal character (e.g. 'a') in path when pattern includes escaped character (e.g. \a) | ||
fails:File.fnmatch matches '\' characters in path when flags includes FNM_NOESACPE | ||
fails:File.fnmatch escapes special characters inside bracket expression | ||
fails:File.fnmatch does not match leading periods in filenames with wildcards by default | ||
fails:File.fnmatch matches patterns with leading periods to dotfiles by default | ||
fails:File.fnmatch matches leading periods in filenames when flags includes FNM_DOTMATCH | ||
fails:File.fnmatch matches multiple directories with ** and * | ||
fails:File.fnmatch matches multiple directories with ** when flags includes File::FNM_PATHNAME | ||
fails:File.fnmatch returns false if '/' in pattern do not match '/' in path when flags includes FNM_PATHNAME | ||
fails:File.fnmatch returns true if '/' in pattern match '/' in path when flags includes FNM_PATHNAME | ||
fails:File.fnmatch accepts an object that has a #to_path method | ||
fails:File.fnmatch raises a TypeError if the first and second arguments are not string-like | ||
fails:File.fnmatch raises a TypeError if the third argument is not an Integer | ||
fails:File.fnmatch does not raise a TypeError if the third argument can be coerced to an Integer | ||
fails:File.fnmatch? matches entire strings | ||
fails:File.fnmatch? does not match partial strings | ||
fails:File.fnmatch? does not support { } patterns by default | ||
fails:File.fnmatch? supports some { } patterns when File::FNM_EXTGLOB is passed | ||
fails:File.fnmatch? doesn't support some { } patterns even when File::FNM_EXTGLOB is passed | ||
fails:File.fnmatch? doesn't match an extra } when File::FNM_EXTGLOB is passed | ||
fails:File.fnmatch? matches when both FNM_EXTGLOB and FNM_PATHNAME are passed | ||
fails:File.fnmatch? matches a single character for each ? character | ||
fails:File.fnmatch? matches zero or more characters for each * character | ||
fails:File.fnmatch? matches ranges of characters using bracket expresions (e.g. [a-z]) | ||
fails:File.fnmatch? matches ranges of characters using bracket expresions, taking case into account | ||
fails:File.fnmatch? does not match characters outside of the range of the bracket expresion | ||
fails:File.fnmatch? matches ranges of characters using exclusive bracket expresions (e.g. [^t] or [!t]) | ||
fails:File.fnmatch? matches characters with a case sensitive comparison | ||
fails:File.fnmatch? matches characters with case insensitive comparison when flags includes FNM_CASEFOLD | ||
fails:File.fnmatch? doesn't match case sensitive characters on platfroms with case sensitive paths, when flags include FNM_SYSCASE | ||
fails:File.fnmatch? does not match '/' characters with ? or * when flags includes FNM_PATHNAME | ||
fails:File.fnmatch? does not match '/' characters inside bracket expressions when flags includes FNM_PATHNAME | ||
fails:File.fnmatch? matches literal ? or * in path when pattern includes \? or \* | ||
fails:File.fnmatch? matches literal character (e.g. 'a') in path when pattern includes escaped character (e.g. \a) | ||
fails:File.fnmatch? matches '\' characters in path when flags includes FNM_NOESACPE | ||
fails:File.fnmatch? escapes special characters inside bracket expression | ||
fails:File.fnmatch? does not match leading periods in filenames with wildcards by default | ||
fails:File.fnmatch? matches patterns with leading periods to dotfiles by default | ||
fails:File.fnmatch? matches leading periods in filenames when flags includes FNM_DOTMATCH | ||
fails:File.fnmatch? matches multiple directories with ** and * | ||
fails:File.fnmatch? matches multiple directories with ** when flags includes File::FNM_PATHNAME | ||
fails:File.fnmatch? returns false if '/' in pattern do not match '/' in path when flags includes FNM_PATHNAME | ||
fails:File.fnmatch? returns true if '/' in pattern match '/' in path when flags includes FNM_PATHNAME | ||
fails:File.fnmatch? accepts an object that has a #to_path method | ||
fails:File.fnmatch? raises a TypeError if the first and second arguments are not string-like | ||
fails:File.fnmatch? raises a TypeError if the third argument is not an Integer | ||
fails:File.fnmatch? does not raise a TypeError if the third argument can be coerced to an Integer | ||
fails(windows):File.fnmatch matches case sensitive characters on platfroms with case insensitive paths, when flags include FNM_SYSCASE | ||
fails(windows):File.fnmatch? matches case sensitive characters on platfroms with case insensitive paths, when flags include FNM_SYSCASE |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
truffle/src/main/java/org/jruby/truffle/nodes/rubinius/DirPrimitiveNodes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
/* | ||
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.nodes.rubinius; | ||
|
||
import com.oracle.truffle.api.CompilerDirectives; | ||
import com.oracle.truffle.api.dsl.Specialization; | ||
import com.oracle.truffle.api.nodes.UnexpectedResultException; | ||
import com.oracle.truffle.api.object.HiddenKey; | ||
import com.oracle.truffle.api.source.SourceSection; | ||
import org.jruby.truffle.nodes.objectstorage.ReadHeadObjectFieldNode; | ||
import org.jruby.truffle.nodes.objectstorage.WriteHeadObjectFieldNode; | ||
import org.jruby.truffle.runtime.RubyCallStack; | ||
import org.jruby.truffle.runtime.RubyContext; | ||
import org.jruby.truffle.runtime.control.RaiseException; | ||
import org.jruby.truffle.runtime.core.*; | ||
|
||
import java.io.File; | ||
|
||
public abstract class DirPrimitiveNodes { | ||
|
||
// TODO CS 14-April-15 use a shape, properties and allocator | ||
|
||
private static final HiddenKey contentsKey = new HiddenKey("contents"); | ||
private static final HiddenKey positionKey = new HiddenKey("position"); | ||
|
||
@RubiniusPrimitive(name = "dir_open") | ||
public static abstract class DirOpenPrimitiveNode extends RubiniusPrimitiveNode { | ||
|
||
@Child private WriteHeadObjectFieldNode writeContentsNode; | ||
@Child private WriteHeadObjectFieldNode writePositionNode; | ||
|
||
public DirOpenPrimitiveNode(RubyContext context, SourceSection sourceSection) { | ||
super(context, sourceSection); | ||
writeContentsNode = new WriteHeadObjectFieldNode(contentsKey); | ||
writePositionNode = new WriteHeadObjectFieldNode(positionKey); | ||
} | ||
|
||
public DirOpenPrimitiveNode(DirOpenPrimitiveNode prev) { | ||
super(prev); | ||
writeContentsNode = prev.writeContentsNode; | ||
writePositionNode = prev.writePositionNode; | ||
} | ||
|
||
@CompilerDirectives.TruffleBoundary | ||
@Specialization | ||
public RubyNilClass open(RubyBasicObject dir, RubyString path, RubyNilClass encoding) { | ||
final String[] contents = new File(path.toString()).list(); | ||
|
||
if (contents == null) { | ||
throw new RaiseException(new RubyException( | ||
getContext().getCoreLibrary().getEnoentClass(), | ||
getContext().makeString("No such file or directory @ dir_initialize - " + path.toString()), | ||
RubyCallStack.getBacktrace(this))); | ||
} | ||
|
||
writeContentsNode.execute(dir, contents); | ||
writePositionNode.execute(dir, -2); // -2 for . and then .. | ||
|
||
return nil(); | ||
} | ||
|
||
} | ||
|
||
@RubiniusPrimitive(name = "dir_read") | ||
public static abstract class DirReadPrimitiveNode extends RubiniusPrimitiveNode { | ||
|
||
@Child private ReadHeadObjectFieldNode readContentsNode; | ||
@Child private ReadHeadObjectFieldNode readPositionNode; | ||
@Child private WriteHeadObjectFieldNode writePositionNode; | ||
|
||
public DirReadPrimitiveNode(RubyContext context, SourceSection sourceSection) { | ||
super(context, sourceSection); | ||
readContentsNode = new ReadHeadObjectFieldNode(contentsKey); | ||
readPositionNode = new ReadHeadObjectFieldNode(positionKey); | ||
writePositionNode = new WriteHeadObjectFieldNode(positionKey); | ||
} | ||
|
||
public DirReadPrimitiveNode(DirReadPrimitiveNode prev) { | ||
super(prev); | ||
readContentsNode = prev.readContentsNode; | ||
readPositionNode = prev.readPositionNode; | ||
writePositionNode = prev.writePositionNode; | ||
} | ||
|
||
@CompilerDirectives.TruffleBoundary | ||
@Specialization | ||
public Object read(RubyBasicObject dir) { | ||
final int position; | ||
|
||
try { | ||
position = readPositionNode.executeInteger(dir); | ||
} catch (UnexpectedResultException e) { | ||
throw new IllegalStateException(); | ||
} | ||
|
||
writePositionNode.execute(dir, position + 1); | ||
|
||
if (position == -2) { | ||
return getContext().makeString("."); | ||
} else if (position == -1) { | ||
return getContext().makeString(".."); | ||
} else { | ||
final String[] contents = (String[]) readContentsNode.execute(dir); | ||
|
||
if (position < contents.length) { | ||
return getContext().makeString(contents[position]); | ||
} else { | ||
return nil(); | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
@RubiniusPrimitive(name = "dir_close") | ||
public static abstract class DirClosePrimitiveNode extends RubiniusPrimitiveNode { | ||
|
||
public DirClosePrimitiveNode(RubyContext context, SourceSection sourceSection) { | ||
super(context, sourceSection); | ||
} | ||
|
||
public DirClosePrimitiveNode(DirClosePrimitiveNode prev) { | ||
super(prev); | ||
} | ||
|
||
@CompilerDirectives.TruffleBoundary | ||
@Specialization | ||
public RubyNilClass open(RubyBasicObject dir) { | ||
return nil(); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.