Skip to content

Commit 83867d4

Browse files
author
Nicolas Laurent
committed
add spec to detect new array methods
1 parent 6551a88 commit 83867d4

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
slow:Truffle::SynchronizedArray redefines all Array and Enumerable methods
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# truffleruby_primitives: true
2+
3+
# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. This
4+
# code is released under a tri EPL/GPL/LGPL license. You can use it,
5+
# redistribute it and/or modify it under the terms of the:
6+
#
7+
# Eclipse Public License version 2.0, or
8+
# GNU General Public License version 2, or
9+
# GNU Lesser General Public License version 2.1.
10+
11+
require_relative '../ruby/spec_helper'
12+
13+
describe "Truffle::SynchronizedArray" do
14+
it "redefines all Array and Enumerable methods" do
15+
expected_methods = ruby_exe("puts Array.public_instance_methods(false) + Enumerable.public_instance_methods(false)")
16+
expected_methods = expected_methods.lines(chomp: true).map { |line| line.to_sym }.uniq!.sort!
17+
synchronized_methods = Truffle::SynchronizedArray.public_instance_methods(false).sort!
18+
19+
if synchronized_methods == expected_methods
20+
synchronized_methods.should == synchronized_methods
21+
else
22+
# if the fast check fails, do a slower check to determine why
23+
expected_methods.each do |m|
24+
synchronized_methods.should include(m)
25+
end
26+
synchronized_methods.each do |m|
27+
expected_methods.should include(m)
28+
end
29+
end
30+
end
31+
end

0 commit comments

Comments
 (0)