Skip to content

Commit

Permalink
Merge pull request #234 from theludovyc/fix#220_do_not_check_indent
Browse files Browse the repository at this point in the history
fix #220 do not check indent
  • Loading branch information
Jeremi360 authored May 16, 2023
2 parents c8d0a9f + 12e03b1 commit d11e1fe
Show file tree
Hide file tree
Showing 12 changed files with 271 additions and 130 deletions.
25 changes: 25 additions & 0 deletions Test/TestExecuter/TestMenu/TestMenu.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
extends "res://Test/RakugoTest.gd"

func test_menu():
var file_path = "res://Test/TestParser/TestMenu/TestMenu.rk"

var file_base_name = get_file_base_name(file_path)

watch_rakugo_signals()

await wait_parse_and_execute_script(file_path)

await wait_menu(["Loop", "End"])

assert_menu_return(0);

await wait_menu(["Loop", "End"])

assert_menu_return(1);

await wait_execute_script_finished(file_base_name)

func test_menu_choice_parse_fail():
var file_path = "res://Test/TestParser/TestMenu/TestMenuChoiceParseFail.rk"

assert_eq(Rakugo.parse_script(file_path), FAILED)
File renamed without changes.
6 changes: 6 additions & 0 deletions Test/TestExecuter/TestMenu/TestMenu.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://dmruluk7xrv2e"]

[ext_resource type="Script" path="res://Test/TestParser/TestMenu/TestMenu.gd" id="1"]

[node name="TestMenu" type="Node"]
script = ExtResource("1")
28 changes: 28 additions & 0 deletions Test/TestExecuter/TestSay/TestSay.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
extends "res://Test/RakugoTest.gd"

const file_path = "res://Test/TestParser/TestSay/TestSay.rk"

var file_base_name = get_file_base_name(file_path)

func test_say():
watch_rakugo_signals()

await wait_parse_and_execute_script(file_path)

await wait_say({}, "Hello, world !")

assert_do_step()

await wait_say({"name": "Sylvie"}, "Hello !")

assert_do_step()

await wait_say({}, "My name is Sylvie")

assert_do_step()

await wait_say({}, "I am 18")

assert_do_step()

await wait_execute_script_finished(file_base_name)
File renamed without changes.
6 changes: 6 additions & 0 deletions Test/TestExecuter/TestSay/TestSay.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://dt8lnvj37mvw0"]

[ext_resource type="Script" path="res://Test/TestParser/TestSay/TestSay.gd" id="1"]

[node name="TestSay" type="Node"]
script = ExtResource("1")
75 changes: 58 additions & 17 deletions Test/TestParser/TestMenu/TestMenu.gd
Original file line number Diff line number Diff line change
@@ -1,25 +1,66 @@
extends "res://Test/RakugoTest.gd"
extends GutTest

func test_menu():
var file_path = "res://Test/TestParser/TestMenu/TestMenu.rk"
const Parser = preload("res://addons/Rakugo/lib/systems/Parser.gd")

var file_base_name = get_file_base_name(file_path)
@onready var parser := Parser.new()

watch_rakugo_signals()

await wait_parse_and_execute_script(file_path)

await wait_menu(["Loop", "End"])
var test_params = [
[
"menu menu:",
"\"loop\" > menu",
"\"end\""
],
[
"menu menu:",
" \"loop\" > menu",
" \"end\""
],
[
" menu menu: ",
" \"loop\" > menu ",
" \"end\""
],
[
"menu menu:",
"\"loop\" > menu",
"\"end\"",
""
],
[
"menu menu:",
"\"loop\" > menu",
"\"end\"",
" "
],
[
"menu menu:",
"\"loop\" > menu",
"\"end\"",
"\"hello, world !\""
],
[
"menu menu:",
"\"loop\" > menu",
"\"end\"",
"# comment"
]
]

assert_menu_return(0);
func test_menu(params=use_parameters(test_params)):
var parsed_script = parser.parse_script(params)

await wait_menu(["Loop", "End"])

assert_menu_return(1);
assert_false(parsed_script.is_empty())

var parsed_array = parsed_script["parse_array"]

assert_false(parsed_array.is_empty())

assert_eq(parsed_script["labels"], {"menu":0})

var menu_choice_results = parsed_array[0][2]

await wait_execute_script_finished(file_base_name)
assert_eq(menu_choice_results[0].get_string("text"), "\"loop\"")

func test_menu_choice_parse_fail():
var file_path = "res://Test/TestParser/TestMenu/TestMenuChoiceParseFail.rk"
assert_eq(menu_choice_results[0].get_string("label"), "menu")

assert_eq(Rakugo.parse_script(file_path), FAILED)
assert_eq(menu_choice_results[1].get_string("text"), "\"end\"")
6 changes: 3 additions & 3 deletions Test/TestParser/TestMenu/TestMenu.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://dmruluk7xrv2e"]
[gd_scene load_steps=2 format=3 uid="uid://cryjirfvh5cuq"]

[ext_resource type="Script" path="res://Test/TestParser/TestMenu/TestMenu.gd" id="1"]
[ext_resource type="Script" path="res://Test/TestParser/TestMenu/TestMenu.gd" id="1_roxlx"]

[node name="TestMenu" type="Node"]
script = ExtResource("1")
script = ExtResource("1_roxlx")
75 changes: 60 additions & 15 deletions Test/TestParser/TestSay/TestSay.gd
Original file line number Diff line number Diff line change
@@ -1,28 +1,73 @@
extends "res://Test/RakugoTest.gd"
extends GutTest

const file_path = "res://Test/TestParser/TestSay/TestSay.rk"
const Parser = preload("res://addons/Rakugo/lib/systems/Parser.gd")

var file_base_name = get_file_base_name(file_path)
@onready var parser := Parser.new()

func test_say():
watch_rakugo_signals()
var test_params = [
["\"Hello, world !\""],
[" \"Hello, world !\""],
[" \"Hello, world !\""],
["\"Hello, world !\" "]
]

await wait_parse_and_execute_script(file_path)
func test_say(params=use_parameters(test_params)):
var parsed_script = parser.parse_script(params)

assert_false(parsed_script.is_empty())

await wait_say({}, "Hello, world !")
var parsed_array = parsed_script["parse_array"]

assert_do_step()
assert_false(parsed_array.is_empty())

await wait_say({"name": "Sylvie"}, "Hello !")
assert_true(parsed_script.get("labels", [""]).is_empty())

assert_do_step()
assert_true(parsed_array[0][0] == "SAY")

await wait_say({}, "My name is Sylvie")
var result = parsed_array[0][1]

assert_do_step()
assert_eq(result.get_string("text"), "\"Hello, world !\"")

func test_say_character():
var rk_script = [
"sy \"Hello !\""
]

var parsed_script = parser.parse_script(rk_script)

assert_false(parsed_script.is_empty())

var parsed_array = parsed_script["parse_array"]

assert_false(parsed_array.is_empty())

await wait_say({}, "I am 18")
assert_true(parsed_script.get("labels", [""]).is_empty())

assert_true(parsed_array[0][0] == "SAY")

var result = parsed_array[0][1]

assert_eq(result.get_string("character_tag"), "sy")

assert_do_step()
assert_eq(result.get_string("text"), "\"Hello !\"")

await wait_execute_script_finished(file_base_name)
func test_say_variable():
var rk_script = [
"\"My name is <sy.name>\""
]

var parsed_script = parser.parse_script(rk_script)

assert_false(parsed_script.is_empty())

var parsed_array = parsed_script["parse_array"]

assert_false(parsed_array.is_empty())

assert_true(parsed_script.get("labels", [""]).is_empty())

assert_true(parsed_array[0][0] == "SAY")

var result = parsed_array[0][1]

assert_eq(result.get_string("text"), "\"My name is <sy.name>\"")
6 changes: 3 additions & 3 deletions Test/TestParser/TestSay/TestSay.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://dt8lnvj37mvw0"]
[gd_scene load_steps=2 format=3 uid="uid://e4471uaguj8k"]

[ext_resource type="Script" path="res://Test/TestParser/TestSay/TestSay.gd" id="1"]
[ext_resource type="Script" path="res://Test/TestParser/TestSay/TestSay.gd" id="1_ux5ov"]

[node name="TestSay" type="Node"]
script = ExtResource("1")
script = ExtResource("1_ux5ov")
Loading

0 comments on commit d11e1fe

Please sign in to comment.