@@ -6,8 +6,7 @@ mod tests {
66 fn test ( ) {
77 let mut game: Game = include_str ! ( "world.ron" ) . parse ( ) . unwrap ( ) ;
88
9- let excuse_me = [ "" , "a" , "and" , "a and" , "and a" ] ;
10- for s in excuse_me {
9+ for s in [ "" , "a" , "and" , "a and" , "and a" ] {
1110 assert_eq ! ( game. ask( s) , "Excuse me?" ) ;
1211 }
1312
@@ -19,13 +18,15 @@ mod tests {
1918 fn look ( ) {
2019 let mut game: Game = include_str ! ( "world.ron" ) . parse ( ) . unwrap ( ) ;
2120
22- let expected = "Center Room\n You are in the center room.\n There is a box here." ;
2321 for s in [
2422 "l" , // alias
2523 "look" , // look command
2624 "look around" , // long form
2725 ] {
28- assert_eq ! ( game. ask( s) , expected) ;
26+ assert_eq ! (
27+ game. ask( s) ,
28+ "Center Room\n You are in the center room.\n There is a box here."
29+ ) ;
2930 }
3031 }
3132
@@ -101,6 +102,13 @@ mod tests {
101102 assert_eq ! ( game. ask( "put apple in apple" ) , "Impossible." ) ;
102103 assert_eq ! ( game. ask( "put box in box" ) , "Impossible." ) ;
103104
105+ // try to open/close non-container
106+ assert_eq ! (
107+ game. ask( "open the apple" ) ,
108+ "You cannot do that to the apple."
109+ ) ;
110+ assert_eq ! ( game. ask( "close apple" ) , "You cannot do that to the apple." ) ;
111+
104112 // close
105113 assert_eq ! ( game. ask( "close box" ) , "Closed." ) ;
106114
@@ -162,4 +170,12 @@ mod tests {
162170 "You hit the self with your dagger."
163171 ) ;
164172 }
173+
174+ #[ test]
175+ fn again ( ) {
176+ let mut game: Game = include_str ! ( "world.ron" ) . parse ( ) . unwrap ( ) ;
177+
178+ game. ask ( "take it" ) ;
179+ game. ask ( "again" ) ; // make sure nothing funny happens
180+ }
165181}
0 commit comments