Skip to content

Commit

Permalink
[Truffle] Add PE tests for constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed May 26, 2015
1 parent 7a55f36 commit 6d3b6f9
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
59 changes: 59 additions & 0 deletions test/truffle/pe/language/constant_pe.rb
@@ -0,0 +1,59 @@
# 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 ConstantFixtures
A = 1

def self.get_existing
Proc
end

def self.get
A
end

def self.get_const_get(name)
ConstantFixtures.const_get(name)
end

module Nested
def self.get_nested
A
end
end

class Base
B = 2
end

class Child < Base
def self.get_inherited
B
end
end

module ConstMissing
def self.get_missing
NO_SUCH_NAMED_CONSTANT
end

def self.const_missing(const)
const
end
end
end

example "ConstantFixtures.get_existing"
example "ConstantFixtures.get"
example "ConstantFixtures.get_const_get(:A)"
example "ConstantFixtures.get_const_get('A')"

example "ConstantFixtures::Nested.get_nested"
example "ConstantFixtures::Child.get_inherited"

example "ConstantFixtures::ConstMissing.get_missing"
1 change: 1 addition & 0 deletions test/truffle/pe/pe.rb
Expand Up @@ -44,6 +44,7 @@ def tagged_example(code)
counter_example "rand"

require_relative 'language/closures_pe.rb'
require_relative 'language/constant_pe.rb'
require_relative 'language/metaprogramming_pe.rb'
require_relative 'core/truefalse_pe.rb'
require_relative 'core/fixnum_pe.rb'
Expand Down

0 comments on commit 6d3b6f9

Please sign in to comment.