Skip to content

Commit e0742a9

Browse files
committed
added new tests for edge case with attached class and no_gil. skip for now.
1 parent 7d25f7b commit e0742a9

File tree

3 files changed

+56
-18
lines changed

3 files changed

+56
-18
lines changed

spec/fixtures/no_gil/no_gil.rubex

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,3 @@ def work_with_gil(double n)
2222
n -= 1
2323
end
2424
end
25-
26-
struct test
27-
int a
28-
end
29-
30-
class A attach test
31-
cfunc void __bar no_gil
32-
int b
33-
end
34-
35-
def foo
36-
__bar
37-
end
38-
39-
cfunc void deallocate
40-
xfree(data$.test)
41-
end
42-
end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
struct test
2+
int a
3+
end
4+
5+
class A attach test
6+
cfunc void __bar(int a) no_gil
7+
int b = a
8+
end
9+
10+
def foo
11+
data$.test.a = 4
12+
13+
no_gil
14+
__bar(data$.test.a)
15+
end
16+
17+
return data$.test.a
18+
end
19+
20+
cfunc void deallocate
21+
xfree(data$.test)
22+
end
23+
end

spec/no_gil_attach_class_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
require 'spec_helper'
2+
3+
describe Rubex do
4+
test_case = "no_gil_attach_class"
5+
6+
context "Case: #{test_case}" do
7+
before do
8+
@path = path_str test_case
9+
end
10+
11+
context ".ast" do
12+
it "generates the AST" do
13+
t = Rubex::Compiler.ast(@path + '.rubex')
14+
end
15+
end
16+
17+
context ".compile" do
18+
skip "compiles to valid C file" do
19+
t,c,e = Rubex::Compiler.compile(@path + '.rubex', test: true)
20+
end
21+
end
22+
23+
context "Black Box testing" do
24+
skip "compiles and checks for valid output" do
25+
setup_and_teardown_compiled_files(test_case) do |dir|
26+
require_relative "#{dir}/#{test_case}.#{os_extension}"
27+
28+
expect(A.new.foo)
29+
end
30+
end
31+
end
32+
end
33+
end

0 commit comments

Comments
 (0)