Skip to content

Commit

Permalink
[Truffle] - Adds Random class
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasallan committed Mar 10, 2015
1 parent 5a506d2 commit 245279f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
1 change: 0 additions & 1 deletion spec/truffle/tags/core/random/new_tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
fails:Random.new returns a new instance of Random
fails:Random.new uses a random seed value if none is supplied
fails:Random.new returns Random instances initialized with different seeds
fails:Random.new accepts an Integer seed value as an argument
Expand Down
3 changes: 2 additions & 1 deletion truffle/src/main/java/org/jruby/truffle/nodes/RubyTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
RubyEncoding.class, //
RubySymbol.class, //
RubyThread.class, //
RubyTime.class, //
RubyTime.class,
RubyRandom.class, //
RubyEncodingConverter.class, //
RubyMethod.class, //
RubyUnboundMethod.class, //
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.jruby.truffle.nodes.core;

@CoreClass(name = "Random")
public abstract class RandomNodes {

}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public class CoreLibrary {
private final RubyClass securityErrorClass;
private final RubyClass standardErrorClass;
private final RubyClass stringClass;
private final RubyClass randomClass;
private final RubyClass stringDataClass;
private final RubyClass symbolClass;
private final RubyClass syntaxErrorClass;
Expand Down Expand Up @@ -284,6 +285,7 @@ public CoreLibrary(RubyContext context) {
rangeClass = defineClass("Range", new RubyRange.RangeAllocator());
regexpClass = defineClass("Regexp", new RubyRegexp.RegexpAllocator());
stringClass = defineClass("String", new RubyString.StringAllocator());
randomClass = defineClass("Random");
symbolClass = defineClass("Symbol");
threadClass = defineClass("Thread", new RubyThread.ThreadAllocator());
timeClass = defineClass("Time", new RubyTime.TimeAllocator());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.jruby.truffle.runtime.core;

/**
* Represents the Ruby {@code Random} class.
*/
public class RubyRandom extends RubyBasicObject {

private Long seedValue;

public RubyRandom(RubyClass randomClass) {
super(randomClass);
}

public void setSeedValue(Long seedValue) {
this.seedValue = seedValue;
}

}

0 comments on commit 245279f

Please sign in to comment.