@@ -303,4 +303,57 @@ public class JavaTestCase {
303303 let actual = filter. map ( |l| l. unwrap ( ) ) . collect :: < Vec < MetaString > > ( ) ;
304304 assert_eq ! ( expected, actual) ;
305305 }
306+
307+ #[ test]
308+ fn stube ( ) {
309+ init ( ) ;
310+
311+ const PYTHON_FILE_STUB : & str = r#"
312+ # BEGIN SOLUTION
313+ print("a")
314+ # END SOLUTION
315+ # KOMMENTTI
316+ #STUB:class Kauppalista:
317+ #STUB:def __init__(self):
318+ #STUB:self.tuotteet = []
319+ #STUB:
320+ #STUB:def tuotteita(self):
321+ #STUB:return len(self.tuotteet)
322+ #STUB:
323+ #STUB:def lisaa(self, tuote: str, maara: int):
324+ #STUB:self.tuotteet.append((tuote, maara))
325+ #STUB:
326+ #STUB:def tuote(self, n: int):
327+ #STUB:return self.tuotteet[n - 1][0]
328+ #STUB:
329+ #STUB:def maara(self, n:int):
330+ #STUB:return self.uotteet[n - 1][1]
331+ "# ;
332+
333+ let expected: Vec < MetaString > = vec ! [
334+ MetaString :: str ( "\n " ) ,
335+ MetaString :: solution( "print(\" a\" )\n " ) ,
336+ MetaString :: str ( "# KOMMENTTI\n " ) ,
337+ MetaString :: stub( "class Kauppalista:\n " ) ,
338+ MetaString :: stub( " def __init__(self):\n " ) ,
339+ MetaString :: stub( " self.tuotteet = []\n " ) ,
340+ MetaString :: stub( "\n " ) ,
341+ MetaString :: stub( " def tuotteita(self):\n " ) ,
342+ MetaString :: stub( " return len(self.tuotteet)\n " ) ,
343+ MetaString :: stub( "\n " ) ,
344+ MetaString :: stub( " def lisaa(self, tuote: str, maara: int):\n " ) ,
345+ MetaString :: stub( " self.tuotteet.append((tuote, maara))\n " ) ,
346+ MetaString :: stub( "\n " ) ,
347+ MetaString :: stub( " def tuote(self, n: int):\n " ) ,
348+ MetaString :: stub( " return self.tuotteet[n - 1][0]\n " ) ,
349+ MetaString :: stub( "\n " ) ,
350+ MetaString :: stub( " def maara(self, n:int):\n " ) ,
351+ MetaString :: stub( " return self.uotteet[n - 1][1]\n " ) ,
352+ ] ;
353+
354+ let source = PYTHON_FILE_STUB . as_bytes ( ) ;
355+ let filter = MetaSyntaxParser :: new ( source, "py" ) ;
356+ let actual = filter. map ( |l| l. unwrap ( ) ) . collect :: < Vec < MetaString > > ( ) ;
357+ assert_eq ! ( expected, actual) ;
358+ }
306359}
0 commit comments