-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSL_Generator_Test.py
188 lines (163 loc) · 5.67 KB
/
SL_Generator_Test.py
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# SL_Generator_Test.py
# Tests for SL Generator class
#
import unittest
from SL_Generator import Generator
from SL_Validator import Validator
class GeneratorTest(unittest.TestCase):
def setUp(self):
userChoice = {"compat": "yarn", "resolve": "long", "newcompat": "yarn"}
self.g = Generator(userChoice)
self.v = Validator()
def testGenerator01GenerateProcess(self):
filePath = "C:\\Temp\\nonExistant.txt"
data = """
title: Start
---
Player: Hey, Sally. #line:34
<<if true>> #line:
Player: Hey, Sally. #line:34
Sally: Oh! Hi.
Sally: You snuck up on me. //comment
Sally: Don't do that.
<<else>>
Player: Hey. #line:305cd
//Sally: Hi. #line:305cde
<<endif>>
===
title: Start
tags:
colorID: 2
position: 567,1160
---
I have [plural {$apples} one="an apple" other="% apples"]!
<<set $monster to "your own hubris">>You accidentally stab yourself with the rock.
[[Dead]]
<<set $light to "dim">> text <<set $monster to "bear">>
//#line: The wind blows softly through the trees. The sound of rustling leaves is reminiscent of the ocean. #line:01 // comment
[[Build a fire|Fire]] #line:02
[[Try to find your way out|Escape]] #line:03
[[Resign to your fate|Dead]] #line:04
===
title: Fire
tags:
colorID: 1
position: -125,790
---
<<set $light to "bright">>You collect some dry wood and begin to build your campfire.#line:
What do you do now?
<<set $monster to "big strong thing that hates yodeling idk names are hard">>
I'm sorry to inform you that you have died. Our records show that a "$monster" killed you.
[[Yes|Start]] #line:12
===
title: Sleep
tags:
colorID: 1
position: 707,164
---
<<set $monster to "an even bigger rock with even better clothes">>You find a sturdy stick and the sharp looking rock.
[[This is unacceptable. Destroy the rock.|Dead]]
[[Put the rock down. You will find your own style, eventually.|Fire]] #line:18
[[Turn the rock into a weapon. Poison your enemies with its sick threads.|Weapon]] #line:19
===
title: Weapon
tags:
colorID: 1
position: 312,114
---
===
title: Start
tags:
colorID: 2
position: 567,1160
---
<<set $light to "dim">><<set $monster to "bear">>
The wind blows softly through the trees. The sound of rustling leaves is reminiscent of the ocean. The wind gently nips at your ears and nose. You feel both at peace and on edge. These woods are full of monsters and night rapidly approaches. What do you do? #line:01
[[Build a fire|Fire]] #line:02
[[Try to find your way out|Escape]] #line:03
[[Resign to your fate|Dead]] #line:04
===
title: Fire
tags:
colorID: 1
position: -125,790
---
<<set $light to "bright">>You collect some dry wood and begin to build your campfire. You carefully stack the logs and sprinkle some kindling around for good measure. Once you're satisfied with your craftsmanship, you strike a match and set it all ablaze. #line:05
What do you do now? #line:06
[[Try to get some sleep|Sleep]] #line:07
[[Craft a weapon|Make]] #line:08
<<set $monster to "big strong thing that hates yodeling idk names are hard">>
[[Practice your yodeling|Dead]] #line:09
===
title: Escape
tags:
colorID: 3
position: 461,799
---
<<set $monster to "something spooky probably">>You fail to escape and die. #line:10
[[Dead]]
===
title: Dead
tags:
colorID: 5
position: 890,767
---
I'm sorry to inform you that you have died. Our records show that a "$monster" killed you. How unfortunate. Would you like to try again? #line:11
[[Yes|Start]] #line:12
===
title: Sleep
tags:
colorID: 1
position: 707,164
---
<<if $light is "bright">>It's too bright. You cannot sleep. #line:13
[[Do something else.|Fire]] #line:14
<<else>>
You fall asleep quite peacefully, blissfully unaware of your impending death. #line:15
<<set $monster to "that minecraft monster in the new update that attacks you if you don't sleep for like three days">>
[[Dead]]
<<endif>>
===
title: Make
tags:
colorID: 1
position: -271,117
---
<<set $monster to "an even bigger rock with even better clothes">>You find a sturdy stick and the sharp looking rock. You ask the rock for fashion advice and where it got those snazzy clothes. The rock does not respond. #line:16
[[This is unacceptable. Destroy the rock.|Dead]] #line:17
[[Put the rock down. You will find your own style, eventually.|Fire]] #line:18
[[Turn the rock into a weapon. Poison your enemies with its sick threads.|Weapon]] #line:19
===
title: Weapon
tags:
colorID: 1
position: 312,114
---
I have [plural {$apples} one="an apple" other="% apples"]! #line:20
<<set $monster to "your own hubris">>You accidentally stab yourself with the rock. #line:21
[[Dead]]
===
"""
sData = data.split("\n")
# expectedData = ""
#=================================
self.v.validatorProcess(filePath, sData)
cDict = self.v.getConflictDic()
uDict = self.v.getLineidUsedDic()
# print(uDict)
eCDictLen = 7
with self.subTest(f"{len(cDict)} != Expected {eCDictLen}"):
self.assertTrue(len(cDict) == eCDictLen)
eUDictLen = 23
with self.subTest(f"{len(uDict)} != Expected {eUDictLen}"):
self.assertTrue(len(uDict) == eUDictLen)
#=================================
newData = self.g.generatorProcess(filePath, sData, self.v)
cDict = self.v.getConflictDic()
uDict = self.v.getLineidUsedDic()
eCDictLen = 7
with self.subTest(f"{len(cDict)} != Expected {eCDictLen}"):
self.assertTrue(len(cDict) == eCDictLen)
eUDictLen = eUDictLen + eCDictLen + 35
with self.subTest(f"{len(uDict)} != Expected {eUDictLen}"):
self.assertTrue(len(uDict) == eUDictLen)