summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/driver.c16
-rw-r--r--test/t/bs_block.rb4
-rw-r--r--test/t/module.rb56
3 files changed, 59 insertions, 17 deletions
diff --git a/test/driver.c b/test/driver.c
index 6b42d025b..4fe58432d 100644
--- a/test/driver.c
+++ b/test/driver.c
@@ -26,10 +26,8 @@ void print_hint(void)
int
main(void)
{
- struct mrb_parser_state *parser;
mrb_state *mrb;
mrb_value return_value;
- int byte_code;
const char *prog = "report()";
print_hint();
@@ -42,16 +40,8 @@ main(void)
}
mrb_init_mrbtest(mrb);
- parser = mrb_parse_nstring(mrb, prog, strlen(prog));
-
- /* generate bytecode */
- byte_code = mrb_generate_code(mrb, parser->tree);
-
- /* evaluate the bytecode */
- return_value = mrb_run(mrb,
- /* pass a proc for evaulation */
- mrb_proc_new(mrb, mrb->irep[byte_code]),
- mrb_top_self(mrb));
+ /* evaluate the test */
+ return_value = mrb_load_string(mrb, prog);
/* did an exception occur? */
if (mrb->exc) {
mrb_p(mrb, return_value);
@@ -62,5 +52,5 @@ main(void)
}
mrb_close(mrb);
- return 0;
+ return EXIT_SUCCESS;
}
diff --git a/test/t/bs_block.rb b/test/t/bs_block.rb
index 084d3b30f..bef9a8564 100644
--- a/test/t/bs_block.rb
+++ b/test/t/bs_block.rb
@@ -62,11 +62,11 @@ end
assert('BS Block 7') do
ans = []
for m in 1..3
- for n in 1..3
+ for n in 2..4
a = [m, n]
ans << a
end
- end == 1..3
+ end == (1..3)
end
assert('BS Block 8') do
diff --git a/test/t/module.rb b/test/t/module.rb
index 95fbb7a86..63c2e7dc8 100644
--- a/test/t/module.rb
+++ b/test/t/module.rb
@@ -9,6 +9,23 @@ assert('Module superclass', '15.2.2.2') do
Module.superclass == Object
end
+# TODO not implemented ATM assert('Module.constants', '15.2.2.3.1') do
+
+# TODO not implemented ATM assert('Module.nesting', '15.2.2.3.2') do
+
+assert('Module#append_features', '15.2.2.4.10') do
+ module Test4AppendFeatures
+ def self.append_features(mod)
+ Test4AppendFeatures2.const_set(:Const4AppendFeatures2, mod)
+ end
+ end
+ module Test4AppendFeatures2
+ include Test4AppendFeatures
+ end
+
+ Test4AppendFeatures2.const_get(:Const4AppendFeatures2) == Test4AppendFeatures2
+end
+
assert('Module#const_defined?', '15.2.2.4.20') do
module Test4ConstDefined
Const4Test4ConstDefined = true
@@ -56,6 +73,41 @@ assert('Module#const_get', '15.2.2.4.23') do
Test4ConstSet.const_get(:Const4Test4ConstSet) == 23
end
-# TODO not implemented ATM assert('Module.constants', '15.2.2') do
+assert('Module#include', '15.2.2.4.27') do
+ module Test4Include
+ Const4Include = 42
+ end
+ module Test4Include2
+ include Test4Include
+ end
+
+ Test4Include2.const_get(:Const4Include) == 42
+end
+
+assert('Module#included', '15.2.2.4.29') do
+ module Test4Included
+ Const4Included = 42
+ def Test4Included.included mod
+ Test4Included.const_set(:Const4Included2, mod)
+ end
+ end
+ module Test4Included2
+ include Test4Included
+ end
+
+ Test4Included2.const_get(:Const4Included) == 42 and
+ Test4Included2.const_get(:Const4Included2) == Test4Included2
+end
+
+assert('Module#included_modules', '15.2.2.4.30') do
+ r1 = true
+ module Test4includedModules
+ Const4Included = 42
+ end
+ module Test4includedModules2
+ r1 = included Test4includedModules
+ end
+
+ Test4includedModules2.included_modules.class == Array
+end
-# TODO not implemented ATM assert('Module.nesting', '15.2.2') do