Skip to content

Commit

Permalink
Merge remote-tracking branch 'topaz/tim/fix-translation' into interac…
Browse files Browse the repository at this point in the history
…ting-solvers
  • Loading branch information
timfel committed Dec 22, 2016
2 parents 3a59f8e + ef9d33e commit 2f8ab38
Show file tree
Hide file tree
Showing 44 changed files with 208 additions and 1,181 deletions.
1 change: 1 addition & 0 deletions .travis.yml
@@ -1,3 +1,4 @@
sudo: false
language: python
python:
- "2.7"
Expand Down
5 changes: 5 additions & 0 deletions lib-topaz/enumerator.rb
Expand Up @@ -7,6 +7,7 @@ def initialize(obj = nil, method = :each, *args, &block)
@object = obj
@method = method.to_sym
@args = args
self
end

def each(&block)
Expand Down Expand Up @@ -91,8 +92,11 @@ def with_object(obj, &block)
end

class Generator
include Enumerable

def initialize(&block)
@block = block
self
end

def each
Expand All @@ -104,6 +108,7 @@ def each
class Yielder
def initialize(&block)
@block = block
self
end

def yield(*args)
Expand Down
1 change: 0 additions & 1 deletion spec/tags/core/class/initialize_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/tags/core/enumerator/generator/each_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/tags/core/enumerator/generator/initialize_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/tags/core/enumerator/initialize_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/tags/core/enumerator/yielder/initialize_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/tags/core/kernel/catch_tags.txt
Expand Up @@ -3,7 +3,6 @@ fails:Kernel.catch raises an ArgumentError if a Symbol is thrown for a String ca
fails:Kernel.catch raises an ArgumentError if a String with different identity is thrown
fails:Kernel.catch accepts an object as an argument
fails:Kernel.catch yields an object when called without arguments
fails:Kernel.catch raises LocalJumpError if no block is given
fails:Kernel.catch when nested catches across invocation boundaries
fails:Kernel.catch when nested catches in the nested invocation with the same key object
fails:Kernel#catch is a private method
1 change: 0 additions & 1 deletion spec/tags/core/module/alias_method_tags.txt
@@ -1,3 +1,2 @@
fails:Module#alias_method retains method visibility
fails:Module#alias_method is a private method
fails:Module#alias_method returns self
1 change: 0 additions & 1 deletion spec/tags/core/module/append_features_tags.txt
@@ -1,5 +1,4 @@
fails:Module#append_features is a private method
fails:Module#append_features copies own tainted status to the given module
fails:Module#append_features copies own untrusted status to the given module
fails:Module#append_features on Class raises a TypeError if calling after rebinded to Class
fails:Module#append_features when other is frozen raises a RuntimeError before appending self
1 change: 0 additions & 1 deletion spec/tags/core/module/const_set_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/tags/core/module/extend_object_tags.txt
@@ -1,3 +1,2 @@
fails:Module#extend_object is a private method
fails:Module#extend_object on Class raises a TypeError if calling after rebinded to Class
fails:Module#extend_object when given a frozen object raises a RuntimeError before extending the object
6 changes: 3 additions & 3 deletions tasks/base.py
Expand Up @@ -6,9 +6,9 @@
class BaseTest(object):
def download_mspec(self):
if not os.path.isdir("../mspec"):
run("cd .. && git clone --depth=100 --quiet https://github.com/rubyspec/mspec")
run("cd .. && git clone --depth=100 --quiet https://github.com/ruby/mspec")

def download_rubyspec(self):
if not os.path.isdir("../rubyspec"):
run("cd .. && git clone --depth=100 --branch='1.x' --quiet https://github.com/rubyspec/rubyspec")
run("cd ../rubyspec && git checkout 1.x")
run("cd .. && git clone --depth=100 --quiet https://github.com/ruby/spec")
run("mv spec rubyspec")
2 changes: 1 addition & 1 deletion tasks/specs.py
Expand Up @@ -26,7 +26,7 @@ def untag(self):


def generate_spectask(taskname):
def spectask(files="", options="", untranslated=False):
def spectask(ctx, files="", options="", untranslated=False):
runner = Rubyspecs(files, options, untranslated=untranslated)
getattr(runner, taskname)()
spectask.__name__ = taskname
Expand Down
18 changes: 6 additions & 12 deletions tasks/travis.py
Expand Up @@ -64,7 +64,7 @@ def upload_build(self):


@invoke.task
def install_requirements():
def install_requirements(ctx):
t = TEST_TYPES[os.environ["TEST_TYPE"]]
if t.deps:
t.install_deps()
Expand All @@ -76,23 +76,23 @@ def install_requirements():


@invoke.task
def run_tests():
def run_tests(ctx):
t = TEST_TYPES[os.environ["TEST_TYPE"]]
t.run_tests()


@invoke.task
def tag_specs(files=""):
def tag_specs(ctx, files=""):
invoke.run("../mspec/bin/mspec tag -t {} -f spec --config=topaz.mspec {}".format("`pwd`/bin/topaz", files))


@invoke.task
def untag_specs(files=""):
def untag_specs(ctx, files=""):
invoke.run("../mspec/bin/mspec tag --del fails -t {} -f spec --config=topaz.mspec {}".format("`pwd`/bin/topaz", files))


@invoke.task
def upload_build():
def upload_build(ctx):
t = TEST_TYPES[os.environ["TEST_TYPE"]]
if t.create_build:
t.upload_build()
Expand Down Expand Up @@ -129,13 +129,7 @@ def run_docs_tests(env):


def run_flake8_tests(env):
# E124 closing bracket does not match visual indentation
# E125 continuation line does not distinguish itself from next logical line
# E128 continuation line under-indented for visual indent
# E129 visually indented line with same indent as next logical line
# E501 line too long
# F811 redefinition of unused
invoke.run('flake8 . --exclude="__pycache__,.git,docs" --ignore="E124,E125,E128,E129,E501,F811"')
invoke.run('flake8 .')


TEST_TYPES = {
Expand Down
7 changes: 7 additions & 0 deletions tests/modules/test_kernel.py
Expand Up @@ -217,6 +217,13 @@ def test_sleep(self, space):
assert space.int_w(w_res) == 0
assert time.time() - now >= 0.002

with self.raises(space, "TypeError"):
space.execute("return sleep nil")
with self.raises(space, "TypeError"):
space.execute("return sleep '1'")
with self.raises(space, "TypeError"):
space.execute("return sleep Object.new")

def test_trust(self, space):
w_res = space.execute("return 'a'.untrusted?")
assert self.unwrap(space, w_res) is False
Expand Down
2 changes: 2 additions & 0 deletions tests/objects/test_arrayobject.py
Expand Up @@ -368,6 +368,8 @@ def test_sort(self, space):
return a.object_id == b.object_id, a, b
""")
assert self.unwrap(space, w_res) == [True, [3, 2, 1], [3, 2, 1]]
with self.raises(space, "NoMethodError"):
space.execute("[0, 1].sort{ |n, m| BasicObject.new }")
with self.raises(space, "ArgumentError", "comparison of Array with Object failed"):
space.execute("[Object.new, []].sort")

Expand Down
28 changes: 14 additions & 14 deletions tests/objects/test_dirobject.py
Expand Up @@ -13,6 +13,20 @@ def test_pwd(self, space):
w_res = space.execute("return Dir.getwd")
assert space.str_w(w_res) == os.getcwd()

def test_read(self, space, tmpdir):
d = tmpdir.mkdir("sub_test_read")
f = d.join("content")
f.write("hello")
f = d.join("content2")
f.write("hello")
w_res = space.execute("""
d = Dir.new('%s')
return [d.read, d.read, d.read, d.read, d.read]
""" % d)
res = self.unwrap(space, w_res)
res.sort()
assert res == [None, ".", "..", "content", "content2"]

def test_new(self, space, tmpdir):
d = tmpdir.mkdir("sub")
f = d.join("content")
Expand Down Expand Up @@ -113,20 +127,6 @@ def test_glob(self, space, tmpdir):
res = self.unwrap(space, w_res)
assert res == [["sub1"], ["sub1"]]

def test_read(self, space, tmpdir):
d = tmpdir.mkdir("sub")
f = d.join("content")
f.write("hello")
f = d.join("content2")
f.write("hello")
w_res = space.execute("""
d = Dir.new('%s')
return [d.read, d.read, d.read, d.read, d.read]
""" % d)
res = self.unwrap(space, w_res)
res.sort()
assert res == [None, ".", "..", "content", "content2"]

def test_close(self, space, tmpdir):
with self.raises(space, "IOError", "closed directory"):
space.execute("""
Expand Down
26 changes: 26 additions & 0 deletions tests/objects/test_floatobject.py
Expand Up @@ -213,3 +213,29 @@ def test_nan(self, space):
assert w_res is space.w_false
w_res = space.execute("return Float::NAN.nan?")
assert w_res is space.w_true

def test_ivar(self, space):
w_res = space.execute("""
class Float
def set; @foo = true; end
def get; @foo; end
end
float = 0.1
res = [float.get]
float.set
res << float.get
res << 0.2.get
return res
""")
assert self.unwrap(space, w_res) == [None, True, None]

def test_freeze(self, space):
w_res = space.execute("""
float = 0.1
res = [float.frozen?]
float.freeze
res << float.frozen?
res << 0.2.frozen?
return res
""")
assert self.unwrap(space, w_res) == [False, True, False]
10 changes: 10 additions & 0 deletions tests/objects/test_intobject.py
Expand Up @@ -230,6 +230,16 @@ def get; @foo; end
assert x == y == -1
assert z is None

def test_freeze(self, space):
w_res = space.execute("""
res = [1.frozen?]
1.freeze
res << 1.frozen?
res << 2.frozen?
return res
""")
assert self.unwrap(space, w_res) == [False, True, False]

def test_succ(self, space):
w_res = space.execute("return -1.succ")
assert self.unwrap(space, w_res) == 0
Expand Down
6 changes: 6 additions & 0 deletions tests/objects/test_regexpobject.py
Expand Up @@ -140,6 +140,12 @@ def test_new_regexp(self, space):
w_res = space.execute("return Regexp.new(/abc/).source")
assert space.str_w(w_res) == "abc"

def test_allocate(self, space):
with self.raises(space, "TypeError", "uninitialized Regexp"):
space.execute("Regexp.allocate.source")
with self.raises(space, "TypeError", "uninitialized Regexp"):
space.execute("Regexp.allocate.match ''")

def test_size(self, space):
w_res = space.execute("""
/(a)(b)(c)/ =~ "hey hey, abc, hey hey"
Expand Down
2 changes: 2 additions & 0 deletions tests/objects/test_stringobject.py
Expand Up @@ -539,6 +539,8 @@ def test_sub(self, space):
return 'helloo'.sub("l", Hash.new { |h, k| replacements.pop() })
""")
assert space.str_w(w_res) == "he2loo"
with self.raises(space, "ArgumentError"):
space.execute("'string'.sub(/regex/)")

def test_succ(self, space):
w_res = space.execute('return "abcd".succ')
Expand Down
4 changes: 4 additions & 0 deletions tests/test_interpreter.py
Expand Up @@ -1105,6 +1105,10 @@ def test_defined(self, space):
""")
assert space.str_w(w_res) == "expression"
w_res = space.execute("""
return [defined?(while x do y end), defined?(return), defined?(__FILE__)]
""")
assert self.unwrap(space, w_res) == ["expression", "expression", "expression"]
w_res = space.execute("""
$abc = 3
return [defined?($abc), defined?($abd)]
""")
Expand Down

0 comments on commit 2f8ab38

Please sign in to comment.