-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
Conflicts: truffle/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java truffle/src/main/java/org/jruby/truffle/nodes/dispatch/UnresolvedDispatchNode.java
- 9.4.12.0
- 9.4.11.0
- 9.4.10.0
- 9.4.9.0
- 9.4.8.0
- 9.4.7.0
- 9.4.6.0
- 9.4.5.0
- 9.4.4.0
- 9.4.3.0
- 9.4.2.0
- 9.4.1.0
- 9.4.0.0
- 9.3.15.0
- 9.3.14.0
- 9.3.13.0
- 9.3.12.0
- 9.3.11.0
- 9.3.10.0
- 9.3.9.0
- 9.3.8.0
- 9.3.7.0
- 9.3.6.0
- 9.3.5.0
- 9.3.4.0
- 9.3.3.0
- 9.3.2.0
- 9.3.1.0
- 9.3.0.0
- 9.2.21.0
- 9.2.20.1
- 9.2.20.0
- 9.2.19.0
- 9.2.18.0
- 9.2.17.0
- 9.2.16.0
- 9.2.15.0
- 9.2.14.0
- 9.2.13.0
- 9.2.12.0
- 9.2.11.1
- 9.2.11.0
- 9.2.10.0
- 9.2.9.0
- 9.2.8.0
- 9.2.7.0
- 9.2.6.0
- 9.2.5.0
- 9.2.4.1
- 9.2.4.0
- 9.2.3.0
- 9.2.2.0
- 9.2.1.0
- 9.2.0.0
- 9.1.17.0
- 9.1.16.0
- 9.1.15.0
- 9.1.14.0
- 9.1.13.0
- 9.1.12.0
- 9.1.11.0
- 9.1.10.0
- 9.1.9.0
- 9.1.8.0
- 9.1.7.0
- 9.1.6.0
- 9.1.5.0
- 9.1.4.0
- 9.1.3.0
- 9.1.2.0
- 9.1.1.0
- 9.1.0.0
- 9.0.5.0
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Copyright (c) 2013, Brian Shirai | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
3. Neither the name of the library nor the names of its contributors may be | ||
used to endorse or promote products derived from this software without | ||
specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, | ||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require "rubysl/securerandom/securerandom" | ||
require "rubysl/securerandom/version" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,265 @@ | ||
# = Secure random number generator interface. | ||
# | ||
# This library is an interface for secure random number generator which is | ||
# suitable for generating session key in HTTP cookies, etc. | ||
# | ||
# It supports following secure random number generators. | ||
# | ||
# * openssl | ||
# * /dev/urandom | ||
# * Win32 | ||
# | ||
# == Example | ||
# | ||
# # random hexadecimal string. | ||
# p SecureRandom.hex(10) #=> "52750b30ffbc7de3b362" | ||
# p SecureRandom.hex(10) #=> "92b15d6c8dc4beb5f559" | ||
# p SecureRandom.hex(11) #=> "6aca1b5c58e4863e6b81b8" | ||
# p SecureRandom.hex(12) #=> "94b2fff3e7fd9b9c391a2306" | ||
# p SecureRandom.hex(13) #=> "39b290146bea6ce975c37cfc23" | ||
# ... | ||
# | ||
# # random base64 string. | ||
# p SecureRandom.base64(10) #=> "EcmTPZwWRAozdA==" | ||
# p SecureRandom.base64(10) #=> "9b0nsevdwNuM/w==" | ||
# p SecureRandom.base64(10) #=> "KO1nIU+p9DKxGg==" | ||
# p SecureRandom.base64(11) #=> "l7XEiFja+8EKEtY=" | ||
# p SecureRandom.base64(12) #=> "7kJSM/MzBJI+75j8" | ||
# p SecureRandom.base64(13) #=> "vKLJ0tXBHqQOuIcSIg==" | ||
# ... | ||
# | ||
# # random binary string. | ||
# p SecureRandom.random_bytes(10) #=> "\016\t{\370g\310pbr\301" | ||
# p SecureRandom.random_bytes(10) #=> "\323U\030TO\234\357\020\a\337" | ||
# ... | ||
|
||
begin | ||
require 'openssl' | ||
rescue LoadError | ||
end | ||
|
||
module SecureRandom | ||
# SecureRandom.random_bytes generates a random binary string. | ||
# | ||
# The argument _n_ specifies the length of the result string. | ||
# | ||
# If _n_ is not specified, 16 is assumed. | ||
# It may be larger in future. | ||
# | ||
# The result may contain any byte: "\x00" - "\xff". | ||
# | ||
# p SecureRandom.random_bytes #=> "\xD8\\\xE0\xF4\r\xB2\xFC*WM\xFF\x83\x18\xF45\xB6" | ||
# p SecureRandom.random_bytes #=> "m\xDC\xFC/\a\x00Uf\xB2\xB2P\xBD\xFF6S\x97" | ||
# | ||
# If secure random number generator is not available, | ||
# NotImplementedError is raised. | ||
def self.random_bytes(n=nil) | ||
n ||= 16 | ||
|
||
if defined? OpenSSL::Random | ||
@pid = 0 if !defined?(@pid) | ||
pid = $$ | ||
if @pid != pid | ||
now = Time.now | ||
ary = [now.to_i, now.nsec, @pid, pid] | ||
OpenSSL::Random.seed(ary.to_s) | ||
@pid = pid | ||
end | ||
return OpenSSL::Random.random_bytes(n) | ||
end | ||
|
||
if !defined?(@has_urandom) || @has_urandom | ||
flags = File::RDONLY | ||
flags |= File::NONBLOCK if defined? File::NONBLOCK | ||
flags |= File::NOCTTY if defined? File::NOCTTY | ||
begin | ||
File.open("/dev/urandom", flags) {|f| | ||
unless f.stat.chardev? | ||
raise Errno::ENOENT | ||
end | ||
@has_urandom = true | ||
ret = f.readpartial(n) | ||
if ret.length != n | ||
raise NotImplementedError, "Unexpected partial read from random device" | ||
end | ||
return ret | ||
} | ||
rescue Errno::ENOENT | ||
@has_urandom = false | ||
end | ||
end | ||
|
||
if !defined?(@has_win32) | ||
begin | ||
require 'Win32API' | ||
|
||
crypt_acquire_context = Win32API.new("advapi32", "CryptAcquireContext", 'PPPII', 'L') | ||
@crypt_gen_random = Win32API.new("advapi32", "CryptGenRandom", 'LIP', 'L') | ||
|
||
hProvStr = " " * 4 | ||
prov_rsa_full = 1 | ||
crypt_verifycontext = 0xF0000000 | ||
|
||
if crypt_acquire_context.call(hProvStr, nil, nil, prov_rsa_full, crypt_verifycontext) == 0 | ||
raise SystemCallError, "CryptAcquireContext failed: #{lastWin32ErrorMessage}" | ||
end | ||
@hProv, = hProvStr.unpack('L') | ||
|
||
@has_win32 = true | ||
rescue LoadError | ||
@has_win32 = false | ||
end | ||
end | ||
if @has_win32 | ||
bytes = " ".force_encoding("ASCII-8BIT") * n | ||
if @crypt_gen_random.call(@hProv, bytes.size, bytes) == 0 | ||
raise SystemCallError, "CryptGenRandom failed: #{lastWin32ErrorMessage}" | ||
end | ||
return bytes | ||
end | ||
|
||
raise NotImplementedError, "No random device" | ||
end | ||
|
||
# SecureRandom.hex generates a random hex string. | ||
# | ||
# The argument _n_ specifies the length of the random length. | ||
# The length of the result string is twice of _n_. | ||
# | ||
# If _n_ is not specified, 16 is assumed. | ||
# It may be larger in future. | ||
# | ||
# The result may contain 0-9 and a-f. | ||
# | ||
# p SecureRandom.hex #=> "eb693ec8252cd630102fd0d0fb7c3485" | ||
# p SecureRandom.hex #=> "91dc3bfb4de5b11d029d376634589b61" | ||
# | ||
# If secure random number generator is not available, | ||
# NotImplementedError is raised. | ||
def self.hex(n=nil) | ||
random_bytes(n).unpack("H*")[0] | ||
end | ||
|
||
# SecureRandom.base64 generates a random base64 string. | ||
# | ||
# The argument _n_ specifies the length of the random length. | ||
# The length of the result string is about 4/3 of _n_. | ||
# | ||
# If _n_ is not specified, 16 is assumed. | ||
# It may be larger in future. | ||
# | ||
# The result may contain A-Z, a-z, 0-9, "+", "/" and "=". | ||
# | ||
# p SecureRandom.base64 #=> "/2BuBuLf3+WfSKyQbRcc/A==" | ||
# p SecureRandom.base64 #=> "6BbW0pxO0YENxn38HMUbcQ==" | ||
# | ||
# If secure random number generator is not available, | ||
# NotImplementedError is raised. | ||
# | ||
# See RFC 3548 for the definition of base64. | ||
def self.base64(n=nil) | ||
[random_bytes(n)].pack("m*").delete("\n") | ||
end | ||
|
||
# SecureRandom.urlsafe_base64 generates a random URL-safe base64 string. | ||
# | ||
# The argument _n_ specifies the length of the random length. | ||
# The length of the result string is about 4/3 of _n_. | ||
# | ||
# If _n_ is not specified, 16 is assumed. | ||
# It may be larger in future. | ||
# | ||
# The boolean argument _padding_ specifies the padding. | ||
# If it is false or nil, padding is not generated. | ||
# Otherwise padding is generated. | ||
# By default, padding is not generated because "=" may be used as a URL delimiter. | ||
# | ||
# The result may contain A-Z, a-z, 0-9, "-" and "_". | ||
# "=" is also used if _padding_ is true. | ||
# | ||
# p SecureRandom.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg" | ||
# p SecureRandom.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg" | ||
# | ||
# p SecureRandom.urlsafe_base64(nil, true) #=> "i0XQ-7gglIsHGV2_BNPrdQ==" | ||
# p SecureRandom.urlsafe_base64(nil, true) #=> "-M8rLhr7JEpJlqFGUMmOxg==" | ||
# | ||
# If secure random number generator is not available, | ||
# NotImplementedError is raised. | ||
# | ||
# See RFC 3548 for the definition of URL-safe base64. | ||
def self.urlsafe_base64(n=nil, padding=false) | ||
s = [random_bytes(n)].pack("m*") | ||
s.delete!("\n") | ||
s.tr!("+/", "-_") | ||
s.delete!("=") if !padding | ||
s | ||
end | ||
|
||
# SecureRandom.random_number generates a random number. | ||
# | ||
# If a positive integer is given as _n_, | ||
# SecureRandom.random_number returns an integer: | ||
# 0 <= SecureRandom.random_number(n) < n. | ||
# | ||
# p SecureRandom.random_number(100) #=> 15 | ||
# p SecureRandom.random_number(100) #=> 88 | ||
# | ||
# If 0 is given or an argument is not given, | ||
# SecureRandom.random_number returns a float: | ||
# 0.0 <= SecureRandom.random_number() < 1.0. | ||
# | ||
# p SecureRandom.random_number #=> 0.596506046187744 | ||
# p SecureRandom.random_number #=> 0.350621695741409 | ||
# | ||
def self.random_number(n=0) | ||
if 0 < n | ||
hex = n.to_s(16) | ||
hex = '0' + hex if (hex.length & 1) == 1 | ||
bin = [hex].pack("H*") | ||
mask = bin[0].ord | ||
mask |= mask >> 1 | ||
mask |= mask >> 2 | ||
mask |= mask >> 4 | ||
begin | ||
rnd = SecureRandom.random_bytes(bin.length) | ||
rnd[0] = (rnd[0].ord & mask).chr | ||
end until rnd < bin | ||
rnd.unpack("H*")[0].hex | ||
else | ||
# assumption: Float::MANT_DIG <= 64 | ||
i64 = SecureRandom.random_bytes(8).unpack("Q")[0] | ||
Math.ldexp(i64 >> (64-Float::MANT_DIG), -Float::MANT_DIG) | ||
end | ||
end | ||
|
||
# SecureRandom.uuid generates a v4 random UUID (Universally Unique IDentifier). | ||
# | ||
# p SecureRandom.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594" | ||
# p SecureRandom.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab" | ||
# p SecureRandom.uuid #=> "62936e70-1815-439b-bf89-8492855a7e6b" | ||
# | ||
# The version 4 UUID is purely random (except the version). | ||
# It doesn't contain meaningful information such as MAC address, time, etc. | ||
# | ||
# See RFC 4122 for details of UUID. | ||
# | ||
def self.uuid | ||
ary = self.random_bytes(16).unpack("NnnnnN") | ||
ary[2] = (ary[2] & 0x0fff) | 0x4000 | ||
ary[3] = (ary[3] & 0x3fff) | 0x8000 | ||
"%08x-%04x-%04x-%04x-%04x%08x" % ary | ||
end | ||
|
||
# Following code is based on David Garamond's GUID library for Ruby. | ||
def self.lastWin32ErrorMessage # :nodoc: | ||
get_last_error = Win32API.new("kernel32", "GetLastError", '', 'L') | ||
format_message = Win32API.new("kernel32", "FormatMessageA", 'LPLLPLPPPPPPPP', 'L') | ||
format_message_ignore_inserts = 0x00000200 | ||
format_message_from_system = 0x00001000 | ||
|
||
code = get_last_error.call | ||
msg = "\0" * 1024 | ||
len = format_message.call(format_message_ignore_inserts + format_message_from_system, 0, code, 0, msg, 1024, nil, nil, nil, nil, nil, nil, nil, nil) | ||
msg[0, len].tr("\r", '').chomp | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module RubySL | ||
module SecureRandom | ||
VERSION = "2.0.0" | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require "rubysl/securerandom" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# TODO require bigdecimal/* | ||
|
||
BigDecimal = Truffle::BigDecimal | ||
|
||
module Kernel | ||
def BigDecimal(*args) | ||
BigDecimal.new *args | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
# 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 | ||
|
||
module Digest | ||
|
||
NO_MESSAGE = Object.new | ||
|
||
class Algorithm | ||
|
||
def self.file(file) | ||
digest = new | ||
digest.update File.read(file) | ||
digest | ||
end | ||
|
||
def self.digest(message) | ||
digest = new | ||
digest.update message | ||
digest.digest | ||
end | ||
|
||
def self.hexdigest(message) | ||
digest = new | ||
digest.update message | ||
digest.hexdigest | ||
end | ||
|
||
def update(message) | ||
Truffle::Digest.update @digest, message | ||
end | ||
|
||
alias_method :<<, :update | ||
|
||
def reset | ||
Truffle::Digest.reset @digest | ||
end | ||
|
||
def digest(message=NO_MESSAGE) | ||
if NO_MESSAGE == message | ||
Truffle::Digest.digest @digest | ||
else | ||
reset | ||
update message | ||
digest! | ||
end | ||
end | ||
|
||
def hexdigest(message=NO_MESSAGE) | ||
Digest.hexencode(digest(message)) | ||
end | ||
|
||
alias_method :to_s, :hexdigest | ||
alias_method :to_str, :hexdigest | ||
|
||
def digest! | ||
digested = digest | ||
reset | ||
digested | ||
end | ||
|
||
def hexdigest! | ||
digested = hexdigest | ||
reset | ||
digested | ||
end | ||
|
||
def digest_length | ||
Truffle::Digest.digest_length @digest | ||
end | ||
|
||
alias_method :size, :digest_length | ||
alias_method :length, :digest_length | ||
|
||
def ==(other) | ||
hexdigest == other.to_str | ||
end | ||
|
||
def inspect | ||
"#<#{self.class.name}: #{hexdigest}>" | ||
end | ||
|
||
end | ||
|
||
class MD5 < Algorithm | ||
|
||
def initialize | ||
@digest = Truffle::Digest.md5 | ||
end | ||
|
||
def block_length | ||
64 | ||
end | ||
|
||
end | ||
|
||
class SHA1 < Algorithm | ||
|
||
def initialize | ||
@digest = Truffle::Digest.sha1 | ||
end | ||
|
||
def block_length | ||
64 | ||
end | ||
|
||
end | ||
|
||
class SHA256 < Algorithm | ||
|
||
def initialize | ||
@digest = Truffle::Digest.sha256 | ||
end | ||
|
||
def block_length | ||
64 | ||
end | ||
|
||
end | ||
|
||
class SHA384 < Algorithm | ||
|
||
def initialize | ||
@digest = Truffle::Digest.sha384 | ||
end | ||
|
||
def block_length | ||
128 | ||
end | ||
|
||
end | ||
|
||
class SHA512 < Algorithm | ||
|
||
def initialize | ||
@digest = Truffle::Digest.sha512 | ||
end | ||
|
||
def block_length | ||
128 | ||
end | ||
|
||
end | ||
|
||
def self.hexencode(message) | ||
StringValue(message).unpack('H*').first | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# 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 | ||
|
||
require 'digest' | ||
|
||
module Digest | ||
|
||
def self.bubblebabble(message) | ||
Truffle::Digest.bubblebabble(StringValue(message)) | ||
end | ||
|
||
class Algorithm | ||
|
||
def self.bubblebabble(message) | ||
digest = new | ||
digest.update message | ||
digest.bubblebabble | ||
end | ||
|
||
def bubblebabble(message=NO_MESSAGE) | ||
Digest.bubblebabble(digest(message)) | ||
end | ||
|
||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'digest' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'digest' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'digest' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'digest' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# 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 | ||
|
||
module Zlib | ||
|
||
NO_COMPRESSION = 0 | ||
BEST_SPEED = 1 | ||
BEST_COMPRESSION = 9 | ||
DEFAULT_COMPRESSION = -1 | ||
|
||
def self.crc32(*args) | ||
Truffle::Zlib.crc32(*args) | ||
end | ||
|
||
module Deflate | ||
|
||
def self.deflate(message, level=DEFAULT_COMPRESSION) | ||
Truffle::Zlib.deflate(message, level) | ||
end | ||
|
||
end | ||
|
||
module Inflate | ||
|
||
def self.inflate(message) | ||
Truffle::Zlib.inflate(message) | ||
end | ||
|
||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
require 'digest/bubblebabble' | ||
|
||
describe "Digest.bubblebabble" do | ||
it "returns a String" do | ||
Digest.bubblebabble('').should be_an_instance_of(String) | ||
end | ||
|
||
it "returns a String in the The Bubble Babble Binary Data Encoding format" do | ||
Digest.bubblebabble('').should == 'xexax' | ||
Digest.bubblebabble('foo').should == 'xinik-zorox' | ||
Digest.bubblebabble('bar').should == 'ximik-cosex' | ||
Digest.bubblebabble('1234567890').should == 'xesef-disof-gytuf-katof-movif-baxux' | ||
end | ||
|
||
it "calls #to_str on an object and returns the bubble babble value of the result" do | ||
obj = mock("to_str") | ||
obj.should_receive(:to_str).and_return('foo') | ||
Digest.bubblebabble(obj).should == 'xinik-zorox' | ||
end | ||
|
||
it "raises a TypeError when passed nil" do | ||
lambda { Digest.bubblebabble(nil) }.should raise_error(TypeError) | ||
end | ||
|
||
it "raises a TypeError when passed a Fixnum" do | ||
lambda { Digest.bubblebabble(9001) }.should raise_error(TypeError) | ||
end | ||
end |
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 | ||
fails:ARGF.binmode returns self | ||
fails:ARGF.binmode sets the file's encoding to ASCII-8BIT |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
fails:ARGF.close closes the current open stream | ||
fails:ARGF.close returns self | ||
fails:ARGF.close raises an IOError if called on a closed stream | ||
fails:ARGF.close can close STDIN |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
fails:ARGF.eof returns true when reaching the end of a file | ||
fails:ARGF.eof raises IOError when called on a closed stream | ||
fails:ARGF.eof? returns true when reaching the end of a file | ||
fails:ARGF.eof? raises IOError when called on a closed stream |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
fails:ARGF.filename returns the current file name on each file | ||
fails:ARGF.filename sets the $FILENAME global variable with the current file name on each file |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
fails:ARGF.gets reads one line of a file | ||
fails:ARGF.gets reads all lines of a file | ||
fails:ARGF.gets reads all lines of two files | ||
fails:ARGF.gets sets $_ global variable with each line read | ||
fails:ARGF.gets modifies the files when in place edit mode is on | ||
fails:ARGF.gets modifies and backups two files when in place edit mode is on | ||
fails:ARGF.gets returns nil when reaching end of files | ||
fails:ARGF.gets reads the contents of the file with default encoding |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
fails:ARGF.path returns the current file name on each file | ||
fails:ARGF.path sets the $FILENAME global variable with the current file name on each file |
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
fails:ARGF.readline reads one line of a file | ||
fails:ARGF.readline reads all lines of a file | ||
fails:ARGF.readline reads all lines of two files | ||
fails:ARGF.readline sets $_ global variable with each line read | ||
fails:ARGF.readline modifies the files when in place edit mode is on | ||
fails:ARGF.readline modifies and backups two files when in place edit mode is on | ||
fails:ARGF.readline raises an EOFError when reaching end of files |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,2 @@ | ||
fails:Module#class_eval uses the optional filename and lineno parameters for error messages | ||
fails:Module#class_eval converts a non-string filename to a string using to_str | ||
fails:Module#class_eval raises a TypeError when the given filename can't be converted to string using to_str | ||
fails:Module#class_eval converts non string eval-string to string using to_str | ||
fails:Module#class_eval raises a TypeError when the given eval-string can't be converted to string using to_str | ||
fails:Module#class_eval raises an ArgumentError when a block and normal arguments are given | ||
fails:Module#class_eval adds methods respecting the lexical constant scope |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,2 @@ | ||
fails:Module#module_eval uses the optional filename and lineno parameters for error messages | ||
fails:Module#module_eval converts a non-string filename to a string using to_str | ||
fails:Module#module_eval raises a TypeError when the given filename can't be converted to string using to_str | ||
fails:Module#module_eval converts non string eval-string to string using to_str | ||
fails:Module#module_eval raises a TypeError when the given eval-string can't be converted to string using to_str | ||
fails:Module#module_eval raises an ArgumentError when a block and normal arguments are given | ||
fails:Module#module_eval adds methods respecting the lexical constant scope |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
fails:The super keyword passes along modified rest args when they weren't originally empty | ||
fails:The super keyword passes along modified rest args when they were originally empty | ||
fails:The super keyword raises a RuntimeError when called with implicit arguments from a method defined with define_method | ||
fails:The super keyword calls method_missing when a superclass method is not found | ||
fails:The super keyword without explicit arguments passes arguments and rest arguments | ||
fails:The super keyword without explicit arguments passes arguments and rest arguments including any modifications |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:BigDecimal#abs returns the absolute value | ||
fails:BigDecimal#abs properly handles special values |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
fails:BigDecimal#add returns a + [Fixnum value] with given precision | ||
fails:BigDecimal#add returns a + [Bignum value] with given precision | ||
fails:BigDecimal#add favors the precision specified in the second argument over the global limit | ||
fails:BigDecimal#add uses the current rounding mode if rounding is needed | ||
fails:BigDecimal#add uses the default ROUND_HALF_UP rounding if it wasn't explicitly changed | ||
fails:BigDecimal#add returns NaN if NaN is involved | ||
fails:BigDecimal#add returns Infinity or -Infinity if these are involved | ||
fails:BigDecimal#add returns NaN if Infinity + (- Infinity) | ||
fails:BigDecimal#add raises TypeError when adds nil | ||
fails:BigDecimal#add raises TypeError when precision parameter is nil | ||
fails:BigDecimal#add raises ArgumentError when precision parameter is negative |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fails:BigDecimal#=== tests for equality | ||
fails:BigDecimal#=== NaN is never equal to any number | ||
fails:BigDecimal#=== returns true for infinity values with the same sign | ||
fails:BigDecimal#=== returns false for infinity values with different signs | ||
fails:BigDecimal#=== returns false when infinite value compared to finite one | ||
fails:BigDecimal#=== returns false when compared objects that can not be coerced into BigDecimal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fails:BigDecimal#ceil returns an Integer, if n is unspecified | ||
fails:BigDecimal#ceil returns a BigDecimal, if n is specified | ||
fails:BigDecimal#ceil returns the smallest integer greater or equal to self, if n is unspecified | ||
fails:BigDecimal#ceil raise exception, if self is special value | ||
fails:BigDecimal#ceil returns n digits right of the decimal point if given n > 0 | ||
fails:BigDecimal#ceil sets n digits left of the decimal point to 0, if given n < 0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:BigDecimal#coerce returns [other, self] both as BigDecimal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fails:BigDecimal#<=> returns 0 if a == b | ||
fails:BigDecimal#<=> returns 1 if a > b | ||
fails:BigDecimal#<=> returns -1 if a < b | ||
fails:BigDecimal#<=> returns nil if NaN is involved | ||
fails:BigDecimal#<=> returns nil if the argument is nil |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
fails:BigDecimal#div with precision set to 0 returns a / b | ||
fails:BigDecimal#div with precision set to 0 returns 0 if divided by Infinity | ||
fails:BigDecimal#div with precision set to 0 returns (+|-) Infinity if (+|-) Infinity divided by one | ||
fails:BigDecimal#div with precision set to 0 returns NaN if Infinity / ((+|-) Infinity) | ||
fails:BigDecimal#div with precision set to 0 returns (+|-) Infinity if divided by zero | ||
fails:BigDecimal#div with precision set to 0 returns NaN if zero is divided by zero | ||
fails:BigDecimal#div returns a / b with optional precision | ||
fails:BigDecimal#div raises FloatDomainError if NaN is involved | ||
fails:BigDecimal#div returns 0 if divided by Infinity and no precision given | ||
fails:BigDecimal#div returns 0 if divided by Infinity with given precision | ||
fails:BigDecimal#div raises ZeroDivisionError if divided by zero and no precision given | ||
fails:BigDecimal#div returns NaN if zero is divided by zero | ||
fails:BigDecimal#div raises FloatDomainError if (+|-) Infinity divided by 1 and no precision given | ||
fails:BigDecimal#div returns (+|-)Infinity if (+|-)Infinity by 1 and precision given | ||
fails:BigDecimal#div returns NaN if Infinity / ((+|-) Infinity) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fails:BigDecimal#/ returns a / b | ||
fails:BigDecimal#/ returns 0 if divided by Infinity | ||
fails:BigDecimal#/ returns (+|-) Infinity if (+|-) Infinity divided by one | ||
fails:BigDecimal#/ returns NaN if Infinity / ((+|-) Infinity) | ||
fails:BigDecimal#/ returns (+|-) Infinity if divided by zero | ||
fails:BigDecimal#/ returns NaN if zero is divided by zero |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
fails:BigDecimal#mod_part_of_divmod returns self modulo other | ||
fails:BigDecimal#mod_part_of_divmod returns a [Float value] when the argument is Float | ||
fails:BigDecimal#mod_part_of_divmod returns NaN if NaN is involved | ||
fails:BigDecimal#mod_part_of_divmod returns NaN if the dividend is Infinity | ||
fails:BigDecimal#mod_part_of_divmod returns the dividend if the divisor is Infinity | ||
fails:BigDecimal#mod_part_of_divmod raises TypeError if the argument cannot be coerced to BigDecimal | ||
fails:BigDecimal#mod_part_of_divmod raises ZeroDivisionError if other is zero | ||
fails:BigDecimal#divmod divides value, returns an array | ||
fails:BigDecimal#divmod array contains quotient and modulus as BigDecimal | ||
fails:BigDecimal#divmod Can be reversed with * and + | ||
fails:BigDecimal#divmod returns an array of two NaNs if NaN is involved | ||
fails:BigDecimal#divmod raises ZeroDivisionError if the divisor is zero | ||
fails:BigDecimal#divmod returns an array of Infinity and NaN if the dividend is Infinity | ||
fails:BigDecimal#divmod returns an array of zero and the dividend if the divisor is Infinity | ||
fails:BigDecimal#divmod returns an array of two zero if the diviend is zero | ||
fails:BigDecimal#divmod raises TypeError if the argument cannot be coerced to BigDecimal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:BigDecimal.double_fig returns the number of digits a Float number is allowed to have |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fails:BigDecimal#eql? tests for equality | ||
fails:BigDecimal#eql? NaN is never equal to any number | ||
fails:BigDecimal#eql? returns true for infinity values with the same sign | ||
fails:BigDecimal#eql? returns false for infinity values with different signs | ||
fails:BigDecimal#eql? returns false when infinite value compared to finite one | ||
fails:BigDecimal#eql? returns false when compared objects that can not be coerced into BigDecimal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fails:BigDecimal#== tests for equality | ||
fails:BigDecimal#== NaN is never equal to any number | ||
fails:BigDecimal#== returns true for infinity values with the same sign | ||
fails:BigDecimal#== returns false for infinity values with different signs | ||
fails:BigDecimal#== returns false when infinite value compared to finite one | ||
fails:BigDecimal#== returns false when compared objects that can not be coerced into BigDecimal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
fails:BigDecimal#** powers of self | ||
fails:BigDecimal#** powers of 1 equal 1 | ||
fails:BigDecimal#** 0 to power of 0 is 1 | ||
fails:BigDecimal#** 0 to powers < 0 is Infinity | ||
fails:BigDecimal#** other powers of 0 are 0 | ||
fails:BigDecimal#** returns NaN if self is NaN | ||
fails:BigDecimal#** returns 0.0 if self is infinite and argument is negative | ||
fails:BigDecimal#** returns infinite if self is infinite and argument is positive | ||
fails:BigDecimal#exponent returns an Integer | ||
fails:BigDecimal#exponent is n if number can be represented as 0.xxx*10**n | ||
fails:BigDecimal#exponent returns 0 if self is 0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:BigDecimal#finite? is false if Infinity or NaN | ||
fails:BigDecimal#finite? returns true for finite values |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fails:BigDecimal#fix returns a BigDecimal | ||
fails:BigDecimal#fix returns the integer part of the absolute value | ||
fails:BigDecimal#fix correctly handles special values | ||
fails:BigDecimal#fix returns 0 if the absolute value is < 1 | ||
fails:BigDecimal#fix does not allow any arguments |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fails:BigDecimal#floor returns the greatest integer smaller or equal to self | ||
fails:BigDecimal#floor raise exception, if self is special value | ||
fails:BigDecimal#floor returns n digits right of the decimal point if given n > 0 | ||
fails:BigDecimal#floor sets n digits left of the decimal point to 0, if given n < 0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fails:BigDecimal#frac returns a BigDecimal | ||
fails:BigDecimal#frac returns the fractional part of the absolute value | ||
fails:BigDecimal#frac returns 0 if the value is 0 | ||
fails:BigDecimal#frac returns 0 if the value is an integer | ||
fails:BigDecimal#frac correctly handles special values |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fails:BigDecimal#> returns true if a > b | ||
fails:BigDecimal#> properly handles infinity values | ||
fails:BigDecimal#> properly handles NaN values | ||
fails:BigDecimal#> raises an ArgumentError if the argument can't be coerced into a BigDecimal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fails:BigDecimal#>= returns true if a >= b | ||
fails:BigDecimal#>= properly handles infinity values | ||
fails:BigDecimal#>= properly handles NaN values | ||
fails:BigDecimal#>= returns nil if the argument is nil |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fails:BigDecimal#infinite? returns 1 if self is Infinity | ||
fails:BigDecimal#infinite? returns -1 if self is -Infinity | ||
fails:BigDecimal#infinite? returns not true otherwise | ||
fails:BigDecimal#infinite? returns not true if self is NaN |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
fails:BigDecimal#inspect returns String | ||
fails:BigDecimal#inspect returns String starting with # | ||
fails:BigDecimal#inspect encloses information in angle brackets | ||
fails:BigDecimal#inspect is comma separated list of three items | ||
fails:BigDecimal#inspect value after first comma is value as string | ||
fails:BigDecimal#inspect last part is number of significant digits | ||
fails:BigDecimal#inspect looks like this |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:BigDecimal.limit returns the value before set if the passed argument is nil or is not specified | ||
fails:BigDecimal.limit use the global limit if no precision is specified |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fails:BigDecimal#< returns true if a < b | ||
fails:BigDecimal#< properly handles infinity values | ||
fails:BigDecimal#< properly handles NaN values | ||
fails:BigDecimal#< raises an ArgumentError if the argument can't be coerced into a BigDecimal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fails:BigDecimal#<= returns true if a <= b | ||
fails:BigDecimal#<= properly handles infinity values | ||
fails:BigDecimal#<= properly handles NaN values | ||
fails:BigDecimal#<= raises an ArgumentError if the argument can't be coerced into a BigDecimal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fails:BigDecimal#- returns NaN if NaN is involved | ||
fails:BigDecimal#- returns NaN both operands are infinite with the same sign | ||
fails:BigDecimal#- returns Infinity or -Infinity if these are involved |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fails:BigDecimal.mode returns the appropriate value and continue the computation if the flag is false | ||
fails:BigDecimal.mode returns Infinity when too big | ||
fails:BigDecimal.mode raise an exception if the flag is true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
fails:BigDecimal#% returns self modulo other | ||
fails:BigDecimal#% returns a [Float value] when the argument is Float | ||
fails:BigDecimal#% returns NaN if NaN is involved | ||
fails:BigDecimal#% returns NaN if the dividend is Infinity | ||
fails:BigDecimal#% returns the dividend if the divisor is Infinity | ||
fails:BigDecimal#% raises TypeError if the argument cannot be coerced to BigDecimal | ||
fails:BigDecimal#% raises ZeroDivisionError if other is zero | ||
fails:BigDecimal#modulo returns self modulo other | ||
fails:BigDecimal#modulo returns a [Float value] when the argument is Float | ||
fails:BigDecimal#modulo returns NaN if NaN is involved | ||
fails:BigDecimal#modulo returns NaN if the dividend is Infinity | ||
fails:BigDecimal#modulo returns the dividend if the divisor is Infinity | ||
fails:BigDecimal#modulo raises TypeError if the argument cannot be coerced to BigDecimal | ||
fails:BigDecimal#modulo raises ZeroDivisionError if other is zero |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fails:BigDecimal#mult returns zero of appropriate sign if self or argument is zero | ||
fails:BigDecimal#mult returns NaN if NaN is involved | ||
fails:BigDecimal#mult returns zero if self or argument is zero | ||
fails:BigDecimal#mult returns infinite value if self or argument is infinite | ||
fails:BigDecimal#mult returns NaN if the result is undefined | ||
fails:BigDecimal#mult multiply self with other with (optional) precision |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fails:BigDecimal#* returns zero of appropriate sign if self or argument is zero | ||
fails:BigDecimal#* returns NaN if NaN is involved | ||
fails:BigDecimal#* returns zero if self or argument is zero | ||
fails:BigDecimal#* returns infinite value if self or argument is infinite | ||
fails:BigDecimal#* returns NaN if the result is undefined | ||
fails:BigDecimal#* multiply self with other |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:BigDecimal#nan? returns true if self is not a number | ||
fails:BigDecimal#nan? returns false if self is not a NaN |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
fails:BigDecimal.new creates a new object of class BigDecimal | ||
fails:BigDecimal.new doesn't segfault when using a very large string to build the number | ||
fails:BigDecimal.new Number of significant digits >= given precision | ||
fails:BigDecimal.new determines precision from initial value | ||
fails:BigDecimal.new ignores leading whitespace | ||
fails:BigDecimal.new ignores trailing garbage | ||
fails:BigDecimal.new treats invalid strings as 0.0 | ||
fails:BigDecimal.new allows omitting the integer part | ||
fails:BigDecimal.new allows for underscores in all parts | ||
fails:BigDecimal.new accepts NaN and [+-]Infinity | ||
fails:BigDecimal.new allows for [eEdD] as exponent separator | ||
fails:BigDecimal.new allows for varying signs |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:BigDecimal#nonzero? returns self if self doesn't equal zero | ||
fails:BigDecimal#nonzero? returns nil otherwise |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fails:BigDecimal#+ returns NaN if NaN is involved | ||
fails:BigDecimal#+ returns Infinity or -Infinity if these are involved | ||
fails:BigDecimal#+ returns NaN if Infinity + (- Infinity) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
fails:BigDecimal#power powers of self | ||
fails:BigDecimal#power powers of 1 equal 1 | ||
fails:BigDecimal#power 0 to power of 0 is 1 | ||
fails:BigDecimal#power 0 to powers < 0 is Infinity | ||
fails:BigDecimal#power other powers of 0 are 0 | ||
fails:BigDecimal#power returns NaN if self is NaN | ||
fails:BigDecimal#power returns 0.0 if self is infinite and argument is negative | ||
fails:BigDecimal#power returns infinite if self is infinite and argument is positive |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fails:BigDecimal#precs returns array of two values | ||
fails:BigDecimal#precs returns Integers as array values | ||
fails:BigDecimal#precs returns the current value of significant digits as the first value | ||
fails:BigDecimal#precs returns the maximum number of significant digits as the second value |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
fails:BigDecimal#quo returns a / b | ||
fails:BigDecimal#quo returns 0 if divided by Infinity | ||
fails:BigDecimal#quo returns (+|-) Infinity if (+|-) Infinity divided by one | ||
fails:BigDecimal#quo returns NaN if Infinity / ((+|-) Infinity) | ||
fails:BigDecimal#quo returns (+|-) Infinity if divided by zero | ||
fails:BigDecimal#quo returns NaN if zero is divided by zero | ||
fails:BigDecimal#quo returns NaN if NaN is involved |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
fails:BigDecimal#remainder it equals modulo, if both values are of same sign | ||
fails:BigDecimal#remainder means self-arg*(self/arg).truncate | ||
fails:BigDecimal#remainder returns NaN used with zero | ||
fails:BigDecimal#remainder returns zero if used on zero | ||
fails:BigDecimal#remainder returns NaN if NaN is involved | ||
fails:BigDecimal#remainder returns NaN if Infinity is involved | ||
fails:BigDecimal#remainder coerces arguments to BigDecimal if possible | ||
fails:BigDecimal#remainder raises TypeError if the argument cannot be coerced to BigDecimal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
fails:BigDecimal#round uses default rounding method unless given | ||
fails:BigDecimal#round BigDecimal::ROUND_UP rounds values away from zero | ||
fails:BigDecimal#round BigDecimal::ROUND_DOWN rounds values towards zero | ||
fails:BigDecimal#round BigDecimal::ROUND_HALF_UP rounds values >= 5 up, otherwise down | ||
fails:BigDecimal#round BigDecimal::ROUND_HALF_DOWN rounds values > 5 up, otherwise down | ||
fails:BigDecimal#round BigDecimal::ROUND_CEILING rounds values towards +infinity | ||
fails:BigDecimal#round BigDecimal::ROUND_FLOOR rounds values towards -infinity | ||
fails:BigDecimal#round BigDecimal::ROUND_HALF_EVEN rounds values > 5 up, < 5 down and == 5 towards even neighbor |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fails:BigDecimal#sign BigDecimal defines several constants for signs | ||
fails:BigDecimal#sign returns positive value if BigDecimal greater than 0 | ||
fails:BigDecimal#sign returns negative value if BigDecimal less than 0 | ||
fails:BigDecimal#sign returns positive zero if BigDecimal equals positve zero | ||
fails:BigDecimal#sign returns negative zero if BigDecimal equals negative zero | ||
fails:BigDecimal#sign returns BigDecimal::SIGN_NaN if BigDecimal is NaN |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
fails:BigDecimal#split splits BigDecimal in an array with four values | ||
fails:BigDecimal#split First value: 1 for numbers > 0 | ||
fails:BigDecimal#split First value: -1 for numbers < 0 | ||
fails:BigDecimal#split First value: 0 if BigDecimal is NaN | ||
fails:BigDecimal#split Second value: a string with the significant digits | ||
fails:BigDecimal#split Third value: the base (currently always ten) | ||
fails:BigDecimal#split Fourth value: The exponent |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
fails:BigDecimal#sqrt returns square root of 2 with desired precision | ||
fails:BigDecimal#sqrt returns square root of 3 with desired precision | ||
fails:BigDecimal#sqrt returns square root of 121 with desired precision | ||
fails:BigDecimal#sqrt returns square root of 0.9E-99999 with desired precision | ||
fails:BigDecimal#sqrt raises ArgumentError when no argument is given | ||
fails:BigDecimal#sqrt raises ArgumentError if a negative number is given | ||
fails:BigDecimal#sqrt raises ArgumentError if 2 arguments are given | ||
fails:BigDecimal#sqrt raises TypeError if nil is given | ||
fails:BigDecimal#sqrt raises TypeError if a string is given | ||
fails:BigDecimal#sqrt raises TypeError if a plain Object is given | ||
fails:BigDecimal#sqrt returns 1 if precision is 0 or 1 | ||
fails:BigDecimal#sqrt raises FloatDomainError on negative values | ||
fails:BigDecimal#sqrt returns positive infitinity for infinity | ||
fails:BigDecimal#sqrt raises FloatDomainError for negative infinity | ||
fails:BigDecimal#sqrt raises FloatDomainError for NaN | ||
fails:BigDecimal#sqrt returns 0 for 0, +0.0 and -0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fails:BigDecimal#sub returns NaN if NaN is involved | ||
fails:BigDecimal#sub returns NaN if both values are infinite with the same signs | ||
fails:BigDecimal#sub returns Infinity or -Infinity if these are involved |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fails:BigDecimal#to_f returns number of type float | ||
fails:BigDecimal#to_f Floating point rounding occurs | ||
fails:BigDecimal#to_f properly handles special values | ||
fails:BigDecimal#to_f remembers negative zero when converted to float |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:BigDecimal#to_i raises FloatDomainError if BigDecimal is infinity or NaN | ||
fails:BigDecimal#to_i returns Integer or Bignum otherwise |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:BigDecimal#to_int raises FloatDomainError if BigDecimal is infinity or NaN | ||
fails:BigDecimal#to_int returns Integer or Bignum otherwise |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
fails:BigDecimal#to_s the default format looks like 0.xxxxEnn | ||
fails:BigDecimal#to_s takes an optional argument | ||
fails:BigDecimal#to_s starts with + if + is supplied and value is positive | ||
fails:BigDecimal#to_s inserts a space every n chars, if integer n is supplied | ||
fails:BigDecimal#to_s can return a leading space for values > 0 | ||
fails:BigDecimal#to_s removes trailing spaces in floating point notation | ||
fails:BigDecimal#to_s can use engineering notation | ||
fails:BigDecimal#to_s can use conventional floating point notation |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
fails:BigDecimal#truncate returns value of type Integer. | ||
fails:BigDecimal#truncate returns the integer part as a BigDecimal if no precision given | ||
fails:BigDecimal#truncate returns value of given precision otherwise | ||
fails:BigDecimal#truncate sets n digits left of the decimal point to 0, if given n < 0 | ||
fails:BigDecimal#truncate returns NaN if self is NaN | ||
fails:BigDecimal#truncate returns Infinity if self is infinite | ||
fails:BigDecimal#truncate returns the same value if self is special value |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:BigDecimal#-@ negates self | ||
fails:BigDecimal#-@ properly handles special values |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:BigDecimal#+@ returns the same value with same sign (twos complement) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:BigDecimal.ver returns the Version number |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:BigDecimal#zero? returns true if self does equal zero | ||
fails:BigDecimal#zero? returns false otherwise |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:Digest.bubblebabble returns a String in the The Bubble Babble Binary Data Encoding format |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:SecureRandom.base64 generates a random base64 string out of specified number of random bytes | ||
fails:SecureRandom.base64 tries to convert the passed argument to an Integer using #to_int |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:SecureRandom.hex generates a random hex string of length twice the specified argement | ||
fails:SecureRandom.hex tries to convert the passed argument to an Integer using #to_int |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:SecureRandom.random_bytes generates a random binary string of specified length | ||
fails:SecureRandom.random_bytes tries to convert the passed argument to an Integer using #to_int |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:Thread::SizedQueue#deq raises a ThreadError if Queue is empty |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:Thread::SizedQueue#pop raises a ThreadError if Queue is empty |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:Thread::SizedQueue#shift raises a ThreadError if Queue is empty |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fails:Zlib.adler32 calculates Adler checksum for string | ||
fails:Zlib.adler32 calculates Adler checksum for string and initial Adler value | ||
fails:Zlib.adler32 calculates the Adler checksum for string and initial Adler value for Bignums | ||
fails:Zlib.adler32 assumes that the initial value is given to adler, if adler is omitted | ||
fails:Zlib.adler32 it returns the CRC initial value, if string is omitted |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:Zlib.crc_table returns the same value as zlib's get_crc_table() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:Zlib::Deflate#deflate deflates some data | ||
fails:Zlib::Deflate#deflate deflates lots of data |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:Zlib::Deflate#params changes the deflate parameters |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:Zlib::Deflate#set_dictionary sets the dictionary |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:Zlib::GzipFile#close finishes the stream and closes the io |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:Zlib::GzipFile#closed? returns the closed status |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:Zlib::GzipFile#comment returns the name | ||
fails:Zlib::GzipFile#comment raises an error on a closed stream |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:Zlib::GzipFile#orig_name returns the name | ||
fails:Zlib::GzipFile#orig_name raises an error on a closed stream |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:GzipReader#each_byte calls the given block for each byte in the stream, passing the byte as an argument | ||
fails:GzipReader#each_byte increments position before calling the block |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fails:GzipReader#eof? returns true when at EOF | ||
fails:GzipReader#eof? returns true when at EOF with the exact length of uncompressed data | ||
fails:GzipReader#eof? returns true when at EOF with a length greater than the size of uncompressed data | ||
fails:GzipReader#eof? returns false when at EOF when there's data left in the buffer to read | ||
fails:GzipReader#eof? does not affect the reading data |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fails:GzipReader#getc returns the next character from the stream | ||
fails:GzipReader#getc increments position | ||
fails:GzipReader#getc returns nil at the end of the stream |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:GzipReader#pos returns the position |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
fails:GzipReader#read with no arguments reads the entire content of a gzip file | ||
fails:GzipReader#read with nil length argument reads the entire content of a gzip file | ||
fails:GzipReader#read reads the contents up to a certain size | ||
fails:GzipReader#read does not accept a negative length to read | ||
fails:GzipReader#read returns an empty string if a 0 length is given | ||
fails:GzipReader#read respects :external_encoding option | ||
fails:GzipReader#read at the end of data returns empty string if length prameter is not specified or 0 | ||
fails:GzipReader#read at the end of data returns nil if length prameter is positive |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fails:GzipReader#rewind resets the position of the stream pointer | ||
fails:GzipReader#rewind resets the position of the stream pointer to data previously read | ||
fails:GzipReader#rewind invokes seek method on the associated IO object |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:Zlib::GzipWriter#<< returns self |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fails:Zlib::GzipWriter#mtime= sets mtime using Integer | ||
fails:Zlib::GzipWriter#mtime= sets mtime using Time | ||
fails:Zlib::GzipWriter#mtime= raises if the header was written |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fails:GzipWriter#write writes some compressed data | ||
fails:GzipWriter#write returns the number of bytes in the input | ||
fails:GzipWriter#write handles inputs of 2^23 bytes |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
fails:Zlib::Inflate#<< appends data to the input stream | ||
fails:Zlib::Inflate#<< treats nil argument as the end of compressed data | ||
fails:Zlib::Inflate#<< just passes through the data after nil argument | ||
fails:Zlib::Inflate#<< properly handles data in chunks | ||
fails:Zlib::Inflate#<< properly handles incomplete data | ||
fails:Zlib::Inflate#<< properly handles excessive data, byte-by-byte | ||
fails:Zlib::Inflate#<< properly handles excessive data, in one go |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
fails:Zlib::Inflate#inflate inflates some data | ||
fails:Zlib::Inflate#inflate inflates lots of data | ||
fails:Zlib::Inflate#inflate works in pass-through mode, once finished | ||
fails:Zlib::Inflate::inflate properly handles data in chunks | ||
fails:Zlib::Inflate::inflate properly handles incomplete data | ||
fails:Zlib::Inflate::inflate properly handles excessive data, byte-by-byte | ||
fails:Zlib::Inflate::inflate properly handles excessive data, in one go |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:Zlib::Inflate#set_dictionary sets the inflate dictionary |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:Zlib::ZStream#adler generates hash |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:Zlib::ZStream#avail_in returns bytes in the input buffer |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:Zlib::ZStream#avail_out returns bytes in the output buffer |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:Zlib::ZStream#data_type returns the type of the data in the stream |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fails:Zlib::ZStream#flush_next_out flushes the stream and flushes the output buffer |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
exclude :test_ipv4_compat, "needs investigation" | ||
exclude :test_ipv4_mapped, "needs investigation" | ||
exclude :test_s_new, "needs investigation" | ||
exclude :test_ip6_arpa, "needs investigation" | ||
exclude :test_ip6_int, "needs investigation" | ||
exclude :test_reverse, "needs investigation" | ||
exclude :test_s_new_ntoh, "needs investigation" | ||
exclude :test_to_s, "needs investigation" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
exclude :test_hash, "needs investigation" | ||
exclude :test_or, "needs investigation" | ||
exclude :test_and, "needs investigation" | ||
exclude :test_carrot, "needs investigation" | ||
exclude :test_equal, "needs investigation" | ||
exclude :test_include?, "needs investigation" | ||
exclude :test_mask, "needs investigation" | ||
exclude :test_shift_left, "needs investigation" | ||
exclude :test_shift_right, "needs investigation" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
exclude :test_tms_outputs_nicely, "needs investigation" | ||
exclude :test_benchmark_makes_extra_calcultations_with_an_Array_at_the_end_of_the_benchmark_and_show_the_result, "needs investigation" | ||
exclude :test_bm_correctly_output_when_no_label_is_given, "needs investigation" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
exclude :test_bigdecimal, "needs investigation" | ||
exclude :test_extended_json_fail2, "needs investigation" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
exclude :test_beg_len, "needs investigation" | ||
exclude :test_bsearch_for_bignum, "needs investigation" | ||
exclude :test_bsearch_for_fixnum, "needs investigation" | ||
exclude :test_bsearch_for_float, "needs investigation" | ||
exclude :test_bsearch_for_other_numerics, "needs investigation" | ||
exclude :test_bsearch_with_mathn, "needs investigation" | ||
exclude :test_comparison_when_recursive, "needs investigation" | ||
exclude :test_cyclic_range_inspect, "needs investigation" | ||
exclude :test_duckrange, "needs investigation" | ||
exclude :test_each, "needs investigation" | ||
exclude :test_each_no_blockarg, "needs investigation" | ||
exclude :test_initialize_twice, "needs investigation" | ||
exclude :test_max, "needs investigation" | ||
exclude :test_min, "needs investigation" | ||
exclude :test_range_bsearch_for_floats, "needs investigation" | ||
exclude :test_range_numeric_string, "needs investigation" | ||
exclude :test_size, "needs investigation" |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* 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.constants; | ||
|
||
import org.jruby.truffle.nodes.RubyNode; | ||
import org.jruby.truffle.nodes.core.KernelNodes.RequireNode; | ||
import org.jruby.truffle.nodes.core.KernelNodesFactory; | ||
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode; | ||
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory; | ||
import org.jruby.truffle.runtime.RubyConstant; | ||
import org.jruby.truffle.runtime.RubyContext; | ||
import org.jruby.truffle.runtime.core.RubyModule; | ||
import org.jruby.truffle.runtime.core.RubyString; | ||
import org.jruby.truffle.runtime.core.RubySymbol; | ||
|
||
import com.oracle.truffle.api.dsl.Cached; | ||
import com.oracle.truffle.api.dsl.NodeChild; | ||
import com.oracle.truffle.api.dsl.NodeChildren; | ||
import com.oracle.truffle.api.dsl.Specialization; | ||
import com.oracle.truffle.api.frame.VirtualFrame; | ||
import com.oracle.truffle.api.source.SourceSection; | ||
|
||
@NodeChildren({ | ||
@NodeChild("module"), @NodeChild("name"), | ||
@NodeChild(value = "lookupConstantNode", type = LookupConstantNode.class, executeWith = { "module", "name" }) | ||
}) | ||
public abstract class GetConstantNode extends RubyNode { | ||
|
||
public GetConstantNode(RubyContext context, SourceSection sourceSection) { | ||
super(context, sourceSection); | ||
} | ||
|
||
public abstract RubyNode getModule(); | ||
public abstract LookupConstantNode getLookupConstantNode(); | ||
|
||
public abstract Object executeGetConstant(VirtualFrame frame, Object module, String name); | ||
|
||
@Specialization(guards = { "constant != null", "!constant.isAutoload()" }) | ||
protected Object getConstant(RubyModule module, String name, RubyConstant constant) { | ||
return constant.getValue(); | ||
} | ||
|
||
@Specialization(guards = { "constant != null", "constant.isAutoload()" }) | ||
protected Object autoloadConstant(VirtualFrame frame, RubyModule module, String name, RubyConstant constant, | ||
@Cached("createRequireNode()") RequireNode requireNode) { | ||
|
||
requireNode.require((RubyString) constant.getValue()); | ||
|
||
// retry | ||
return this.executeGetConstant(frame, module, name); | ||
} | ||
|
||
@Specialization(guards = "constant == null") | ||
protected Object missingConstant(VirtualFrame frame, RubyModule module, String name, Object constant, | ||
@Cached("createConstMissingNode()") CallDispatchHeadNode constMissingNode, | ||
@Cached("getContext().getSymbol(name)") RubySymbol symbolName) { | ||
return constMissingNode.call(frame, module, "const_missing", null, symbolName); | ||
} | ||
|
||
protected RequireNode createRequireNode() { | ||
return KernelNodesFactory.RequireNodeFactory.create(getContext(), getSourceSection(), new RubyNode[] {}); | ||
} | ||
|
||
protected CallDispatchHeadNode createConstMissingNode() { | ||
return DispatchHeadNodeFactory.createMethodCall(getContext()); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* 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.constants; | ||
|
||
import org.jruby.truffle.nodes.RubyNode; | ||
import org.jruby.truffle.nodes.dispatch.DispatchNode; | ||
import org.jruby.truffle.runtime.LexicalScope; | ||
import org.jruby.truffle.runtime.ModuleOperations; | ||
import org.jruby.truffle.runtime.RubyConstant; | ||
import org.jruby.truffle.runtime.RubyContext; | ||
import org.jruby.truffle.runtime.control.RaiseException; | ||
import org.jruby.truffle.runtime.core.RubyModule; | ||
|
||
import com.oracle.truffle.api.CompilerDirectives; | ||
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; | ||
import com.oracle.truffle.api.dsl.Cached; | ||
import com.oracle.truffle.api.dsl.NodeChild; | ||
import com.oracle.truffle.api.dsl.NodeChildren; | ||
import com.oracle.truffle.api.dsl.Specialization; | ||
import com.oracle.truffle.api.frame.VirtualFrame; | ||
import com.oracle.truffle.api.source.SourceSection; | ||
|
||
@NodeChildren({ @NodeChild("module"), @NodeChild("name") }) | ||
public abstract class LookupConstantNode extends RubyNode { | ||
|
||
public static int getCacheLimit() { | ||
return DispatchNode.DISPATCH_POLYMORPHIC_MAX; | ||
} | ||
|
||
private final LexicalScope lexicalScope; | ||
|
||
public LookupConstantNode(RubyContext context, SourceSection sourceSection, LexicalScope lexicalScope) { | ||
super(context, sourceSection); | ||
this.lexicalScope = lexicalScope; | ||
} | ||
|
||
public LexicalScope getLexicalScope() { | ||
return lexicalScope; | ||
} | ||
|
||
public abstract RubyConstant executeLookupConstant(VirtualFrame frame, Object module, String name); | ||
|
||
@Specialization(guards = { | ||
"module == cachedModule", | ||
"name.equals(cachedName)" | ||
}, assumptions = "cachedModule.getUnmodifiedAssumption()", limit = "getCacheLimit()") | ||
protected RubyConstant lookupConstant(VirtualFrame frame, RubyModule module, String name, | ||
@Cached("module") RubyModule cachedModule, | ||
@Cached("name") String cachedName, | ||
@Cached("doLookup(cachedModule, cachedName)") RubyConstant constant, | ||
@Cached("isVisible(cachedModule, constant)") boolean isVisible) { | ||
if (!isVisible) { | ||
CompilerDirectives.transferToInterpreter(); | ||
throw new RaiseException(getContext().getCoreLibrary().nameErrorPrivateConstant(module, name, this)); | ||
} | ||
return constant; | ||
} | ||
|
||
@TruffleBoundary | ||
@Specialization | ||
protected RubyConstant lookupConstantUncached(RubyModule module, String name) { | ||
RubyConstant constant = doLookup(module, name); | ||
boolean isVisible = isVisible(module, constant); | ||
|
||
if (!isVisible) { | ||
CompilerDirectives.transferToInterpreter(); | ||
throw new RaiseException(getContext().getCoreLibrary().nameErrorPrivateConstant(module, name, this)); | ||
} | ||
return constant; | ||
} | ||
|
||
@Specialization(guards = "!isRubyModule(module)") | ||
protected RubyConstant lookupNotModule(Object module, String name) { | ||
CompilerDirectives.transferToInterpreter(); | ||
throw new RaiseException(getContext().getCoreLibrary().typeErrorIsNotA(module.toString(), "class/module", this)); | ||
} | ||
|
||
protected RubyConstant doLookup(RubyModule module, String name) { | ||
return ModuleOperations.lookupConstant(getContext(), lexicalScope, module, name); | ||
} | ||
|
||
protected boolean isVisible(RubyModule module, RubyConstant constant) { | ||
return constant == null || constant.isVisibleTo(getContext(), lexicalScope, module); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,244 @@ | ||
/* | ||
* Copyright (c) 2013, 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.core; | ||
|
||
import com.oracle.truffle.api.CompilerDirectives; | ||
import com.oracle.truffle.api.dsl.Specialization; | ||
import com.oracle.truffle.api.nodes.Node; | ||
import com.oracle.truffle.api.object.*; | ||
import com.oracle.truffle.api.source.SourceSection; | ||
|
||
import org.jruby.truffle.nodes.objects.Allocator; | ||
import org.jruby.truffle.runtime.RubyContext; | ||
import org.jruby.truffle.runtime.UndefinedPlaceholder; | ||
import org.jruby.truffle.runtime.core.*; | ||
|
||
import java.math.BigDecimal; | ||
import java.math.MathContext; | ||
import java.util.EnumSet; | ||
|
||
@CoreClass(name = "Truffle::BigDecimal") | ||
public abstract class BigDecimalNodes { | ||
|
||
private static final HiddenKey VALUE_IDENTIFIER = new HiddenKey("value"); | ||
private static final DynamicObjectFactory BIG_DECIMAL_FACTORY; | ||
public static final Property VALUE_PROPERTY; | ||
|
||
static { | ||
Shape.Allocator allocator = RubyBasicObject.LAYOUT.createAllocator(); | ||
VALUE_PROPERTY = Property.create( | ||
VALUE_IDENTIFIER, | ||
allocator.locationForType(BigDecimal.class, EnumSet.of(LocationModifier.NonNull)), | ||
0); | ||
Shape shape = RubyBasicObject.EMPTY_SHAPE.addProperty(VALUE_PROPERTY); | ||
BIG_DECIMAL_FACTORY = shape.createFactory(); | ||
} | ||
|
||
// TODO (pitr 15-May-2015) figure out where to put RubyBigDecimal, or remove completely | ||
public static class RubyBigDecimal extends RubyBasicObject { | ||
public RubyBigDecimal(RubyClass rubyClass, DynamicObject dynamicObject) { | ||
super(rubyClass, dynamicObject); | ||
} | ||
} | ||
|
||
public static class RubyBigDecimalAllocator implements Allocator { | ||
|
||
@Override | ||
public RubyBasicObject allocate(RubyContext context, RubyClass rubyClass, Node currentNode) { | ||
return createRubyBigDecimal(rubyClass, BigDecimal.ZERO); | ||
} | ||
|
||
} | ||
|
||
public static BigDecimal getBigDecimalValue(RubyBasicObject bignum) { | ||
assert bignum.getDynamicObject().getShape().hasProperty(VALUE_IDENTIFIER); | ||
return (BigDecimal) VALUE_PROPERTY.get(bignum.getDynamicObject(), true); | ||
} | ||
|
||
public static void setBigDecimalValue(RubyBasicObject bignum, BigDecimal value) { | ||
assert bignum.getDynamicObject().getShape().hasProperty(VALUE_IDENTIFIER); | ||
VALUE_PROPERTY.setSafe(bignum.getDynamicObject(), value, null); | ||
} | ||
|
||
public static RubyBigDecimal createRubyBigDecimal(RubyClass rubyClass, BigDecimal value) { | ||
return new RubyBigDecimal(rubyClass, BIG_DECIMAL_FACTORY.newInstance(value)); | ||
} | ||
|
||
public abstract static class BigDecimalCoreMethodNode extends CoreMethodArrayArgumentsNode { | ||
|
||
public BigDecimalCoreMethodNode(RubyContext context, SourceSection sourceSection) { | ||
super(context, sourceSection); | ||
} | ||
|
||
public static boolean isRubyBigDecimal(Object value) { | ||
return value instanceof RubyBigDecimal; | ||
} | ||
} | ||
|
||
@CoreMethod(names = "initialize", required = 1) | ||
public abstract static class InitializeNode extends BigDecimalCoreMethodNode { | ||
|
||
public InitializeNode(RubyContext context, SourceSection sourceSection) { | ||
super(context, sourceSection); | ||
} | ||
|
||
@Specialization(guards = "isRubyBigDecimal(v)") | ||
public RubyBasicObject initialize(RubyBigDecimal self, RubyBasicObject v) { | ||
return v; | ||
} | ||
|
||
@Specialization(guards = "isRubyString(v)") | ||
public RubyBasicObject initializeFromString(RubyBigDecimal self, RubyBasicObject v) { | ||
switch (v.toString()) { | ||
case "NaN": // FIXME | ||
case "Infinity": // FIXME | ||
case "+Infinity": // FIXME | ||
case "-Infinity": // FIXME | ||
return self; | ||
} | ||
|
||
setBigDecimalValue(self, new BigDecimal(v.toString())); | ||
return self; | ||
} | ||
} | ||
|
||
// TODO: double specializations | ||
|
||
@CoreMethod(names = "+", required = 1) | ||
public abstract static class AdditionNode extends BigDecimalCoreMethodNode { | ||
|
||
public AdditionNode(RubyContext context, SourceSection sourceSection) { | ||
super(context, sourceSection); | ||
} | ||
|
||
@Specialization | ||
public Object add(RubyBasicObject a, int b) { | ||
return createRubyBigDecimal( | ||
getContext().getCoreLibrary().getBigDecimalClass(), | ||
getBigDecimalValue(a).add(BigDecimal.valueOf(b))); | ||
} | ||
|
||
@Specialization | ||
public Object add(RubyBasicObject a, long b) { | ||
return createRubyBigDecimal( | ||
getContext().getCoreLibrary().getBigDecimalClass(), | ||
getBigDecimalValue(a).add(BigDecimal.valueOf(b))); | ||
} | ||
|
||
@Specialization(guards = "isRubyBigDecimal(b)") | ||
public Object add(RubyBasicObject a, RubyBasicObject b) { | ||
return createRubyBigDecimal( | ||
getContext().getCoreLibrary().getBigDecimalClass(), | ||
getBigDecimalValue(a).add(getBigDecimalValue(b))); | ||
} | ||
|
||
} | ||
|
||
@CoreMethod(names = "add", required = 2) | ||
public abstract static class AddNode extends BigDecimalCoreMethodNode { | ||
|
||
public AddNode(RubyContext context, SourceSection sourceSection) { | ||
super(context, sourceSection); | ||
} | ||
|
||
@Specialization(guards = "isRubyBigDecimal(b)") | ||
public Object add(RubyBasicObject a, RubyBasicObject b, int precision) { | ||
return createRubyBigDecimal( | ||
getContext().getCoreLibrary().getBigDecimalClass(), | ||
getBigDecimalValue(a).add(getBigDecimalValue(b), new MathContext(precision))); | ||
} | ||
|
||
} | ||
|
||
@CoreMethod(names = "-", required = 1) | ||
public abstract static class SubtractNode extends BigDecimalCoreMethodNode { | ||
|
||
public SubtractNode(RubyContext context, SourceSection sourceSection) { | ||
super(context, sourceSection); | ||
} | ||
|
||
@Specialization | ||
public Object subtract(RubyBasicObject a, int b) { | ||
return createRubyBigDecimal( | ||
getContext().getCoreLibrary().getBigDecimalClass(), | ||
getBigDecimalValue(a).subtract(BigDecimal.valueOf(b))); | ||
} | ||
|
||
@Specialization | ||
public Object subtract(RubyBasicObject a, long b) { | ||
return createRubyBigDecimal( | ||
getContext().getCoreLibrary().getBigDecimalClass(), | ||
getBigDecimalValue(a).subtract(BigDecimal.valueOf(b))); | ||
} | ||
|
||
@Specialization(guards = "isRubyBigDecimal(b)") | ||
public Object subtract(RubyBasicObject a, RubyBasicObject b) { | ||
return createRubyBigDecimal( | ||
getContext().getCoreLibrary().getBigDecimalClass(), | ||
getBigDecimalValue(a).subtract(getBigDecimalValue(b))); | ||
} | ||
|
||
} | ||
|
||
@CoreMethod(names = "sub", required = 2) | ||
public abstract static class SubNode extends BigDecimalCoreMethodNode { | ||
|
||
public SubNode(RubyContext context, SourceSection sourceSection) { | ||
super(context, sourceSection); | ||
} | ||
|
||
@Specialization(guards = "isRubyBigDecimal(b)") | ||
public Object sub(RubyBasicObject a, RubyBasicObject b, int precision) { | ||
return createRubyBigDecimal( | ||
getContext().getCoreLibrary().getBigDecimalClass(), | ||
getBigDecimalValue(a).subtract(getBigDecimalValue(b), new MathContext(precision))); | ||
} | ||
} | ||
|
||
@CoreMethod(names = {"==", "eql?"}, required = 1) | ||
public abstract static class EqualNode extends BigDecimalCoreMethodNode { | ||
|
||
public EqualNode(RubyContext context, SourceSection sourceSection) { | ||
super(context, sourceSection); | ||
} | ||
|
||
@Specialization | ||
public boolean equal(RubyBasicObject a, int b) { | ||
return getBigDecimalValue(a).compareTo(BigDecimal.valueOf(b)) == 0; | ||
} | ||
|
||
@Specialization | ||
public boolean equal(RubyBasicObject a, long b) { | ||
return getBigDecimalValue(a).compareTo(BigDecimal.valueOf(b)) == 0; | ||
} | ||
|
||
@Specialization(guards = "isRubyBigDecimal(b)") | ||
public boolean equal(RubyBasicObject a, RubyBasicObject b) { | ||
return getBigDecimalValue(a).compareTo(getBigDecimalValue(b)) == 0; | ||
} | ||
|
||
} | ||
|
||
@CoreMethod(names = {"to_s", "inspect"}) | ||
public abstract static class ToSNode extends CoreMethodArrayArgumentsNode { | ||
|
||
public ToSNode(RubyContext context, SourceSection sourceSection) { | ||
super(context, sourceSection); | ||
} | ||
|
||
@CompilerDirectives.TruffleBoundary | ||
@Specialization | ||
public RubyString toS(RubyBasicObject value) { | ||
return getContext().makeString(getBigDecimalValue(value).toString()); | ||
} | ||
|
||
} | ||
|
||
} |