Changeset 2291
- Timestamp:
- 02/27/10 09:18:29 (2 years ago)
- Location:
- cobra/trunk
- Files:
-
- 7 modified
-
Source/BackEndClr/SharpGenerator.cobra (modified) (8 diffs)
-
Source/Cobra.Lang/CobraCore.cobra (modified) (1 diff)
-
Source/CommandLine.cobra (modified) (1 diff)
-
Source/Phases/BindRunTimeLibraryPhase.cobra (modified) (1 diff)
-
Tests/120-classes/920-type-decl-clauses.cobra (modified) (3 diffs)
-
Tests/140-structs/300-type-decl-clauses.cobra (modified) (4 diffs)
-
Tests/320-misc-two/250-qualified/200-qual-generic.cobra (modified) (1 diff)
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') -
cobra/trunk/Source/Cobra.Lang/CobraCore.cobra
r2229 r2291 138 138 Run all Cobra `test` sections in all assemblies using reflection to locate them. 139 139 """ 140 # start = DateTime.now 141 _runAllTests(Assembly.getEntryAssembly, Dictionary<of String, String>()) 142 # duration = DateTime.now.subtract(start) 143 # trace duration 144 145 def _runAllTests(ass as Assembly, found as Dictionary<of String, String>) # CC: found should be Set<of String> 146 name = ass.getName.toString 147 if found.containsKey(name) 148 return 149 found.add(name, name) 150 if _skipAssemblyNameForTesting(name) # saves some time 151 return 152 153 # print 'Testing assembly:', ass 154 for type in ass.getExportedTypes 155 members = type.getMember('RunTestsIfNeeded') 156 if members and members.length and members[0] inherits MethodInfo 157 method = members[0] to MethodInfo 158 # trace type, method 159 if type.containsGenericParameters 160 # TODO: this is quite awful. tests in generic types are being skipped! 161 # potential solution 1: move type test out of the type into a "sister" type: private __FooTest 162 # potential solution 2: require a constructed type in Cobra: `test Foo<of int> ...` and then put that in a method attribute in the gen C# and use that type 163 continue 164 method.invoke(type, nil) 165 166 # traverse further assemblies 167 for assName in ass.getReferencedAssemblies 168 subAss = Assembly.load(assName) 169 _runAllTests(subAss to !, found) 140 # listener = Cobra.Lang.Test.TextWriterListener(Console.out) 141 listener = Cobra.Lang.Test.TextWriterOnlyOnFailureListener(Console.out) 142 tr = Cobra.Lang.Test.TestRunner(listener) 143 tr.runAllTests 170 144 171 145 var _skipPrefixes = @['System.', 'Mono.', 'mscorlib,', 'System,'] -
cobra/trunk/Source/CommandLine.cobra
r2275 r2291 714 714 print 'Not running tests due to errors above.' 715 715 return 716 testInvoker = c.modules [c.modules.count-1] # CC:.last716 testInvoker = c.modules.last 717 717 assert testInvoker inherits NativeModule 718 718 assert testInvoker.fileName.startsWith('test-') -
cobra/trunk/Source/Phases/BindRunTimeLibraryPhase.cobra
r2101 r2291 32 32 c = .compiler 33 33 pathsToCompile = c.pathsToCompile 34 runTimePaths = c.commandLineArgParser.readFilesFile(Path.combine(Path.combine(.cobraExeDir, 'Cobra.Lang'), 'files.text')) 34 filesPath = Path.combine(Path.combine(.cobraExeDir, 'Cobra.Lang'), 'files.text') 35 runTimePaths = c.commandLineArgParser.readFilesFile(filesPath) 35 36 runTimePaths.reverse 36 37 for runTimePath in runTimePaths -
cobra/trunk/Tests/120-classes/920-type-decl-clauses.cobra
r1944 r2291 4 4 use System.Collections 5 5 6 class TestAttribute inherits Attribute6 class FooAttribute inherits Attribute 7 7 pass 8 8 9 class Test2Attribute inherits Attribute9 class Foo2Attribute inherits Attribute 10 10 pass 11 11 … … 42 42 pass 43 43 44 class H inherits Object implements IDisposable has Test44 class H inherits Object implements IDisposable has Foo 45 45 def dispose 46 46 pass 47 47 48 class I inherits Object implements IDisposable has Testis public48 class I inherits Object implements IDisposable has Foo is public 49 49 def dispose 50 50 pass 51 51 52 class J inherits Object implements IDisposable, IEnumerable has Test, Test2 is public52 class J inherits Object implements IDisposable, IEnumerable has Foo, Foo2 is public 53 53 def dispose 54 54 pass … … 59 59 inherits Object 60 60 implements IDisposable 61 has Test61 has Foo 62 62 is public 63 63 def dispose -
cobra/trunk/Tests/140-structs/300-type-decl-clauses.cobra
r1946 r2291 4 4 use System.Collections 5 5 6 class TestAttribute inherits Attribute6 class FooAttribute inherits Attribute 7 7 pass 8 8 9 class Test2Attribute inherits Attribute9 class Foo2Attribute inherits Attribute 10 10 pass 11 11 … … 18 18 pass 19 19 20 struct C has Testis internal20 struct C has Foo is internal 21 21 22 22 pass 23 23 24 struct D is internal has Test24 struct D is internal has Foo 25 25 pass 26 26 27 27 struct E is internal 28 28 29 has Test29 has Foo 30 30 31 31 pass … … 34 34 35 35 36 has Test36 has Foo 37 37 pass 38 38 39 struct G is internal implements IDisposable has Test39 struct G is internal implements IDisposable has Foo 40 40 def dispose 41 41 pass 42 42 43 struct H implements IDisposable, IEnumerable has Test, Test2 is public43 struct H implements IDisposable, IEnumerable has Foo, Foo2 is public 44 44 def dispose 45 45 pass … … 49 49 struct I 50 50 implements IDisposable 51 has Test51 has Foo 52 52 is public 53 53 def dispose -
cobra/trunk/Tests/320-misc-two/250-qualified/200-qual-generic.cobra
r1224 r2291 3 3 class Referer 4 4 5 def stuff as A.B.C.Container<of String> # dotted generic name use to confound compiler5 def stuff as A.B.C.Container<of String> # dotted generic name used to confound compiler 6 6 return nil to passthrough 7 7



