Skip to content

Commit de765ae

Browse files
committed
Add tests for mruby and move CRuby tests location.
1 parent 26ba53e commit de765ae

19 files changed

Lines changed: 406 additions & 238 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ mkmf.log
1515
!/test/tmp/.keep
1616
/build_config.rb.lock
1717
/sample.rb
18+
/test.cruby/tmp/*.po

Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ require "bundler/gem_tasks"
1919
require "rake/testtask"
2020

2121
Rake::TestTask.new(:test) do |t|
22-
t.libs << "test"
22+
t.libs << "test.cruby"
2323
t.libs << "lib"
24-
t.test_files = FileList["test/**/*_test.rb"]
24+
t.test_files = FileList["test.cruby/**/*_test.rb"]
2525
end
2626

2727
require "rake/extensiontask"

test.cruby/gettextpo_test.rb

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# frozen_string_literal: true
2+
3+
# Copyright (C) 2026 gemmaro
4+
#
5+
# This program is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
18+
require_relative "test_helper"
19+
20+
class GettextPOTest < Test::Unit::TestCase
21+
def load_tests(name)
22+
path = File.join(__dir__, "../test/#{name}.rb")
23+
instance_eval(File.read(path), path)
24+
end
25+
26+
test 'common with mruby' do
27+
%w[
28+
check
29+
file
30+
filepos
31+
format
32+
header
33+
message
34+
message_iterator
35+
version
36+
].each do |target|
37+
load_tests(target)
38+
end
39+
end
40+
41+
def _create_message_and_drop_file
42+
file = GettextPO::File.new
43+
iterator = file.message_iterator
44+
iterator.insert("msgid1", "msgstr1")
45+
end
46+
47+
test "dangling pointer" do
48+
message = _create_message_and_drop_file
49+
GC.start(full_mark: true, immediate_sweep: true)
50+
assert_equal "msgid1", message.msgid
51+
end
52+
end
File renamed without changes.

0 commit comments

Comments
 (0)