Created
August 5, 2011 06:31
-
-
Save Ziaw/1127024 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Nemerle; | |
using Nemerle.Collections; | |
using Nemerle.Compiler; | |
using Nemerle.Compiler.Parsetree; | |
using Nemerle.Text; | |
using Nemerle.Utility; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace NUnitDSL | |
{ | |
[Nemerle.MacroUsage(Nemerle.MacroPhase.BeforeInheritance, | |
Nemerle.MacroTargets.Method)] | |
public macro TestCase(type_builder : TypeBuilder, _method : ParsedMethod, token : Token) | |
syntax("testcase", token) | |
{ | |
TestCaseImpl.TestCase(type_builder, token); | |
} | |
module TestCaseImpl | |
{ | |
public TestCase(tb : TypeBuilder, token : Token) : void | |
{ | |
def (name, body) = match (token.NToList()) | |
{ | |
| [name, body] => (name.ToString(), body); | |
| _ => Message.FatalError("invalid syntax"); | |
} | |
def (bodyExpr, _) = MainParser.ParseExpr(tb.GlobalEnv, Token.LooseGroup(body.Location, body)); | |
def bodyExpr = Util.locate(body.Location, <[ $bodyExpr ]>); | |
Util.locate(token.Location, tb.Define(<[decl: public $(name : usesite)() : void { $bodyExpr }]>)); | |
tb.Compile(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test | |
{ | |
testcase Test | |
{ | |
Console.WriteLine("1"); | |
Console.WriteLine("1"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment