@@ -50,7 +50,8 @@ def helper() -> str:
5050 helper . AddSourceFile ( "main.spy" , @"
5151import utils
5252
53- result = utils.helper()
53+ def main():
54+ result = utils.helper()
5455" ) ;
5556
5657 helper . WithEntryPoint ( "main.spy" ) ;
@@ -72,7 +73,8 @@ def add(x: int, y: int) -> int:
7273 helper . AddSourceFile ( "main.spy" , @"
7374import lib.math
7475
75- result = lib.math.add(5, 3)
76+ def main():
77+ result = lib.math.add(5, 3)
7678" ) ;
7779
7880 helper . WithEntryPoint ( "main.spy" ) ;
@@ -100,8 +102,9 @@ def concat(a: str, b: str) -> str:
100102import math_ops
101103import string_ops
102104
103- num = math_ops.add(5, 3)
104- text = string_ops.concat('hello', 'world')
105+ def main():
106+ num = math_ops.add(5, 3)
107+ text = string_ops.concat('hello', 'world')
105108" ) ;
106109
107110 helper . WithEntryPoint ( "main.spy" ) ;
@@ -123,8 +126,9 @@ public void BasicImport_ImportVariable_Works()
123126 helper . AddSourceFile ( "main.spy" , @"
124127import config
125128
126- size = config.MAX_SIZE
127- name = config.APP_NAME
129+ def main():
130+ size = config.MAX_SIZE
131+ name = config.APP_NAME
128132" ) ;
129133
130134 helper . WithEntryPoint ( "main.spy" ) ;
@@ -154,6 +158,9 @@ def func_b() -> int:
154158
155159 helper . AddSourceFile ( "main.spy" , @"
156160import module_a
161+
162+ def main():
163+ pass
157164" ) ;
158165
159166 helper . WithEntryPoint ( "main.spy" ) ;
@@ -172,7 +179,8 @@ public void BasicImport_ModuleNotFound_ReportsError()
172179 helper . AddSourceFile ( "main.spy" , @"
173180import nonexistent_module
174181
175- x = nonexistent_module.func()
182+ def main():
183+ x = nonexistent_module.func()
176184" ) ;
177185
178186 helper . WithEntryPoint ( "main.spy" ) ;
@@ -200,7 +208,8 @@ def helper() -> str:
200208 helper . AddSourceFile ( "main.spy" , @"
201209import mypackage.module
202210
203- result = mypackage.module.helper()
211+ def main():
212+ result = mypackage.module.helper()
204213" ) ;
205214
206215 helper . WithEntryPoint ( "main.spy" ) ;
@@ -232,8 +241,9 @@ def utility_func() -> str:
232241 helper . AddSourceFile ( "main.spy" , @"
233242import mypackage
234243
235- result = mypackage.utility_func()
236- value = mypackage.DATA_VALUE
244+ def main():
245+ result = mypackage.utility_func()
246+ value = mypackage.DATA_VALUE
237247" ) ;
238248
239249 helper . WithEntryPoint ( "main.spy" ) ;
@@ -255,8 +265,9 @@ public void PackageInit_WithVariables_DefinesPackageLevelVariables()
255265 helper . AddSourceFile ( "main.spy" , @"
256266import mypackage
257267
258- version = mypackage.VERSION
259- debug = mypackage.DEBUG
268+ def main():
269+ version = mypackage.VERSION
270+ debug = mypackage.DEBUG
260271" ) ;
261272
262273 helper . WithEntryPoint ( "main.spy" ) ;
@@ -281,8 +292,9 @@ def helper() -> int:
281292 helper . AddSourceFile ( "main.spy" , @"
282293import mypackage
283294
284- result = mypackage.package_function()
285- value = mypackage.helper()
295+ def main():
296+ result = mypackage.package_function()
297+ value = mypackage.helper()
286298" ) ;
287299
288300 helper . WithEntryPoint ( "main.spy" ) ;
@@ -305,7 +317,8 @@ def child_func() -> str:
305317 helper . AddSourceFile ( "main.spy" , @"
306318import parent.child
307319
308- result = parent.child.child_func()
320+ def main():
321+ result = parent.child.child_func()
309322" ) ;
310323
311324 helper . WithEntryPoint ( "main.spy" ) ;
@@ -327,7 +340,8 @@ def format_string(s: str) -> str:
327340 helper . AddSourceFile ( "main.spy" , @"
328341from utils import format_string
329342
330- result = format_string('test')
343+ def main():
344+ result = format_string('test')
331345" ) ;
332346
333347 helper . WithEntryPoint ( "main.spy" ) ;
@@ -350,7 +364,8 @@ public void ProjectFile_BasicConfiguration_CompilesSuccessfully()
350364 . WithEntryPoint ( "main.spy" ) ;
351365
352366 helper . AddSourceFile ( "main.spy" , @"
353- x: int = 42
367+ def main():
368+ x: int = 42
354369" ) ;
355370
356371 helper . CreateProjectFile ( ) ;
@@ -399,8 +414,9 @@ def helper() -> str:
399414import utils
400415import config
401416
402- result = utils.helper()
403- version = config.VERSION
417+ def main():
418+ result = utils.helper()
419+ version = config.VERSION
404420" ) ;
405421
406422 helper . CreateProjectFile ( ) ;
@@ -418,7 +434,8 @@ public void ProjectFile_CustomSourceDirectory_FindsSourceFiles()
418434 . WithEntryPoint ( "app.spy" ) ;
419435
420436 helper . AddSourceFile ( "app.spy" , @"
421- x: int = 100
437+ def main():
438+ x: int = 100
422439" ) ;
423440
424441 helper . CreateProjectFile ( ) ;
@@ -444,7 +461,8 @@ def compute() -> int:
444461 helper . AddSourceFile ( "main.spy" , @"
445462import dependency
446463
447- result = dependency.compute()
464+ def main():
465+ result = dependency.compute()
448466" ) ;
449467
450468 helper . WithEntryPoint ( "main.spy" ) ;
@@ -473,7 +491,8 @@ def middle_func() -> int:
473491 helper . AddSourceFile ( "main.spy" , @"
474492import middle
475493
476- result = middle.middle_func()
494+ def main():
495+ result = middle.middle_func()
477496" ) ;
478497
479498 helper . WithEntryPoint ( "main.spy" ) ;
@@ -509,8 +528,9 @@ def get_value_b() -> int:
509528import module_a
510529import module_b
511530
512- a = module_a.get_value_a()
513- b = module_b.get_value_b()
531+ def main():
532+ a = module_a.get_value_a()
533+ b = module_b.get_value_b()
514534" ) ;
515535
516536 helper . WithEntryPoint ( "main.spy" ) ;
@@ -565,7 +585,8 @@ def func_b() -> int:
565585import a
566586import b
567587
568- result = a.func_a() + b.func_b()
588+ def main():
589+ result = a.func_a() + b.func_b()
569590" ) ;
570591
571592 helper . WithEntryPoint ( "main.spy" ) ;
@@ -590,8 +611,9 @@ def subtract(x: int, y: int) -> int:
590611 helper . AddSourceFile ( "main.spy" , @"
591612import calculator
592613
593- sum = calculator.add(10, 5)
594- diff = calculator.subtract(10, 5)
614+ def main():
615+ sum = calculator.add(10, 5)
616+ diff = calculator.subtract(10, 5)
595617" ) ;
596618
597619 helper . WithEntryPoint ( "main.spy" ) ;
@@ -613,8 +635,9 @@ def expects_int(x: int) -> int:
613635 helper . AddSourceFile ( "main.spy" , @"
614636import typed_module
615637
616- # Should fail: passing string to int parameter
617- result = typed_module.expects_int('not an int')
638+ def main():
639+ # Should fail: passing string to int parameter
640+ result = typed_module.expects_int('not an int')
618641" ) ;
619642
620643 helper . WithEntryPoint ( "main.spy" ) ;
@@ -659,9 +682,10 @@ def divide(x: int, y: int) -> int:
659682 helper . AddSourceFile ( "main.spy" , @"
660683import math_lib
661684
662- sum = math_lib.add(10, 5)
663- product = math_lib.multiply(10, 5)
664- version = math_lib.VERSION
685+ def main():
686+ sum = math_lib.add(10, 5)
687+ product = math_lib.multiply(10, 5)
688+ version = math_lib.VERSION
665689" ) ;
666690
667691 helper . WithEntryPoint ( "main.spy" ) ;
@@ -689,8 +713,9 @@ def format_text(s: str) -> str:
689713import app.utils
690714import app.data
691715
692- text = app.utils.format_text('test')
693- config = app.data.CONFIG
716+ def main():
717+ text = app.utils.format_text('test')
718+ config = app.data.CONFIG
694719" ) ;
695720
696721 helper . WithEntryPoint ( "main.spy" ) ;
@@ -717,7 +742,8 @@ def func_b() -> int:
717742import module_a
718743from module_b import func_b
719744
720- total = module_a.VALUE_A + func_b()
745+ def main():
746+ total = module_a.VALUE_A + func_b()
721747" ) ;
722748
723749 helper . WithEntryPoint ( "main.spy" ) ;
@@ -753,8 +779,9 @@ def utility() -> str:
753779import lib
754780import config
755781
756- result = lib.utility()
757- debug = config.DEBUG
782+ def main():
783+ result = lib.utility()
784+ debug = config.DEBUG
758785" ) ;
759786
760787 helper . CreateProjectFile ( ) ;
@@ -782,11 +809,12 @@ public void ComplexScenario_LargeProjectWithManyFiles_CompilesEfficiently()
782809
783810 // Create main that imports all
784811 var imports = string . Join ( "\n " , Enumerable . Range ( 0 , 10 ) . Select ( i => $ "import util_{ i } ") ) ;
785- var calls = string . Join ( "\n " , Enumerable . Range ( 0 , 10 ) . Select ( i => $ "val_{ i } = util_{ i } .func_{ i } ()") ) ;
812+ var calls = string . Join ( "\n " , Enumerable . Range ( 0 , 10 ) . Select ( i => $ " val_{ i } = util_{ i } .func_{ i } ()") ) ;
786813
787814 helper . AddSourceFile ( "main.spy" , $@ "
788815{ imports }
789816
817+ def main():
790818{ calls }
791819" ) ;
792820
@@ -814,7 +842,8 @@ from .. import PARENT_VALUE
814842 helper . AddSourceFile ( "main.spy" , @"
815843import parent.child
816844
817- value = parent.child.CHILD_VALUE
845+ def main():
846+ value = parent.child.CHILD_VALUE
818847" ) ;
819848
820849 helper . WithEntryPoint ( "main.spy" ) ;
@@ -835,6 +864,9 @@ public void EdgeCase_EmptyModule_CompilesSuccessfully()
835864 helper . AddSourceFile ( "empty.spy" , "" ) ;
836865 helper . AddSourceFile ( "main.spy" , @"
837866import empty
867+
868+ def main():
869+ pass
838870" ) ;
839871
840872 helper . WithEntryPoint ( "main.spy" ) ;
@@ -855,6 +887,9 @@ public void EdgeCase_ModuleWithOnlyComments_CompilesSuccessfully()
855887
856888 helper . AddSourceFile ( "main.spy" , @"
857889import comments
890+
891+ def main():
892+ pass
858893" ) ;
859894
860895 helper . WithEntryPoint ( "main.spy" ) ;
@@ -884,8 +919,9 @@ def func() -> int:
884919import package_a.helper
885920import package_b.helper
886921
887- val_a = package_a.helper.func()
888- val_b = package_b.helper.func()
922+ def main():
923+ val_a = package_a.helper.func()
924+ val_b = package_b.helper.func()
889925" ) ;
890926
891927 helper . WithEntryPoint ( "main.spy" ) ;
@@ -909,7 +945,8 @@ def deep_func() -> str:
909945 helper . AddSourceFile ( "main.spy" , @"
910946import level1.level2.level3
911947
912- result = level1.level2.level3.deep_func()
948+ def main():
949+ result = level1.level2.level3.deep_func()
913950" ) ;
914951
915952 helper . WithEntryPoint ( "main.spy" ) ;
0 commit comments