diff options
| author | Amir Rajan <[email protected]> | 2021-01-18 12:08:34 -0600 |
|---|---|---|
| committer | Amir Rajan <[email protected]> | 2021-01-18 12:08:34 -0600 |
| commit | a4b9c048a1d751f5226833bb0c527ba1a8ac5d09 (patch) | |
| tree | 3f2535e7a6272e796d50e7f07c906d4c9eb1b14a /samples/10_advanced_debugging/03_unit_tests | |
| parent | a24a71805b1924ae7f80776c736f94575c171d2c (diff) | |
| download | dragonruby-game-toolkit-contrib-a4b9c048a1d751f5226833bb0c527ba1a8ac5d09.tar.gz dragonruby-game-toolkit-contrib-a4b9c048a1d751f5226833bb0c527ba1a8ac5d09.zip | |
Synced with 2.3.
Diffstat (limited to 'samples/10_advanced_debugging/03_unit_tests')
11 files changed, 87 insertions, 13 deletions
diff --git a/samples/10_advanced_debugging/03_unit_tests/exception_raising_tests.rb b/samples/10_advanced_debugging/03_unit_tests/exception_raising_tests.rb index 57efdb2..b7e1223 100644 --- a/samples/10_advanced_debugging/03_unit_tests/exception_raising_tests.rb +++ b/samples/10_advanced_debugging/03_unit_tests/exception_raising_tests.rb @@ -15,7 +15,5 @@ def test_exception_in_newing_object args, assert end end -puts "running tests" $gtk.reset 100 $gtk.log_level = :off -$gtk.tests.start diff --git a/samples/10_advanced_debugging/03_unit_tests/gen_docs.rb b/samples/10_advanced_debugging/03_unit_tests/gen_docs.rb index 0e41326..a627653 100644 --- a/samples/10_advanced_debugging/03_unit_tests/gen_docs.rb +++ b/samples/10_advanced_debugging/03_unit_tests/gen_docs.rb @@ -1,2 +1,2 @@ -# sh ./amir-build-and-run.sh --eval samples/99_zz_gtk_unit_tests/gen_docs.rb --no-tick +# ./dragonruby mygame --eval samples/99_zz_gtk_unit_tests/gen_docs.rb --no-tick Kernel.export_docs! diff --git a/samples/10_advanced_debugging/03_unit_tests/geometry_tests.rb b/samples/10_advanced_debugging/03_unit_tests/geometry_tests.rb index d823d78..fb61af3 100644 --- a/samples/10_advanced_debugging/03_unit_tests/geometry_tests.rb +++ b/samples/10_advanced_debugging/03_unit_tests/geometry_tests.rb @@ -110,7 +110,5 @@ begin :scale_rect end end -puts "running tests" $gtk.reset 100 $gtk.log_level = :off -$gtk.tests.start diff --git a/samples/10_advanced_debugging/03_unit_tests/http_tests.rb b/samples/10_advanced_debugging/03_unit_tests/http_tests.rb index 1132f85..01a22b3 100644 --- a/samples/10_advanced_debugging/03_unit_tests/http_tests.rb +++ b/samples/10_advanced_debugging/03_unit_tests/http_tests.rb @@ -18,7 +18,5 @@ def test_http args, assert try_assert_or_schedule args, assert end -puts "running tests" $gtk.reset 100 $gtk.log_level = :off -$gtk.tests.start diff --git a/samples/10_advanced_debugging/03_unit_tests/object_to_primitive_tests.rb b/samples/10_advanced_debugging/03_unit_tests/object_to_primitive_tests.rb index 4686c6e..8ba2654 100644 --- a/samples/10_advanced_debugging/03_unit_tests/object_to_primitive_tests.rb +++ b/samples/10_advanced_debugging/03_unit_tests/object_to_primitive_tests.rb @@ -14,4 +14,3 @@ end $gtk.reset 100 $gtk.log_level = :off -$gtk.tests.start diff --git a/samples/10_advanced_debugging/03_unit_tests/parsing_tests.rb b/samples/10_advanced_debugging/03_unit_tests/parsing_tests.rb index 4dede2b..7fa1591 100644 --- a/samples/10_advanced_debugging/03_unit_tests/parsing_tests.rb +++ b/samples/10_advanced_debugging/03_unit_tests/parsing_tests.rb @@ -23,7 +23,5 @@ S assert.equal! result, expected, "Parsing xml failed." end -puts "running tests" $gtk.reset 100 $gtk.log_level = :off -$gtk.tests.start diff --git a/samples/10_advanced_debugging/03_unit_tests/require_tests.rb b/samples/10_advanced_debugging/03_unit_tests/require_tests.rb new file mode 100644 index 0000000..7ebfc3a --- /dev/null +++ b/samples/10_advanced_debugging/03_unit_tests/require_tests.rb @@ -0,0 +1,38 @@ +def write_src path, src + $gtk.write_file path, src +end + +write_src 'app/unit_testing_game.rb', <<-S +module UnitTesting + class Game + end +end +S + +write_src 'lib/unit_testing_lib.rb', <<-S +module UnitTesting + class Lib + end +end +S + +write_src 'app/nested/unit_testing_nested.rb', <<-S +module UnitTesting + class Nested + end +end +S + +require 'app/unit_testing_game.rb' +require 'app/nested/unit_testing_nested.rb' +require 'lib/unit_testing_lib.rb' + +def test_require args, assert + UnitTesting::Game.new + UnitTesting::Lib.new + UnitTesting::Nested.new + $gtk.exec 'rm ./mygame/app/unit_testing_game.rb' + $gtk.exec 'rm ./mygame/app/nested/unit_testing_nested.rb' + $gtk.exec 'rm ./mygame/lib/unit_testing_lib.rb' + assert.ok! +end diff --git a/samples/10_advanced_debugging/03_unit_tests/run-tests.sh b/samples/10_advanced_debugging/03_unit_tests/run-tests.sh new file mode 100644 index 0000000..e551edf --- /dev/null +++ b/samples/10_advanced_debugging/03_unit_tests/run-tests.sh @@ -0,0 +1,10 @@ +./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/require_tests.rb +./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/gen_docs.rb +./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/geometry_tests.rb +./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/http_tests.rb +./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/object_to_primitive_tests.rb +./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/parsing_tests.rb +./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/require_tests.rb +./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/serialize_deserialize_tests.rb +./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/state_serialization_experimental_tests.rb +./dragonruby mygame --test samples/10_advanced_debugging/03_unit_tests/suggest_autocompletion_tests.rb diff --git a/samples/10_advanced_debugging/03_unit_tests/serialize_deserialize_tests.rb b/samples/10_advanced_debugging/03_unit_tests/serialize_deserialize_tests.rb index e67b1ee..8505bdf 100644 --- a/samples/10_advanced_debugging/03_unit_tests/serialize_deserialize_tests.rb +++ b/samples/10_advanced_debugging/03_unit_tests/serialize_deserialize_tests.rb @@ -113,5 +113,3 @@ def test_by_reference_state_strict_entities args, assert deserialized_state = args.gtk.deserialize_state serialized_state assert.equal! deserialized_state.strict_entity.one, deserialized_state.strict_entity.two end - -$tests.start diff --git a/samples/10_advanced_debugging/03_unit_tests/state_serialization_experimental_tests.rb b/samples/10_advanced_debugging/03_unit_tests/state_serialization_experimental_tests.rb index ffd8064..50258a8 100644 --- a/samples/10_advanced_debugging/03_unit_tests/state_serialization_experimental_tests.rb +++ b/samples/10_advanced_debugging/03_unit_tests/state_serialization_experimental_tests.rb @@ -104,4 +104,3 @@ end $gtk.reset 100 $gtk.log_level = :off -$gtk.tests.start diff --git a/samples/10_advanced_debugging/03_unit_tests/suggest_autocompletion_tests.rb b/samples/10_advanced_debugging/03_unit_tests/suggest_autocompletion_tests.rb new file mode 100644 index 0000000..e286a6c --- /dev/null +++ b/samples/10_advanced_debugging/03_unit_tests/suggest_autocompletion_tests.rb @@ -0,0 +1,38 @@ +def default_suggest_autocompletion args + { + index: 4, + text: "args.", + __meta__: { + other_options: [ + { + index: Fixnum, + file: "app/main.rb" + } + ] + } + } +end + +def assert_completion source, *expected + results = suggest_autocompletion text: (source.strip.gsub ":cursor", ""), + index: (source.strip.index ":cursor") + + puts results +end + +def test_args_completion args, assert + $gtk.write_file_root "autocomplete.txt", ($gtk.suggest_autocompletion text: <<-S, index: 128).join("\n") +require 'app/game.rb' + +def tick args + args.gtk.suppress_mailbox = false + $game ||= Game.new + $game.args = args + $game.args. + $game.tick +end +S + + puts "contents:" + puts ($gtk.read_file "autocomplete.txt") +end |
