mrubyc-test 0.5.3 → 0.7.0.pre.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +28 -29
- data/README.md +12 -8
- data/bin/console +1 -1
- data/lib/mrubyc/test/config.rb +14 -4
- data/lib/mrubyc/test/generator/attribute.rb +8 -3
- data/lib/mrubyc/test/generator/double.rb +2 -0
- data/lib/mrubyc/test/generator/script.rb +18 -4
- data/lib/mrubyc/test/generator/test_case.rb +1 -0
- data/lib/mrubyc/test/init.rb +2 -2
- data/lib/mrubyc/test/version.rb +1 -1
- data/lib/mrubyc-ext/mrubyc_test_case.rb +2 -2
- data/lib/mrubyc-ext/object.rb +2 -2
- data/lib/mrubyc-test.rb +56 -20
- data/lib/templates/main.c.erb +23 -4
- data/lib/templates/test.rb.erb +3 -3
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7ba5b056b71ff5fc5377dda272e651a3784dfdc7627f3a746e7ce6bb30ff975
|
4
|
+
data.tar.gz: 2d587b1e8d998ba84434634ff0f7599ccec2bd69b41a41ac80693b057593fb67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0c73ee66679987cc53adc9631e500f3cec3a70107807c3bebede1f3310dc2846db4e367a9eb215172b72c2535ddd7353a350bf50eeb45760d911ed7366ba6a5
|
7
|
+
data.tar.gz: a8a29d343d482ce81c2d83221f788d3cf9997739cafee556b2d3cd0342dee43d6e8a28880d5504e00fdc9465e68013e3da3c63dac754bd397ea72b4ad443e0c8
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mrubyc-test (0.
|
4
|
+
mrubyc-test (0.6.2)
|
5
5
|
activesupport (~> 6.0)
|
6
6
|
rufo (~> 0.12)
|
7
7
|
thor (~> 1.0)
|
@@ -9,37 +9,36 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (6.
|
12
|
+
activesupport (6.1.4.1)
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
-
i18n (>=
|
15
|
-
minitest (
|
16
|
-
tzinfo (~>
|
17
|
-
zeitwerk (~> 2.
|
18
|
-
concurrent-ruby (1.1.
|
19
|
-
diff-lcs (1.
|
20
|
-
i18n (1.8.
|
14
|
+
i18n (>= 1.6, < 2)
|
15
|
+
minitest (>= 5.1)
|
16
|
+
tzinfo (~> 2.0)
|
17
|
+
zeitwerk (~> 2.3)
|
18
|
+
concurrent-ruby (1.1.9)
|
19
|
+
diff-lcs (1.4.4)
|
20
|
+
i18n (1.8.10)
|
21
21
|
concurrent-ruby (~> 1.0)
|
22
|
-
minitest (5.14.
|
23
|
-
rake (13.0.
|
24
|
-
rspec (3.
|
25
|
-
rspec-core (~> 3.
|
26
|
-
rspec-expectations (~> 3.
|
27
|
-
rspec-mocks (~> 3.
|
28
|
-
rspec-core (3.
|
29
|
-
rspec-support (~> 3.
|
30
|
-
rspec-expectations (3.
|
22
|
+
minitest (5.14.4)
|
23
|
+
rake (13.0.6)
|
24
|
+
rspec (3.10.0)
|
25
|
+
rspec-core (~> 3.10.0)
|
26
|
+
rspec-expectations (~> 3.10.0)
|
27
|
+
rspec-mocks (~> 3.10.0)
|
28
|
+
rspec-core (3.10.1)
|
29
|
+
rspec-support (~> 3.10.0)
|
30
|
+
rspec-expectations (3.10.1)
|
31
31
|
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
-
rspec-support (~> 3.
|
33
|
-
rspec-mocks (3.
|
32
|
+
rspec-support (~> 3.10.0)
|
33
|
+
rspec-mocks (3.10.2)
|
34
34
|
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
-
rspec-support (~> 3.
|
36
|
-
rspec-support (3.
|
37
|
-
rufo (0.
|
38
|
-
thor (1.0
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
zeitwerk (2.3.0)
|
35
|
+
rspec-support (~> 3.10.0)
|
36
|
+
rspec-support (3.10.2)
|
37
|
+
rufo (0.13.0)
|
38
|
+
thor (1.1.0)
|
39
|
+
tzinfo (2.0.4)
|
40
|
+
concurrent-ruby (~> 1.0)
|
41
|
+
zeitwerk (2.4.2)
|
43
42
|
|
44
43
|
PLATFORMS
|
45
44
|
ruby
|
@@ -51,4 +50,4 @@ DEPENDENCIES
|
|
51
50
|
rspec (~> 3.9)
|
52
51
|
|
53
52
|
BUNDLED WITH
|
54
|
-
2.
|
53
|
+
2.2.5
|
data/README.md
CHANGED
@@ -4,9 +4,9 @@
|
|
4
4
|
|
5
5
|
mrubyc-test is an unit test framework for [mruby/c](https://github.com/mrubyc/mrubyc), supporting basic assertions, stub and mock.
|
6
6
|
|
7
|
-
##
|
7
|
+
## Dependency
|
8
8
|
|
9
|
-
|
9
|
+
- mrubyc-test 0.7.0+ depends on mrubyc 3.0+
|
10
10
|
|
11
11
|
## Features
|
12
12
|
|
@@ -38,7 +38,7 @@ Or install it yourself as:
|
|
38
38
|
## Usage
|
39
39
|
|
40
40
|
Assuming you are using [mrubyc-utils](https://github.com/hasumikin/mrubyc-utils) to manage your project and [rbenv](https://github.com/rbenv/rbenv) to manage Ruby versions.
|
41
|
-
It means you have
|
41
|
+
It means you have `Mrubycfile` and `.ruby-version` in the top directory of your project.
|
42
42
|
|
43
43
|
Besides, you have to locate mruby model files that are the target of testing like `mrblib/models/class_name.rb`
|
44
44
|
|
@@ -49,8 +49,8 @@ This is an example of ESP32 project:
|
|
49
49
|
```
|
50
50
|
~/your_project $ tree
|
51
51
|
.
|
52
|
-
├──
|
53
|
-
├── .ruby-version
|
52
|
+
├── Mrubycfile # Created by mrubyc-utils
|
53
|
+
├── .ruby-version # It should be mruby's version like 'mruby-3.0.0'
|
54
54
|
├── Makefile
|
55
55
|
├── build
|
56
56
|
├── components
|
@@ -119,17 +119,17 @@ end
|
|
119
119
|
```ruby
|
120
120
|
class Sample
|
121
121
|
def do_other_thing
|
122
|
-
is_to_be_hit()
|
122
|
+
is_to_be_hit(1, 2) # Two args for example
|
123
123
|
end
|
124
124
|
end
|
125
125
|
```
|
126
126
|
|
127
|
-
You can test whether `#is_to_be_hit` method will be called:
|
127
|
+
You can test whether `#is_to_be_hit(v1, v2)` method will be called:
|
128
128
|
|
129
129
|
```ruby
|
130
130
|
def mock_case
|
131
131
|
sample_obj = Sample.new
|
132
|
-
mock(sample_obj).is_to_be_hit
|
132
|
+
mock(sample_obj).is_to_be_hit(2) # `2` should be count of parameters
|
133
133
|
sample_obj.do_other_thing
|
134
134
|
end
|
135
135
|
```
|
@@ -144,6 +144,10 @@ end
|
|
144
144
|
- Other assertions like LT(<), GTE(>=), include?, ...etc.
|
145
145
|
- bla bla bla
|
146
146
|
|
147
|
+
## Acknowledgements
|
148
|
+
|
149
|
+
The API design and implementation of this gem is greatly inspired by [test-unit](https://github.com/test-unit/test-unit). Thank the great work.
|
150
|
+
|
147
151
|
## Contributing
|
148
152
|
|
149
153
|
Bug reports and pull requests are welcome on GitHub at https://github.com/mrubyc/mrubyc-test. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/bin/console
CHANGED
data/lib/mrubyc/test/config.rb
CHANGED
@@ -8,21 +8,31 @@ module Mrubyc
|
|
8
8
|
class Config
|
9
9
|
class << self
|
10
10
|
def read(check: true)
|
11
|
-
|
12
|
-
config = YAML.load_file('.mrubycconfig')
|
11
|
+
config = YAML.load_file(mrubycfile)
|
13
12
|
if check
|
14
13
|
if !config || config == [] || !config['test_dir']
|
15
|
-
raise 'Check if
|
14
|
+
raise 'Check if `Mrubycfile or .mrubycconfig` exists.'
|
16
15
|
end
|
17
16
|
end
|
18
17
|
config || {}
|
19
18
|
end
|
20
19
|
|
21
20
|
def write(config)
|
22
|
-
File.open(
|
21
|
+
File.open(mrubycfile, 'r+') do |file|
|
23
22
|
file.write(config.to_yaml)
|
24
23
|
end
|
25
24
|
end
|
25
|
+
|
26
|
+
def mrubycfile
|
27
|
+
if File.exists? 'Mrubycfile'
|
28
|
+
'Mrubycfile'
|
29
|
+
elsif File.exists? '.mrubycconfig'
|
30
|
+
'.mrubycconfig'
|
31
|
+
else
|
32
|
+
FileUtils.touch 'Mrubycfile'
|
33
|
+
'Mrubycfile'
|
34
|
+
end
|
35
|
+
end
|
26
36
|
end
|
27
37
|
end
|
28
38
|
end
|
@@ -10,14 +10,19 @@ module Mrubyc
|
|
10
10
|
def run(model_files: [], test_files:)
|
11
11
|
# get information from model files(application code)
|
12
12
|
model_files.each do |model_file|
|
13
|
+
puts "loading #{model_file}"
|
13
14
|
load model_file
|
14
15
|
class_name = File.basename(model_file, '.rb').camelize
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
model_class = if Module.const_defined?(class_name)
|
17
|
+
Module.const_get(class_name)
|
18
|
+
elsif Module.const_defined?(class_name.upcase)
|
19
|
+
Module.const_get(class_name.upcase)
|
20
|
+
end
|
21
|
+
unless model_class
|
18
22
|
print "\e[33m"
|
19
23
|
puts "[WARN] #{model_file} doesn't have corresponding class `#{class_name}`."
|
20
24
|
print "\e[m"
|
25
|
+
next
|
21
26
|
end
|
22
27
|
model_class.class_eval do
|
23
28
|
def method_missing(_method_name, *_args)
|
@@ -17,11 +17,13 @@ module Mrubyc
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def method_missing(method_name, *args)
|
20
|
+
param_size = args[0] || 0
|
20
21
|
@@double_method_locations << {
|
21
22
|
type: @type,
|
22
23
|
class: @klass,
|
23
24
|
method_name: method_name,
|
24
25
|
args: args.to_s,
|
26
|
+
method_parameters: Array.new(param_size).map.with_index{|_, i| ('a'.ord + i).chr }.join(','),
|
25
27
|
block: (block_given? ? yield : nil),
|
26
28
|
label: @location.label,
|
27
29
|
path: @location.absolute_path || @location.path,
|
@@ -10,11 +10,25 @@ module Mrubyc
|
|
10
10
|
class << self
|
11
11
|
def run(model_files: [], test_files:, test_cases:, verbose:, method_name_pattern:)
|
12
12
|
config = Mrubyc::Test::Config.read
|
13
|
-
test_erb = ERB.new(
|
14
|
-
|
13
|
+
test_erb = ERB.new(
|
14
|
+
File.read(
|
15
|
+
File.expand_path('../../../../templates/test.rb.erb', __FILE__)
|
16
|
+
), nil, '-'
|
17
|
+
)
|
18
|
+
models_erb = ERB.new(
|
19
|
+
File.read(
|
20
|
+
File.expand_path('../../../../templates/models.rb.erb', __FILE__)
|
21
|
+
), nil, '-'
|
22
|
+
)
|
15
23
|
mrubyc_class_dir = File.expand_path('../../../../mrubyc-ext/', __FILE__)
|
16
|
-
File.write(File.join(
|
17
|
-
|
24
|
+
File.write(File.join(
|
25
|
+
config['test_tmp_dir'], 'test.rb'),
|
26
|
+
Rufo.format(test_erb.result(binding))
|
27
|
+
)
|
28
|
+
File.write(File.join(
|
29
|
+
config['test_tmp_dir'], 'models.rb'),
|
30
|
+
Rufo.format(models_erb.result(binding))
|
31
|
+
)
|
18
32
|
end
|
19
33
|
end
|
20
34
|
end
|
data/lib/mrubyc/test/init.rb
CHANGED
@@ -11,12 +11,12 @@ module Mrubyc
|
|
11
11
|
puts 'Initializing...'
|
12
12
|
puts
|
13
13
|
|
14
|
-
puts ' touch
|
14
|
+
puts ' touch Mrubycfile'
|
15
15
|
config = Mrubyc::Test::Config.read(check: false)
|
16
16
|
config['test_dir'] = 'test'
|
17
17
|
config['test_tmp_dir'] = 'test/tmp'
|
18
18
|
config['mruby_lib_dir'] = 'mrblib'
|
19
|
-
puts ' add config to
|
19
|
+
puts ' add config to Mrubycfile'
|
20
20
|
Mrubyc::Test::Config.write(config)
|
21
21
|
|
22
22
|
hal_dir = "#{config['test_tmp_dir']}/hal"
|
data/lib/mrubyc/test/version.rb
CHANGED
data/lib/mrubyc-ext/object.rb
CHANGED
data/lib/mrubyc-test.rb
CHANGED
@@ -25,30 +25,30 @@ module Mrubyc::Test
|
|
25
25
|
def prepare(test_files, verbose, method_name_pattern)
|
26
26
|
config = Mrubyc::Test::Config.read
|
27
27
|
model_files = Dir.glob(File.join(Dir.pwd, config['mruby_lib_dir'], 'models', '*.rb'))
|
28
|
-
|
29
28
|
# gather attributes from your implementations and tests
|
30
|
-
attributes = Mrubyc::Test::Generator::Attribute.run(
|
31
|
-
|
29
|
+
attributes = Mrubyc::Test::Generator::Attribute.run(
|
30
|
+
model_files: model_files,
|
31
|
+
test_files: test_files
|
32
|
+
)
|
32
33
|
# convert attributes into tast_cases
|
33
34
|
test_cases = Mrubyc::Test::Generator::TestCase.run(attributes)
|
34
|
-
|
35
35
|
# generate a ruby script that will be compiled by mrbc and executed in mruby/c VM
|
36
|
-
Mrubyc::Test::Generator::Script.run(
|
36
|
+
Mrubyc::Test::Generator::Script.run(
|
37
|
+
model_files: model_files,
|
38
|
+
test_files: test_files,
|
39
|
+
test_cases: test_cases,
|
40
|
+
verbose: verbose,
|
41
|
+
method_name_pattern: method_name_pattern
|
42
|
+
)
|
37
43
|
end
|
38
44
|
|
39
|
-
def make
|
45
|
+
def make(mrbc_path)
|
40
46
|
config = Mrubyc::Test::Config.read
|
41
47
|
tmp_dir = File.join(Dir.pwd, config['test_tmp_dir'])
|
42
48
|
puts "cd #{tmp_dir}"
|
43
49
|
puts
|
44
50
|
exit_code = 0
|
45
51
|
pwd = Dir.pwd
|
46
|
-
mruby_version = File.read('.ruby-version').gsub("\n", '').chomp
|
47
|
-
unless mruby_version.index('mruby')
|
48
|
-
puts '.ruby-version doesn\'t set `mruby-x.x.x It is recommended to use the latest version of https://github.com/hasumikin/mrubyc-utils`'
|
49
|
-
print 'You can specify the version name of mruby [mruby-x.x.x]: '
|
50
|
-
mruby_version = STDIN.gets.chomp
|
51
|
-
end
|
52
52
|
hal_path = "#{pwd}/#{config['mrubyc_src_dir']}/hal"
|
53
53
|
hal_bak_path = "#{pwd}/#{config['mrubyc_src_dir']}/~hal"
|
54
54
|
FileUtils.mv(hal_path, hal_bak_path) if FileTest.exist?(hal_path)
|
@@ -56,9 +56,9 @@ module Mrubyc::Test
|
|
56
56
|
FileUtils.ln_s "#{pwd}/#{config['test_tmp_dir']}/hal", "#{pwd}/#{config['mrubyc_src_dir']}/hal"
|
57
57
|
Dir.chdir(tmp_dir) do
|
58
58
|
[
|
59
|
-
"
|
60
|
-
"
|
61
|
-
"cc -I #{pwd}/#{config['mrubyc_src_dir']} -o test main.c #{pwd}/#{config['mrubyc_src_dir']}/*.c #{pwd}/#{config['mrubyc_src_dir']}/hal/*.c #{ENV["CFLAGS"]} #{ENV["LDFLAGS"]}",
|
59
|
+
"#{mrbc_path} -B test test.rb",
|
60
|
+
"#{mrbc_path} -B models models.rb",
|
61
|
+
"cc -O0 -g3 -Wall -I #{pwd}/#{config['mrubyc_src_dir']} -o test main.c #{pwd}/#{config['mrubyc_src_dir']}/*.c #{pwd}/#{config['mrubyc_src_dir']}/hal/*.c -DMRBC_USE_HAL_POSIX #{ENV["CFLAGS"]} #{ENV["LDFLAGS"]}",
|
62
62
|
"./test"].each do |cmd|
|
63
63
|
puts cmd
|
64
64
|
puts
|
@@ -84,21 +84,57 @@ module Mrubyc::Test
|
|
84
84
|
|
85
85
|
end
|
86
86
|
|
87
|
-
desc 'test',
|
88
|
-
|
89
|
-
|
90
|
-
|
87
|
+
desc 'test', <<~DESC
|
88
|
+
[Default command]
|
89
|
+
Execute test. You can specify a test file like
|
90
|
+
`mrubyc-test test test/array_test.rb`'
|
91
|
+
DESC
|
92
|
+
option :every, type: :numeric, default: 10, aliases: "-e",
|
93
|
+
banner: <<~DESC.chomp
|
94
|
+
NUMBER
|
95
|
+
To avoid Out of Memory, test will be devided up to
|
96
|
+
every specified NUMBER of xxx_test.rb files
|
97
|
+
DESC
|
98
|
+
option :verbose, type: :boolean, default: false, aliases: "-v",
|
99
|
+
banner: "[true/false] - Show test result verbosely"
|
100
|
+
option :name, type: :string, aliases: "-n",
|
101
|
+
banner: <<~DESC.chomp
|
102
|
+
NAME
|
103
|
+
Specify the NAME of tests you want to run. If you
|
104
|
+
write --name='/PATTERN/', it will be processed as a regular
|
105
|
+
expression. It must be single-quoted and doubled-backslash.
|
106
|
+
eg) --name='/a\\\\db/' will create Regexp object `/a\\db/`
|
107
|
+
and match strings like `a1b`
|
108
|
+
DESC
|
109
|
+
option :mrbc_path, type: :string, aliases: "-p",
|
110
|
+
banner: <<~DESC.chomp
|
111
|
+
PATH
|
112
|
+
Specify the path to mrbc.
|
113
|
+
eg: /home/hoge/mruby/build/host/bin/mrbc
|
114
|
+
RBENV_VERSION will be ignored if you specify this option.
|
115
|
+
DESC
|
91
116
|
def test(testfilepath = "test/*.rb")
|
92
117
|
init_env
|
118
|
+
config = Mrubyc::Test::Config.read
|
93
119
|
method_name_pattern = (%r{\A/(.*)/\Z} =~ options[:name] ? Regexp.new($1) : options[:name])
|
94
120
|
test_path = if testfilepath == ""
|
95
121
|
File.join(Dir.pwd, config['test_dir'], "*.rb")
|
96
122
|
else
|
97
123
|
File.join(Dir.pwd, testfilepath)
|
98
124
|
end
|
125
|
+
mrbc_path = options[:mrbc_path] || config['mrbc_path']
|
126
|
+
unless mrbc_path
|
127
|
+
mruby_version = File.read('.ruby-version').gsub("\n", '').chomp
|
128
|
+
unless mruby_version.index('mruby')
|
129
|
+
puts '.ruby-version doesn\'t set `mruby-x.x.x It is recommended to use the latest version of https://github.com/hasumikin/mrubyc-utils`'
|
130
|
+
print 'You can specify the version name of mruby [mruby-x.x.x]: '
|
131
|
+
mruby_version = STDIN.gets.chomp
|
132
|
+
end
|
133
|
+
"RBENV_VERSION=#{mruby_version} mrbc"
|
134
|
+
end
|
99
135
|
Dir.glob(test_path).each_slice(options[:every]) do |test_files|
|
100
136
|
prepare(test_files, options[:verbose], method_name_pattern)
|
101
|
-
make
|
137
|
+
make(mrbc_path)
|
102
138
|
end
|
103
139
|
end
|
104
140
|
|
data/lib/templates/main.c.erb
CHANGED
@@ -4,19 +4,37 @@
|
|
4
4
|
#include "models.c"
|
5
5
|
#include "test.c"
|
6
6
|
|
7
|
-
#define MEMORY_SIZE (1024*
|
7
|
+
#define MEMORY_SIZE (1024*640)-1
|
8
8
|
static uint8_t my_memory_pool[MEMORY_SIZE];
|
9
9
|
|
10
|
-
int exit_code;
|
10
|
+
int exit_code = 0;
|
11
11
|
|
12
|
-
static void c_exit(
|
12
|
+
static void c_exit(struct VM *vm, mrbc_value v[], int argc)
|
13
|
+
{
|
13
14
|
exit_code = GET_INT_ARG(1);
|
14
15
|
}
|
15
16
|
|
17
|
+
//================================================================
|
18
|
+
/*! Object#instance_variable_get
|
19
|
+
*/
|
20
|
+
static void c_instance_variable_get(struct VM *vm, mrbc_value v[], int argc)
|
21
|
+
{
|
22
|
+
mrbc_kv_handle *kvh = &v[0].instance->ivar;
|
23
|
+
const char *name = (const char *)GET_STRING_ARG(1);
|
24
|
+
for(int i = 0; i < kvh->n_stored; i++) {
|
25
|
+
if (strncmp(&name[1], symid_to_str(kvh->data[i].sym_id), strlen(name) - 1) == 0) {
|
26
|
+
SET_RETURN(kvh->data[i].value);
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
SET_NIL_RETURN();
|
31
|
+
}
|
32
|
+
|
16
33
|
//================================================================
|
17
34
|
/*! DEBUG PRINT
|
18
35
|
*/
|
19
|
-
static void c_debugprint(
|
36
|
+
static void c_debugprint(struct VM *vm, mrbc_value v[], int argc)
|
37
|
+
{
|
20
38
|
console_putchar('\n');
|
21
39
|
for( int i = 0; i < 79; i++ ) { console_putchar('='); }
|
22
40
|
console_putchar('\n');
|
@@ -34,6 +52,7 @@ int main(void) {
|
|
34
52
|
mrbc_init(my_memory_pool, MEMORY_SIZE);
|
35
53
|
mrbc_define_method(0, mrbc_class_object, "debugprint", c_debugprint);
|
36
54
|
mrbc_define_method(0, mrbc_class_object, "exit", c_exit);
|
55
|
+
mrbc_define_method(0, mrbc_class_object, "instance_variable_get", c_instance_variable_get);
|
37
56
|
mrbc_create_task( models, 0 );
|
38
57
|
mrbc_create_task( test, 0 );
|
39
58
|
mrbc_run();
|
data/lib/templates/test.rb.erb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
# For more information, see <%= Gem.loaded_specs['mrubyc-test']&.homepage %>
|
8
8
|
#
|
9
9
|
|
10
|
-
if
|
10
|
+
if RUBY_ENGINE == 'mruby/c'
|
11
11
|
class Math
|
12
12
|
end
|
13
13
|
class Numeric
|
@@ -108,7 +108,7 @@ end
|
|
108
108
|
<% end -%>
|
109
109
|
<% test_case[:mocks].each do |mock| -%>
|
110
110
|
class <%= mock[:class_name] %>
|
111
|
-
def <%= mock[:method_name] %>
|
111
|
+
def <%= mock[:method_name] %>(<%= mock[:method_parameters] %>)
|
112
112
|
$mock.actual.add_by_key :<%= mock[:method_name] %>
|
113
113
|
end
|
114
114
|
end
|
@@ -126,7 +126,7 @@ end
|
|
126
126
|
end
|
127
127
|
<% test_case[:mocks].each do |mock| -%>
|
128
128
|
class <%= mock[:class_name] %>Double
|
129
|
-
def <%= mock[:method_name] %>
|
129
|
+
def <%= mock[:method_name] %>(_param_size = 0)
|
130
130
|
$mock.expected.add_by_key :<%= mock[:method_name] %>
|
131
131
|
end
|
132
132
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mrubyc-test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0.pre.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HASUMI Hitoshi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -137,7 +137,7 @@ homepage: https://github.com/mrubyc/mrubyc-test
|
|
137
137
|
licenses:
|
138
138
|
- BSD-3-Clause
|
139
139
|
metadata: {}
|
140
|
-
post_install_message:
|
140
|
+
post_install_message:
|
141
141
|
rdoc_options: []
|
142
142
|
require_paths:
|
143
143
|
- lib
|
@@ -148,12 +148,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
148
148
|
version: '0'
|
149
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
150
|
requirements:
|
151
|
-
- - "
|
151
|
+
- - ">"
|
152
152
|
- !ruby/object:Gem::Version
|
153
|
-
version:
|
153
|
+
version: 1.3.1
|
154
154
|
requirements: []
|
155
|
-
rubygems_version: 3.
|
156
|
-
signing_key:
|
155
|
+
rubygems_version: 3.2.17
|
156
|
+
signing_key:
|
157
157
|
specification_version: 4
|
158
158
|
summary: Test Framework for mruby/c
|
159
159
|
test_files: []
|