public void FunctionSymbolCreate_Success(string cSharpFilePath) { workSpace.InitOrUpdateParserTreeOfFile(cSharpFilePath, GetFileContent(cSharpFilePath)); workSpace.RunDefinedPhraseAllfile(); GetFunctionIdentityVisitor visitor = new GetFunctionIdentityVisitor(); visitor.Visit(workSpace._parserRuleContextOfFile[cSharpFilePath]); var functionIdentify = visitor.FunctionIdentifier; //symbol and scope is exactly typed Assert.IsInstanceOf(typeof(FunctionSymbol), functionIdentify.Symbol); Assert.IsInstanceOf(typeof(FunctionSymbol), functionIdentify.Scope); //check property of symbol var symbol = functionIdentify.Symbol as FunctionSymbol; Assert.AreEqual(functionIdentify.GetText(), symbol.GetName()); Assert.AreSame(functionIdentify, symbol.DefNode); //symbol exists in parent scope Assert.AreSame(symbol, symbol.Resolve(symbol.GetName())); Assert.AreEqual("global.TestBuildArchitecture.DataTest.Test.Plus", symbol.GetFullyQualifiedName(".")); }
public void SetTypeForFunction_BuiltInType_Success() { string file = @"C:\Users\ACER\Desktop\luanvan\started\TestBuildArchitecture\DataTest\SetTypeForFunction_BuiltInType_Success.cs"; workSpace.InitOrUpdateParserTreeOfFile(file, GetFileContent(file)); workSpace.RunDefinedPhraseAllfile(); workSpace.RunResolvePhraseAllFile(); GetFunctionIdentityVisitor visitor = new GetFunctionIdentityVisitor(); visitor.Visit(workSpace._parserRuleContextOfFile[file]); var function = visitor.FunctionIdentifier; var symbol = function.Symbol as FunctionSymbol; Assert.AreEqual("Test", symbol.GetName()); Assert.AreEqual("int", symbol.GetSymbolType().GetName()); }