Skip to content

Commit 3c13d0b

Browse files
committed
Add the non-working expressions test to YS2.
1 parent 58289ed commit 3c13d0b

5 files changed

Lines changed: 31 additions & 5 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
id,node,lineNumber,tags

examples/yarn2/expressions.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
id,text,file,node,lineNumber
2+
line:/Users/sweaver/Git/YarnRunner-Python/examples/yarn2/expressions.yarn-Start-0,Hello there {0}.,/Users/sweaver/Git/YarnRunner-Python/examples/yarn2/expressions.yarn,Start,5

examples/yarn2/expressions.yarn

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
title: Start
2+
---
3+
<<set $name to "Sam">>
4+
5+
Hello there {$name}.
6+
===

examples/yarn2/expressions.yarnc

180 Bytes
Binary file not shown.

tests/test_expressions.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
11
import os
22
from .context import YarnRunner
33

4-
compiled_yarn_f = open(os.path.join(os.path.dirname(
4+
compiled_yarn_f1 = open(os.path.join(os.path.dirname(
55
__file__), '../examples/yarn1/expressions.yarnc'), 'rb')
6-
names_csv_f = open(os.path.join(os.path.dirname(
6+
names_csv_f1 = open(os.path.join(os.path.dirname(
77
__file__), '../examples/yarn1/expressions.csv'), 'r')
8+
compiled_yarn_f2 = open(os.path.join(os.path.dirname(
9+
__file__), '../examples/yarn2/expressions.yarnc'), 'rb')
10+
names_csv_f2 = open(os.path.join(os.path.dirname(
11+
__file__), '../examples/yarn2/expressions.csv'), 'r')
812

9-
runner = YarnRunner(compiled_yarn_f, names_csv_f, autostart=False)
13+
runner1 = YarnRunner(compiled_yarn_f1, names_csv_f1, autostart=False)
14+
runner2 = YarnRunner(compiled_yarn_f2, names_csv_f2, autostart=False)
1015

1116
# TODO: implement a test for expression parsing
1217

1318

14-
def test_expressions():
19+
def test_expressions1():
1520
try:
16-
runner.resume()
21+
runner1.resume()
22+
23+
# the runner should throw an error
24+
raise Exception(
25+
"The runner ran without any issues. This test should fail. An Exception was expected.")
26+
except Exception as e:
27+
assert str(
28+
e) == "Yarn stories with interpolated inline expressions are not yet supported."
29+
30+
31+
def test_expressions2():
32+
try:
33+
runner2.resume()
1734

1835
# the runner should throw an error
1936
raise Exception(

0 commit comments

Comments
 (0)