Created
January 9, 2019 15:29
-
-
Save atilaneves/016c946a7c9064a9d3922be7fef48aa7 to your computer and use it in GitHub Desktop.
Manual contract test
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
// This is only here to write a blog about it later | |
@("struct.onefield.int.manual") | |
@MockTU!( | |
{ | |
import clang; | |
return MockCursor( | |
Cursor.Kind.TranslationUnit, | |
"", | |
MockType(), | |
[ | |
MockCursor(Cursor.Kind.StructDecl, | |
"Foo", | |
MockType(Type.Kind.Record, | |
"struct Foo"), | |
[ | |
MockCursor(Cursor.Kind.FieldDecl, | |
"i", | |
MockType(Type.Kind.Int, | |
"int")), | |
], | |
), | |
], | |
); | |
} | |
) | |
@Types!(Cursor, MockCursor) | |
void testStructOneFieldInt(T)() { | |
mixin createTU!(T, "it.c.compile.struct_", "onefield.int"); | |
tu.children.length.should == 1; | |
const struct_ = tu.children[0]; | |
struct_.kind.should == Cursor.Kind.StructDecl; | |
struct_.spelling.should == "Foo"; | |
struct_.type.kind.should == Type.Kind.Record; | |
struct_.type.spelling.should == "struct Foo"; | |
printChildren(struct_); | |
struct_.children.length.should == 1; | |
const member = struct_.children[0]; | |
member.kind.should == Cursor.Kind.FieldDecl; | |
member.spelling.should == "i"; | |
member.type.kind.should == Type.Kind.Int; | |
member.type.spelling.should == "int"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment