summaryrefslogtreecommitdiff
path: root/Tests/Game/Commands/test_LookCommand.gd
blob: 558efc147d58f10352a81beab073439c8de458b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
extends CommandParserTestBase

const LookCommand = preload("res://Scripts/Game/Commands/LookCommand.cs")

var _around_permutations = generate_capitalization_permutations('around')
var _at_permutations = generate_capitalization_permutations('at')
var _look_permutations = generate_capitalization_permutations('look')

func parse(input: String) -> LookCommand:
	return autofree(_instance.TryParse(input))

func after_all():
	assert_no_new_orphans()

func test_parsing_look_command_without_an_argument_returns_non_null():
	assert_not_null(parse('look'))

func test_parsing_look_command_is_case_insensitive(permutation=use_parameters(_look_permutations)):
	assert_not_null(parse(permutation))

func test_parsing_look_command_without_an_argument_returns_look_command_with_an_emtpy_target():
	assert_eq('', parse('look').Target)

func test_parsing_look_at_command_is_case_insensitive(permutation=use_parameters(_at_permutations)):
	assert_not_null(parse('look ' + permutation))

func test_parsing_look_at_command_without_further_arguments_returns_look_command_with_an_emtpy_target():
	assert_eq('', parse('look at').Target)

func test_parsing_look_at_command_without_further_arguments_returns_look_command_with_non_null_modifier():
	assert_not_null(parse('look at').Modifier)

func test_parsing_look_at_command_without_further_arguments_returns_look_command_with_at_modifier():
	assert_eq('At', parse('look at').ModifierAsString)

func test_parsing_look_at_command_with_more_arguments_returns_look_command_with_non_empty_target():
	assert_ne('', parse('look at door on the left').Target)

func test_parsing_look_at_command_with_an_additional_argument_returns_look_command_with_the_additional_argument_as_the_target():
	assert_eq('window', parse('look at window').Target)

func test_parsing_look_at_command_with_multiple_additional_arguments_returns_look_command_with_the_additional_arguments_as_the_target():
	assert_eq('table near the door', parse('look at table near the door').Target)

func test_parsing_look_around_command_is_case_insensitive(permutation=use_parameters(_around_permutations)):
	assert_not_null(parse('look ' + permutation))

func test_parsing_look_around_command_without_further_arguments_returns_look_command_with_an_empty_target():
	assert_eq('', parse('look around').Target)

func test_parsing_look_around_command_without_further_arguments_returns_look_command_with_non_null_modifier():
	assert_not_null(parse('look around').Modifier)

func test_parsing_look_around_command_without_further_arguments_returns_look_command_with_around_modifier():
	assert_eq('Around', parse('look around').ModifierAsString)

func test_parsing_look_around_command_ignores_all_additional_arguments():
	assert_eq('', parse('look around the room').Target)