Skip to content

Commit 396cc79

Browse files
committed
Added tests
1 parent aa06490 commit 396cc79

4 files changed

Lines changed: 70 additions & 1 deletion

File tree

.github/workflows/test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: ubuntu
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
8+
strategy:
9+
matrix:
10+
ruby: [ '3.0', 2.7, 2.6, head ]
11+
os: [ ubuntu-latest, macos-latest, windows-latest ]
12+
runs-on: ${{ matrix.os }}
13+
steps:
14+
- uses: actions/checkout@master
15+
- name: Set up Ruby
16+
uses: ruby/setup-ruby@v1
17+
with:
18+
ruby-version: ${{ matrix.ruby }}
19+
- name: Run test
20+
run: rake test

Rakefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require "bundler/gem_tasks"
2+
require "rake/testtask"
3+
4+
Rake::TestTask.new(:test) do |t|
5+
t.test_files = FileList["test/**/test_*.rb"]
6+
end
7+
8+
task :default => :test

ruby2_keywords.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = IO.popen(%W[git -C #{__dir__} describe --tags --match v[0-9]*], &:read)[/\Av?(\d+(?:\.\d+)*)/, 1]
1+
version = "0.0.3"
22
abort "Version must not reach 1" if version[/\d+/].to_i >= 1
33

44
Gem::Specification.new do |s|

test/test_keyword.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
require 'test/unit'
2+
LOADING_RUBY2_KEYWORDS = (RUBY_VERSION.scan(/\d+/).map(&:to_i) <=> [2, 7]) < 0
3+
if LOADING_RUBY2_KEYWORDS
4+
require 'ruby2_keywords'
5+
end
6+
7+
class TestKeywordArguments < Test::Unit::TestCase
8+
def test_loaded_features
9+
list = $LOADED_FEATURES.grep(%r[/ruby2_keywords\.rb\z])
10+
if LOADING_RUBY2_KEYWORDS
11+
assert_not_empty(list)
12+
assert_not_include($LOADED_FEATURES, "ruby2_keywords.rb")
13+
else
14+
assert_empty(list)
15+
assert_include($LOADED_FEATURES, "ruby2_keywords.rb")
16+
end
17+
end
18+
19+
def test_module_ruby2_keywords
20+
assert_send([Module, :private_method_defined?, :ruby2_keywords])
21+
assert_operator(Module.instance_method(:ruby2_keywords).arity, :<, 0)
22+
end
23+
24+
def test_toplevel_ruby2_keywords
25+
main = TOPLEVEL_BINDING.receiver
26+
assert_send([main, :respond_to?, :ruby2_keywords, true])
27+
assert_operator(main.method(:ruby2_keywords).arity, :<, 0)
28+
end
29+
30+
def test_proc_ruby2_keywords
31+
assert_respond_to(Proc.new {}, :ruby2_keywords)
32+
end
33+
34+
def test_hash_ruby2_keywords_hash?
35+
assert_false(Hash.ruby2_keywords_hash?({}))
36+
end
37+
38+
def test_hash_ruby2_keywords_hash
39+
assert_equal({}, Hash.ruby2_keywords_hash({}.freeze))
40+
end
41+
end

0 commit comments

Comments
 (0)