Changeset 2291 for cobra/trunk/Source/BackEndClr/SharpGenerator.cobra
- Timestamp:
- 02/27/10 09:18:29 (2 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
cobra/trunk/Source/BackEndClr/SharpGenerator.cobra
r2251 r2291 63 63 print ' bool success = false;' 64 64 print ' try {' 65 for module in _modules66 module.writeSharpTestInvocation(f)65 print ' CobraLangInternal.Test.ITestRunListener listener = new CobraLangInternal.Test.TextWriterListener(System.Console.Out);' 66 print ' new CobraLangInternal.Test.TestRunner(listener).RunAllTests();' 67 67 if .hasExceptionReportOption 68 68 print ' success = true;' … … 583 583 is partial 584 584 585 get sharp Suffixas String585 get sharpFullName as String 586 586 value as Object? 587 if not .addOnValues.tryGetValue('sharpSuffix', out value) 588 suffix = if(.fullName == 'Cobra.Lang', .compiler.embedRunTimeSuffix, '') 589 .addOnValues['sharpSuffix'] = suffix 590 return suffix 587 if not .addOnValues.tryGetValue('sharpFullName', out value) 588 fullName = .fullName 589 if fullName == 'Cobra.Lang' 590 name = 'Cobra.Lang' + .compiler.embedRunTimeSuffix 591 else if fullName.startsWith('Cobra.Lang.') 592 name = 'Cobra.Lang[.compiler.embedRunTimeSuffix].' + fullName['Cobra.Lang.'.length:] 593 else 594 name = fullName 595 .addOnValues['sharpFullName'] = name 596 return name 591 597 else 592 598 return value to String … … 600 606 return 'global::' 601 607 else 602 return . fullName + .sharpSuffix608 return .sharpFullName 603 609 604 610 get sharpQualifier as String … … 607 613 return 'global::' 608 614 else 609 return . fullName + .sharpSuffix+ '.'615 return .sharpFullName + '.' 610 616 611 617 def writeSharpDef(sw as CurlyWriter) is override … … 613 619 base.writeSharpDef(sw) 614 620 if not .isRoot 615 sw.writeAndIndent('namespace [.name][.sharpSuffix] {\n\n') 621 suffix = if(.fullName == 'Cobra.Lang', .compiler.embedRunTimeSuffix, '') 622 sw.writeAndIndent('namespace [.name][suffix] {\n\n') 616 623 for ud in _useDirectives 617 624 ud.writeSharpDef(sw) … … 995 1002 .compiler.boxMemberStack.push(decl) 996 1003 try 997 /#998 delme999 if decl inherits BoxMember1000 if decl.parentBox is not this # skip extension methods that were not declared in this box1001 continue1002 #/1003 1004 decl.writeSharpDef(sw) 1004 1005 finally … … 1078 1079 1079 1080 def writeSharpTest(sw as CurlyWriter) 1080 # Running tests from the static initializer seems like a good idea, but has been problematic at various times on both .NET and Mono, so no more: 1081 # sw.write('\nstatic [.rootName]() { RunTestsIfNeeded(); }\n') 1082 # -- er, it turned out that the problem was likely -dst on SourceSite. Consequently we could try returning to static initializers to trigger tests. 1083 sw.write('\nprivate static bool __didStartTests = false;\n') 1084 newWord = .newForSharpTest 1085 sw.write('\npublic static[newWord] void RunTestsIfNeeded() { if (!__didStartTests) RunTests(); }\n') 1086 sw.write('\npublic static[newWord] void RunTests()') 1087 sw.writeAndIndent(' {\n') 1088 sw.write('__didStartTests = true;\n') 1089 sw.write('CobraLangInternal.CobraImp.TestBegan("[.name]");\n') 1090 if _testMethod 1091 sw.write('[_testMethod.sharpName]();\n') 1092 for decl in _declsInOrder 1093 decl.writeSharpTestInvocation(sw) 1094 sw.write('CobraLangInternal.CobraImp.TestEnded("[.name]");\n') 1095 sw.dedentAndWrite('}\n') 1096 1097 var _didWriteSharpTestInvocation = false 1081 pass 1098 1082 1099 1083 def writeSharpTestInvocation(sw as CurlyWriter) is override 1100 # used by the test option 1101 if _didWriteSharpTestInvocation 1102 return 1103 if .isExtern 1104 return 1105 if .isGenericDef # sorry, but static methods always require a type arg even if you don't need it. workaround. make another class with a 'test' section that tests the generic class TODO: make Cobra do this, but then watch for use of the generic param! 1106 return 1107 #assert .parentNameSpace # suppress for nested classes 1108 sw.write('\t\t[.sharpRef].RunTestsIfNeeded();\n') 1109 _didWriteSharpTestInvocation = true 1084 pass 1110 1085 1111 1086 get newForSharpTest as String … … 2824 2799 sw.write('try') 2825 2800 _tryBlock.writeSharpDef(sw, false) 2826 # delme sw.write('[helperName] = true;\n')2827 2801 sw.dedent 2828 2802 sw.write('}\n')



