diff --git a/src/Engine/ProtoAssociative/CodeGen.cs b/src/Engine/ProtoAssociative/CodeGen.cs index 527f9270469..37b49051a23 100644 --- a/src/Engine/ProtoAssociative/CodeGen.cs +++ b/src/Engine/ProtoAssociative/CodeGen.cs @@ -598,9 +598,6 @@ private void EmitAllocc(int type) ++pc; codeBlock.instrStream.instrList.Add(instr); - - // TODO: Figure out why using AppendInstruction fails for adding these instructions to ExpressionInterpreter - //AppendInstruction(instr); } protected override void EmitRetb( int line = ProtoCore.DSASM.Constants.kInvalidIndex, int col = ProtoCore.DSASM.Constants.kInvalidIndex, @@ -612,8 +609,7 @@ protected override void EmitRetb( int line = ProtoCore.DSASM.Constants.kInvalidI AuditReturnLocation(ref line, ref col, ref endline, ref endcol); ++pc; - instr.debug = GetDebugObject(line, col, endline, endcol, ProtoCore.DSASM.Constants.kInvalidIndex); - + codeBlock.instrStream.instrList.Add(instr); updatePcDictionary(line, col); } @@ -628,8 +624,6 @@ protected override void EmitRetcn(int blockId = Constants.kInvalidIndex, int lin AuditReturnLocation(ref line, ref col, ref endline, ref endcol); ++pc; - instr.debug = GetDebugObject(line, col, endline, endcol, ProtoCore.DSASM.Constants.kInvalidIndex); - codeBlock.instrStream.instrList.Add(instr); updatePcDictionary(line, col); } @@ -643,7 +637,6 @@ protected override void EmitReturn(int line = ProtoCore.DSASM.Constants.kInvalid AuditReturnLocation(ref line, ref col, ref endline, ref endcol); ++pc; - instr.debug = GetDebugObject(line, col, endline, endcol, ProtoCore.DSASM.Constants.kInvalidIndex); codeBlock.instrStream.instrList.Add(instr); updatePcDictionary(line, col); } @@ -733,14 +726,6 @@ private void EmitFunctionCall(int depth, Constants.kInvalidIndex, Constants.kInvalidIndex, procNode.PC); } - // Break at function call inside dynamic lang block created for a 'true' or 'false' expression inside an inline conditional - else if (core.DebuggerProperties.breakOptions.HasFlag(DebugProperties.BreakpointOptions.EmitInlineConditionalBreakpoint)) - { - ProtoCore.CodeModel.CodePoint startInclusive = core.DebuggerProperties.highlightRange.StartInclusive; - ProtoCore.CodeModel.CodePoint endExclusive = core.DebuggerProperties.highlightRange.EndExclusive; - - EmitCall(procNode.ID, blockId, type, startInclusive.LineNo, startInclusive.CharNo, endExclusive.LineNo, endExclusive.CharNo, procNode.PC); - } else if (parentExpression != null) { EmitCall(procNode.ID, blockId, type, parentExpression.line, parentExpression.col, parentExpression.endLine, parentExpression.endCol, procNode.PC); @@ -1739,23 +1724,6 @@ public override ProcedureNode TraverseFunctionCall( Constants.kInvalidIndex, procNode.PC); } - // Break at function call inside dynamic lang block created for a 'true' or 'false' expression inside an inline conditional - else if (core.DebuggerProperties.breakOptions.HasFlag(DebugProperties.BreakpointOptions.EmitInlineConditionalBreakpoint)) - { - var codeRange = core.DebuggerProperties.highlightRange; - - var startInclusive = codeRange.StartInclusive; - var endExclusive = codeRange.EndExclusive; - - EmitCall(procNode.ID, - blockId, - type, - startInclusive.LineNo, - startInclusive.CharNo, - endExclusive.LineNo, - endExclusive.CharNo, - procNode.PC); - } // Use startCol and endCol of binary expression node containing function call except if it's a setter else if (bnode != null && !procNode.Name.StartsWith(Constants.kSetterPrefix)) { @@ -2043,48 +2011,6 @@ private bool AuditReturnLocation(ref int line, ref int col, ref int endLine, ref return false; } - private int EmitExpressionInterpreter(ProtoCore.AST.Node codeBlockNode) - { - core.watchStartPC = this.pc; - compilePass = ProtoCore.CompilerDefinitions.CompilePass.GlobalScope; - ProtoCore.AST.AssociativeAST.CodeBlockNode codeblock = codeBlockNode as ProtoCore.AST.AssociativeAST.CodeBlockNode; - - ProtoCore.Type inferedType = new ProtoCore.Type(); - - globalClassIndex = ProtoCore.DSASM.Constants.kInvalidIndex; - globalProcIndex = ProtoCore.DSASM.Constants.kGlobalScope; - - // check if currently inside a function when the break was called - if (context.DebugProps.DebugStackFrameContains(DebugProperties.StackFrameFlagOptions.FepRun)) - { - // Save the current scope for the expression interpreter - globalClassIndex = context.WatchClassScope = context.MemoryState.CurrentStackFrameClassScope; - globalProcIndex = core.watchFunctionScope = context.MemoryState.CurrentStackFrameFunctionScope; - int functionBlock = context.MemoryState.CurrentStackFrameFunctionBlock; - - if (globalClassIndex != -1) - localProcedure = core.ClassTable.ClassNodes[globalClassIndex].ProcTable.Procedures[globalProcIndex]; - else - { - // TODO: to investigate whethter to use the table under executable or in core.FuncTable - Randy, Jun - localProcedure = core.DSExecutable.procedureTable[functionBlock].Procedures[globalProcIndex]; - } - } - - foreach (AssociativeNode node in codeblock.Body) - { - inferedType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.Var, 0); - - DfsTraverse(node, ref inferedType, false, null, ProtoCore.CompilerDefinitions.SubCompilePass.UnboundIdentifier); - } - - core.InferedType = inferedType; - - this.pc = core.watchStartPC; - - return codeBlock.codeBlockId; - } - private void AllocateContextGlobals() { if (null != context && null != context.GlobalVarList && context.GlobalVarList.Count > 0) @@ -2110,12 +2036,6 @@ public override int Emit(ProtoCore.AST.Node codeBlockNode, ProtoCore.Associative AllocateContextGlobals(); - core.watchStartPC = this.pc; - if (core.Options.RunMode == ProtoCore.DSASM.InterpreterMode.Expression) - { - return EmitExpressionInterpreter(codeBlockNode); - } - this.localCodeBlockNode = codeBlockNode; ProtoCore.AST.AssociativeAST.CodeBlockNode codeblock = codeBlockNode as ProtoCore.AST.AssociativeAST.CodeBlockNode; bool isTopBlock = null == codeBlock.parent; @@ -2293,48 +2213,46 @@ private void EmitIdentifierNode(AssociativeNode node, ref ProtoCore.Type infered { // The variable is unbound ProtoCore.DSASM.SymbolNode unboundVariable = null; - if (ProtoCore.DSASM.InterpreterMode.Expression != core.Options.RunMode) - { - inferedType.UID = (int)ProtoCore.PrimitiveType.Null; - // Jun Comment: Specification - // If resolution fails at this point a com.Design-Script.Imperative.Core.UnboundIdentifier - // warning is emitted during pre-execute phase, and at the ID is bound to null. (R1 - Feb) + inferedType.UID = (int)ProtoCore.PrimitiveType.Null; - // Set the first symbol that triggers the cycle to null - ProtoCore.AssociativeGraph.GraphNode nullAssignGraphNode = new ProtoCore.AssociativeGraph.GraphNode(); - nullAssignGraphNode.updateBlock.startpc = pc; + // Jun Comment: Specification + // If resolution fails at this point a com.Design-Script.Imperative.Core.UnboundIdentifier + // warning is emitted during pre-execute phase, and at the ID is bound to null. (R1 - Feb) - EmitPushNull(); + // Set the first symbol that triggers the cycle to null + ProtoCore.AssociativeGraph.GraphNode nullAssignGraphNode = new ProtoCore.AssociativeGraph.GraphNode(); + nullAssignGraphNode.updateBlock.startpc = pc; - // Push the identifier local block - ProtoCore.Type varType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.Var, 0); + EmitPushNull(); - // TODO Jun: Refactor Allocate() to just return the symbol node itself - unboundVariable = Allocate(globalClassIndex, globalClassIndex, globalProcIndex, t.Value, varType, line: t.line, col: t.col); - Validity.Assert(unboundVariable != null); + // Push the identifier local block + ProtoCore.Type varType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.Var, 0); - int symbolindex = unboundVariable.symbolTableIndex; - if (ProtoCore.DSASM.Constants.kInvalidIndex != globalClassIndex) - { - symbolnode = core.ClassTable.ClassNodes[globalClassIndex].Symbols.symbolList[symbolindex]; - } - else - { - symbolnode = codeBlock.symbolTable.symbolList[symbolindex]; - } + // TODO Jun: Refactor Allocate() to just return the symbol node itself + unboundVariable = Allocate(globalClassIndex, globalClassIndex, globalProcIndex, t.Value, varType, line: t.line, col: t.col); + Validity.Assert(unboundVariable != null); + + int symbolindex = unboundVariable.symbolTableIndex; + if (ProtoCore.DSASM.Constants.kInvalidIndex != globalClassIndex) + { + symbolnode = core.ClassTable.ClassNodes[globalClassIndex].Symbols.symbolList[symbolindex]; + } + else + { + symbolnode = codeBlock.symbolTable.symbolList[symbolindex]; + } - EmitInstrConsole(kw.pop, t.Value); - EmitPopForSymbol(unboundVariable, runtimeIndex); + EmitInstrConsole(kw.pop, t.Value); + EmitPopForSymbol(unboundVariable, runtimeIndex); - nullAssignGraphNode.PushSymbolReference(symbolnode); - nullAssignGraphNode.procIndex = globalProcIndex; - nullAssignGraphNode.classIndex = globalClassIndex; - nullAssignGraphNode.updateBlock.endpc = pc - 1; + nullAssignGraphNode.PushSymbolReference(symbolnode); + nullAssignGraphNode.procIndex = globalProcIndex; + nullAssignGraphNode.classIndex = globalClassIndex; + nullAssignGraphNode.updateBlock.endpc = pc - 1; - PushGraphNode(nullAssignGraphNode); - EmitDependency(ProtoCore.DSASM.Constants.kInvalidIndex, false); - } + PushGraphNode(nullAssignGraphNode); + EmitDependency(ProtoCore.DSASM.Constants.kInvalidIndex, false); if (isAllocated) { @@ -2377,17 +2295,6 @@ private void EmitIdentifierNode(AssociativeNode node, ref ProtoCore.Type infered } else { - if (core.Options.RunMode == ProtoCore.DSASM.InterpreterMode.Expression && - !isAllocated) - { - // It happens when the debugger try to watch a variable - // which has been out of scope (as watch is done through - // execute an expression "t = v;" where v is the variable - // to be watched. - EmitPushNull(); - return; - } - Validity.Assert(isAllocated); if (graphNode != null @@ -2482,16 +2389,10 @@ private void EmitIdentifierNode(AssociativeNode node, ref ProtoCore.Type infered context.DependentVariablesInScope.Add(dependendNode); } - if (ProtoCore.DSASM.InterpreterMode.Expression == core.Options.RunMode) - { - EmitInstrConsole(ProtoCore.DSASM.kw.pushw, t.Value); - EmitPushForSymbolW(symbolnode, runtimeIndex, t.line, t.col); - } - else - { - EmitInstrConsole(kw.push, t.Value); - EmitPushForSymbol(symbolnode, runtimeIndex, t); - } + + EmitInstrConsole(kw.push, t.Value); + EmitPushForSymbol(symbolnode, runtimeIndex, t); + bool emitReplicationGuideFlag = emitReplicationGuide; emitReplicationGuide = false; @@ -2512,20 +2413,16 @@ private void EmitIdentifierNode(AssociativeNode node, ref ProtoCore.Type infered } } - - if (ProtoCore.DSASM.InterpreterMode.Expression != core.Options.RunMode) + if (dimensions > 0) { - if (dimensions > 0) - { - EmitPushDimensions(dimensions); - EmitLoadElement(symbolnode, runtimeIndex); - } + EmitPushDimensions(dimensions); + EmitLoadElement(symbolnode, runtimeIndex); + } - if (emitReplicationGuide) - { - EmitAtLevel(t.AtLevel); - EmitReplicationGuides(t.ReplicationGuides); - } + if (emitReplicationGuide) + { + EmitAtLevel(t.AtLevel); + EmitReplicationGuides(t.ReplicationGuides); } if (core.TypeSystem.IsHigherRank(type.UID, inferedType.UID)) @@ -3497,9 +3394,6 @@ private void EmitConstructorDefinitionNode(AssociativeNode node, ref ProtoCore.T ProtoCore.FunctionEndPoint fep = null; if (!funcDef.IsExternLib) { - // Traverse default assignment for the class - emitDebugInfo = false; - //Traverse default argument for the constructor foreach (ProtoCore.DSASM.ArgumentInfo argNode in localProcedure.ArgumentInfos) { @@ -3528,7 +3422,6 @@ private void EmitConstructorDefinitionNode(AssociativeNode node, ref ProtoCore.T bNodeTemp.RightNode = icNode; EmitBinaryExpressionNode(bNodeTemp, ref inferedType); } - emitDebugInfo = true; EmitCodeBlock(funcDef.FunctionBody.Body, ref inferedType, subPass, true); @@ -3829,8 +3722,6 @@ private void EmitFunctionDefinitionNode(AssociativeNode node, ref ProtoCore.Type ProtoCore.FunctionEndPoint fep = null; if (!funcDef.IsExternLib) { - //Traverse default argument - emitDebugInfo = false; foreach (ProtoCore.DSASM.ArgumentInfo argNode in localProcedure.ArgumentInfos) { if (!argNode.IsDefault) @@ -3856,7 +3747,6 @@ private void EmitFunctionDefinitionNode(AssociativeNode node, ref ProtoCore.Type bNodeTemp.RightNode = icNode; EmitBinaryExpressionNode(bNodeTemp, ref inferedType, false, null, ProtoCore.CompilerDefinitions.SubCompilePass.UnboundIdentifier); } - emitDebugInfo = true; EmitCompileLogFunctionStart(GetFunctionSignatureString(funcDef.Name, funcDef.ReturnType, funcDef.Signature)); @@ -4208,26 +4098,6 @@ private void EmitInlineConditionalNode(AssociativeNode node, ref ProtoCore.Type identNode.Name = ProtoCore.DSASM.Constants.kInlineConditionalMethodName; inlineCall.Function = identNode; - DebugProperties.BreakpointOptions oldOptions = core.DebuggerProperties.breakOptions; - DebugProperties.BreakpointOptions newOptions = oldOptions; - newOptions |= DebugProperties.BreakpointOptions.EmitInlineConditionalBreakpoint; - core.DebuggerProperties.breakOptions = newOptions; - - core.DebuggerProperties.highlightRange = new ProtoCore.CodeModel.CodeRange - { - StartInclusive = new ProtoCore.CodeModel.CodePoint - { - LineNo = parentNode.line, - CharNo = parentNode.col - }, - - EndExclusive = new ProtoCore.CodeModel.CodePoint - { - LineNo = parentNode.endLine, - CharNo = parentNode.endCol - } - }; - // As SSA conversion is enabled, we have got the values of // true and false branch, so it isn't necessary to create // language blocks. @@ -4285,22 +4155,6 @@ private void EmitInlineConditionalNode(AssociativeNode node, ref ProtoCore.Type inlineCall.FormalArguments.Add(dynBlockF); } - core.DebuggerProperties.breakOptions = oldOptions; - core.DebuggerProperties.highlightRange = new ProtoCore.CodeModel.CodeRange - { - StartInclusive = new ProtoCore.CodeModel.CodePoint - { - LineNo = Constants.kInvalidIndex, - CharNo = Constants.kInvalidIndex - }, - - EndExclusive = new ProtoCore.CodeModel.CodePoint - { - LineNo = Constants.kInvalidIndex, - CharNo = Constants.kInvalidIndex - } - }; - // Save the pc and store it after the call EmitFunctionCallNode(inlineCall, ref inferedType, false, graphNode, ProtoCore.CompilerDefinitions.SubCompilePass.UnboundIdentifier); @@ -4960,8 +4814,6 @@ private void EmitBinaryExpressionNode(AssociativeNode node, ref ProtoCore.Type i ProtoCore.Type leftType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.Var, 0); ProtoCore.Type rightType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.Var, 0); - DebugProperties.BreakpointOptions oldOptions = core.DebuggerProperties.breakOptions; - // If this is an assignment statement, setup the top level graph node bool isGraphInScope = false; if (ProtoCore.DSASM.Operator.assign == bnode.Optr) @@ -5071,11 +4923,6 @@ private void EmitBinaryExpressionNode(AssociativeNode node, ref ProtoCore.Type i DfsTraverse(bnode.LeftNode, ref inferedType, isBooleanOperation, graphNode, subPass); - if (inferedType.UID == (int)PrimitiveType.FunctionPointer && subPass != ProtoCore.CompilerDefinitions.SubCompilePass.UnboundIdentifier && emitDebugInfo) - { - buildStatus.LogSemanticError(Resources.FunctionPointerNotAllowedAtBinaryExpression, core.CurrentDSFileName, bnode.LeftNode.line, bnode.LeftNode.col); - } - leftType.UID = inferedType.UID; leftType.rank = inferedType.rank; } @@ -5094,10 +4941,6 @@ private void EmitBinaryExpressionNode(AssociativeNode node, ref ProtoCore.Type i if (bnode.RightNode == null && bnode.Optr == Operator.assign && bnode.LeftNode is IdentifierNode) { - DebugProperties.BreakpointOptions newOptions = oldOptions; - newOptions |= DebugProperties.BreakpointOptions.SuppressNullVarDeclarationBreakpoint; - core.DebuggerProperties.breakOptions = newOptions; - IdentifierNode t = bnode.LeftNode as IdentifierNode; ProtoCore.DSASM.SymbolNode symbolnode = null; bool isAccessible = false; @@ -5138,10 +4981,6 @@ private void EmitBinaryExpressionNode(AssociativeNode node, ref ProtoCore.Type i return; } - if (inferedType.UID == (int)PrimitiveType.FunctionPointer && emitDebugInfo) - { - buildStatus.LogSemanticError(Resources.FunctionPointerNotAllowedAtBinaryExpression, core.CurrentDSFileName, bnode.RightNode.line, bnode.RightNode.col); - } EmitBinaryOperation(leftType, rightType, bnode.Optr); isBooleanOp = false; @@ -5210,10 +5049,6 @@ private void EmitBinaryExpressionNode(AssociativeNode node, ref ProtoCore.Type i bool isAccessibleFp; int realType; var procNode = core.ClassTable.ClassNodes[globalClassIndex].GetMemberFunction(t.Name, null, globalClassIndex, out isAccessibleFp, out realType); - if (procNode != null && procNode.ID != Constants.kInvalidIndex && emitDebugInfo) - { - buildStatus.LogSemanticError(String.Format(Resources.FunctionAsVariableError, t.Name), core.CurrentDSFileName, t.line, t.col); - } } //int type = (int)ProtoCore.PrimitiveType.kTypeVoid; @@ -5294,11 +5129,6 @@ private void EmitBinaryExpressionNode(AssociativeNode node, ref ProtoCore.Type i if (!isAllocated || !isAccessible) { symbolnode = Allocate(globalClassIndex, globalClassIndex, globalProcIndex, t.Name, inferedType, line: bnode.line, col: bnode.col); - // Add the symbols during watching process to the watch symbol list. - if (core.Options.RunMode == ProtoCore.DSASM.InterpreterMode.Expression) - { - core.watchSymbolList.Add(symbolnode); - } Validity.Assert(symbolnode != null); } @@ -5329,24 +5159,16 @@ private void EmitBinaryExpressionNode(AssociativeNode node, ref ProtoCore.Type i } else { - if (core.Options.RunMode != ProtoCore.DSASM.InterpreterMode.Expression) + if (dimensions == 0) { - if (dimensions == 0) - { - EmitInstrConsole(kw.pop, t.Value); - EmitPopForSymbol(symbolnode, runtimeIndex, node.line, node.col, node.endLine, node.endCol); - } - else - { - EmitPushDimensions(dimensions); - EmitInstrConsole(kw.setelement, t.Value); - EmitSetElement(symbolnode, runtimeIndex); - } + EmitInstrConsole(kw.pop, t.Value); + EmitPopForSymbol(symbolnode, runtimeIndex, node.line, node.col, node.endLine, node.endCol); } else { - EmitInstrConsole(ProtoCore.DSASM.kw.popw, t.Name); - EmitPopForSymbolW(symbolnode, runtimeIndex, node.line, node.col, node.endLine, node.endCol); + EmitPushDimensions(dimensions); + EmitInstrConsole(kw.setelement, t.Value); + EmitSetElement(symbolnode, runtimeIndex); } } } @@ -5392,11 +5214,6 @@ private void EmitBinaryExpressionNode(AssociativeNode node, ref ProtoCore.Type i symbolnode = Allocate(globalClassIndex, globalClassIndex, globalProcIndex, t.Name, inferedType, line: bnode.line, col: bnode.col); - if (core.Options.RunMode == ProtoCore.DSASM.InterpreterMode.Expression) - { - core.watchSymbolList.Add(symbolnode); - } - if (dimensions > 0) { symbolnode.datatype.rank = dimensions; @@ -5437,24 +5254,17 @@ private void EmitBinaryExpressionNode(AssociativeNode node, ref ProtoCore.Type i EmitPushUpdateInstruction(regLX, bnode.OriginalAstID); } - if (core.Options.RunMode != ProtoCore.DSASM.InterpreterMode.Expression) + + if (dimensions == 0) { - if (dimensions == 0) - { - EmitInstrConsole(kw.pop, symbolnode.name); - EmitPopForSymbol(symbolnode, runtimeIndex, node.line, node.col, node.endLine, node.endCol); - } - else - { - EmitPushDimensions(dimensions); - EmitInstrConsole(kw.setelement, t.Value); - EmitSetElement(symbolnode, runtimeIndex); - } + EmitInstrConsole(kw.pop, symbolnode.name); + EmitPopForSymbol(symbolnode, runtimeIndex, node.line, node.col, node.endLine, node.endCol); } else { - EmitInstrConsole(ProtoCore.DSASM.kw.popw, symbolnode.name); - EmitPopForSymbolW(symbolnode, runtimeIndex, node.line, node.col, node.endLine, node.endCol); + EmitPushDimensions(dimensions); + EmitInstrConsole(kw.setelement, t.Value); + EmitSetElement(symbolnode, runtimeIndex); } AutoGenerateUpdateReference(bnode.LeftNode, graphNode); @@ -5575,7 +5385,6 @@ private void EmitBinaryExpressionNode(AssociativeNode node, ref ProtoCore.Type i buildStatus.LogSemanticError(message, core.CurrentDSFileName, bnode.line, bnode.col); throw new BuildHaltException(message); } - core.DebuggerProperties.breakOptions = oldOptions; } private void EmitImportNode(AssociativeNode node, ref ProtoCore.Type inferedType, ProtoCore.CompilerDefinitions.SubCompilePass subPass = ProtoCore.CompilerDefinitions.SubCompilePass.None) diff --git a/src/Engine/ProtoAssociative/Compiler.cs b/src/Engine/ProtoAssociative/Compiler.cs index 5365f20a703..d3ef1aaef3f 100644 --- a/src/Engine/ProtoAssociative/Compiler.cs +++ b/src/Engine/ProtoAssociative/Compiler.cs @@ -27,24 +27,21 @@ public override bool Compile(out int blockId, ProtoCore.DSASM.CodeBlock parentBl { ProtoCore.CodeGen oldCodegen = core.assocCodegen; - if (ProtoCore.DSASM.InterpreterMode.Normal == core.Options.RunMode) + if ((core.IsParsingPreloadedAssembly || core.IsParsingCodeBlockNode) && parentBlock == null) { - if ((core.IsParsingPreloadedAssembly || core.IsParsingCodeBlockNode) && parentBlock == null) + if (core.CodeBlockList.Count == 0) { - if (core.CodeBlockList.Count == 0) - { - core.assocCodegen = new ProtoAssociative.CodeGen(core, callContext, parentBlock); - } - else - { - // We reuse the existing toplevel CodeBlockList's for the procedureTable's - // by calling this overloaded constructor - pratapa - core.assocCodegen = new ProtoAssociative.CodeGen(core); - } + core.assocCodegen = new ProtoAssociative.CodeGen(core, callContext, parentBlock); } else - core.assocCodegen = new ProtoAssociative.CodeGen(core, callContext, parentBlock); + { + // We reuse the existing toplevel CodeBlockList's for the procedureTable's + // by calling this overloaded constructor - pratapa + core.assocCodegen = new ProtoAssociative.CodeGen(core); + } } + else + core.assocCodegen = new ProtoAssociative.CodeGen(core, callContext, parentBlock); if (null != core.AssocNode) { @@ -76,31 +73,12 @@ public override bool Compile(out int blockId, ProtoCore.DSASM.CodeBlock parentBl } core.assocCodegen.context = callContext; - - //Temporarily change the code block for code gen to the current block, in the case it is an imperative block - //CodeGen for ProtoImperative is modified to passing in the core object. - ProtoCore.DSASM.CodeBlock oldCodeBlock = core.assocCodegen.codeBlock; - if (core.Options.RunMode == ProtoCore.DSASM.InterpreterMode.Expression) - { - int tempBlockId = callContext.CurrentBlockId; - ProtoCore.DSASM.CodeBlock tempCodeBlock = ProtoCore.Utils.CoreUtils.GetCodeBlock(core.CodeBlockList, tempBlockId); - while (null != tempCodeBlock && tempCodeBlock.blockType != ProtoCore.DSASM.CodeBlockType.Language) - { - tempCodeBlock = tempCodeBlock.parent; - } - core.assocCodegen.codeBlock = tempCodeBlock; - } core.assocCodegen.codeBlock.EventSink = sink; + if (core.BuildStatus.ErrorCount == 0) //if there is syntax error, no build needed { blockId = core.assocCodegen.Emit((codeBlockNode as ProtoCore.AST.AssociativeAST.CodeBlockNode), graphNode); } - if (core.Options.RunMode == ProtoCore.DSASM.InterpreterMode.Expression) - { - blockId = core.assocCodegen.codeBlock.codeBlockId; - //Restore the code block. - core.assocCodegen.codeBlock = oldCodeBlock; - } } // @keyu: we have to restore asscoCodegen here. It may be diff --git a/src/Engine/ProtoCore/CodeGen.cs b/src/Engine/ProtoCore/CodeGen.cs index cd23f495027..4c018d07338 100644 --- a/src/Engine/ProtoCore/CodeGen.cs +++ b/src/Engine/ProtoCore/CodeGen.cs @@ -58,7 +58,6 @@ public abstract class CodeGen protected ProtoCore.DSASM.ProcedureNode localProcedure; protected ProtoCore.AST.Node localFunctionDefNode; protected ProtoCore.AST.Node localCodeBlockNode; - protected bool emitDebugInfo = true; protected List functionCallStack; protected bool IsAssociativeArrayIndexing { get; set; } @@ -197,14 +196,6 @@ protected void AllocateVar(ProtoCore.DSASM.SymbolNode symbol) protected void SetStackIndex(ProtoCore.DSASM.SymbolNode symbol) { - if (core.Options.RunMode == ProtoCore.DSASM.InterpreterMode.Expression) - { - //Set the index of the symbol relative to the watching stack - symbol.index = core.watchBaseOffset; - core.watchBaseOffset += 1; - return; - } - int langblockOffset = 0; bool isGlobal = null == localProcedure; @@ -330,27 +321,6 @@ protected string GetConstructBlockName(string construct) return blockScope.ToString() + "_" + construct + "_" + desc; } - protected ProtoCore.DSASM.DebugInfo GetDebugObject(int line, int col, int eline, int ecol, int nextStep_a, int nextStep_b = ProtoCore.DSASM.Constants.kInvalidIndex) - { - ProtoCore.DSASM.DebugInfo debug = null; - - if (core.Options.EmitBreakpoints) - { - if ( (core.Options.IDEDebugMode || core.Options.WatchTestMode || core.Options.IsDeltaExecution) - && ProtoCore.DSASM.Constants.kInvalidIndex != line - && ProtoCore.DSASM.Constants.kInvalidIndex != col) - { - debug = new ProtoCore.DSASM.DebugInfo(line, col, eline, ecol, core.CurrentDSFileName); - debug.nextStep.Add(nextStep_a); - - if (ProtoCore.DSASM.Constants.kInvalidIndex != nextStep_b) - debug.nextStep.Add(nextStep_b); - } - } - - return debug; - } - abstract protected void EmitGetterSetterForIdentList( ProtoCore.AST.Node node, ref ProtoCore.Type inferedType, @@ -969,11 +939,6 @@ protected bool VerifyAllocation(string name, int classScope, int functionScope, symbol = null; isAccessible = false; CodeBlock currentCodeBlock = codeBlock; - if (core.Options.RunMode == DSASM.InterpreterMode.Expression) - { - int tempBlockId = context.CurrentBlockId; - currentCodeBlock = ProtoCore.Utils.CoreUtils.GetCodeBlock(core.CodeBlockList, tempBlockId); - } if (classScope != Constants.kGlobalScope) { @@ -1006,17 +971,6 @@ protected bool VerifyAllocation(string name, int classScope, int functionScope, return false; } - if (core.Options.RunMode == ProtoCore.DSASM.InterpreterMode.Expression) - { - //Search local variables in the class member function first - if (functionScope != Constants.kGlobalScope) - { - symbol = core.GetFirstVisibleSymbol(name, classScope, functionScope, currentCodeBlock); - isAccessible = symbol != null; - return isAccessible; - } - } - ClassNode thisClass = core.ClassTable.ClassNodes[classScope]; bool hasThisSymbol; @@ -1147,7 +1101,6 @@ protected void EmitCall(int fi, instr.op3 = StackValue.BuildBlockIndex(blockId); ++pc; - instr.debug = GetDebugObject(line, col, endLine, endCol, entrypoint); AppendInstruction(instr); } @@ -1176,7 +1129,6 @@ protected void EmitDynamicCall(int functionIndex, int type, instr.op2 = StackValue.BuildClassIndex(type); ++pc; - instr.debug = GetDebugObject(line, col, endline, endcol, entrypoint); AppendInstruction(instr, line, col); } @@ -1190,7 +1142,6 @@ protected void EmitJmp(int L1, int line = ProtoCore.DSASM.Constants.kInvalidInde instr.op1 = StackValue.BuildLabelIndex(L1); ++pc; - instr.debug = GetDebugObject(line, col, eline, ecol, L1); AppendInstruction(instr, line, col); } @@ -1204,12 +1155,6 @@ protected void EmitCJmp(int label, int line = ProtoCore.DSASM.Constants.kInvalid instr.op1 = StackValue.BuildLabelIndex(label); ++pc; - if (core.DebuggerProperties.breakOptions.HasFlag(DebugProperties.BreakpointOptions.EmitInlineConditionalBreakpoint)) - { - instr.debug = null; - } - else - instr.debug = GetDebugObject(line, col, eline, ecol, label); AppendInstruction(instr, line, col); } @@ -1281,7 +1226,6 @@ protected void EmitPop(StackValue op, Validity.Assert(op.IsVariableIndex || op.IsMemberVariableIndex || op.IsRegister); ++pc; - instr.debug = GetDebugObject(line, col, eline, ecol, pc); AppendInstruction(instr, line, col); } @@ -1324,19 +1268,6 @@ protected void EmitSetElement(SymbolNode symbol, instr.op3 = StackValue.BuildBlockIndex(blockId); ++pc; - - bool outputBreakpoint = false; - DebugProperties.BreakpointOptions options = core.DebuggerProperties.breakOptions; - if (options.HasFlag(DebugProperties.BreakpointOptions.EmitPopForTempBreakpoint)) - outputBreakpoint = true; - - // Do not emit breakpoints for null or var type declarations - if (!core.DebuggerProperties.breakOptions.HasFlag(DebugProperties.BreakpointOptions.SuppressNullVarDeclarationBreakpoint)) - { - // Don't need no pop for temp (unless caller demands it). - if (outputBreakpoint || !symbol.name.StartsWith("%")) - instr.debug = GetDebugObject(line, col, eline, ecol, pc); - } AppendInstruction(instr, line, col); } @@ -1360,46 +1291,9 @@ protected void EmitPopForSymbol(SymbolNode symbol, instr.op3 = StackValue.BuildBlockIndex(blockId); ++pc; - - bool outputBreakpoint = false; - DebugProperties.BreakpointOptions options = core.DebuggerProperties.breakOptions; - if (options.HasFlag(DebugProperties.BreakpointOptions.EmitPopForTempBreakpoint)) - outputBreakpoint = true; - - // Do not emit breakpoints for null or var type declarations - if (!core.DebuggerProperties.breakOptions.HasFlag(DebugProperties.BreakpointOptions.SuppressNullVarDeclarationBreakpoint)) - { - // Don't need no pop for temp (unless caller demands it). - if (outputBreakpoint || !symbol.name.StartsWith("%")) - instr.debug = GetDebugObject(line, col, eline, ecol, pc); - } AppendInstruction(instr, line, col); } - protected void EmitPopForSymbolW(SymbolNode symbol, - int blockId, - int line = ProtoCore.DSASM.Constants.kInvalidIndex, - int col = ProtoCore.DSASM.Constants.kInvalidIndex, - int eline = ProtoCore.DSASM.Constants.kInvalidIndex, - int ecol = ProtoCore.DSASM.Constants.kInvalidIndex) - { - Validity.Assert(symbol != null); - if (symbol == null) - { - return; - } - - Instruction instr = new Instruction(); - instr.opCode = ProtoCore.DSASM.OpCode.POPW; - instr.op1 = BuildOperand(symbol); - instr.op2 = StackValue.BuildClassIndex(symbol.classScope); - instr.op3 = StackValue.BuildBlockIndex(blockId); - - ++pc; - - AppendInstruction(instr); - } - protected void EmitPushBlockID(int blockID) { EmitInstrConsole(ProtoCore.DSASM.kw.pushb, blockID.ToString()); @@ -1446,11 +1340,7 @@ protected void EmitPushUpdateInstruction(StackValue op, private void AppendInstruction(Instruction instr, int line = Constants.kInvalidIndex, int col = Constants.kInvalidIndex) { - if (DSASM.InterpreterMode.Expression == core.Options.RunMode) - { - core.ExprInterpreterExe.iStreamCanvas.instrList.Add(instr); - } - else if(!core.IsParsingCodeBlockNode && !core.IsParsingPreloadedAssembly) + if(!core.IsParsingCodeBlockNode && !core.IsParsingPreloadedAssembly) { codeBlock.instrStream.instrList.Add(instr); @@ -1488,31 +1378,8 @@ protected void EmitPushForSymbol(SymbolNode symbol, int blockId, ProtoCore.AST.N instr.op3 = StackValue.BuildBlockIndex(blockId); ++pc; - - DebugProperties.BreakpointOptions options = core.DebuggerProperties.breakOptions; - if (options.HasFlag(DebugProperties.BreakpointOptions.EmitIdentifierBreakpoint)) - { - instr.debug = GetDebugObject(identNode.line, identNode.col, - identNode.endLine, identNode.endCol, pc); - } - AppendInstruction(instr, identNode.line, identNode.col); } - - protected void EmitPushForSymbolW(SymbolNode symbol, int blockId, int line = ProtoCore.DSASM.Constants.kInvalidIndex, int col = ProtoCore.DSASM.Constants.kInvalidIndex) - { - SetEntry(); - Instruction instr = new Instruction(); - instr.opCode = ProtoCore.DSASM.OpCode.PUSHW; - instr.op1 = BuildOperand(symbol); - instr.op2 = StackValue.BuildClassIndex(symbol.classScope); - instr.op3 = StackValue.BuildBlockIndex(blockId); - - ++pc; - //instr.debug = GetDebugObject(line, col, pc); - AppendInstruction(instr); - } - protected void EmitPushm(StackValue op, int classIndex, int blockId, int line = ProtoCore.DSASM.Constants.kInvalidIndex, int col = ProtoCore.DSASM.Constants.kInvalidIndex, int eline = ProtoCore.DSASM.Constants.kInvalidIndex, int ecol = ProtoCore.DSASM.Constants.kInvalidIndex) @@ -1525,7 +1392,6 @@ protected void EmitPushm(StackValue op, int classIndex, int blockId, int line = instr.op3 = StackValue.BuildBlockIndex(blockId); ++pc; - instr.debug = GetDebugObject(line, col, eline, ecol, pc); AppendInstruction(instr, line, col); } @@ -1539,10 +1405,6 @@ protected void EmitSetMemElement(StackValue op, int blockId, int line = ProtoCor instr.op2 = StackValue.BuildBlockIndex(blockId); ++pc; - if (emitDebugInfo) - { - instr.debug = GetDebugObject(line, col, endline, endcol, pc); - } AppendInstruction(instr, line, col); } @@ -1556,10 +1418,6 @@ protected void EmitPopm(StackValue op, int blockId, int line = ProtoCore.DSASM.C instr.op2 = StackValue.BuildBlockIndex(blockId); ++pc; - if (emitDebugInfo) - { - instr.debug = GetDebugObject(line, col, endline, endcol, pc); - } AppendInstruction(instr, line, col); } @@ -1607,7 +1465,6 @@ protected void EmitBinary( instr.opCode = opcode; ++pc; - instr.debug = GetDebugObject(line, col, eline, ecol, pc); AppendInstruction(instr, line, col); } @@ -1619,7 +1476,6 @@ protected void EmitUnary(ProtoCore.DSASM.OpCode opcode, int line = ProtoCore.DSA instr.opCode = opcode; ++pc; - instr.debug = GetDebugObject(line, col, eline, ecol, pc); AppendInstruction(instr, line, col); } diff --git a/src/Engine/ProtoCore/Context.cs b/src/Engine/ProtoCore/Context.cs index c3642df2e54..2c3e093131d 100644 --- a/src/Engine/ProtoCore/Context.cs +++ b/src/Engine/ProtoCore/Context.cs @@ -22,8 +22,8 @@ public class Context /// /// When compiling expression interpreter code, the codegen needs a copy of certain runtime values /// - public int WatchClassScope { get; set; } - public DebugProperties DebugProps { get; private set; } + //public int WatchClassScope { get; set; } + //public DebugProperties DebugProps { get; private set; } /// /// This flag controls whether we want a full codeblock to apply SSA Transform. @@ -56,14 +56,6 @@ public void SetData(string source, Dictionary context, Dictionar applySSATransform = true; } - public void SetExprInterpreterProperties(int currentBlockID, ProtoCore.Runtime.RuntimeMemory memState, int watchScope, DebugProperties debugProps) - { - CurrentBlockId = currentBlockID; - MemoryState = memState; - WatchClassScope = watchScope; - DebugProps = debugProps; - } - public Context(string source, Dictionary context = null, Dictionary flagList = null) { GlobalVarList = context; @@ -78,4 +70,4 @@ public Context(string source, Dictionary context = null, Diction } } } -} \ No newline at end of file +} diff --git a/src/Engine/ProtoCore/Core.cs b/src/Engine/ProtoCore/Core.cs index cf561fed00d..6b81e0ca7cf 100644 --- a/src/Engine/ProtoCore/Core.cs +++ b/src/Engine/ProtoCore/Core.cs @@ -67,13 +67,10 @@ public Options() GenerateSSA = true; ExecuteSSA = true; - GCTempVarsOnDebug = true; DumpFunctionResolverLogic = false; BuildOptErrorAsWarning = false; ExecutionMode = ExecutionMode.Serial; - IDEDebugMode = false; - WatchTestMode = false; IncludeDirectories = new List(); RootModulePathName = Path.GetFullPath(@"."); staticCycleCheck = true; @@ -91,14 +88,9 @@ public Options() public bool DumpIL { get; private set; } public bool GenerateSSA { get; set; } public bool ExecuteSSA { get; set; } - public bool GCTempVarsOnDebug { get; set; } public bool Verbose { get; set; } - public bool SuppressBuildOutput { get; set; } public bool BuildOptErrorAsWarning { get; set; } - public bool IDEDebugMode { get; set; } //set to true if two way mapping b/w DesignScript and JIL code is needed - public bool WatchTestMode { get; set; } // set to true when running automation tests for expression interpreter public ExecutionMode ExecutionMode { get; set; } - public string FormatToPrintFloatingPoints { get; set; } public bool staticCycleCheck { get; set; } public bool dynamicCycleCheck { get; set; } public bool DumpFunctionResolverLogic { get; set; } @@ -106,7 +98,6 @@ public Options() public bool SuppressFunctionResolutionWarning { get; set; } public bool AssociativeToImperativePropagation { get; set; } public bool IsDeltaExecution { get; set; } - public InterpreterMode RunMode { get; set; } /// /// TODO: Aparajit: This flag is true for Delta AST compilation @@ -280,14 +271,6 @@ public void AddContextData(Dictionary data) // otherwize the inferedtype information will be lost public Type InferedType; - - /// - /// Debugger properties generated at compile time. - /// This is copied to the RuntimeCore after compilation - /// - public DebugProperties DebuggerProperties; - - public bool builtInsLoaded { get; set; } public List LoadedDLLs = new List(); public int deltaCompileStartPC { get; set; } @@ -389,8 +372,6 @@ public void ResetForDeltaExecution() { Options.ApplyUpdate = false; - Options.RunMode = InterpreterMode.Normal; - // The main codeblock never goes out of scope // Resetting CodeBlockIndex means getting the number of main codeblocks that dont go out of scope. // As of the current requirements, there is only 1 main scope, the rest are nested within. @@ -407,7 +388,6 @@ public void ResetForDeltaExecution() // Remove inactive graphnodes in the list GraphNodeCallList.RemoveAll(g => !g.isActive); - ExprInterpreterExe = null; } public void ResetForPrecompilation() @@ -445,17 +425,6 @@ public void ResetForPrecompilation() // TODO Jun: Cleansify me - i dont need to be here public AssociativeNode AssocNode { get; set; } - public int watchStartPC { get; set; } - - - // - // TODO Jun: This is the expression interpreters executable. - // It must be moved to its own core, whre each core is an instance of a compiler+interpreter - // - public Executable ExprInterpreterExe { get; set; } - public int watchFunctionScope { get; set; } - public int watchBaseOffset { get; set; } - public List watchSymbolList { get; set; } public CodeGen assocCodegen { get; set; } @@ -475,12 +444,6 @@ public Core(Options options) FunctionTable = new FunctionTable(); - - watchFunctionScope = Constants.kInvalidIndex; - watchSymbolList = new List(); - watchBaseOffset = 0; - - GlobOffset = 0; GlobHeapOffset = 0; BaseOffset = 0; @@ -511,8 +474,6 @@ public Core(Options options) DynamicVariableTable = new DynamicVariableTable(); DynamicFunctionTable = new DynamicFunctionTable(); - watchStartPC = Constants.kInvalidIndex; - deltaCompileStartPC = Constants.kInvalidIndex; BuildStatus = new BuildStatus(this, null, Options.BuildOptErrorAsWarning); @@ -523,17 +484,11 @@ public Core(Options options) SSAExprUID = 0; ExpressionUID = 0; - ExprInterpreterExe = null; - Options.RunMode = InterpreterMode.Normal; - assocCodegen = null; // Default execution log is Console.Out. ExecutionLog = Console.Out; - DebuggerProperties = new DebugProperties(); - - ParsingMode = ParseMode.Normal; IsParsingPreloadedAssembly = false; @@ -570,8 +525,7 @@ public SymbolNode GetFirstVisibleSymbol(string name, int classscope, int functio // CodeBlockType.Function is a temporary block type which is set when // the compile is generating code for function defintion node and will // be set back to Associative. - var isSearchBoundry = searchBlock.blockType == CodeBlockType.Function || - (Options.RunMode == InterpreterMode.Expression && searchBlock.parent == null); + var isSearchBoundry = searchBlock.blockType == CodeBlockType.Function; if (isSearchBoundry) { @@ -592,9 +546,7 @@ public SymbolNode GetFirstVisibleSymbol(string name, int classscope, int functio // Search variable might be defined in function. // If we are not in class defintion, then just stop here, otherwise // we should search global block's symbol table. - if (searchBlock != null && - (searchBlock.blockType == CodeBlockType.Function || (Options.RunMode == InterpreterMode.Expression && searchBlock.parent == null)) && - classscope == Constants.kGlobalScope) + if (searchBlock?.blockType == CodeBlockType.Function && classscope == Constants.kGlobalScope) { symbolIndex = searchBlock.symbolTable.IndexOf(name, classscope, function); } @@ -669,57 +621,6 @@ private void BfsBuildInstructionStreams(CodeBlock codeBlock, InstructionStream[] } } - - public void GenerateExprExe() - { - // TODO Jun: Determine if we really need another executable for the expression interpreter - Validity.Assert(null == ExprInterpreterExe); - ExprInterpreterExe = new Executable(); - ExprInterpreterExe.FunctionTable = FunctionTable; - ExprInterpreterExe.DynamicVarTable = DynamicVariableTable; - ExprInterpreterExe.FuncPointerTable = FunctionPointerTable; - ExprInterpreterExe.DynamicFuncTable = DynamicFunctionTable; - ExprInterpreterExe.ContextDataMngr = ContextDataManager; - ExprInterpreterExe.Configurations = Configurations; - ExprInterpreterExe.CodeToLocation = CodeToLocation; - ExprInterpreterExe.CurrentDSFileName = CurrentDSFileName; - - // Copy all tables - ExprInterpreterExe.classTable = DSExecutable.classTable; - ExprInterpreterExe.procedureTable = DSExecutable.procedureTable; - ExprInterpreterExe.runtimeSymbols = DSExecutable.runtimeSymbols; - - - ExprInterpreterExe.TypeSystem = TypeSystem; - - // Copy all instruction streams - // TODO Jun: What method to copy all? Use that - ExprInterpreterExe.instrStreamList = new InstructionStream[DSExecutable.instrStreamList.Length]; - for (int i = 0; i < DSExecutable.instrStreamList.Length; ++i) - { - if (null != DSExecutable.instrStreamList[i]) - { - ExprInterpreterExe.instrStreamList[i] = new InstructionStream(DSExecutable.instrStreamList[i].language, this); - //ExprInterpreterExe.instrStreamList[i] = new InstructionStream(DSExecutable.instrStreamList[i].language, DSExecutable.instrStreamList[i].dependencyGraph, this); - for (int j = 0; j < DSExecutable.instrStreamList[i].instrList.Count; ++j) - { - ExprInterpreterExe.instrStreamList[i].instrList.Add(DSExecutable.instrStreamList[i].instrList[j]); - } - } - } - } - - - public void GenerateExprExeInstructions(int blockScope) - { - // Append the expression instruction at the end of the current block - for (int n = 0; n < ExprInterpreterExe.iStreamCanvas.instrList.Count; ++n) - { - ExprInterpreterExe.instrStreamList[blockScope].instrList.Add(ExprInterpreterExe.iStreamCanvas.instrList[n]); - } - } - - public void GenerateExecutable() { Validity.Assert(CodeBlockList.Count >= 0); @@ -759,7 +660,6 @@ public void GenerateExecutable() BfsBuildInstructionStreams(CodeBlockList[n], DSExecutable.instrStreamList); } - GenerateExprExe(); DSExecutable.FunctionTable = FunctionTable; DSExecutable.DynamicVarTable = DynamicVariableTable; DSExecutable.DynamicFuncTable = DynamicFunctionTable; diff --git a/src/Engine/ProtoCore/DSASM/Defs.cs b/src/Engine/ProtoCore/DSASM/Defs.cs index 95da9509091..bb9ed4bbeee 100644 --- a/src/Engine/ProtoCore/DSASM/Defs.cs +++ b/src/Engine/ProtoCore/DSASM/Defs.cs @@ -1,13 +1,7 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace ProtoCore.DSASM { - public enum InterpreterMode - { - Expression, - Normal, - } - namespace CallingConvention { public enum BounceType @@ -96,7 +90,6 @@ public struct kw public const string newobj = "newobj"; public const string push = "push"; public const string pushm = "pushm"; - public const string pushw = "pushw"; public const string pushdep = "pushdep"; public const string pushrepguide = "pushguide"; public const string pushlevel = "pushlevel"; @@ -104,7 +97,6 @@ public struct kw public const string retb = "retb"; public const string retcn = "retcn"; public const string pop = "pop"; - public const string popw = "popw"; public const string popm = "popm"; public const string poprepguides = "popguides"; public const string poplevel = "poplevel"; diff --git a/src/Engine/ProtoCore/DSASM/Executive.cs b/src/Engine/ProtoCore/DSASM/Executive.cs index ecc0a89a0f2..8902f75339b 100644 --- a/src/Engine/ProtoCore/DSASM/Executive.cs +++ b/src/Engine/ProtoCore/DSASM/Executive.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -49,8 +49,7 @@ public RuntimeCore RuntimeCore enum DebugFlags { NONE, - ENABLE_LOG, - SPAWN_DEBUGGER + ENABLE_LOG } // Execute DS Release build @@ -137,17 +136,15 @@ private void SetupGraphNodesInScope() /// /// /// - /// /// - public StackValue Bounce(int exeblock, int entry, StackFrame stackFrame, int locals = 0, bool fepRun = false, Executive exec = null, List breakpoints = null) + public StackValue Bounce(int exeblock, int entry, StackFrame stackFrame, int locals = 0, bool fepRun = false, Executive exec = null) { if (stackFrame != null) { rmem.PushFrameForLocals(locals); rmem.PushStackFrame(stackFrame); - runtimeCore.DebugProps.SetUpBounce(exec, stackFrame.FunctionCallerBlock, stackFrame.ReturnPC); } - return runtimeCore.ExecutionInstance.Execute(exeblock, entry, fepRun, breakpoints); + return runtimeCore.ExecutionInstance.Execute(exeblock, entry, fepRun); } /// @@ -160,7 +157,6 @@ public StackValue Bounce(int exeblock, int entry, StackFrame stackFrame, int loc /// /// /// - /// /// public StackValue BounceUsingExecutive( DSASM.Executive executive, @@ -169,16 +165,14 @@ public StackValue BounceUsingExecutive( StackFrame stackFrame, int locals = 0, bool fepRun = false, - DSASM.Executive exec = null, - List breakpoints = null) + DSASM.Executive exec = null) { if (stackFrame != null) { rmem.PushFrameForLocals(locals); rmem.PushStackFrame(stackFrame); - runtimeCore.DebugProps.SetUpBounce(exec, stackFrame.FunctionCallerBlock, stackFrame.ReturnPC); } - executive.Execute(exeblock, entry, breakpoints); + executive.Execute(exeblock, entry); return executive.RX; } @@ -193,20 +187,6 @@ private bool IsGlobalScope() (rmem.CurrentStackFrameClassScope == Constants.kInvalidIndex && rmem.CurrentStackFrameFunctionScope == Constants.kInvalidIndex); } - private void BounceExplicit(int exeblock, int entry, Language language, StackFrame frame, List breakpoints) - { - fepRun = false; - rmem.PushStackFrame(frame); - - SetupExecutive(exeblock, entry, language, breakpoints); - - bool debugRun = (0 != (debugFlags & (int)DebugFlags.SPAWN_DEBUGGER)); - if (!fepRun || fepRun && debugRun) - { - logVMMessage("Start JIL Execution - " + CoreUtils.GetLanguageString(language)); - } - } - private void BounceExplicit(int exeblock, int entry, Language language, StackFrame frame) { fepRun = false; @@ -214,8 +194,7 @@ private void BounceExplicit(int exeblock, int entry, Language language, StackFra SetupExecutive(exeblock, entry); - bool debugRun = (0 != (debugFlags & (int)DebugFlags.SPAWN_DEBUGGER)); - if (!fepRun || fepRun && debugRun) + if (!fepRun) { logVMMessage("Start JIL Execution - " + CoreUtils.GetLanguageString(language)); } @@ -275,10 +254,8 @@ private void RestoreFromCall() int ci = rmem.GetAtRelative(StackFrame.FrameIndexClassIndex).ClassIndex; int fi = rmem.GetAtRelative(StackFrame.FrameIndexFunctionIndex).FunctionIndex; int blockId = rmem.GetAtRelative(StackFrame.FrameIndexBlockIndex).BlockIndex; - if (runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - ReturnSiteGC(blockId, ci, fi); - } + + ReturnSiteGC(blockId, ci, fi); ProcedureNode procNode = GetProcedureNode(blockId, ci, fi); if (procNode.IsConstructor) @@ -303,30 +280,24 @@ private void RestoreFromCall() CallingConvention.CallType callType = sv.CallType; IsExplicitCall = CallingConvention.CallType.Explicit == callType || CallingConvention.CallType.ExplicitBase == callType; - if (!runtimeCore.Options.IDEDebugMode || runtimeCore.Options.RunMode == InterpreterMode.Expression) - { - int localCount = procNode.LocalCount; - int paramCount = procNode.ArgumentTypes.Count; + int localCount = procNode.LocalCount; + int paramCount = procNode.ArgumentTypes.Count; - var execStateRestore = RetrieveExecutionStatesFromStack(localCount, paramCount); + var execStateRestore = RetrieveExecutionStatesFromStack(localCount, paramCount); - rmem.FramePointer = (int)rmem.GetAtRelative(StackFrame.FrameIndexFramePointer).IntegerValue; - rmem.PopFrame(StackFrame.StackFrameSize + localCount + paramCount + (execStateRestore?.Count ?? 0)); + rmem.FramePointer = (int)rmem.GetAtRelative(StackFrame.FrameIndexFramePointer).IntegerValue; + rmem.PopFrame(StackFrame.StackFrameSize + localCount + paramCount + (execStateRestore?.Count ?? 0)); - if (runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - // Restoring the registers require the current frame pointer of the stack frame - ResumeRegistersFromStackExceptRX(); - bounceType = (CallingConvention.BounceType)TX.CallType; - } + // Restoring the registers require the current frame pointer of the stack frame + ResumeRegistersFromStackExceptRX(); + bounceType = (CallingConvention.BounceType)TX.CallType; - if (execStateRestore != null) + if (execStateRestore != null) + { + Validity.Assert(execStateRestore.Count == procNode.GraphNodeList.Count); + for (int n = 0; n < execStateRestore.Count; ++n) { - Validity.Assert(execStateRestore.Count == procNode.GraphNodeList.Count); - for (int n = 0; n < execStateRestore.Count; ++n) - { - procNode.GraphNodeList[n].isDirty = execStateRestore[n]; - } + procNode.GraphNodeList[n].isDirty = execStateRestore[n]; } } @@ -346,16 +317,9 @@ private void RestoreFromCall() if (IsExplicitCall) { - bool wasDebugPropsPopped = false; - if (!isDispose) - { - wasDebugPropsPopped = DebugReturn(procNode, pc); - } - - // This condition should only be reached in the following cases: - // 1. Debug StepOver or External Function call in non-replicating mode + // This condition should only be reached in the following case: // 2. Normal execution in Serial (explicit call), non-replicating mode - if (!procNode.IsConstructor && !wasDebugPropsPopped) + if (!procNode.IsConstructor) { RX = CallSite.PerformReturnTypeCoerce(procNode, runtimeCore, RX); if (CoreUtils.IsDotMethod(procNode.Name)) @@ -466,18 +430,7 @@ private void SetupExecutive(int exeblock, int entry) PushInterpreterProps(Properties); Properties.Reset(); - if (runtimeCore.Options.RunMode == InterpreterMode.Normal) - { - exe = runtimeCore.DSExecutable; - } - else if (runtimeCore.Options.RunMode == InterpreterMode.Expression) - { - exe = runtimeCore.ExprInterpreterExe; - } - else - { - Validity.Assert(false, "Invalid execution mode"); - } + exe = runtimeCore.DSExecutable; executingBlock = exeblock; @@ -508,11 +461,6 @@ private void SetupExecutive(int exeblock, int entry) SetupEntryPoint(); } - if (runtimeCore.Options.RunMode == InterpreterMode.Expression) - { - pc = entry; - } - Validity.Assert(null != rmem); } @@ -521,18 +469,7 @@ private void SetupExecutiveForCall(int exeblock, int entry) PushInterpreterProps(Properties); Properties.Reset(); - if (runtimeCore.Options.RunMode == InterpreterMode.Normal) - { - exe = runtimeCore.DSExecutable; - } - else if (runtimeCore.Options.RunMode == InterpreterMode.Expression) - { - exe = runtimeCore.ExprInterpreterExe; - } - else - { - Validity.Assert(false, "Invalid execution mode"); - } + exe = runtimeCore.DSExecutable; fepRun = true; executingBlock = exeblock; @@ -603,8 +540,7 @@ public StackValue Callr(int blockDeclId, int functionIndex, int classIndex, ref bool explicitCall, - bool isDynamicCall = false, - bool hasDebugInfo = false) + bool isDynamicCall = false) { // This is curently unused but required for stack alignment var svDepth = rmem.Pop(); @@ -758,40 +694,6 @@ public StackValue Callr(int blockDeclId, fepRun ? StackFrameType.Function : StackFrameType.LanguageBlock, StackFrameType.Function, 0, rmem.FramePointer, blockDeclId, GetRegisters(), 0); StackValue sv = StackValue.Null; - if (runtimeCore.Options.IDEDebugMode && runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - if (runtimeCore.ContinuationStruct.IsFirstCall) - { - runtimeCore.DebugProps.SetUpCallrForDebug( - runtimeCore, - this, - fNode, - pc, - false, - callsite, - arguments, - replicationGuides, - stackFrame, - dotCallDimensions, - hasDebugInfo); - } - else - { - runtimeCore.DebugProps.SetUpCallrForDebug( - runtimeCore, - this, - fNode, - pc, - false, - callsite, - runtimeCore.ContinuationStruct.InitialArguments, - replicationGuides, - stackFrame, - runtimeCore.ContinuationStruct.InitialDotCallDimensions, - hasDebugInfo); - } - } - //Dispatch without recursion tracking explicitCall = false; IsExplicitCall = explicitCall; @@ -818,12 +720,6 @@ public StackValue Callr(int blockDeclId, // If the function was called implicitly, The code below assumes this and must be executed if (!explicitCall) { - // Restore debug properties after returning from a CALL/CALLR - if (runtimeCore.Options.IDEDebugMode && runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - runtimeCore.DebugProps.RestoreCallrForNoBreak(runtimeCore, fNode); - } - if (CoreUtils.IsDotMethod(fNode.Name)) { sv = IndexIntoArray(sv, dotCallDimensions); @@ -862,7 +758,6 @@ internal StackValue CallDispose(ProcedureNode fNode, private StackValue CallrForMemberFunction(int blockIndex, int classIndex, int procIndex, - bool hasDebugInfo, ref bool isExplicitCall) { var svDepth = rmem.Pop(); @@ -903,26 +798,6 @@ private StackValue CallrForMemberFunction(int blockIndex, Validity.Assert(null != callsite); - bool setDebugProperty = runtimeCore.Options.IDEDebugMode && - runtimeCore.Options.RunMode != InterpreterMode.Expression && - procNode != null; - - if (setDebugProperty) - { - runtimeCore.DebugProps.SetUpCallrForDebug( - runtimeCore, - this, - procNode, - pc, - false, - callsite, - arguments, - repGuides, - stackFrame, - null, - hasDebugInfo); - } - var argumentAtLevels = AtLevelHandler.GetArgumentAtLevelStructure(arguments, atLevels, runtimeCore); StackValue sv = callsite.JILDispatch(argumentAtLevels.Arguments, @@ -1640,671 +1515,68 @@ private void XLangUpdateDependencyGraph(int currentLangBlock) } } - if (upadatedList.Count > 0) - { - foreach (AssociativeGraph.UpdateNodeRef noderef in upadatedList) - { - istream.xUpdateList.Remove(noderef); - } - } - } - - private void ResumeRegistersFromStack() - { - int fp = rmem.FramePointer; - if (fp >= rmem.GlobOffset + StackFrame.StackFrameSize) - { - RX = rmem.GetAtRelative(StackFrame.FrameIndexRX); - TX = rmem.GetAtRelative(StackFrame.FrameIndexTX); - } - } - - private void ResumeRegistersFromStackExceptRX() - { - int fp = rmem.FramePointer; - if (fp >= rmem.GlobOffset + StackFrame.StackFrameSize) - { - TX = rmem.GetAtRelative(StackFrame.FrameIndexTX); - } - } - - private void SaveRegistersToStack() - { - int fp = rmem.FramePointer; - if (fp >= rmem.GlobOffset + StackFrame.StackFrameSize) - { - rmem.SetAtRelative(StackFrame.FrameIndexRX, RX); - rmem.SetAtRelative(StackFrame.FrameIndexTX, TX); - } - } - - public List GetRegisters() - { - return new List { RX, TX }; - } - - /// - /// Performs type coercion of returned value and GC of arguments, this ptr and Dot methods - /// - private void DebugPerformCoercionAndGC(DebugFrame debugFrame) - { - ProcedureNode procNode = debugFrame.FinalFepChosen != null ? debugFrame.FinalFepChosen.procedureNode : null; - if (!debugFrame.IsBaseCall) - { - RX = CallSite.PerformReturnTypeCoerce(procNode, runtimeCore, RX); - - if (debugFrame.ThisPtr == null && CoreUtils.IsDotMethod(procNode.Name)) - { - RX = IndexIntoArray(RX, debugFrame.DotCallDimensions); - rmem.PopFrame(Constants.kDotCallArgCount); - } - } - } - - /// - /// Pops Debug stackframe, performs coercion and GC and pops stackframe if there's a break inside the function - /// - /// - bool RestoreDebugPropsOnReturnFromBuiltIns() - { - bool waspopped = false; - // Restore fepRun - Validity.Assert(runtimeCore.DebugProps.DebugStackFrame.Count > 0); - - DebugFrame debugFrame = runtimeCore.DebugProps.DebugStackFrame.Peek(); - bool isReplicating = debugFrame.IsReplicating; - - if (!isReplicating) - { - bool isResume = debugFrame.IsResume; - - // RestoreCallrForNoBreak and PerformReturnTypeCoerce are NOT called if this is true - // so these have to be explicitly called here - if (isResume) - { - debugFrame = runtimeCore.DebugProps.DebugStackFrame.Pop(); - waspopped = true; - if (runtimeCore.DebugProps.DebugStackFrame.Count > 1) - { - DebugFrame frame = runtimeCore.DebugProps.DebugStackFrame.Peek(); - frame.IsResume = true; - } - - DebugPerformCoercionAndGC(debugFrame); - - // Restore registers except RX on popping of function stackframe - ResumeRegistersFromStackExceptRX(); - - terminate = false; - } - - if (runtimeCore.DebugProps.RunMode.Equals(Runmode.StepOut) && pc == runtimeCore.DebugProps.StepOutReturnPC) - { - runtimeCore.Breakpoints.Clear(); - runtimeCore.Breakpoints.AddRange(runtimeCore.DebugProps.AllbreakPoints); - } - } - return waspopped; - - } - - bool RestoreDebugPropsOnReturnFromFunctionCall(ref int exeblock, ref List instructions, out int ci, out int fi, out bool isReplicating, - out DebugFrame debugFrame) - { - // - // TODO: Aparajit, Jun - Determine an alternative to the waspopped flag - // - bool waspopped = false; - Validity.Assert(runtimeCore.DebugProps.DebugStackFrame.Count > 0); - - debugFrame = runtimeCore.DebugProps.DebugStackFrame.Peek(); - - isReplicating = debugFrame.IsReplicating; - - if (!isReplicating) - { - bool isResume = debugFrame.IsResume; - - // Comment Jun: Since we dont step into _Dispose() calls, then its debugframe should not be popped off here. - bool isDispose = debugFrame.IsDisposeCall; - - // RestoreCallrForNoBreak and PerformReturnTypeCoerce are NOT called if this is true - // or for base class ctor calls and therefore need to be taken care of here - if ((isResume || debugFrame.IsBaseCall) && !isDispose) - { - debugFrame = runtimeCore.DebugProps.DebugStackFrame.Pop(); - waspopped = true; - - if (isResume) - { - if (runtimeCore.DebugProps.DebugStackFrame.Count > 1) - { - DebugFrame frame = runtimeCore.DebugProps.DebugStackFrame.Peek(); - frame.IsResume = true; - } - } - - DebugPerformCoercionAndGC(debugFrame); - - // Restore registers except RX on popping of function stackframe - ResumeRegistersFromStackExceptRX(); - - terminate = false; - } - - Properties.executingGraphNode = debugFrame.ExecutingGraphNode; - - if (runtimeCore.DebugProps.RunMode.Equals(Runmode.StepOut) && pc == runtimeCore.DebugProps.StepOutReturnPC) - { - runtimeCore.Breakpoints.Clear(); - runtimeCore.Breakpoints.AddRange(runtimeCore.DebugProps.AllbreakPoints); - } - } - - // Restore return address and lang block - pc = (int)rmem.GetAtRelative(StackFrame.FrameIndexReturnAddress).IntegerValue; - exeblock = rmem.GetAtRelative(StackFrame.FrameIndexCallerBlockIndex).BlockIndex; - - istream = exe.instrStreamList[exeblock]; - instructions = istream.instrList; - executingLanguage = istream.language; - - ci = rmem.GetAtRelative(StackFrame.FrameIndexClassIndex).ClassIndex; - fi = rmem.GetAtRelative(StackFrame.FrameIndexFunctionIndex).FunctionIndex; - - int localCount; - int paramCount; - int blockId = rmem.GetAtRelative(StackFrame.FrameIndexFunctionBlockIndex).BlockIndex; - GetLocalAndParamCount(blockId, ci, fi, out localCount, out paramCount); - - // Get execution states - var execStateRestore = RetrieveExecutionStatesFromStack(localCount, paramCount); - - // Pop function stackframe as this is not allowed in Ret/Retc in debug mode - rmem.FramePointer = (int)rmem.GetAtRelative(StackFrame.FrameIndexFramePointer).IntegerValue; - - rmem.PopFrame(StackFrame.StackFrameSize + localCount + paramCount + (execStateRestore?.Count ?? 0)); - - ResumeRegistersFromStackExceptRX(); - - //StackValue svFrameType = rmem.GetAtRelative(StackFrame.kFrameIndexCallerStackFrameType); - StackValue svFrameType = rmem.GetAtRelative(StackFrame.FrameIndexStackFrameType); - StackFrameType frametype = svFrameType.FrameType; - if (frametype == StackFrameType.LanguageBlock) - { - bounceType = TX.BounceType; - } - return waspopped; - } - - void RestoreDebugPropsOnReturnFromLangBlock(ref int exeblock, ref List instructions) - { - // On the new stack frame, this dependency has already been executed at retb in RestoreFromBounce - //XLangUpdateDependencyGraph(exeblock); - - Validity.Assert(runtimeCore.DebugProps.DebugStackFrame.Count > 0); - { - // Restore fepRun - DebugFrame debugFrame = runtimeCore.DebugProps.DebugStackFrame.Pop(); - - bool isResume = debugFrame.IsResume; - - if (isResume) - { - if (runtimeCore.DebugProps.DebugStackFrame.Count > 1) - { - DebugFrame frame = runtimeCore.DebugProps.DebugStackFrame.Peek(); - frame.IsResume = true; - } - - terminate = false; - - // Restore registers except RX on popping of language stackframe - ResumeRegistersFromStackExceptRX(); - } - - // Restore return address and lang block - pc = (int)rmem.GetAtRelative(StackFrame.FrameIndexReturnAddress).IntegerValue; - exeblock = rmem.GetAtRelative(StackFrame.FrameIndexCallerBlockIndex).BlockIndex; - - istream = exe.instrStreamList[exeblock]; - instructions = istream.instrList; - executingLanguage = istream.language; - - Properties.executingGraphNode = debugFrame.ExecutingGraphNode; - - // Pop language stackframe as this is not allowed in Retb in debug mode - rmem.FramePointer = (int)rmem.GetAtRelative(StackFrame.FrameIndexFramePointer).IntegerValue; - rmem.PopFrame(StackFrame.StackFrameSize); - - ResumeRegistersFromStackExceptRX(); - bounceType = TX.BounceType; - } - - if (pc < 0) - { - throw new EndOfScript(); - } - } - - /// - /// Restores Debug properties from function call and/or from Dot call - /// - /// - /// - /// - /// - /// - /// - /// - private bool DebugReturnFromFunctionCall(int currentPC, ref int exeblock, out int ci, out int fi, out bool isReplicating, out DebugFrame debugFrame) - { - var tempFrame = runtimeCore.DebugProps.DebugStackFrame.Peek(); - - List instructions = istream.instrList; - - bool waspopped = RestoreDebugPropsOnReturnFromFunctionCall(ref exeblock, ref instructions, out ci, out fi, out isReplicating, out debugFrame); - - // TODO: If return from previous function calls "_Dispose", and we have stepped into it, - // we need to restore the caller stackframe - pratapa - if (tempFrame.IsDisposeCall) - { - // TODO: If we have stepped inside _Dispose and are resuming from it - pratapa - if (!terminate) - { - // 1. Call everything after RETURNSITEGC in OpCode.RETURN/ OpCode.RETC - // 2. Call RestoreDebugPropsOnReturnFromFunctionCall() for caller function - // 3. Return address from _Dispose is one more than the correct value and therefore needs to be fixed - } - // TODO: This works assuming debugging inside _Dispose functions is disabled - // ie stepping over _Dispose - pratapa - runtimeCore.DebugProps.DebugEntryPC = runtimeCore.DebugProps.ReturnPCFromDispose; - //break; - } - else - { - debugFrame = runtimeCore.DebugProps.DebugStackFrame.Peek(); - // If call returns to Dot Call, restore debug props for Dot call - if (debugFrame.IsDotCall) - { - waspopped = RestoreDebugPropsOnReturnFromBuiltIns(); - } - runtimeCore.DebugProps.DebugEntryPC = currentPC; - } - - return waspopped; - } - - private bool DebugReturn(ProcedureNode procNode, int currentPC) - { - // - // TODO: Aparajit, Jun - Determine an alternative to the waspopped flag - // - bool waspopped = false; - - bool isReplicating; - int exeblock = Constants.kInvalidIndex; - int ci; - int fi; - - DebugFrame debugFrame = null; - if (runtimeCore.Options.IDEDebugMode && runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - waspopped = DebugReturnFromFunctionCall(currentPC, ref exeblock, out ci, out fi, out isReplicating, out debugFrame); - - if (!waspopped) - { - runtimeCore.DebugProps.RestoreCallrForNoBreak(runtimeCore, procNode, isReplicating); - } - } - - return waspopped; - } - - private void SetupExecutive(int exeblock, int entry, Language language, List breakpoints) - { - // exe need to be assigned at the constructor, - // for function call with replication, gc is triggered to handle the parameter and return value at FunctionEndPoint - // gc requirs exe to be not null but at that point, Execute has not been called - //Validity.Assert(exe == null); - exe = runtimeCore.DSExecutable; - executingBlock = exeblock; - - runtimeCore.DebugProps.CurrentBlockId = exeblock; - - istream = exe.instrStreamList[exeblock]; - Validity.Assert(null != istream); - runtimeCore.DebugProps.DebugEntryPC = entry; - - List instructions = istream.instrList; - Validity.Assert(null != instructions); - - SetupGraphNodesInScope(); - - // Restore the previous state - //rmem = runtimeCore.RuntimeMemory; - rmem = runtimeCore.RuntimeMemory; - - if (runtimeCore.DebugProps.isResume) // resume from a breakpoint, - { - Validity.Assert(runtimeCore.DebugProps.DebugStackFrame.Count > 0); - - DebugFrame debugFrame = runtimeCore.DebugProps.DebugStackFrame.Peek(); - - // TODO: The FepRun info need not be cached in DebugProps any longer - // as it can be replaced by StackFrameType in rmem.Stack - pratapa - fepRun = debugFrame.FepRun == 1; - //StackFrameType stackFrameType = (StackFrameType)rmem.GetAtRelative(StackFrame.kFrameIndexStackFrameType).opdata; - //fepRun = (stackFrameType == StackFrameType.kTypeFunction) ? true : false; - - //ResumeRegistersFromStack(); - - fepRunStack = runtimeCore.DebugProps.FRStack; - - Properties = PopInterpreterProps(); - Properties.executingGraphNode = runtimeCore.DebugProps.executingGraphNode; - deferedGraphNodes = runtimeCore.DebugProps.deferedGraphnodes; - - } - else - { - PushInterpreterProps(Properties); - Properties.Reset(); - } - - if (false == fepRun) - { - if (runtimeCore.DebugProps.isResume) // resume from a breakpoint, - { - pc = entry; - } - else - { - pc = istream.entrypoint; - rmem.FramePointer = rmem.Stack.Count; - } - } - else - { - pc = entry; - } - executingLanguage = exe.instrStreamList[exeblock].language; - - if (Language.Associative == executingLanguage && !runtimeCore.DebugProps.isResume) - { - SetupEntryPoint(); - } - - Validity.Assert(null != rmem); - } - - - private bool HandleBreakpoint(List breakpoints, List runningInstructions, int currentPC) - { - bool terminateExec = false; - bool isBreakPoint = false; - - if ((currentPC >= 0) && (currentPC < runningInstructions.Count)) - { - isBreakPoint = breakpoints.Contains(runningInstructions[currentPC]); - } - - if (currentPC >= runningInstructions.Count || currentPC < 0 || isBreakPoint) - { - if (currentPC < 0) - { - runtimeCore.ReasonForExecutionSuspend = ReasonForExecutionSuspend.NoEntryPoint; - terminateExec = true; - //break; - } - else if (pc >= runningInstructions.Count) - { - runtimeCore.ReasonForExecutionSuspend = ReasonForExecutionSuspend.EndOfFile; - terminateExec = true; - //break; - } - else - { - Validity.Assert(breakpoints.Contains(runningInstructions[currentPC])); - runtimeCore.ReasonForExecutionSuspend = ReasonForExecutionSuspend.Breakpoint; - logVMMessage("Breakpoint at: " + runningInstructions[currentPC]); - - Validity.Assert(runtimeCore.DebugProps.DebugStackFrame.Count > 0); - { - DebugFrame debugFrame = runtimeCore.DebugProps.DebugStackFrame.Peek(); - - // Since the first frame always belongs to the global language block - if (runtimeCore.DebugProps.DebugStackFrame.Count > 1) - { - debugFrame.IsResume = true; - } - } - SaveRegistersToStack(); - - runtimeCore.DebugProps.isResume = true; - runtimeCore.DebugProps.FRStack = fepRunStack; - runtimeCore.DebugProps.executingGraphNode = Properties.executingGraphNode; - runtimeCore.DebugProps.deferedGraphnodes = deferedGraphNodes; - - if (runtimeCore.DebugProps.RunMode == Runmode.StepNext) - { - foreach (DebugFrame debugFrame in runtimeCore.DebugProps.DebugStackFrame) - { - debugFrame.FunctionStepOver = false; - } - } - - runtimeCore.RunningBlock = executingBlock; - PushInterpreterProps(Properties); - - if (runtimeCore.DebugProps.FirstStackFrame != null) - { - runtimeCore.DebugProps.FirstStackFrame = null; - } - throw new DebugHalting(); - } - } - return terminateExec; - } - - /// - /// This is the VM execution entry function - /// - /// - /// - /// - /// - public void Execute(int exeblock, int entry, List breakpoints, Language language = Language.NotSpecified) - { - terminate = true; - if (entry != Constants.kInvalidPC) - { - terminate = false; - if (runtimeCore.Options.IDEDebugMode && runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - ExecuteDebug(exeblock, entry, breakpoints, language); - } - else - { - Execute(exeblock, entry, language); - } - } - } - - // This will be called only at the time of creation of the main interpreter in the explicit case OR - // for every implicit function call (like in replication) OR - // for every implicit bounce (like in dynamic lang block in inline condition) OR - // for a Debug Resume from a breakpoint - private void ExecuteDebug(int exeblock, int entry, List breakpoints, Language language = Language.NotSpecified) - { - // TODO Jun: Call RestoreFromBounce here? - StackValue svType = rmem.GetAtRelative(StackFrame.FrameIndexStackFrameType); - StackFrameType type = svType.FrameType; - if (StackFrameType.LanguageBlock == type || StackFrameType.Function == type) - { - ResumeRegistersFromStack(); - bounceType = TX.BounceType; - } - - SetupExecutive(exeblock, entry, language, breakpoints); - - - bool debugRun = (0 != (debugFlags & (int)DebugFlags.SPAWN_DEBUGGER)); - if (!fepRun || fepRun && debugRun) - { - logVMMessage("Start JIL Execution - " + CoreUtils.GetLanguageString(language)); - } - - runtimeCore.DebugProps.isResume = false; - - while (!terminate) - { - // This will be true only for inline conditions in Associative blocks - if (runtimeCore.DebugProps.InlineConditionOptions.isInlineConditional && - runtimeCore.DebugProps.InlineConditionOptions.instructionStream == exeblock && runtimeCore.DebugProps.InlineConditionOptions.endPc == pc) - { - // turn off inline conditional flag - { - runtimeCore.DebugProps.InlineConditionOptions.isInlineConditional = false; - runtimeCore.DebugProps.InlineConditionOptions.startPc = Constants.kInvalidIndex; - runtimeCore.DebugProps.InlineConditionOptions.endPc = Constants.kInvalidIndex; - runtimeCore.DebugProps.InlineConditionOptions.instructionStream = 0; - } - - // if no longer inside a replicated/external function call, restore breakpoints - if (!runtimeCore.DebugProps.DebugStackFrameContains(DebugProperties.StackFrameFlagOptions.IsReplicating) && - !runtimeCore.DebugProps.DebugStackFrameContains(DebugProperties.StackFrameFlagOptions.IsExternalFunction)) - { - if (runtimeCore.DebugProps.InlineConditionOptions.ActiveBreakPoints.Count > 0) - { - runtimeCore.Breakpoints.Clear(); - runtimeCore.Breakpoints.AddRange(runtimeCore.DebugProps.InlineConditionOptions.ActiveBreakPoints); - runtimeCore.DebugProps.InlineConditionOptions.ActiveBreakPoints.Clear(); - } - } - } - - List instructions = istream.instrList; - - // Execute the instruction! - Instruction executeInstruction = instructions[pc]; - Exec(instructions[pc]); - - bool restoreInstructionStream = executeInstruction.opCode == OpCode.CALLR || executeInstruction.opCode == OpCode.RETURN; - if (restoreInstructionStream && IsExplicitCall) - { - // The instruction stream list is updated on callr - instructions = istream.instrList; - exeblock = executingBlock; - runtimeCore.DebugProps.CurrentBlockId = exeblock; - } - - // Disabling support for stepping into replicating function calls temporarily - pratapa - // Check if the current instruction is a return from a function call or constructor - - DebugFrame tempFrame = null; - if (!IsExplicitCall && instructions[runtimeCore.DebugProps.DebugEntryPC].opCode == OpCode.RETURN) - { - int ci, fi; - bool isReplicating; - DebugFrame debugFrame; - DebugReturnFromFunctionCall(pc, ref exeblock, out ci, out fi, out isReplicating, out debugFrame); - - instructions = istream.instrList; - executingBlock = exeblock; - runtimeCore.DebugProps.CurrentBlockId = exeblock; - - SetupGraphNodesInScope(); - } - else if (executeInstruction.opCode == OpCode.RETB) - { - tempFrame = runtimeCore.DebugProps.DebugStackFrame.Peek(); - - RestoreDebugPropsOnReturnFromLangBlock(ref exeblock, ref instructions); - - // TODO: If return from previous lang block calls "_Dispose", and we have stepped into it, - // we need to restore the calling stackframe - pratapa - if (tempFrame.IsDisposeCall) - { - // TODO: If we have stepped inside _Dispose and are resuming from it - pratapa - if (!terminate) - { - // 1. Call everything after GC in OpCode.RETB - // 2. Call RestoreDebugPropsOnReturnFromLangBlock() for caller lang block - // 3. Return address from _Dispose is one more than the correct value and therefore needs to be fixed - } - // TODO: This works assuming debugging inside _Dispose functions is disabled - // ie stepping over _Dispose - pratapa - runtimeCore.DebugProps.DebugEntryPC = runtimeCore.DebugProps.ReturnPCFromDispose; - break; - } - else - { - runtimeCore.DebugProps.DebugEntryPC = pc; - } - // Comment Jun: On explictit bounce, only on retb we update the executing block - // as the block scope has already change by returning to the caller block - executingBlock = exeblock; - runtimeCore.RunningBlock = exeblock; - } - else - { - runtimeCore.DebugProps.DebugEntryPC = pc; - } - - DebugFrame frame = runtimeCore.DebugProps.DebugStackFrame.Peek(); - if (frame.IsInlineConditional) - { - RestoreDebugPropsOnReturnFromBuiltIns(); - runtimeCore.DebugProps.DebugEntryPC = pc; - } - - //runtimeCore.RuntimeMemory = rmem; - runtimeCore.RuntimeMemory = rmem; - - bool terminateExec = HandleBreakpoint(breakpoints, istream.instrList, pc); - if (terminateExec) + if (upadatedList.Count > 0) + { + foreach (AssociativeGraph.UpdateNodeRef noderef in upadatedList) { - break; + istream.xUpdateList.Remove(noderef); } } + } - if (!fepRun || fepRun && debugRun) + private void ResumeRegistersFromStackExceptRX() + { + int fp = rmem.FramePointer; + if (fp >= rmem.GlobOffset + StackFrame.StackFrameSize) { - logVMMessage("End JIL Execution - " + CoreUtils.GetLanguageString(language)); + TX = rmem.GetAtRelative(StackFrame.FrameIndexTX); } } - - private void Execute(int exeblock, int entry, Language language = Language.NotSpecified) + public List GetRegisters() { - SetupExecutive(exeblock, entry); - - string engine = CoreUtils.GetLanguageString(language); + return new List { RX, TX }; + } - bool debugRun = IsDebugRun(); - if (!fepRun || fepRun && debugRun) + /// + /// This is the VM execution entry function + /// + /// + /// + /// + public void Execute(int exeblock, int entry, Language language = Language.NotSpecified) + { + terminate = true; + if (entry != Constants.kInvalidPC) { - logVMMessage("Start JIL Execution - " + engine); - } + terminate = false; + SetupExecutive(exeblock, entry); - while (!terminate) - { - if(runtimeCore.CancellationPending) + string engine = CoreUtils.GetLanguageString(language); + + if (!fepRun) { - throw new ExecutionCancelledException(); + logVMMessage("Start JIL Execution - " + engine); } - if (pc >= istream.instrList.Count || pc < 0) + while (!terminate) { - break; + if (runtimeCore.CancellationPending) + { + throw new ExecutionCancelledException(); + } + + if (pc >= istream.instrList.Count || pc < 0) + { + break; + } + Exec(istream.instrList[pc]); } - Exec(istream.instrList[pc]); - } - if (!fepRun || fepRun && debugRun) - { - logVMMessage("End JIL Execution - " + engine); + if (!fepRun) + { + logVMMessage("End JIL Execution - " + engine); + } } } @@ -2394,41 +1666,6 @@ private StackValue GetOperandData(int blockId, StackValue opSymbol, StackValue o return data; } - private void PopToW(int blockId, StackValue op1, StackValue op2, StackValue opVal) - { - int symbolIndex = op1.SymbolIndex; - int classIndex = op2.ClassIndex; - SymbolNode symbol = GetSymbolNode(blockId, classIndex, symbolIndex); - int offset = symbol.index; - runtimeCore.watchStack[offset] = opVal; - } - - private void PushW(int block, StackValue op1, StackValue op2) - { - int symbol = op1.SymbolIndex; - int scope = op2.ClassIndex; - SymbolNode node; - if (Constants.kGlobalScope == scope) - { - node = exe.runtimeSymbols[block].symbolList[symbol]; - } - else - { - node = exe.classTable.ClassNodes[scope].Symbols.symbolList[symbol]; - } - - int offset = node.index; - //For watch symbol, use watching stack. - if (runtimeCore.WatchSymbolList.Contains(node)) - { - rmem.Push(runtimeCore.watchStack[offset]); - } - else - { - rmem.Push(GetOperandData(block, op1, op2)); - } - } - protected StackValue PopTo(int blockId, StackValue op1, StackValue op2, StackValue opVal) { StackValue opPrev = StackValue.Null; @@ -2442,12 +1679,6 @@ protected StackValue PopTo(int blockId, StackValue op1, StackValue op2, StackVal rmem.SetSymbolValue(symbol, opVal); exe.UpdatedSymbols.Add(symbol); - if (IsDebugRun()) - { - logWatchWindow(blockId, op1.SymbolIndex); - System.Console.ReadLine(); - } - if (Constants.kGlobalScope == op2.ClassIndex) { logWatchWindow(blockId, op1.SymbolIndex); @@ -2462,12 +1693,6 @@ protected StackValue PopTo(int blockId, StackValue op1, StackValue op2, StackVal rmem.SetSymbolValue(staticMember, opVal); exe.UpdatedSymbols.Add(staticMember); - if (IsDebugRun()) - { - logWatchWindow(blockId, op1.StaticVariableIndex); - System.Console.ReadLine(); - } - logWatchWindow(blockId, op1.StaticVariableIndex); break; case AddressType.Register: @@ -2543,12 +1768,6 @@ protected StackValue PopToIndexedArray(int blockId, int symbol, int classIndex, ret = array.SetValueForIndices(dimlist, data, runtimeCore); } - if (IsDebugRun()) - { - logWatchWindow(blockId, symbolnode.symbolTableIndex); - System.Console.ReadLine(); - } - if (IsGlobalScope()) { logWatchWindow(blockId, symbolnode.symbolTableIndex); @@ -2558,12 +1777,6 @@ protected StackValue PopToIndexedArray(int blockId, int symbol, int classIndex, return ret; } - private bool IsDebugRun() - { - return (debugFlags & (int)DebugFlags.SPAWN_DEBUGGER) != 0; - } - - protected void runtimeVerify(bool condition, string msg = "Dsasm runtime error. Exiting...\n") { // TODO Jun: hook this up to a runtime error handler @@ -2600,64 +1813,6 @@ public StackValue GetIndexedArray(StackValue svArray, List indices) return StackValue.Null; } - public StackValue GetIndexedArrayW(int dimensions, int blockId, StackValue op1, StackValue op2) - { - var dims = new List(); - for (int n = dimensions - 1; n >= 0; --n) - { - dims.Insert(0, rmem.Pop()); - } - - int symbolIndex = op1.SymbolIndex; - int classIndex = op2.ClassIndex; - - SymbolNode symbolNode = GetSymbolNode(blockId, classIndex, symbolIndex); - int stackindex = symbolNode.index; - string varname = symbolNode.name; - - StackValue thisArray; - if (runtimeCore.Options.RunMode == InterpreterMode.Expression && runtimeCore.WatchSymbolList.Contains(symbolNode)) - { - thisArray = runtimeCore.watchStack[symbolNode.index]; - } - else - { - if (op1.IsMemberVariableIndex) - { - StackValue thisptr = rmem.GetAtRelative(StackFrame.FrameIndexThisPtr); - thisArray = rmem.Heap.ToHeapObject(thisptr).GetValueFromIndex(stackindex, runtimeCore); - } - else - { - thisArray = rmem.GetSymbolValue(symbolNode); - } - } - - if (!thisArray.IsArray) - { - if (varname.StartsWith(Constants.kForLoopExpression)) - { - return thisArray; - } - - runtimeCore.RuntimeStatus.LogWarning(WarningID.OverIndexing, Resources.IndexIntoNonArrayObject); - return StackValue.Null; - } - - StackValue result; - try - { - result = GetIndexedArray(thisArray, dims); - } - catch (ArgumentOutOfRangeException) - { - runtimeCore.RuntimeStatus.LogWarning(WarningID.OverIndexing, Resources.IndexIntoNonArrayObject); - return StackValue.Null; - } - - return result; - } - public StackValue GetIndexedArray(List dims, int blockId, StackValue op1, StackValue op2) { int symbolIndex = op1.SymbolIndex; @@ -2932,17 +2087,6 @@ public void GCCodeBlock(int blockId, int functionIndex = Constants.kGlobalScope, && sn.functionIndex == functionIndex && !sn.name.Equals(Constants.kWatchResultVar); - if (runtimeCore.Options.GCTempVarsOnDebug && runtimeCore.Options.ExecuteSSA) - { - if (runtimeCore.Options.IDEDebugMode) - { - allowGC = sn.classScope == classIndex - && sn.functionIndex == functionIndex - && !sn.name.Equals(Constants.kWatchResultVar) - && !sn.isSSATemp; - } - } - if (allowGC) { int offset = sn.index; @@ -2977,16 +2121,6 @@ public void ReturnSiteGC(int blockId, int classIndex, int functionIndex) } } - public void Modify_istream_instrList_FromSetValue(int blockId, int pc, StackValue op) - { - exe.instrStreamList[blockId].instrList[pc].op1 = op; - } - - public void Modify_istream_entrypoint_FromSetValue(int blockId, int pc) - { - exe.instrStreamList[blockId].entrypoint = pc; - } - public AssociativeGraph.GraphNode GetFirstGraphNode(string varName, out int blockId) { blockId = 0; @@ -3027,22 +2161,6 @@ public ProcedureNode GetProcedureNode(int blockId, int classIndex, int functionI } } - private void GetLocalAndParamCount(int blockId, int classIndex, int functionIndex, out int localCount, out int paramCount) - { - localCount = paramCount = 0; - - if (Constants.kGlobalScope != classIndex) - { - localCount = exe.classTable.ClassNodes[classIndex].ProcTable.Procedures[functionIndex].LocalCount; - paramCount = exe.classTable.ClassNodes[classIndex].ProcTable.Procedures[functionIndex].ArgumentTypes.Count; - } - else - { - localCount = exe.procedureTable[blockId].Procedures[functionIndex].LocalCount; - paramCount = exe.procedureTable[blockId].Procedures[functionIndex].ArgumentTypes.Count; - } - } - public List> GetCachedReplicationGuides(int argumentCount) { int index = runtimeCore.ReplicationGuides.Count - argumentCount; @@ -3128,60 +2246,17 @@ private void PUSH_Handler(Instruction instruction) int fp = runtimeCore.RuntimeMemory.FramePointer; - if (runtimeCore.Options.RunMode == InterpreterMode.Expression && instruction.op1.IsThisPtr) - { - runtimeCore.RuntimeMemory.FramePointer = runtimeCore.watchFramePointer; - } - StackValue opdata1 = GetOperandData(blockId, instruction.op1, instruction.op2); - if (runtimeCore.Options.RunMode == InterpreterMode.Expression && instruction.op1.IsThisPtr) - { - runtimeCore.RuntimeMemory.FramePointer = fp; - } - rmem.Push(opdata1); ++pc; } - private void PUSHW_Handler(Instruction instruction) - { - int blockId = Constants.kInvalidIndex; - - StackValue op1 = instruction.op1; - StackValue op2 = instruction.op2; - - if (op1.IsVariableIndex || - op1.IsMemberVariableIndex || - op1.IsPointer || - op1.IsArray || - op1.IsStaticVariableIndex || - op1.IsFunctionPointer) - { - - StackValue svBlock = instruction.op3; - blockId = svBlock.BlockIndex; - } - - int fp = runtimeCore.RuntimeMemory.FramePointer; - if (runtimeCore.Options.RunMode == InterpreterMode.Expression) - runtimeCore.RuntimeMemory.FramePointer = runtimeCore.watchFramePointer; - - PushW(blockId, op1, op2); - - if (runtimeCore.Options.RunMode == InterpreterMode.Expression) - runtimeCore.RuntimeMemory.FramePointer = fp; - - ++pc; - } - private void PUSHB_Handler(Instruction instruction) { - if (runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - runtimeCore.RuntimeMemory.PushConstructBlockId(instruction.op1.BlockIndex); - } + runtimeCore.RuntimeMemory.PushConstructBlockId(instruction.op1.BlockIndex); + ++pc; } @@ -3394,27 +2469,6 @@ protected virtual void POP_Handler(Instruction instruction) POP_helper(instruction, out blockId, out dimensions); } - private void POPW_Handler(Instruction instruction) - { - int blockId = Constants.kInvalidIndex; - int staticType = (int)PrimitiveType.Var; - int rank = Constants.kArbitraryRank; - if (instruction.op1.IsVariableIndex || - instruction.op1.IsPointer || - instruction.op1.IsArray) - { - StackValue svBlock = instruction.op3; - blockId = svBlock.BlockIndex; - } - - StackValue svData = rmem.Pop(); - StackValue coercedValue = TypeSystem.Coerce(svData, staticType, rank, runtimeCore); - PopToW(blockId, instruction.op1, instruction.op2, coercedValue); - - rmem.Heap.GC(); - ++pc; - } - private void SETMEMELEMENT_Helper(Instruction instruction) { int classIndex = Constants.kInvalidIndex; @@ -4093,24 +3147,15 @@ private void ALLOCA_Handler(Instruction instruction) private void BOUNCE_Handler(Instruction instruction) { - // We disallow language blocks inside watch window currently - pratapa - Validity.Assert(InterpreterMode.Expression != runtimeCore.Options.RunMode); - int blockId = instruction.op1.BlockIndex; - // Comment Jun: On a bounce, update the debug property to reflect this. - // Before the explicit bounce, this was done in Execute() which is now no longer the case - // as Execute is only called once during first bounce and succeeding bounce reuse the same interpreter - runtimeCore.DebugProps.CurrentBlockId = blockId; - // TODO(Jun/Jiong): Considering store the orig block id to stack frame runtimeCore.RunningBlock = blockId; runtimeCore.RuntimeMemory = rmem; - if (runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - runtimeCore.RuntimeMemory.PushConstructBlockId(blockId); - } + + runtimeCore.RuntimeMemory.PushConstructBlockId(blockId); + int ci = Constants.kInvalidIndex; int fi = Constants.kInvalidIndex; @@ -4153,28 +3198,10 @@ private void BOUNCE_Handler(Instruction instruction) StackFrameType callerType = (fepRun) ? StackFrameType.Function : StackFrameType.LanguageBlock; + StackFrame stackFrame = new StackFrame(svThisPtr, ci, fi, returnAddr, blockDecl, blockCaller, callerType, type, depth + 1, framePointer, 0, registers, 0); - if (runtimeCore.Options.IDEDebugMode && runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - // Comment Jun: Temporarily disable debug mode on bounce - //Validity.Assert(false); - - //Validity.Assert(runtimeCore.Breakpoints != null); - //blockDecl = blockCaller = runtimeCore.DebugProps.CurrentBlockId; - - runtimeCore.DebugProps.SetUpBounce(this, blockCaller, returnAddr); - - StackFrame stackFrame = new StackFrame(svThisPtr, ci, fi, returnAddr, blockDecl, blockCaller, callerType, type, depth + 1, framePointer, 0, registers, 0); - Language bounceLangauge = exe.instrStreamList[blockId].language; - BounceExplicit(blockId, 0, bounceLangauge, stackFrame, runtimeCore.Breakpoints); - } - else //if (runtimeCore.Breakpoints == null) - { - StackFrame stackFrame = new StackFrame(svThisPtr, ci, fi, returnAddr, blockDecl, blockCaller, callerType, type, depth + 1, framePointer, 0, registers, 0); - - Language bounceLangauge = exe.instrStreamList[blockId].language; - BounceExplicit(blockId, 0, bounceLangauge, stackFrame); - } + Language bounceLangauge = exe.instrStreamList[blockId].language; + BounceExplicit(blockId, 0, bounceLangauge, stackFrame); } private void CALL_Handler(Instruction instruction) @@ -4188,10 +3215,8 @@ private void CALL_Handler(Instruction instruction) StackValue svBlock = rmem.Pop(); int blockId = svBlock.BlockIndex; - if (runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - rmem.PushConstructBlockId(blockId); - } + + rmem.PushConstructBlockId(blockId); ProcedureNode fNode; if (ci != Constants.kInvalidIndex) @@ -4203,15 +3228,6 @@ private void CALL_Handler(Instruction instruction) fNode = exe.procedureTable[blockId].Procedures[fi]; } - // Disabling support for stepping into replicating function calls temporarily - // This CALL instruction has a corresponding RETC instruction - // and for debugger purposes for every RETURN/RETC where we restore the states, - // we need a corresponding SetUpCallr to save the states. Therefore this call here - pratapa - if (runtimeCore.Options.IDEDebugMode && runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - runtimeCore.DebugProps.SetUpCallrForDebug(runtimeCore, this, fNode, pc, true); - } - StackValue svThisPointer = StackValue.BuildInvalid(); int pcoffset = 0; @@ -4304,10 +3320,7 @@ private void CALL_Handler(Instruction instruction) UpdateMethodDependencyGraph(pc, fi, ci); } - if (runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - rmem.PopConstructBlockId(); - } + rmem.PopConstructBlockId(); SetupGraphNodesInScope(); } @@ -4326,7 +3339,6 @@ protected virtual void CALLR_Handler(Instruction instruction) instr.op1 = instruction.op1; instr.op2 = instruction.op2; instr.op3 = instruction.op3; - instr.debug = instruction.debug; instr.opCode = instruction.opCode; bool succeeded = ResolveDynamicFunction(instr, out isMemberFunctionPointer); @@ -4357,11 +3369,11 @@ protected virtual void CALLR_Handler(Instruction instruction) // if (isMemberFunctionPointer) { - RX = CallrForMemberFunction(blockIndex, classIndex, functionIndex, instr.debug != null, ref explicitCall); + RX = CallrForMemberFunction(blockIndex, classIndex, functionIndex, ref explicitCall); } else if (!runtimeCore.Options.IsDeltaExecution) { - RX = Callr(blockIndex, functionIndex, classIndex, ref explicitCall, isDynamicCall, instr.debug != null); + RX = Callr(blockIndex, functionIndex, classIndex, ref explicitCall, isDynamicCall); } else { @@ -4371,7 +3383,7 @@ protected virtual void CALLR_Handler(Instruction instruction) // The only affected downstream operations are the ones connected to the graph associated with this call try { - RX = Callr(blockIndex, functionIndex, classIndex, ref explicitCall, isDynamicCall, instr.debug != null); + RX = Callr(blockIndex, functionIndex, classIndex, ref explicitCall, isDynamicCall); } catch (ReplicationCaseNotCurrentlySupported e) { @@ -4392,10 +3404,7 @@ private void RETB_Handler() { RX = rmem.Pop(); - if (runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - runtimeCore.RuntimeMemory.PopConstructBlockId(); - } + runtimeCore.RuntimeMemory.PopConstructBlockId(); if (!runtimeCore.Options.IsDeltaExecution || (runtimeCore.Options.IsDeltaExecution && 0 != runtimeCore.RunningBlock)) { @@ -4427,7 +3436,6 @@ private void RETB_Handler() // Pop the frame as we are adding stackframes for language blocks as well - pratapa // Do not do this for the final Retb //if (runtimeCore.RunningBlock != 0) - if (!runtimeCore.Options.IDEDebugMode || runtimeCore.Options.RunMode == InterpreterMode.Expression) { rmem.FramePointer = (int)rmem.GetAtRelative(StackFrame.FrameIndexFramePointer).IntegerValue; rmem.PopFrame(StackFrame.StackFrameSize); @@ -4466,10 +3474,7 @@ private void RETB_Handler() private void RETCN_Handler(Instruction instruction) { - if (runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - runtimeCore.RuntimeMemory.PopConstructBlockId(); - } + runtimeCore.RuntimeMemory.PopConstructBlockId(); StackValue op1 = instruction.op1; int blockId = op1.BlockIndex; @@ -4508,18 +3513,6 @@ private void RETURN_Handler() { runtimeVerify(rmem.ValidateStackFrame()); - if (runtimeCore.Options.ExecuteSSA) - { - if (runtimeCore.Options.GCTempVarsOnDebug && runtimeCore.Options.IDEDebugMode) - { - // GC anonymous variables in the return stmt - if (null != Properties.executingGraphNode && !Properties.executingGraphNode.IsSSANode()) - { - Properties.executingGraphNode.symbolListWithinExpression.Clear(); - } - } - } - RestoreFromCall(); } @@ -4604,14 +3597,7 @@ private void DEP_Handler(Instruction instruction) int classIndex = Constants.kInvalidIndex; int functionIndex = Constants.kGlobalScope; bool isInFunction = GetCurrentScope(out classIndex, out functionIndex); - - if (runtimeCore.Options.IDEDebugMode && runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - Validity.Assert(runtimeCore.DebugProps.DebugStackFrame.Count > 0); - { - isInFunction = runtimeCore.DebugProps.DebugStackFrameContains(DebugProperties.StackFrameFlagOptions.FepRun); - } - } + isInFunction = false; if (isInFunction) { @@ -4629,28 +3615,6 @@ private void DEP_Handler(Instruction instruction) istream.xUpdateList.Add(Properties.executingGraphNode.updateNodeRefList[0]); } } - if (runtimeCore.Options.ExecuteSSA) - { - if (runtimeCore.Options.GCTempVarsOnDebug && runtimeCore.Options.IDEDebugMode) - { - if (!Properties.executingGraphNode.IsSSANode()) - { - bool isSetter = Properties.executingGraphNode.updateNodeRefList[0].nodeList.Count > 1; - var symbols = Properties.executingGraphNode.symbolListWithinExpression; - - if (isSetter) - { - int count = symbols.Count; - if (count > 0) - { - symbols = symbols.Take(count - 1).ToList(); - } - } - - Properties.executingGraphNode.symbolListWithinExpression.Clear(); - } - } - } if (runtimeCore.Options.ExecuteSSA) { @@ -4737,13 +3701,6 @@ private void JDEP_Handler(Instruction instruction) int functionIndex = Constants.kGlobalScope; bool isInFunction = GetCurrentScope(out classIndex, out functionIndex); - - if (runtimeCore.Options.IDEDebugMode && runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - Validity.Assert(runtimeCore.DebugProps.DebugStackFrame.Count > 0); - isInFunction = runtimeCore.DebugProps.DebugStackFrameContains(DebugProperties.StackFrameFlagOptions.FepRun); - } - if (isInFunction) { ci = classIndex; @@ -4853,20 +3810,6 @@ private void PUSHDEP_Handler(Instruction instruction) private void SETEXPUID_Handler() { - if (runtimeCore.Options.IDEDebugMode && runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - if (runtimeCore.DebugProps.RunMode == Runmode.StepNext) - { - if (!runtimeCore.DebugProps.DebugStackFrameContains(DebugProperties.StackFrameFlagOptions.IsFunctionStepOver)) - { - // if ec is at end of an expression in imperative lang block - // we force restore the breakpoints - runtimeCore.Breakpoints.Clear(); - runtimeCore.Breakpoints.AddRange(runtimeCore.DebugProps.AllbreakPoints); - } - } - } - pc++; } @@ -4906,12 +3849,6 @@ private void Exec(Instruction instruction) return; } - case OpCode.PUSHW: - { - PUSHW_Handler(instruction); - return; - } - case OpCode.PUSHBLOCK: { PUSHB_Handler(instruction); @@ -4966,12 +3903,6 @@ private void Exec(Instruction instruction) return; } - case OpCode.POPW: - { - POPW_Handler(instruction); - return; - } - case OpCode.POPM: { POPM_Handler(instruction); diff --git a/src/Engine/ProtoCore/DSASM/InstructionSet.cs b/src/Engine/ProtoCore/DSASM/InstructionSet.cs index 801c4d50351..5f47dcfca7b 100644 --- a/src/Engine/ProtoCore/DSASM/InstructionSet.cs +++ b/src/Engine/ProtoCore/DSASM/InstructionSet.cs @@ -74,12 +74,10 @@ public enum OpCode PUSH, PUSHBLOCK, // Push construction block id in imperative code PUSHM, - PUSHW, PUSHDEP, // Push symbols in left-hand-side identifier list in impertiave langauge block PUSHREPGUIDE, // Push replicaion guide to the stack PUSHLEVEL, // Push at-level to the stak POP, - POPW, POPM, POPREPGUIDES, // Pop replication guides from stack and save to the core @@ -1085,42 +1083,5 @@ public class Instruction public Operand op1; // Comment Jun: Aliasing StackValue to Operand only here ... to make it clear that an instruction has operands public Operand op2; public Operand op3; - public DebugInfo debug; - } - - public class DebugInfo - { - public ProtoCore.CodeModel.CodeRange Location { get; set; } - public List nextStep; - - public DebugInfo(int line, int col, int eline, int ecol, string file = null) - { - InitializeDebugInfo(line, col, eline, ecol, file); - } - - private void InitializeDebugInfo(int line, int col, int eline, int ecol, string file) - { - nextStep = new List(); - - CodeModel.CodeFile sourceLocation = new CodeModel.CodeFile { FilePath = file }; - ProtoCore.CodeModel.CodeRange range = new CodeModel.CodeRange - { - StartInclusive = new CodeModel.CodePoint - { - LineNo = line, - CharNo = col, - SourceLocation = sourceLocation - }, - - EndExclusive = new CodeModel.CodePoint - { - LineNo = eline, - CharNo = ecol, - SourceLocation = sourceLocation - } - }; - - Location = range; - } } } diff --git a/src/Engine/ProtoCore/DSASM/Interpreter.cs b/src/Engine/ProtoCore/DSASM/Interpreter.cs index 568ab9642ec..1e10c7c6006 100644 --- a/src/Engine/ProtoCore/DSASM/Interpreter.cs +++ b/src/Engine/ProtoCore/DSASM/Interpreter.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace ProtoCore.DSASM { @@ -16,10 +16,10 @@ public void Push(StackValue val) runtime.rmem.Push(val); } - public StackValue Run(int codeblock = Constants.kInvalidIndex, int entry = Constants.kInvalidIndex, Language lang = Language.NotSpecified, List breakpoints = null) + public StackValue Run(int codeblock = Constants.kInvalidIndex, int entry = Constants.kInvalidIndex, Language lang = Language.NotSpecified) { runtime.RX = StackValue.Null; - runtime.Execute(codeblock, entry, breakpoints, lang); + runtime.Execute(codeblock, entry, lang); return runtime.RX; } } diff --git a/src/Engine/ProtoCore/DSASM/Mirror/ExecutionMirror.cs b/src/Engine/ProtoCore/DSASM/Mirror/ExecutionMirror.cs index 534610d1e9f..b839bb5fa2b 100644 --- a/src/Engine/ProtoCore/DSASM/Mirror/ExecutionMirror.cs +++ b/src/Engine/ProtoCore/DSASM/Mirror/ExecutionMirror.cs @@ -358,21 +358,6 @@ private int GetSymbolIndex(string name, out int ci, ref int block, out SymbolNod ci = Constants.kInvalidIndex; int functionBlock = Constants.kGlobalScope; - if (runtimeCore.DebugProps.DebugStackFrameContains(DebugProperties.StackFrameFlagOptions.FepRun)) - { - ci = runtimeCore.watchClassScope = rmem.CurrentStackFrameClassScope; - functionIndex = rmem.CurrentStackFrameFunctionScope; - functionBlock = rmem.CurrentStackFrameFunctionBlock; - } - - // TODO Jun: 'block' is incremented only if there was no other block provided by the programmer - // This is only to address NUnit issues when retrieving a global variable - // Some predefined functions are hard coded in the AST so isSingleAssocBlock will never be true - //if (exe.isSingleAssocBlock) - //{ - // ++block; - //} - int index = -1; if (ci != Constants.kInvalidIndex) { @@ -559,43 +544,6 @@ public string GetType(Obj obj) } } - public Obj GetWatchValue() - { - RuntimeCore runtimeCore = MirrorTarget.RuntimeCore; - int count = runtimeCore.watchStack.Count; - int n = runtimeCore.WatchSymbolList.FindIndex(x => { return string.Equals(x.name, Constants.kWatchResultVar); }); - - if (n < 0 || n >= count) - { - runtimeCore.WatchSymbolList.Clear(); - return new Obj { Payload = null }; - } - - Obj retVal = null; - try - { - StackValue sv = runtimeCore.watchStack[n]; - if (!sv.IsInvalid) - { - retVal = Unpack(runtimeCore.watchStack[n], MirrorTarget.rmem.Heap, runtimeCore); - } - else - { - retVal = new Obj { Payload = null }; - } - } - catch - { - retVal = new Obj { Payload = null }; - } - finally - { - runtimeCore.WatchSymbolList.Clear(); - } - - return retVal; - } - // // 1. Get the graphnode given the varname // 2. Get the sv of the symbol diff --git a/src/Engine/ProtoCore/DebuggerProperties.cs b/src/Engine/ProtoCore/DebuggerProperties.cs index c0b9bede930..8f21c70e109 100644 --- a/src/Engine/ProtoCore/DebuggerProperties.cs +++ b/src/Engine/ProtoCore/DebuggerProperties.cs @@ -1,13 +1,7 @@ using System; using System.Collections.Generic; using ProtoCore.AssociativeGraph; -using ProtoCore.CodeModel; using ProtoCore.DSASM; -using ProtoCore.Lang.Replication; -using ProtoCore.Runtime; -using ProtoCore.Utils; - -using StackFrame = ProtoCore.DSASM.StackFrame; namespace ProtoCore { @@ -38,567 +32,6 @@ public ConsoleEventSink() } } - public enum ReasonForExecutionSuspend - { - PreStart, - Breakpoint, - Exception, - Warning, - EndOfFile, - NoEntryPoint, - VMSplit - - } - - public enum Runmode - { - RunTo, StepNext, StepIn, StepOut - } - - public class DebugFrame - { - public DebugFrame() - { - IsReplicating = false; - IsExternalFunction = false; - IsBaseCall = false; - IsDotCall = false; - IsInlineConditional = false; - IsMemberFunction = false; - IsDisposeCall = false; - HasDebugInfo = false; - - FinalFepChosen = null; - FunctionStepOver = false; - DotCallDimensions = null; - Arguments = null; - ThisPtr = null; - } - - public FunctionEndPoint FinalFepChosen { get; set; } - - // TODO: FepRun may no longer be needed as this may also be obtained from the language stack frame - pratapa - public int FepRun { get; set; } - public GraphNode ExecutingGraphNode { get; set; } - public List DotCallDimensions { get; set; } - public List Arguments { get; set; } - public StackValue? ThisPtr { get; set; } - - // Flag indicating whether execution cursor is being resumed from within the lang block or function - public bool IsResume { get; set; } - public bool IsReplicating { get; set; } - public bool IsExternalFunction { get; set; } - public bool IsBaseCall { get; set; } - public bool IsDotCall { get; set; } - public bool IsInlineConditional { get; set; } - public bool IsMemberFunction { get; set; } - public bool IsDisposeCall { get; set; } - public bool HasDebugInfo { get; set; } - - public bool FunctionStepOver { get; set; } - - } - - public class DebugProperties - { - public DebugProperties() - { - DebugStackFrame = new Stack(); - - isResume = false; - executingGraphNode = null; - ActiveBreakPoints = new List(); - AllbreakPoints = null; - FRStack = new Stack(); - FirstStackFrame = new StackFrame(1); - - DebugEntryPC = Constants.kInvalidIndex; - CurrentBlockId = Constants.kInvalidIndex; - StepOutReturnPC = Constants.kInvalidIndex; - ReturnPCFromDispose = Constants.kInvalidIndex; - IsPopmCall = false; - } - - public enum BreakpointOptions - { - None = 0x00000000, - EmitIdentifierBreakpoint = 0x00000001, - EmitPopForTempBreakpoint = 0x00000002, - EmitCallrForTempBreakpoint = 0x00000004, - EmitInlineConditionalBreakpoint = 0x00000008, - SuppressNullVarDeclarationBreakpoint = 0x00000010 - } - - public enum StackFrameFlagOptions - { - FepRun = 1, - IsReplicating, - IsExternalFunction, - IsFunctionStepOver - } - - // This field allows the code generator to selectively output DebugInfo - // for various parts of the code emission process. For an example, a - // regular identifier of variable would not generally output a DebugInfo - // object on the corresponding instruction. This can be temporary turned - // on (in some very limited cases) if desired. - // - // Moving forward we would introduce few more options in this enumeration - // to handle various cases. Note that since memory is reset when a struct - // is instantiated, the default value of "breakpointOptions" will be 0. - // Any flag introduced to "BreakpointOptions" enumeration will always be - // "turned off" by default. For flags that are usually turned on and only - // turned off in few scenarios, consider using a name that has the - // inversed meaning. For example function calls are always emitted, to - // suppress the emission in few cases, use the term along the line of - // "SuppressFunctionBreakpoint", which will by default absent. - // - private BreakpointOptions breakpointOptions = BreakpointOptions.None; - - public BreakpointOptions breakOptions - { - get { return breakpointOptions; } - set { breakpointOptions = value; } - } - - public StackFrame FirstStackFrame { get; set; } - - // Used in Watch test framework - public string CurrentSymbolName { get; set; } - public bool IsPopmCall { get; set; } - - public InlineConditional InlineConditionOptions = new InlineConditional - { - isInlineConditional = false, - startPc = Constants.kInvalidIndex, - endPc = Constants.kInvalidIndex, - instructionStream = 0, - ActiveBreakPoints = new List() - }; - - public CodeRange highlightRange = new CodeRange - { - StartInclusive = new CodePoint - { - LineNo = Constants.kInvalidIndex, - CharNo = Constants.kInvalidIndex - }, - - EndExclusive = new CodePoint - { - LineNo = Constants.kInvalidIndex, - CharNo = Constants.kInvalidIndex - } - }; - - /// - /// Returns the Program counter. This is only valid when the executive is suspended - /// - public int DebugEntryPC { get; set; } - // used by the code gen to insert the file name to the instruction - - // this is needed because in the if/for/while structure, the core.runningBlock is its parent's block id, not its own - // we will not be able to inspect the local variable in these structures by using core.runningBlock as the current block id - // - // core.runningBlock is updated only at Bounce opcode - // the instructions of if/for/while stay in their parent instruction stream but there symbols stay in their own symbol tables - public int CurrentBlockId { get; set; } - public bool isResume { get; set; } - public int StepOutReturnPC { get; set; } - public Stack FRStack { get; set; } - public GraphNode executingGraphNode { get; set; } - public List deferedGraphnodes { get; set; } - public List ActiveBreakPoints { get; set; } - - public List AllbreakPoints { get; set; } - public Runmode RunMode { get; set; } - public int ReturnPCFromDispose { get; set; } - - public Stack DebugStackFrame { get; set; } - - public bool DebugStackFrameContains(StackFrameFlagOptions option) - { - foreach (DebugFrame debugFrame in DebugStackFrame) - { - if(option == StackFrameFlagOptions.FepRun) - { - if (debugFrame.FepRun == 1) - { - return true; - } - } - else if (option == StackFrameFlagOptions.IsReplicating) - { - if(debugFrame.IsReplicating) - { - return true; - } - } - else if (option == StackFrameFlagOptions.IsExternalFunction) - { - if (debugFrame.IsExternalFunction) - { - return true; - } - } - else if (option == StackFrameFlagOptions.IsFunctionStepOver) - { - if (debugFrame.FunctionStepOver) - { - return true; - } - } - } - return false; - } - - private int FindEndPCForAssocGraphNode(int tempPC, InstructionStream istream, ProcedureNode fNode, GraphNode graphNode, bool handleSSATemps) - { - int limit = Constants.kInvalidIndex; - GraphNode currentGraphNode = graphNode; - - if (currentGraphNode != null) - { - if (tempPC < currentGraphNode.updateBlock.startpc || tempPC > currentGraphNode.updateBlock.endpc) - { - return Constants.kInvalidIndex; - } - - int i = currentGraphNode.dependencyGraphListID; - GraphNode nextGraphNode = currentGraphNode; - while (currentGraphNode.exprUID != Constants.kInvalidIndex - && currentGraphNode.exprUID == nextGraphNode.exprUID) - - { - limit = nextGraphNode.updateBlock.endpc; - if (++i < istream.dependencyGraph.GraphList.Count) - { - nextGraphNode = istream.dependencyGraph.GraphList[i]; - } - else - { - break; - } - - // Is it the next statement - // This check will be deprecated on full SSA - if (handleSSATemps) - { - if (!nextGraphNode.IsSSANode()) - { - // The next graphnode is nolonger part of the current statement - // This is the end pc needed to run until - nextGraphNode = istream.dependencyGraph.GraphList[i]; - limit = nextGraphNode.updateBlock.endpc; - break; - } - } - } - } - // If graph node is null in associative lang block, it either is the very first property declaration or - // it is the very first or only function call statement ("return = f();") inside the calling function - // Here there's most likely a DEP or RETURN respectively after the function call - // in which case, search for the instruction and set that as the new pc limit - else if (!fNode.Name.Contains(Constants.kSetterPrefix)) - { - while (++tempPC < istream.instrList.Count) - { - Instruction instr = istream.instrList[tempPC]; - if (instr.opCode == OpCode.DEP || instr.opCode == OpCode.RETURN) - { - limit = tempPC; - break; - } - } - } - return limit; - } - - public void SetUpBounce(DSASM.Executive exec, int exeblock, int returnAddr) - { - DebugFrame debugFrame = new DebugFrame(); - - // TODO: Replace FepRun with StackFrameTypeinfo from Core.Rmem.Stack - pratapa - debugFrame.FepRun = 0; - debugFrame.IsResume = false; - - if (exec != null) - { - debugFrame.ExecutingGraphNode = exec.Properties.executingGraphNode; - - } - else - debugFrame.ExecutingGraphNode = null; - - DebugStackFrame.Push(debugFrame); - } - - private void SetUpCallr(ref DebugFrame debugFrame, bool isReplicating, bool isExternalFunc, DSASM.Executive exec, int fepRun = 1) - { - // There is no corresponding RETURN instruction for external functions such as FFI's and dot calls - //if (procNode.name != DSDefinitions.Kw.kw_Dispose) - { - debugFrame.IsExternalFunction = isExternalFunc; - debugFrame.IsReplicating = isReplicating; - - // TODO: Replace FepRun with StackFrameTypeinfo from Core.Rmem.Stack - pratapa - debugFrame.FepRun = fepRun; - debugFrame.IsResume = false; - debugFrame.ExecutingGraphNode = exec.Properties.executingGraphNode; - - } - } - - public void SetUpCallrForDebug(RuntimeCore runtimeCore, DSASM.Executive exec, ProcedureNode fNode, int pc, bool isBaseCall = false, - CallSite callsite = null, List arguments = null, List> replicationGuides = null, StackFrame stackFrame = null, - List dotCallDimensions = null, bool hasDebugInfo = false, bool isMember = false, StackValue? thisPtr = null) - { - //ProtoCore.DSASM.Executive exec = core.CurrentExecutive.CurrentDSASMExec; - - DebugFrame debugFrame = new DebugFrame(); - debugFrame.IsBaseCall = isBaseCall; - debugFrame.Arguments = arguments; - debugFrame.IsMemberFunction = isMember; - debugFrame.ThisPtr = thisPtr; - debugFrame.HasDebugInfo = hasDebugInfo; - - if (CoreUtils.IsDisposeMethod(fNode.Name)) - { - debugFrame.IsDisposeCall = true; - ReturnPCFromDispose = DebugEntryPC; - } - - if (RunMode == Runmode.StepNext) - { - debugFrame.FunctionStepOver = true; - } - - bool isReplicating = false; - bool isExternalFunction = false; - - // callsite is set to null for a base class constructor call in CALL - if (callsite == null) - { - isReplicating = false; - isExternalFunction = false; - - SetUpCallr(ref debugFrame, isReplicating, isExternalFunction, exec); - DebugStackFrame.Push(debugFrame); - - return; - } - - // Comment Jun: A dot call does not replicate and must be handled immediately - if (fNode.Name == Constants.kDotMethodName) - { - isReplicating = false; - isExternalFunction = false; - debugFrame.IsDotCall = true; - debugFrame.DotCallDimensions = dotCallDimensions; - - SetUpCallr(ref debugFrame, isReplicating, isExternalFunction, exec); - DebugStackFrame.Push(debugFrame); - - return; - } - - List> replicationTrials; - bool willReplicate = callsite.WillCallReplicate(new Context(), arguments, replicationGuides, stackFrame, runtimeCore, out replicationTrials); - - // the inline conditional built-in is handled separately as 'WillCallReplicate' is always true in this case - if(fNode.Name.Equals(Constants.kInlineConditionalMethodName)) - { - // The inline conditional built-in is created only for associative blocks and needs to be handled separately as below - InstructionStream istream = runtimeCore.DSExecutable.instrStreamList[CurrentBlockId]; - Validity.Assert(istream.language == Language.Associative); - { - runtimeCore.DebugProps.InlineConditionOptions.isInlineConditional = true; - runtimeCore.DebugProps.InlineConditionOptions.startPc = pc; - - runtimeCore.DebugProps.InlineConditionOptions.endPc = FindEndPCForAssocGraphNode(pc, istream, fNode, exec.Properties.executingGraphNode, runtimeCore.Options.ExecuteSSA); - - - runtimeCore.DebugProps.InlineConditionOptions.instructionStream = runtimeCore.RunningBlock; - debugFrame.IsInlineConditional = true; - } - - // no replication case - if (willReplicate && replicationTrials.Count == 1) - { - runtimeCore.DebugProps.InlineConditionOptions.ActiveBreakPoints.AddRange(runtimeCore.Breakpoints); - - isReplicating = false; - isExternalFunction = false; - } - else // an inline conditional call that replicates - { - // Clear all breakpoints for outermost replicated call - if(!DebugStackFrameContains(StackFrameFlagOptions.IsReplicating)) - { - ActiveBreakPoints.AddRange(runtimeCore.Breakpoints); - runtimeCore.Breakpoints.Clear(); - } - isExternalFunction = false; - isReplicating = true; - } - SetUpCallr(ref debugFrame, isReplicating, isExternalFunction, exec, 0); - - DebugStackFrame.Push(debugFrame); - - return; - } - // Prevent breaking inside a function that is external except for dot calls - // by clearing all breakpoints from outermost external function call - // This check takes precedence over the replication check - else if (fNode.IsExternal && fNode.Name != Constants.kDotMethodName) - { - // Clear all breakpoints - if (!DebugStackFrameContains(StackFrameFlagOptions.IsExternalFunction) && fNode.Name != Constants.kFunctionRangeExpression) - { - ActiveBreakPoints.AddRange(runtimeCore.Breakpoints); - runtimeCore.Breakpoints.Clear(); - } - - isExternalFunction = true; - isReplicating = false; - } - // Find if function call will replicate or not and if so - // prevent stepping in by removing all breakpoints from outermost replicated call - else if (willReplicate) - { - // Clear all breakpoints for outermost replicated call - if(!DebugStackFrameContains(StackFrameFlagOptions.IsReplicating)) - { - ActiveBreakPoints.AddRange(runtimeCore.Breakpoints); - runtimeCore.Breakpoints.Clear(); - } - - isReplicating = true; - isExternalFunction = false; - } - // For all other function calls - else - { - isReplicating = false; - isExternalFunction = false; - } - - SetUpCallr(ref debugFrame, isReplicating, isExternalFunction, exec); - DebugStackFrame.Push(debugFrame); - } - - /// - /// Called only when we step over a function (including replicated and external functions) - /// Pops Debug stackframe and Restores breakpoints - /// - /// - /// - /// - public void RestoreCallrForNoBreak(RuntimeCore runtimeCore, ProcedureNode fNode, bool isReplicating = false) - { - Validity.Assert(DebugStackFrame.Count > 0); - - // All functions that reach this point are restored here as they have not been - // done so in RETURN/RETC - DebugFrame debugFrame = DebugStackFrame.Pop(); - - // Restore breakpoints which occur after returning from outermost replicating function call - // as well as outermost external function call - if (!DebugStackFrameContains(StackFrameFlagOptions.IsReplicating) && - !DebugStackFrameContains(StackFrameFlagOptions.IsExternalFunction)) - { - if (ActiveBreakPoints.Count > 0 && fNode.Name != Constants.kFunctionRangeExpression) - { - runtimeCore.Breakpoints.AddRange(ActiveBreakPoints); - //if (SetUpStepOverFunctionCalls(core, fNode, ActiveBreakPoints)) - { - ActiveBreakPoints.Clear(); - } - } - } - - // If stepping over function call in debug mode - if (debugFrame.HasDebugInfo && RunMode == Runmode.StepNext) - { - // if stepping over outermost function call - if (!DebugStackFrameContains(StackFrameFlagOptions.IsFunctionStepOver)) - { - SetUpStepOverFunctionCalls(runtimeCore, fNode, debugFrame.ExecutingGraphNode, debugFrame.HasDebugInfo); - } - } - } - - public void SetUpStepOverFunctionCalls(RuntimeCore runtimeCore, ProcedureNode fNode, GraphNode graphNode, bool hasDebugInfo) - { - int tempPC = DebugEntryPC; - int limit = 0; // end pc of current expression - InstructionStream istream; - - int pc = tempPC; - if (runtimeCore.DebugProps.InlineConditionOptions.isInlineConditional) - { - tempPC = InlineConditionOptions.startPc; - limit = InlineConditionOptions.endPc; - istream = runtimeCore.DSExecutable.instrStreamList[InlineConditionOptions.instructionStream]; - } - else - { - pc = tempPC; - istream = runtimeCore.DSExecutable.instrStreamList[runtimeCore.RunningBlock]; - if (istream.language == Language.Associative) - { - limit = FindEndPCForAssocGraphNode(pc, istream, fNode, graphNode, runtimeCore.Options.ExecuteSSA); - //Validity.Assert(limit != ProtoCore.DSASM.Constants.kInvalidIndex); - } - else if (istream.language == Language.Imperative) - { - // Check for 'SETEXPUID' instruction to check for end of expression - while (++pc < istream.instrList.Count) - { - Instruction instr = istream.instrList[pc]; - if (instr.opCode == OpCode.SETEXPUID) - { - limit = pc; - break; - } - } - } - } - - // Determine if this is outermost CALLR in the expression - // until then do not restore any breakpoints - // If outermost CALLR, restore breakpoints after end of expression - pc = tempPC; - int numNestedFunctionCalls = 0; - while (++pc <= limit) - { - Instruction instr = istream.instrList[pc]; - if (instr.opCode == OpCode.CALLR && instr.debug != null) - { - numNestedFunctionCalls++; - } - } - if (numNestedFunctionCalls == 0) - { - // If this is the outermost function call - runtimeCore.Breakpoints.Clear(); - runtimeCore.Breakpoints.AddRange(AllbreakPoints); - - pc = tempPC; - while (++pc <= limit) - { - Instruction instr = istream.instrList[pc]; - // We still want to break at the closing brace of a function or ctor call or language block - if (instr.debug != null && instr.opCode != OpCode.RETURN && (instr.opCode != OpCode.RETB)) - { - if (runtimeCore.Breakpoints.Contains(instr)) - runtimeCore.Breakpoints.Remove(instr); - } - } - } - } - } - public class ExecutionStateEventArgs : EventArgs { public enum State diff --git a/src/Engine/ProtoCore/Executive.cs b/src/Engine/ProtoCore/Executive.cs index 4bd1bd75662..ab491bc7cfe 100644 --- a/src/Engine/ProtoCore/Executive.cs +++ b/src/Engine/ProtoCore/Executive.cs @@ -15,14 +15,13 @@ public Executive (RuntimeCore runtimeCore) public ProtoCore.DSASM.Executive CurrentDSASMExec { get; set; } - public StackValue Execute(int codeblock, int entry, bool fepRun = false, System.Collections.Generic.List breakpoints = null) + public StackValue Execute(int codeblock, int entry, bool fepRun = false) { ProtoCore.DSASM.Interpreter interpreter = new ProtoCore.DSASM.Interpreter(runtimeCore, fepRun); CurrentDSASMExec = interpreter.runtime; - return interpreter.Run(codeblock, entry, CurrentDSASMExec.executingLanguage, breakpoints); + return interpreter.Run(codeblock, entry, CurrentDSASMExec.executingLanguage); } } } - \ No newline at end of file diff --git a/src/Engine/ProtoCore/FFI/FFIExecutionManager.cs b/src/Engine/ProtoCore/FFI/FFIExecutionManager.cs index ec6817f9261..8c09a6dbeb0 100644 --- a/src/Engine/ProtoCore/FFI/FFIExecutionManager.cs +++ b/src/Engine/ProtoCore/FFI/FFIExecutionManager.cs @@ -159,11 +159,6 @@ public string[] IncludeDirectories get { return runtimeCore.Options.IncludeDirectories.ToArray(); } } - public bool IsDebugMode - { - get { return runtimeCore.Options.IDEDebugMode; } - } - public object GetConfigValue(string config) { object value = null; diff --git a/src/Engine/ProtoCore/Lang/BuiltInFunctionEndPoint.cs b/src/Engine/ProtoCore/Lang/BuiltInFunctionEndPoint.cs index 896800a6fc5..5275b8518ff 100644 --- a/src/Engine/ProtoCore/Lang/BuiltInFunctionEndPoint.cs +++ b/src/Engine/ProtoCore/Lang/BuiltInFunctionEndPoint.cs @@ -396,13 +396,6 @@ public override StackValue Execute(ProtoCore.Runtime.Context c, List case BuiltInMethods.MethodID.ImportData: ret = ContextDataBuiltIns.ImportData(formalParameters[0], formalParameters[1], runtimeCore, interpreter, c); break; - case BuiltInMethods.MethodID.Break: - { - DebuggerBuiltIns.Break(interpreter, stackFrame); - ret = StackValue.Null; - break; - } - case BuiltInMethods.MethodID.GetKeys: { StackValue array = formalParameters[0]; @@ -561,11 +554,11 @@ private StackValue InlineConditionalMethod(List formalParameters, Pr StackFrameType callerType = stackFrame.StackFrameType; - blockCaller = runtimeCore.DebugProps.CurrentBlockId; + blockCaller = 0; //Need to figure out how to get this here StackFrame bounceStackFrame = new StackFrame(svThisPtr, ci, fi, returnAddr, blockDecl, blockCaller, callerType, type, depth, framePointer, 0, interpreter.runtime.GetRegisters(), 0); - StackValue ret = interpreter.runtime.Bounce(blockId, 0, bounceStackFrame, 0, false, runtimeCore.CurrentExecutive.CurrentDSASMExec, runtimeCore.Breakpoints); + StackValue ret = interpreter.runtime.Bounce(blockId, 0, bounceStackFrame, 0, false, runtimeCore.CurrentExecutive.CurrentDSASMExec); runtimeCore.RunningBlock = oldRunningBlockId; return ret; @@ -718,39 +711,11 @@ private StackValue DotMethod(StackValue lhs, StackFrame stackFrame, DSASM.Execut ProtoCore.CallSite callsite = runtimeData.GetCallSite( thisObjectType, functionName, runtime.exe, runtimeCore); Validity.Assert(null != callsite); - // TODO: Disabling support for stepping into replicated function calls temporarily - pratapa - if (runtimeCore.Options.IDEDebugMode && - runtimeCore.Options.RunMode != InterpreterMode.Expression && - procNode != null) - { - runtimeCore.DebugProps.SetUpCallrForDebug( - runtimeCore, - runtimeCore.CurrentExecutive.CurrentDSASMExec, - procNode, - stackFrame.ReturnPC - 1, - false, callsite, - arguments, - replicationGuides, - newStackFrame, - null, - false, - true, - thisObject); - } - var argumentAtLevels = AtLevelHandler.GetArgumentAtLevelStructure(arguments, atLevels, runtimeCore); argumentAtLevels.Arguments.ForEach(x => runtimeCore.AddCallSiteGCRoot(callsite.CallSiteID, x)); StackValue ret = callsite.JILDispatchViaNewInterpreter(context, argumentAtLevels.Arguments, replicationGuides, argumentAtLevels.DominantStructure, newStackFrame, runtimeCore); runtimeCore.RemoveCallSiteGCRoot(callsite.CallSiteID); - // Restore debug properties after returning from a CALL/CALLR - if (runtimeCore.Options.IDEDebugMode && - runtimeCore.Options.RunMode != InterpreterMode.Expression && - procNode != null) - { - runtimeCore.DebugProps.RestoreCallrForNoBreak(runtimeCore, procNode); - } - return ret; } } @@ -819,46 +784,7 @@ internal static int GetElapsedTime(ProtoCore.DSASM.Interpreter runtime) return ms; } } - internal class DebuggerBuiltIns - { - // set a breakpoint at the next breakable instruction - internal static void Break(Interpreter interpreter, StackFrame stackFrame) - { - RuntimeCore runtimeCore = interpreter.runtime.RuntimeCore; - if (!runtimeCore.Options.IDEDebugMode) - return; - - if (runtimeCore.DebugProps.DebugStackFrameContains(DebugProperties.StackFrameFlagOptions.IsReplicating)) - return; - - // Search for next breakable instruction in list of instructions and add to RegisteredBreakPoints - - int pc = stackFrame.ReturnPC; - int blockId = stackFrame.FunctionCallerBlock; - List instructions = runtimeCore.DSExecutable.instrStreamList[blockId].instrList; - - // Search instructions from DebugEntryPC onwards for the next breakpoint and add it to current list of breakpoints - // if there is a bounce, then jump to new lang block and continue searching - while (pc < instructions.Count) - { - if (instructions[pc].debug != null) - { - if(!runtimeCore.Breakpoints.Contains(instructions[pc])) - runtimeCore.Breakpoints.Add(instructions[pc]); - break; - } - else if (instructions[pc].opCode == OpCode.BOUNCE) - { - blockId = instructions[pc].op1.BlockIndex; - instructions = runtimeCore.DSExecutable.instrStreamList[blockId].instrList; - pc = 0; - continue; - } - pc++; - } - - } - } + internal class FileIOBuiltIns { //This Function is to Restore a String Type StackValue to a String diff --git a/src/Engine/ProtoCore/Lang/BuiltInMethods.cs b/src/Engine/ProtoCore/Lang/BuiltInMethods.cs index 8db5af10fd9..85ca34b74f7 100644 --- a/src/Engine/ProtoCore/Lang/BuiltInMethods.cs +++ b/src/Engine/ProtoCore/Lang/BuiltInMethods.cs @@ -60,7 +60,6 @@ public enum MethodID Transpose, Union, InlineConditional, - Break, GetKeys, GetValues, RemoveKey, @@ -126,7 +125,6 @@ public enum MethodID "Transpose", // kTranspose "SetUnion", // kUnion Constants.kInlineConditionalMethodName, - "Break", // kBreak "GetKeys", // kGetKeys "GetValues", // kGetValues "RemoveKey", // kRemoveKey @@ -846,14 +844,6 @@ public BuiltInMethods(Core core) ID = BuiltInMethods.MethodID.ToStringFromArrayAndFormat }, - new BuiltInMethod - { - ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.Void, 0), - Parameters = new List>(), - ID = BuiltInMethods.MethodID.Break, - MethodAttributes = new MethodAttributes(true), - }, - new BuiltInMethod { ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.Var, Constants.kArbitraryRank), diff --git a/src/Engine/ProtoCore/Lang/CallSite.cs b/src/Engine/ProtoCore/Lang/CallSite.cs index db237faa6c3..d5b64cb4136 100644 --- a/src/Engine/ProtoCore/Lang/CallSite.cs +++ b/src/Engine/ProtoCore/Lang/CallSite.cs @@ -1740,12 +1740,6 @@ private StackValue ExecWithZeroRI(List functionEndPoint, Conte return StackValue.Null; } - if (runtimeCore.Options.IDEDebugMode && runtimeCore.Options.RunMode != InterpreterMode.Expression) - { - DebugFrame debugFrame = runtimeCore.DebugProps.DebugStackFrame.Peek(); - debugFrame.FinalFepChosen = finalFep; - } - List coercedParameters = finalFep.CoerceParameters(formalParameters, runtimeCore); // Correct block id where the function is defined. diff --git a/src/Engine/ProtoCore/Lang/FunctionPointerEvaluator.cs b/src/Engine/ProtoCore/Lang/FunctionPointerEvaluator.cs index 71911ba0520..1778b70fca9 100644 --- a/src/Engine/ProtoCore/Lang/FunctionPointerEvaluator.cs +++ b/src/Engine/ProtoCore/Lang/FunctionPointerEvaluator.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using ProtoCore.DSASM; using ProtoCore.Exceptions; using ProtoCore.Properties; @@ -122,22 +122,6 @@ public StackValue Evaluate(List args, StackFrame stackFrame) interpreter.runtime.GetRegisters(), 0); - bool isInDebugMode = runtimeCore.Options.IDEDebugMode && - runtimeCore.Options.RunMode != InterpreterMode.Expression; - if (isInDebugMode) - { - runtimeCore.DebugProps.SetUpCallrForDebug( - runtimeCore, - interpreter.runtime, - procNode, - returnAddr - 1, - false, - callsite, - args, - new List>(), - newStackFrame); - } - StackValue rx = callsite.JILDispatchViaNewInterpreter( new Runtime.Context(), args, @@ -146,11 +130,6 @@ public StackValue Evaluate(List args, StackFrame stackFrame) newStackFrame, runtimeCore); - if (isInDebugMode) - { - runtimeCore.DebugProps.RestoreCallrForNoBreak(runtimeCore, procNode); - } - return rx; } diff --git a/src/Engine/ProtoCore/Lang/JILFunctionEndPoint.cs b/src/Engine/ProtoCore/Lang/JILFunctionEndPoint.cs index b9eae6bc9cd..7d6a920287d 100644 --- a/src/Engine/ProtoCore/Lang/JILFunctionEndPoint.cs +++ b/src/Engine/ProtoCore/Lang/JILFunctionEndPoint.cs @@ -1,4 +1,4 @@ - + using System.Collections.Generic; using ProtoCore.DSASM; using ProtoCore.Lang.Replication; @@ -138,7 +138,7 @@ public override StackValue Execute(ProtoCore.Runtime.Context c, List } else { - svRet = interpreter.Run(runtimeCore.RunningBlock, activation.pc, Language.NotSpecified, runtimeCore.Breakpoints); + svRet = interpreter.Run(runtimeCore.RunningBlock, activation.pc, Language.NotSpecified); runtimeCore.RunningBlock = origRunningBlock; } diff --git a/src/Engine/ProtoCore/RuntimeCore.cs b/src/Engine/ProtoCore/RuntimeCore.cs index 57b80bce5fc..c0937752716 100644 --- a/src/Engine/ProtoCore/RuntimeCore.cs +++ b/src/Engine/ProtoCore/RuntimeCore.cs @@ -70,18 +70,9 @@ public RuntimeCore(Heap heap, Options options = null, Executable executable = nu RunningBlock = 0; ExecutionState = (int)ExecutionStateEventArgs.State.Invalid; //not yet started - ContinuationStruct = new ContinuationStructure(); - - - watchStack = new List(); - watchFramePointer = Constants.kInvalidIndex; - WatchSymbolList = new List(); - FunctionCallDepth = 0; cancellationPending = false; - watchClassScope = Constants.kInvalidIndex; - ExecutionInstance = CurrentExecutive = new Executive(this); ExecutiveProvider = new ExecutiveProvider(); @@ -107,20 +98,18 @@ public void SetupForExecution(ProtoCore.Core compileCore, int globalStackFrameSi } RunningBlock = 0; RuntimeStatus.MessageHandler = compileCore.BuildStatus.MessageHandler; - WatchSymbolList = compileCore.watchSymbolList; - SetProperties(compileCore.Options, compileCore.DSExecutable, compileCore.DebuggerProperties, null, compileCore.ExprInterpreterExe); + + SetProperties(compileCore.Options, compileCore.DSExecutable, null); RegisterDllTypes(compileCore.DllTypesToLoad); NotifyExecutionEvent(ProtoCore.ExecutionStateEventArgs.State.ExecutionBegin); LastDispatchedCallSite = null; } - public void SetProperties(Options runtimeOptions, Executable executable, DebugProperties debugProps = null, ProtoCore.Runtime.Context context = null, Executable exprInterpreterExe = null) + public void SetProperties(Options runtimeOptions, Executable executable, ProtoCore.Runtime.Context context = null) { this.Context = context; this.DSExecutable = executable; this.Options = runtimeOptions; - this.DebugProps = debugProps; - this.ExprInterpreterExe = exprInterpreterExe; } /// @@ -143,7 +132,6 @@ public void RegisterDllTypes(List dllTypes) // Execution properties public Executable DSExecutable { get; private set; } - public Executable ExprInterpreterExe { get; private set; } public Options Options { get; private set; } public RuntimeStatus RuntimeStatus { get; set; } public Stack InterpreterProps { get; set; } @@ -200,27 +188,6 @@ public bool CancellationPending return cancellationPending; } } - -#region DEBUGGER_PROPERTIES - - public int watchClassScope { get; set; } - - public DebugProperties DebugProps { get; set; } - public List Breakpoints { get; set; } - - // Continuation properties used for Serial mode execution and Debugging of Replicated calls - public ContinuationStructure ContinuationStruct { get; set; } - /// - /// Returns the reason why the execution was last suspended - /// - public ReasonForExecutionSuspend ReasonForExecutionSuspend { get; internal set; } - - - public List watchStack { get; set; } - public int watchFramePointer { get; set; } - - public List WatchSymbolList { get; set; } -#endregion private Dictionary> callsiteGCRoots = new Dictionary>(); /// @@ -302,7 +269,7 @@ public int GetCurrentBlockId() { int constructBlockId = RuntimeMemory.CurrentConstructBlockId; if (constructBlockId == Constants.kInvalidIndex) - return DebugProps.CurrentBlockId; + return 0; //Todo do we need this? CodeBlock constructBlock = ProtoCore.Utils.CoreUtils.GetCodeBlock(DSExecutable.CodeBlocks, constructBlockId); while (null != constructBlock && constructBlock.blockType == CodeBlockType.Construct) @@ -313,10 +280,7 @@ public int GetCurrentBlockId() if (null != constructBlock) constructBlockId = constructBlock.codeBlockId; - if (constructBlockId != DebugProps.CurrentBlockId) - return DebugProps.CurrentBlockId; - else - return RuntimeMemory.CurrentConstructBlockId; + return RuntimeMemory.CurrentConstructBlockId; } //STop diff --git a/src/Engine/ProtoCore/RuntimeStatus.cs b/src/Engine/ProtoCore/RuntimeStatus.cs index 5cbc5792d75..07db74f08d3 100644 --- a/src/Engine/ProtoCore/RuntimeStatus.cs +++ b/src/Engine/ProtoCore/RuntimeStatus.cs @@ -378,27 +378,7 @@ private void GetLocationByGraphNode(ref int line, ref int col) int startpc = prop.executingGraphNode.updateBlock.startpc; int endpc = prop.executingGraphNode.updateBlock.endpc; int block = prop.executingGraphNode.languageBlockId; - - // Determine if the current executing graph node is in an imported file scope - // If so, continue searching in the outer graph nodes for the line and col in the outer-most context - pratapa - - for (int i = startpc; i <= endpc; ++i) - { - var instruction = runtimeCore.DSExecutable.instrStreamList[block].instrList[i]; - if (instruction.debug != null) - { - if (instruction.debug.Location.StartInclusive.SourceLocation.FilePath != null) - { - fileScope = true; - break; - } - else - { - fileScope = false; - break; - } - } - } + if (fileScope) continue; diff --git a/src/Engine/ProtoCore/Utils/CoreUtils.cs b/src/Engine/ProtoCore/Utils/CoreUtils.cs index f35ac0161c4..517dc73b5df 100644 --- a/src/Engine/ProtoCore/Utils/CoreUtils.cs +++ b/src/Engine/ProtoCore/Utils/CoreUtils.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using ProtoCore.AST.AssociativeAST; using ProtoCore.DSASM; @@ -12,11 +12,8 @@ public static class CoreUtils public static void InsertPredefinedAndBuiltinMethods(Core core, CodeBlockNode root) { - if (DSASM.InterpreterMode.Normal == core.Options.RunMode) - { - InsertPredefinedMethod(core, root); - InsertBuiltInMethods(core, root); - } + InsertPredefinedMethod(core, root); + InsertBuiltInMethods(core, root); } private static FunctionDefinitionNode GenerateBuiltInMethodSignatureNode(Lang.BuiltInMethods.BuiltInMethod method) { diff --git a/src/Engine/ProtoImperative/CodeGen.cs b/src/Engine/ProtoImperative/CodeGen.cs index bed77a09d3a..2e06774bc7f 100644 --- a/src/Engine/ProtoImperative/CodeGen.cs +++ b/src/Engine/ProtoImperative/CodeGen.cs @@ -199,7 +199,6 @@ protected override void EmitReturn(int line = ProtoCore.DSASM.Constants.kInvalid AuditReturnLocationFromFunction(ref line, ref col, ref endline, ref endcol); ++pc; - instr.debug = GetDebugObject(line, col, endline, endcol, pc); codeBlock.instrStream.instrList.Add(instr); // TODO: Figure out why using AppendInstruction fails for adding these instructions to ExpressionInterpreter @@ -216,7 +215,6 @@ protected override void EmitRetb(int line = ProtoCore.DSASM.Constants.kInvalidIn AuditReturnLocationFromCodeBlock(ref line, ref col, ref endline, ref endcol); ++pc; - instr.debug = GetDebugObject(line, col, endline, endcol, pc); codeBlock.instrStream.instrList.Add(instr); // TODO: Figure out why using AppendInstruction fails for adding these instructions to ExpressionInterpreter @@ -233,7 +231,6 @@ protected override void EmitRetcn(int blockId = Constants.kInvalidIndex, int lin AuditReturnLocationFromCodeBlock(ref line, ref col, ref endline, ref endcol); ++pc; - instr.debug = GetDebugObject(line, col, endline, endcol, pc); codeBlock.instrStream.instrList.Add(instr); // TODO: Figure out why using AppendInstruction fails for adding these instructions to ExpressionInterpreter @@ -465,7 +462,6 @@ public override ProtoCore.DSASM.ProcedureNode TraverseFunctionCall(ProtoCore.AST // The function call EmitInstrConsole(ProtoCore.DSASM.kw.callr, procNode.Name); - DebugProperties.BreakpointOptions oldOptions = core.DebuggerProperties.breakOptions; if(procNode.Name.StartsWith(Constants.kSetterPrefix)) { EmitCall(procNode.ID, blockId, type, parentNode.line, parentNode.col, parentNode.endLine, parentNode.endCol); @@ -474,8 +470,7 @@ public override ProtoCore.DSASM.ProcedureNode TraverseFunctionCall(ProtoCore.AST { EmitCall(procNode.ID, blockId, type, bnode.line, bnode.col, bnode.endLine, bnode.endCol); } - else if (!procNode.Name.Equals(Constants.kFunctionRangeExpression) || - oldOptions.HasFlag(DebugProperties.BreakpointOptions.EmitCallrForTempBreakpoint)) + else if (!procNode.Name.Equals(Constants.kFunctionRangeExpression)) { EmitCall(procNode.ID, blockId, type, node.line, node.col, node.endLine, node.endCol); } @@ -610,7 +605,6 @@ localCodeBlockNode is IfStmtPositionNode || private int EmitExpressionInterpreter(ProtoCore.AST.Node codeBlockNode) { - core.watchStartPC = this.pc; ProtoCore.AST.ImperativeAST.CodeBlockNode codeblock = codeBlockNode as ProtoCore.AST.ImperativeAST.CodeBlockNode; ProtoCore.Type inferedType = new ProtoCore.Type(); @@ -622,20 +616,12 @@ private int EmitExpressionInterpreter(ProtoCore.AST.Node codeBlockNode) } core.InferedType = inferedType; - this.pc = core.watchStartPC; - return codeBlock.codeBlockId; } public override int Emit(ProtoCore.AST.Node codeBlockNode, ProtoCore.AssociativeGraph.GraphNode graphNode = null) { - core.watchStartPC = this.pc; - if (core.Options.RunMode == ProtoCore.DSASM.InterpreterMode.Expression) - { - return EmitExpressionInterpreter(codeBlockNode); - } - this.localCodeBlockNode = codeBlockNode; ProtoCore.AST.ImperativeAST.CodeBlockNode codeblock = codeBlockNode as ProtoCore.AST.ImperativeAST.CodeBlockNode; // Imperative language block would never be the top language block. @@ -1394,11 +1380,6 @@ private void EmitBinaryExpressionNode(ImperativeNode node, ref ProtoCore.Type in DfsTraverse(b.LeftNode, ref inferedType, isBooleanOperation, graphNode, ProtoCore.CompilerDefinitions.SubCompilePass.None, parentNode); - if (inferedType.UID == (int)PrimitiveType.FunctionPointer && emitDebugInfo) - { - buildStatus.LogSemanticError(Resources.FunctionPointerNotAllowedAtBinaryExpression, core.CurrentDSFileName, b.LeftNode.line, b.LeftNode.col); - } - leftType.UID = inferedType.UID; leftType.rank = inferedType.rank; } @@ -1514,11 +1495,6 @@ private void EmitBinaryExpressionNode(ImperativeNode node, ref ProtoCore.Type in if (b.Optr != Operator.assign) { - if (inferedType.UID == (int)PrimitiveType.FunctionPointer && emitDebugInfo) - { - var message = Resources.FunctionPointerNotAllowedAtBinaryExpression; - buildStatus.LogSemanticError(message, core.CurrentDSFileName, b.RightNode.line, b.RightNode.col); - } EmitBinaryOperation(leftType, rightType, b.Optr); return; @@ -1542,10 +1518,6 @@ private void EmitBinaryExpressionNode(ImperativeNode node, ref ProtoCore.Type in bool isAccessibleFp; int realType; var procNode = core.ClassTable.ClassNodes[globalClassIndex].GetMemberFunction(t.Name, null, globalClassIndex, out isAccessibleFp, out realType); - if (procNode != null && procNode.ID != Constants.kInvalidIndex && emitDebugInfo) - { - buildStatus.LogSemanticError(String.Format(Resources.FunctionAsVaribleError, t.Name), core.CurrentDSFileName, t.line, t.col); - } } bool isAccessible; @@ -1874,10 +1846,6 @@ private void EmitForLoopNode(ImperativeNode node, ref ProtoCore.Type inferredTyp x = x + val; } */ - DebugProperties.BreakpointOptions oldOptions = core.DebuggerProperties.breakOptions; - DebugProperties.BreakpointOptions newOptions = oldOptions; - newOptions |= DebugProperties.BreakpointOptions.EmitCallrForTempBreakpoint; - core.DebuggerProperties.breakOptions = newOptions; // TODO Jun: This compilation unit has many opportunities for optimization // 1. Compiling to while need not be necessary if 'expr' has exactly one element @@ -1945,18 +1913,8 @@ private void EmitForLoopNode(ImperativeNode node, ref ProtoCore.Type inferredTyp NodeUtils.UpdateBinaryExpressionLocation(arrayexprAssignment); - switch (forNode.Expression.GetType().ToString()) - { - case "ProtoCore.AST.ImperativeAST.IdentifierNode": - case "ProtoCore.AST.ImperativeAST.ExprListNode": - newOptions |= DebugProperties.BreakpointOptions.EmitPopForTempBreakpoint; - core.DebuggerProperties.breakOptions = newOptions; - break; - } - type.UID = (int)ProtoCore.PrimitiveType.Void; EmitBinaryExpressionNode(arrayexprAssignment, ref type, isBooleanOp, graphNode); - core.DebuggerProperties.breakOptions = oldOptions; // Restore breakpoint behaviors. // %counter = 0; var countIdent = GetForLoopCounter(); @@ -2109,14 +2067,7 @@ private void EmitInlineConditionalNode(ImperativeNode node, ref ProtoCore.Type i ifNode.IfBody = trueBody; ifNode.ElseBody = falseBody; - DebugProperties.BreakpointOptions oldOptions = core.DebuggerProperties.breakOptions; - DebugProperties.BreakpointOptions newOptions = oldOptions; - newOptions |= DebugProperties.BreakpointOptions.EmitInlineConditionalBreakpoint; - core.DebuggerProperties.breakOptions = newOptions; - EmitIfStmtNode(ifNode, ref inferedType, parentNode, true, graphNode); - - core.DebuggerProperties.breakOptions = oldOptions; } private void EmitRangeExprNode(ImperativeNode node, ref ProtoCore.Type inferedType, ProtoCore.AssociativeGraph.GraphNode graphNode = null) diff --git a/src/Engine/ProtoScript/Runners/DebugRunner.cs b/src/Engine/ProtoScript/Runners/DebugRunner.cs deleted file mode 100644 index 0c5d3bf70bf..00000000000 --- a/src/Engine/ProtoScript/Runners/DebugRunner.cs +++ /dev/null @@ -1,517 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using ProtoCore.DSASM; -using ProtoCore.DSASM.Mirror; -using ProtoCore.Lang; -using ProtoCore.Utils; - -namespace ProtoScript.Runners -{ - /// - /// Debug runner is intended for debug IDE etc. use, it starts a virtual machine in debug mode - /// These calls are blocking, but maintain a seperate VM Thread intfrastructure - /// - public class DebugRunner - { - private bool inited; - private bool executionsuspended; - private VMState lastState; - private ProtoCore.Core core; - public ProtoCore.RuntimeCore runtimeCore; - private String code; - private readonly List allbreakPoints = new List(); - public bool isEnded { get; set; } - - public VMState LastState - { - get - { - return lastState; - } - private set - { - lastState = value; - } - } - - public Instruction CurrentInstruction { get; private set; } - - int resumeBlockID; - public DebugRunner(ProtoCore.Core core) - { - this.core = core; - this.core.Options.IDEDebugMode = true; - RegisteredBreakpoints = new List(); - executionsuspended = false; - } - - private ProtoCore.RuntimeCore CreateRuntimeCore(ProtoCore.Core core) - { - ProtoCore.RuntimeCore runtimeCore = new ProtoCore.RuntimeCore(core.Heap); - runtimeCore.SetupForExecution(core, core.GlobOffset); - return runtimeCore; - } - - /// - /// Setup to run with customised launch options - /// - /// Ready to run? - /// - private bool _PreStart(string code, string fileName) - { - this.code = code; - if (null == core) - { - core = new ProtoCore.Core(new ProtoCore.Options { IDEDebugMode = true }); - core.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(core)); - core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core)); - - } - - - if (null != fileName) - { - core.CurrentDSFileName = Path.GetFullPath(fileName); - core.Options.RootModulePathName = Path.GetFullPath(fileName); - } - - //Run the compilation process - if (Compile(out resumeBlockID)) - { - inited = true; - runtimeCore = CreateRuntimeCore(core); - - FirstExec(); - BuildReverseIndex(); - return true; - } - else - { - inited = false; - return false; - } - } - - public bool PreStart(string src) - { - return _PreStart(src, null); - } - - public bool LoadAndPreStart(string src) - { - return _PreStart(File.ReadAllText(src), src); - } - - /// - /// Perform one execution step on the VM - /// - /// - /// - public VMState Step() - { - DebuggerStateCheckBeforeRun(); - - runtimeCore.DebugProps.RunMode = ProtoCore.Runmode.StepIn; - runtimeCore.DebugProps.AllbreakPoints = allbreakPoints; - lastState = RunVM(allbreakPoints); - return lastState; - } - - public VMState StepOver() - { - DebuggerStateCheckBeforeRun(); - // check if the current instruction is a function call instruction - // if it is, set a breakpoint at the next instruction and call Run - // if not, call Step - VMState vms = null; - - runtimeCore.DebugProps.AllbreakPoints = allbreakPoints; - Instruction instr = GetCurrentInstruction(); - if (instr.opCode == OpCode.CALL || - instr.opCode == OpCode.CALLR) - { - runtimeCore.DebugProps.RunMode = ProtoCore.Runmode.StepNext; - List instructions = new List(); - foreach (Breakpoint bp in RegisteredBreakpoints) - { - instructions.Add(BreakpointToInstruction(bp)); - } - vms = RunVM(instructions); - } - else - { - vms = Step(); - } - - return vms; - } - - public VMState Run() - { - DebuggerStateCheckBeforeRun(); - - runtimeCore.DebugProps.RunMode = ProtoCore.Runmode.RunTo; - runtimeCore.DebugProps.AllbreakPoints = allbreakPoints; - - List instructions = new List(); - foreach (Breakpoint bp in RegisteredBreakpoints) - { - instructions.Add(BreakpointToInstruction(bp)); - } - return RunVM(instructions); - } - - private void DebuggerStateCheckBeforeRun() - { - if (lastState != null) - lastState.Invalidate(); - if (!inited) - throw new RunnerNotInitied(); - if (isEnded) - throw new EndofScriptException(); - } - private VMState RunVM(List breakPoints) - { - //Get the next available location and set a break point - //Unset the break point at the current location - Instruction currentInstr = null; // will be instantialized when a proper breakpoint is reached - VMState vms = null; - try - { - if (executionsuspended) - runtimeCore.NotifyExecutionEvent(ProtoCore.ExecutionStateEventArgs.State.ExecutionResume); - - Execute(runtimeCore.DebugProps.DebugEntryPC, breakPoints); - isEnded = true; // the script has ended smoothly, - } - catch (ProtoCore.Exceptions.DebugHalting) - { - if (runtimeCore.CurrentExecutive == null) //This was before the VM was properly started - return null; - currentInstr = GetCurrentInstruction(); // set the current instruction to the current breakpoint instruction - runtimeCore.NotifyExecutionEvent(ProtoCore.ExecutionStateEventArgs.State.ExecutionBreak); - executionsuspended = true; - } - catch (ProtoCore.Exceptions.EndOfScript) - { - isEnded = true; - } - finally - { - ExecutionMirror execMirror = new ProtoCore.DSASM.Mirror.ExecutionMirror(runtimeCore.CurrentExecutive.CurrentDSASMExec, runtimeCore); - vms = new VMState(execMirror, core); - vms.isEnded = isEnded; - ProtoCore.CodeModel.CodePoint start = new ProtoCore.CodeModel.CodePoint(); - ProtoCore.CodeModel.CodePoint end = new ProtoCore.CodeModel.CodePoint(); - - if (currentInstr != null) // equal to null means that the whole script has ended, reset the cursor - { - start = InstructionToBeginCodePoint(currentInstr); - end = InstructionToEndCodePoint(currentInstr); - } - CurrentInstruction = currentInstr; - - vms.ExecutionCursor = new ProtoCore.CodeModel.CodeRange { StartInclusive = start, EndExclusive = end }; - } - - return vms; - - } - - private Instruction GetCurrentInstruction() - { - return core.DSExecutable.instrStreamList[runtimeCore.RunningBlock].instrList[runtimeCore.DebugProps.DebugEntryPC]; - } - - private ProtoCore.CodeModel.CodePoint InstructionToBeginCodePoint(Instruction instr) - { - if (instr.debug == null) - throw new InvalidOperationException("This instuction has no source representation"); - - return instr.debug.Location.StartInclusive; - } - private ProtoCore.CodeModel.CodePoint InstructionToEndCodePoint(Instruction instr) - { - if (instr.debug == null) - throw new InvalidOperationException("This instuction has no source representation"); - - return instr.debug.Location.EndExclusive; - } - - #region Breakpoints - - public List RegisteredBreakpoints - { - get; - private set; - } - public bool ToggleBreakpoint(ProtoCore.CodeModel.CodePoint cp) - { - Breakpoint bp = BuildBreakPointFromCodePoint(cp); - - if (bp == null) - return false; - - if (RegisteredBreakpoints.Count(x => x.Location == bp.Location) != 0) - RegisteredBreakpoints.Remove(bp); - else - RegisteredBreakpoints.Add(bp); - - return true; - } - - private Breakpoint BuildBreakPointFromCodePoint(ProtoCore.CodeModel.CodePoint codePoint) - { - if (codePoint.SourceLocation == null) - codePoint.SourceLocation = new ProtoCore.CodeModel.CodeFile(); - // get the instructions with debug info in at cursor position and in the same file - IEnumerable sameLine = allbreakPoints.Where(x => x.debug.Location.StartInclusive.SourceLocation == codePoint.SourceLocation && - x.debug.Location.EndExclusive.SourceLocation == codePoint.SourceLocation && - x.debug.Location.StartInclusive.LineNo == codePoint.LineNo); - if (sameLine.Count() == 0) - return null; - - IEnumerable sameCol = sameLine.Where(x => x.debug.Location.StartInclusive.CharNo <= codePoint.CharNo && x.debug.Location.EndExclusive.CharNo >= codePoint.CharNo); - Instruction instr = null; - if (sameCol.Count() != 0) - { - instr = sameCol.ElementAt(0); - foreach (Instruction i in sameCol) - { - if (i.debug.Location.EndExclusive.CharNo - i.debug.Location.StartInclusive.CharNo < instr.debug.Location.EndExclusive.CharNo - instr.debug.Location.StartInclusive.CharNo) - instr = i; - } - } - else - { - instr = sameLine.ElementAt(0); - foreach (Instruction i in sameLine) - { - if (i.debug.Location.EndExclusive.CharNo - i.debug.Location.StartInclusive.CharNo > instr.debug.Location.EndExclusive.CharNo - instr.debug.Location.StartInclusive.CharNo) - instr = i; - } - } - - return new Breakpoint(instr.debug); - } - private Instruction BreakpointToInstruction(Breakpoint bp) - { - return allbreakPoints.Where(x => x.debug.Location == bp.Location).ElementAt(0); - } - /// - /// A list of the current known breakpoints - /// Interact with through register and unregister methods - /// - - - #endregion - - private bool Compile(out int blockId) - { - bool buildSucceeded = false; - blockId = ProtoCore.DSASM.Constants.kInvalidIndex; - try - { - //defining the global Assoc block that wraps the entire .ds source file - ProtoCore.LanguageCodeBlock globalBlock = new ProtoCore.LanguageCodeBlock(); - globalBlock.Language = ProtoCore.Language.Associative; - globalBlock.Code = code; - - //passing the global Assoc wrapper block to the compiler - ProtoCore.CompileTime.Context context = new ProtoCore.CompileTime.Context(); - ProtoCore.Language id = globalBlock.Language; - core.Compilers[id].Compile(out blockId, null, globalBlock, context); - - core.BuildStatus.ReportBuildResult(); - - buildSucceeded = core.BuildStatus.BuildSucceeded; - core.GenerateExecutable(); - - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - return false; - } - - return buildSucceeded; - } - - /// - /// First exec starts up the VM and breaks at the first instruction - /// - private void FirstExec() - { - List bps = new List(); - runtimeCore.DebugProps.DebugEntryPC = core.DSExecutable.instrStreamList[0].entrypoint; - - foreach (InstructionStream instrStream in core.DSExecutable.instrStreamList) - { - //Register the first initial breakpoint - if (null != instrStream) - { - for (int i = 0; i < instrStream.instrList.Count; i++) - { - if (instrStream.instrList[i].debug != null) - { - bps.Add(instrStream.instrList[i]); - break; - } - } - } - } - try - { - // Jun Comment: Do not pre execute, wait for the next click - //Execute(entryPoint, bps); - } - catch (ProtoCore.Exceptions.DebugHalting) - { } - - } - - /// - /// Walk over the registered Debug points - /// - private List> BuildReverseIndex() - { - //List of Lines -> List of Debug Infos - List> ret = new List>(); - - foreach (InstructionStream instrStream in core.DSExecutable.instrStreamList) - { - if (null != instrStream) - { - int lastLineMarker = -1; - Dictionary lastDiList = null; - //Register the first initial breakpoint - for (int i = 0; i < instrStream.instrList.Count; i++) - { - DebugInfo di = instrStream.instrList[i].debug; - if (di != null) - { - if (instrStream.instrList[i].opCode != OpCode.BOUNCE) - allbreakPoints.Add(instrStream.instrList[i]); - - if (di.Location.StartInclusive.LineNo != lastLineMarker) - { - Validity.Assert(di.Location.StartInclusive.LineNo > lastLineMarker); - lastDiList = new Dictionary(); - lastDiList.Add(di, instrStream.instrList[i]); - ret.Add(lastDiList); - } - else - lastDiList.Add(di, instrStream.instrList[i]); - - } - } - } - } - - return ret; - } - - private ExecutionMirror Execute(int programCounterToExecuteFrom, List breakpoints, bool fepRun = false) - { - runtimeCore.Breakpoints = breakpoints; - resumeBlockID = runtimeCore.RunningBlock; - - - if (runtimeCore.DebugProps.FirstStackFrame != null) - { - runtimeCore.DebugProps.FirstStackFrame.FramePointer = core.GlobOffset; - - // Comment Jun: Tell the new bounce stackframe that this is an implicit bounce - // Register TX is used for this. - StackValue svCallConvention = StackValue.BuildCallingConversion((int)ProtoCore.DSASM.CallingConvention.BounceType.Implicit); - runtimeCore.DebugProps.FirstStackFrame.TX = svCallConvention; - } - - // Initialize the entry point interpreter - int locals = 0; // This is the global scope, there are no locals - ProtoCore.DSASM.Interpreter interpreter = new ProtoCore.DSASM.Interpreter(runtimeCore); - runtimeCore.CurrentExecutive.CurrentDSASMExec = interpreter.runtime; - runtimeCore.CurrentExecutive.CurrentDSASMExec.Bounce( - resumeBlockID, - programCounterToExecuteFrom, - runtimeCore.DebugProps.FirstStackFrame, - locals, - fepRun, - null, - breakpoints); - - return new ExecutionMirror(runtimeCore.CurrentExecutive.CurrentDSASMExec, runtimeCore); - - } - /// - /// This class supports introgation of the VM state - /// - public class VMState - { - public ExecutionMirror mirror { get; private set; } - public bool isEnded { get; set; } - public ProtoCore.CodeModel.CodeRange ExecutionCursor { get; set; } - - public VMState(ExecutionMirror mirror, ProtoCore.Core core, int fi = -1) - { - this.mirror = mirror; - } - - /// - /// Have we been through a state transition? - /// - public bool IsInvalid { get; private set; } - - public void Invalidate() - { - IsInvalid = true; - } - - public List DumpScope() - { - - - throw new NotImplementedException(); - } - } - - public class Breakpoint - { - // public ProtoCore.CodeModel.CodePoint Location { get; private set; } - //public Breakpoint(ProtoCore.CodeModel.CodePoint location) - //{ - // this.Location = location; - //} - - public ProtoCore.CodeModel.CodeRange Location { get; set; } - - public Breakpoint(DebugInfo di, string sourceLocation = null) - { - Location = di.Location; - } - public override bool Equals(object obj) - { - if (obj is Breakpoint) - { - Breakpoint bp = obj as Breakpoint; - if (Location.Equals(bp.Location)) - return true; - } - return false; - } - - public override int GetHashCode() - { - return Location.GetHashCode(); - } - } - - public class RunnerNotInitied : Exception - { } - - public class EndofScriptException : Exception - { } - } -} diff --git a/src/Engine/ProtoScript/Runners/ExpressionInterpreterRunner.cs b/src/Engine/ProtoScript/Runners/ExpressionInterpreterRunner.cs deleted file mode 100644 index 2bea2d0a515..00000000000 --- a/src/Engine/ProtoScript/Runners/ExpressionInterpreterRunner.cs +++ /dev/null @@ -1,200 +0,0 @@ -using System; -using ProtoCore.DSASM; -using ProtoCore.DSASM.Mirror; - -namespace ProtoScript.Runners -{ - public class ExpressionInterpreterRunner - { - private ProtoCore.Core Core; - private ProtoCore.RuntimeCore runtimeCore; - private readonly ProtoCore.DebugServices.EventSink EventSink = new ProtoCore.DebugServices.ConsoleEventSink(); - - public ExpressionInterpreterRunner(ProtoCore.Core core, ProtoCore.RuntimeCore runtimeCore) - { - Core = core; - this.runtimeCore = runtimeCore; - } - - public bool Compile(string code, int currentBlockID, out int blockId) - { - bool buildSucceeded = false; - blockId = ProtoCore.DSASM.Constants.kInvalidIndex; - try - { - //defining the global Assoc block that wraps the entire .ds source file - ProtoCore.LanguageCodeBlock globalBlock = new ProtoCore.LanguageCodeBlock(); - globalBlock.Language = ProtoCore.Language.Associative; - //globalBlock.language = ProtoCore.Language.kImperative; - globalBlock.Code = code; - - //passing the global Assoc wrapper block to the compiler - ProtoCore.CompileTime.Context context = new ProtoCore.CompileTime.Context(); - context.SetExprInterpreterProperties(currentBlockID, runtimeCore.RuntimeMemory, runtimeCore.watchClassScope, runtimeCore.DebugProps); - ProtoCore.Language id = globalBlock.Language; - - runtimeCore.ExprInterpreterExe.iStreamCanvas = new InstructionStream(globalBlock.Language, Core); - - // Save the global offset and restore after compilation - int offsetRestore = Core.GlobOffset; - Core.GlobOffset = runtimeCore.RuntimeMemory.Stack.Count; - - Core.Compilers[id].Compile(out blockId, null, globalBlock, context, EventSink); - - // Restore the global offset - Core.GlobOffset = offsetRestore; - - Core.BuildStatus.ReportBuildResult(); - - buildSucceeded = Core.BuildStatus.BuildSucceeded; - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - - return buildSucceeded; - } - - public ExecutionMirror Execute(string code) - { - bool ssastate = Core.Options.GenerateSSA; - bool ssastateExec = Core.Options.ExecuteSSA; - - runtimeCore.Options.RunMode = ProtoCore.DSASM.InterpreterMode.Expression; - - runtimeCore.Options.GenerateSSA = false; - runtimeCore.Options.ExecuteSSA = false; - - code = string.Format("{0} = {1};", Constants.kWatchResultVar, code); - - // TODO Jun: Move this initaliztion of the exe into a unified function - //Core.ExprInterpreterExe = new Executable(); - - int blockId = ProtoCore.DSASM.Constants.kInvalidIndex; - runtimeCore.RuntimeMemory.AlignStackForExprInterpreter(); - - //Initialize the watch stack and watchBaseOffset - //The watchBaseOffset is used to indexing the watch variables and related temporary variables - Core.watchBaseOffset = 0; - runtimeCore.watchStack.Clear(); - - bool succeeded = Compile(code, runtimeCore.GetCurrentBlockId(), out blockId); - - //Clear the warnings and errors so they will not continue impact the next compilation. - Core.BuildStatus.ClearErrors(); - Core.BuildStatus.ClearWarnings(); - - for (int i = 0; i < Core.watchBaseOffset; ++i ) - runtimeCore.watchStack.Add(StackValue.Null); - - //Record the old function call depth - //Fix IDE-523: part of error for watching non-existing member - int oldFunctionCallDepth = runtimeCore.FunctionCallDepth; - - //Record the old start PC - int oldStartPC = Core.watchStartPC; - if (succeeded) - { - - //a2. Record the old start PC for restore instructions - Core.watchStartPC = runtimeCore.ExprInterpreterExe.instrStreamList[blockId].instrList.Count; - Core.GenerateExprExeInstructions(blockId); - - //a3. Record the old running block - int restoreBlock = runtimeCore.RunningBlock; - runtimeCore.RunningBlock = blockId; - - //a4. Record the old debug entry PC and stack size of FileFepChosen - int oldDebugEntryPC = runtimeCore.DebugProps.DebugEntryPC; - - //a5. Record the frame pointer for referencing to thisPtr - runtimeCore.watchFramePointer = runtimeCore.RuntimeMemory.FramePointer; - - // The "Core.Bounce" below is gonna adjust the "FramePointer" - // based on the current size of "Core.Rmem.Stack". All that is - // good except that "Bounce" does not restore the previous value - // of frame pointer after "bouncing back". Here we make a backup - // of it and restore it right after the "Core.Bounce" call. - // - //Core.Executives[Core.CodeBlockList[Core.RunningBlock].language]. - try - { - ProtoCore.DSASM.StackFrame stackFrame = null; - int locals = 0; - - runtimeCore.CurrentExecutive.CurrentDSASMExec.Bounce(blockId, Core.watchStartPC, stackFrame, locals); - - // As Core.InterpreterProps stack member is pushed to every time the Expression Interpreter begins executing - // it needs to be popped off at the end for stack alignment - pratapa - runtimeCore.InterpreterProps.Pop(); - } - catch - { } - - //r5. Restore frame pointer. - runtimeCore.RuntimeMemory.FramePointer = runtimeCore.watchFramePointer; - - //r4. Restore the debug entry PC and stack size of FileFepChosen - runtimeCore.DebugProps.DebugEntryPC = oldDebugEntryPC; - - //r3. Restore the running block - runtimeCore.RunningBlock = restoreBlock; - - //r2. Restore the instructions in Core.ExprInterpreterExe - int from = Core.watchStartPC; - int elems = runtimeCore.ExprInterpreterExe.iStreamCanvas.instrList.Count; - runtimeCore.ExprInterpreterExe.instrStreamList[blockId].instrList.RemoveRange(from, elems); - - //Restore the start PC - Core.watchStartPC = oldStartPC; - - //Restore the function call depth - //Fix IDE-523: part of error for watching non-existing member - runtimeCore.FunctionCallDepth = oldFunctionCallDepth; - - - //Clear the watchSymbolList - foreach (SymbolNode node in runtimeCore.WatchSymbolList) - { - if (ProtoCore.DSASM.Constants.kInvalidIndex == node.classScope) - Core.DSExecutable.runtimeSymbols[node.runtimeTableIndex].Remove(node); - else - Core.ClassTable.ClassNodes[node.classScope].Symbols.Remove(node); - } - } - else - { - //Restore the start PC - Core.watchStartPC = oldStartPC; - - //Restore the function call depth - //Fix IDE-523: part of error for watching non-existing member - runtimeCore.FunctionCallDepth = oldFunctionCallDepth; - - //Clear the watchSymbolList - foreach (SymbolNode node in runtimeCore.WatchSymbolList) - { - if (ProtoCore.DSASM.Constants.kInvalidIndex == node.classScope) - Core.DSExecutable.runtimeSymbols[node.runtimeTableIndex].Remove(node); - else - Core.ClassTable.ClassNodes[node.classScope].Symbols.Remove(node); - } - - // TODO: investigate why additional elements are added to the stack. - runtimeCore.RuntimeMemory.RestoreStackForExprInterpreter(); - - throw new ProtoCore.Exceptions.CompileErrorsOccured(); - } - - // TODO: investigate why additional elements are added to the stack. - runtimeCore.RuntimeMemory.RestoreStackForExprInterpreter(); - - runtimeCore.Options.GenerateSSA = ssastate; - runtimeCore.Options.ExecuteSSA = ssastateExec; - runtimeCore.Options.RunMode = ProtoCore.DSASM.InterpreterMode.Normal; - - return new ExecutionMirror(runtimeCore.CurrentExecutive.CurrentDSASMExec, runtimeCore); - } - } -} diff --git a/test/Engine/ProtoTest/Associative/ReplicatorTest.cs b/test/Engine/ProtoTest/Associative/ReplicatorTest.cs deleted file mode 100644 index 83544cf08ba..00000000000 --- a/test/Engine/ProtoTest/Associative/ReplicatorTest.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Collections.Generic; -using NUnit.Framework; -using ProtoCore.DSASM; -using ProtoCore.Lang.Replication; -using ProtoFFI; -using ProtoScript.Runners; -namespace ProtoTest.Associative -{ - class ReplicatorTest : ProtoTestBase - { - DebugRunner fsr; - - public override void Setup() - { - // Specify some of the requirements of IDE. - base.Setup(); - fsr = new DebugRunner(core); - DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); - CLRModuleType.ClearTypes(); - } - - [Test] - public void ComputeReducedParams() - { - // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-4115 - string code = - @" - a = [1,2]; - b = [3,4]; - "; - - //Run - fsr.PreStart(code); - DebugRunner.VMState vms = null; - vms = fsr.Run(); - var mirror = vms.mirror; - List args = new List(); - args.Add(mirror.GetRawFirstValue("a")); - args.Add(mirror.GetRawFirstValue("b")); - List ris = new List(); - ris.Add( - new ReplicationInstruction() - { - ZipIndecies = new List { 0, 1 }, - Zipped = true - } - ); - runtimeCore = fsr.runtimeCore; - List> combin = ProtoCore.Lang.Replication.Replicator.ComputeAllReducedParams(args, ris, runtimeCore); - Assert.IsTrue(combin[0][0].IntegerValue == 1); - Assert.IsTrue(combin[0][1].IntegerValue == 3); - } - } -} diff --git a/test/Engine/ProtoTest/DebugTests/BasicTests.cs b/test/Engine/ProtoTest/DebugTests/BasicTests.cs deleted file mode 100644 index 51bbda619a8..00000000000 --- a/test/Engine/ProtoTest/DebugTests/BasicTests.cs +++ /dev/null @@ -1,5947 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using NUnit.Framework; -using ProtoCore.DSASM; -using ProtoCore.DSASM.Mirror; -using ProtoCore.Lang; -using ProtoFFI; -using ProtoScript.Runners; -using ProtoTestFx.TD; - -namespace ProtoTest.DebugTests -{ - [TestFixture, Category("Debugger")] - class BasicTests : ProtoTestBase - { - private DebugRunner fsr; - private string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\"; - - public override void Setup() - { - base.Setup(); - core.Options.kDynamicCycleThreshold = 5; - - fsr = new DebugRunner(core); - - DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); - CLRModuleType.ClearTypes(); - } - - public override void TearDown() - { - runtimeCore = fsr.runtimeCore; - base.TearDown(); - } - - private List UnpackToList(ExecutionMirror mirror, Obj obj) - { - if (obj == null || !obj.DsasmValue.IsArray) - return null; - - return mirror.MirrorTarget.rmem.Heap.ToHeapObject(obj.DsasmValue).Values.Select(x => mirror.Unpack(x)).ToList(); - } - - [Test] - [Category("ExpressionInterpreterRunner")] - public void TestWatchExpression1() - { - // Execute and verify the main script in a debug session - fsr.PreStart( -@" - -a = 1; -b = 20; - -"); - DebugRunner.VMState vms = fsr.Step(); - vms = fsr.Step(); - - // Execute and verify the watch window expression script - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () => - { - watchRunner.Execute(@"%"); - }); - - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a"); - Obj objExecVal = mirror.GetWatchValue(); - Assert.IsTrue((Int64)objExecVal.Payload == 1); - - - vms = fsr.Step(); - - // Execute and verify the watch window expression script - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - Assert.Throws(typeof(ProtoCore.Exceptions.CompileErrorsOccured), () => - { - watchRunner.Execute(@"%"); - }); - - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"b"); - objExecVal = mirror.GetWatchValue(); - Assert.IsTrue((Int64)objExecVal.Payload == 20); - } - - [Test] - [Category("ExpressionInterpreterRunner")] - public void TestWatchExpression4() - { - // Execute and verify the main script in a debug session - fsr.PreStart( -@" -def f : int(i : int, j : int) -{ - a = 5; - return = 7; -} - -a = f(1, 2); -b = 2; -c = 3; -"); - - // First step should bring the exec cursor to "a = f(1, 2)". - DebugRunner.VMState vms = fsr.StepOver(); - - { - // This is to simulate the event when "a" is added into the watch window - // before it gets assigned a value. This should not cause subsequent stepping - // to go wrong. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a"); - Obj objExecVal = mirror.GetWatchValue(); - - // This should not return a value since "a" is unassigned now. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(null, objExecVal.Payload); - } - - // Second step should bring it to "b = 2;". - vms = fsr.StepOver(); - - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a"); - Obj objExecVal = mirror.GetWatchValue(); - - // Now "a" should be "7" as the result of assignment from return value of "f". - Assert.AreNotEqual(null, objExecVal); - Assert.AreNotEqual(null, objExecVal.Payload); - Assert.AreEqual("7", objExecVal.Payload.ToString()); - } - - // Third step should bring it to "c = 3;". - vms = fsr.StepOver(); - - // Final step ends the debug session. - vms = fsr.StepOver(); - Assert.AreEqual(true, vms.isEnded); - } - - [Test] - [Category("Failure")] - [Category("ExpressionInterpreterRunner")] - public void TestWatchExpression5() - { - string sourceCode = @" -a = [ 1, 0, 0.0 ]; // Line 2 -b = [ a, 1 ]; // Line 3 - -[Imperative] // Line 5 -{ - a[1] = 1; // Line 7 - m = a; // Line 8 -} // Line 9 -"; - fsr.PreStart(sourceCode); - DebugRunner.VMState vms = fsr.StepOver(); - Assert.AreEqual(2, vms.ExecutionCursor.StartInclusive.LineNo); - vms = fsr.StepOver(); - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); - vms = fsr.StepOver(); - Assert.AreEqual(7, vms.ExecutionCursor.StartInclusive.LineNo); - vms = fsr.StepOver(); - Assert.AreEqual(8, vms.ExecutionCursor.StartInclusive.LineNo); - vms = fsr.StepOver(); - Assert.AreEqual(9, vms.ExecutionCursor.StartInclusive.LineNo); - - // Get the value of "m[0]". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"m[0]"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should be "1". - Assert.AreNotEqual(null, objExecVal); - Assert.AreNotEqual(null, objExecVal.Payload); - Assert.AreEqual("1", objExecVal.Payload.ToString()); - } - - vms = fsr.StepOver(); // Causes "b = { a, 1 };" to execute. - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); - - // Get the value of "m[0]". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"m[0]"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should still be "1". - Assert.AreNotEqual(null, objExecVal); - // Assert.AreEqual(null, objExecVal.Payload); - } - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("ExpressionInterpreterRunner")] - public void TestWatchExpressionInFunction() - { - // Execute and verify the main script in a debug session - fsr.PreStart( -@" -def foo() -{ - aaa = 4; - return = null; -} - -bbb = foo(); -"); - - // First step should bring the exec cursor to "bbb = foo()". - DebugRunner.VMState vms = fsr.StepOver(); - Assert.AreEqual(8, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(8, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(13, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // Highlight "aaa = 4;" - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(4, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(13, vms.ExecutionCursor.EndExclusive.CharNo); - - // Get the value of "aaa". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"aaa"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(null, objExecVal.Payload); - } - - vms = fsr.StepOver(); // Highlight "return = null;" - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(5, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(19, vms.ExecutionCursor.EndExclusive.CharNo); - - // Get the value of "aaa". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"aaa"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreNotEqual(null, objExecVal.Payload); - Assert.AreEqual("4", objExecVal.Payload.ToString()); - } - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("ExpressionInterpreterRunner")] - public void TestWatchExpressionInFunctionNestedInImperativeBlock() - { - // This comes from IDE-538 - fsr.PreStart( -@"z=[Imperative] //Line 1 -{ - def GetNumberSquare(test:int) - { - result = test * test; - return = result; - } - x = GetNumberSquare(5); - return = x; -} -"); - - DebugRunner.VMState vms = fsr.StepOver();//Line 8 - - vms = fsr.Step();//Line 5 - - // Get the value of "result". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"result"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(null, objExecVal.Payload); - } - - // Get the value of "test". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"test"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(5, (Int64)objExecVal.Payload); - } - - vms = fsr.Step();//Line 6 - - // Get the value of "result". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"result"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(25, (Int64)objExecVal.Payload); - } - - // Get the value of "test". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"test"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(5, (Int64)objExecVal.Payload); - } - - vms = fsr.Step();//Line 7 - - // Get the value of "result". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"result"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(25, (Int64)objExecVal.Payload); - } - - // Get the value of "test". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"test"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(5, (Int64)objExecVal.Payload); - } - - vms = fsr.Step();//Line 8 - - // Get the value of "result". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"result"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(null, objExecVal.Payload); - } - - // Get the value of "test". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"test"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(null, objExecVal.Payload); - } - } - - [Test, Category("Failure")] - [Category("ExpressionInterpreterRunner")] - public void TestWatchExpressionInFunctionNestedWithImperativeBlock() - { - // This comes from IDE-544 - fsr.PreStart( -@"def func(d : int) //Line 1 -{ - m : int; - m = 10; - temp = 0; // Line #5 - [Imperative] - { - temp = m; // Line #8 - } - return = temp; // Line #10 -} - -n = func(1); -"); - - DebugRunner.VMState vms = fsr.StepOver();//Line 13 - - vms = fsr.Step();//Line 4 - - // Get the value of "m". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"m"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(null, objExecVal.Payload); - } - - // Get the value of "temp". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"temp"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(null, objExecVal.Payload); - } - - vms = fsr.Step();//Line 5 - - // Get the value of "m". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"m"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(10, (Int64)objExecVal.Payload); - } - - // Get the value of "temp". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"temp"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(null, objExecVal.Payload); - } - - vms = fsr.Step();//Line 8 - - // Get the value of "m". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"m"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(10, (Int64)objExecVal.Payload); - } - - // Get the value of "temp". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"temp"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(null, objExecVal.Payload); - } - - vms = fsr.Step();//Line 9 - - // Get the value of "m". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"m"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(10, (Int64)objExecVal.Payload); - } - - // Get the value of "temp". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"temp"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(10, (Int64)objExecVal.Payload); - } - - vms = fsr.Step();//Line 10 - - // Get the value of "m". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"m"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(10, (Int64)objExecVal.Payload); - } - - // Get the value of "temp". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"temp"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(0, (Int64)objExecVal.Payload); - } - } - - [Test] - [Category("ExpressionInterpreterRunner")] - public void TestWatchExpressionImperative1() - { - // Execute and verify the main script in a debug session - fsr.PreStart( -@" -[Imperative] -{ - first = 1; - second = 2; - third = 3; - fourth = 4; - fifth = 5; -} -"); - - // First step should bring the exec cursor to "first = 1;". - DebugRunner.VMState vms = fsr.StepOver(); - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(4, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(15, vms.ExecutionCursor.EndExclusive.CharNo); - - { - // This is to simulate the event when "first" is added into the watch window - // before it gets assigned a value. This should not cause subsequent stepping - // to go wrong. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"first"); - Obj objExecVal = mirror.GetWatchValue(); - - // This should not return a valid payload as "first" is unassigned now. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(null, objExecVal.Payload); - } - - // Second step should bring it to "second = 2;". - vms = fsr.StepOver(); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(5, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(16, vms.ExecutionCursor.EndExclusive.CharNo); - - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"first"); - Obj objExecVal = mirror.GetWatchValue(); - - // This time "first" gets assigned a value of "1"... - Assert.AreNotEqual(null, objExecVal); - Assert.AreNotEqual(null, objExecVal.Payload); - Assert.AreEqual("1", objExecVal.Payload.ToString()); - } - - // Third step should bring it to "third = 3;". - vms = fsr.StepOver(); - Assert.AreEqual(6, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(6, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(15, vms.ExecutionCursor.EndExclusive.CharNo); - - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"second"); - Obj objExecVal = mirror.GetWatchValue(); - - // This time "second" gets assigned a value of "2"... - Assert.AreNotEqual(null, objExecVal); - Assert.AreNotEqual(null, objExecVal.Payload); - Assert.AreEqual("2", objExecVal.Payload.ToString()); - } - - // Third step should bring it to "fourth = 4;". - vms = fsr.StepOver(); - Assert.AreEqual(7, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(16, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("ExpressionInterpreterRunner")] - public void TestWatchExpressionImperative2() - { - // Execute and verify the main script in a debug session - fsr.PreStart( -@" -[Imperative] -{ - a = 1; - b = 20; -} - -"); - DebugRunner.VMState vms = fsr.Step(); - vms = fsr.Step(); - - // Execute and verify the watch window expression script - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a"); - Obj objExecVal = mirror.GetWatchValue(); - Assert.IsTrue((Int64)objExecVal.Payload == 1); - - - vms = fsr.Step(); - - // Execute and verify the watch window expression script - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"b"); - objExecVal = mirror.GetWatchValue(); - Assert.IsTrue((Int64)objExecVal.Payload == 20); - } - - [Test] - [Category("ExpressionInterpreterRunner")] - public void TestWatchExpressionImperative4() - { - // Execute and verify the main script in a debug session - fsr.PreStart( -@" -[Associative] -{ -} - -[Imperative] -{ - eee = 43420; -} -"); - - // First step should highlight closing bracket of "Associative" block. - DebugRunner.VMState vms = fsr.StepOver(); - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(4, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // Highlight "eee = 43420;" - Assert.AreEqual(8, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(8, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(17, vms.ExecutionCursor.EndExclusive.CharNo); - - // Get the value of "eee". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"eee"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(null, objExecVal.Payload); - } - - vms = fsr.StepOver(); // Highlight closing bracket of "Imperative" block. - Assert.AreEqual(9, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(9, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - - // Get the value of "eee". - { - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"eee"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreNotEqual(null, objExecVal.Payload); - Assert.AreEqual("43420", objExecVal.Payload.ToString()); - } - } - - [Test] - [Category("ExpressionInterpreterRunner")] - public void TestWatchExpressionInNestedBlock2() - { - // Execute and verify the defect IDE-519 - fsr.PreStart( -@"[Associative] // Line 1 -{ - [Imperative] - { - i = 3; - } // The value of 'i' cannot be inspected here. - - // If this line is removed, then 'i' can be inspected. - f = i; -} -"); - - DebugRunner.VMState vms = fsr.StepOver();//Line 5 - - vms = fsr.Step();//Line 6 - - { - // Get the value of "i". - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"i"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(3, (Int64)objExecVal.Payload); - } - - vms = fsr.Step();//Line 7 - - { - // Get the value of "i". - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"i"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(null, objExecVal.Payload); - } - } - - [Test] - [Category("Debugger")] - public void TestImperativeExec() - { - - String code = -@"[Imperative] -{ - foo = 5; - bah = 10; -} -"; - - - //ProtoScript.Runners.DebugRunner fsr = new ProtoScript.Runners.DebugRunner(null); - fsr.PreStart(code); - - DebugRunner.VMState vms = fsr.Step(); - vms = fsr.Step(); - Object o = vms.mirror.GetDebugValue("foo").Payload;// .GetDebugValue("foo").Payload; - Assert.IsTrue((Int64)o == 5); - } - - [Test] - [Category("Debugger")] - public void TestStepNext() - { - String code = -@" - a = 1; - b = 2.0; - c = true; - d = null; -"; - fsr.PreStart(code); - DebugRunner.VMState vms = fsr.Step(); - vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("a"); - string type = vms.mirror.GetType("a"); - - Assert.IsTrue((Int64)o.Payload == 1); - Assert.IsTrue(type == "int"); - - int startLineNo, startCharNo, endLineNo, endCharNo; - - startLineNo = vms.ExecutionCursor.StartInclusive.LineNo; - startCharNo = vms.ExecutionCursor.StartInclusive.CharNo; - - endLineNo = vms.ExecutionCursor.EndExclusive.LineNo; - endCharNo = vms.ExecutionCursor.EndExclusive.CharNo; - - Assert.IsTrue((Int64)startLineNo == 3); - Assert.IsTrue((Int64)startCharNo == 5); - - Assert.IsTrue((Int64)endLineNo == 3); - Assert.IsTrue((Int64)endCharNo == 13); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - - Assert.IsTrue((double)o.Payload == 2.0); - Assert.IsTrue(type == "double"); - - startLineNo = vms.ExecutionCursor.StartInclusive.LineNo; - startCharNo = vms.ExecutionCursor.StartInclusive.CharNo; - - Assert.IsTrue((Int64)startLineNo == 4); - Assert.IsTrue((Int64)startCharNo == 5); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("c"); - type = vms.mirror.GetType("c"); - - Assert.IsTrue((Boolean)o.Payload); - Assert.IsTrue(type == "bool"); - - startLineNo = vms.ExecutionCursor.StartInclusive.LineNo; - startCharNo = vms.ExecutionCursor.StartInclusive.CharNo; - - Assert.IsTrue((Int64)startLineNo == 5); - Assert.IsTrue((Int64)startCharNo == 5); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("d"); - type = vms.mirror.GetType("d"); - - Assert.IsTrue(o.Payload == null); - Assert.IsTrue(type == "null"); - - startLineNo = vms.ExecutionCursor.StartInclusive.LineNo; - startCharNo = vms.ExecutionCursor.StartInclusive.CharNo; - - Assert.IsTrue((Int64)startLineNo == 0); - Assert.IsTrue((Int64)startCharNo == 0); - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void TestStepIntoSingleFunction() - { - String code = -@" - def f : int(i : int, j : int) - { - a = 5; - return = 7; - } - - a = f(1, 2); - b = 2; - c = 3; -"; - fsr.PreStart(code); - fsr.Step(); // "f(1, 2)" - fsr.Step(); // "a = 5;" - DebugRunner.VMState vms = fsr.Step(); // "return = 7;" - - Obj o = vms.mirror.GetDebugValue("a"); - string type = vms.mirror.GetType("a"); - - Assert.IsTrue((Int64)o.Payload == 5); - Assert.IsTrue(type == "int"); - - // "return = 7;" statement highlighted. - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(9, vms.ExecutionCursor.StartInclusive.CharNo); - - vms = fsr.Step(); // Closing bracket "}" of "f". - Assert.AreEqual(6, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - - fsr.Step(); // "a = f(1, 2);" - vms = fsr.Step(); // "b = 2;" - o = vms.mirror.GetDebugValue("a"); - Assert.AreEqual(7, (Int64)o.Payload); - - vms = fsr.Step(); // "c = 3;" - o = vms.mirror.GetDebugValue("b"); - Assert.AreEqual(2, (Int64)o.Payload); - - vms = fsr.Step(); // Ended. - o = vms.mirror.GetDebugValue("c"); - Assert.AreEqual(3, (Int64)o.Payload); - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void TestStepIntoFunctionFromLangBlock() - { - String code = - @" -def f (input) -{ - return = input * 2; -} - -val = [Imperative] -{ - sum = 1; - sum1 = f(sum); - - return = sum1; -} -"; - fsr.PreStart(code); - fsr.Step(); - - DebugRunner.VMState vms = fsr.Step(); - Object o = vms.mirror.GetDebugValue("sum").Payload; - Assert.IsTrue((Int64)o == 1); - - // The second step-in should highlight "sum1 = f(sum)" statement. - Assert.AreEqual(10, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(10, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(16, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // Third step-in. - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(4, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(21, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void TestStepInOutLanguageBlockImperative() - { - string sourceCode = @" -b = 5; - -c = [Imperative] -{ - x = 4 + b; - return = x; -} - -d = c; -"; - - fsr.PreStart(sourceCode); - - DebugRunner.VMState vms = fsr.StepOver(); // "b = 5;" - Assert.AreEqual(2, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // "x = 4 + b;" - Assert.AreEqual(6, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(6, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(15, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // "return = x;" - Assert.AreEqual(7, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(16, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // "}" of the "Imperative" block - Assert.AreEqual(8, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(8, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // The entire "c = ..." assignment block - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(8, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // "d = c;" - Assert.AreEqual(10, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(10, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); - Assert.AreEqual(true, vms.isEnded); - } - - [Test] - [Category("Debugger")] - public void TestInlineConditionImperativeBlock_Defect_IDE_637() - { - string sourceCode = @"x = 330; - -def foo(y : int) -{ - return = y + 222; -} - -[Imperative] -{ - a = x < foo(22) ? 3 : 55; -}"; - fsr.PreStart(sourceCode); - - DebugRunner.VMState vms = fsr.Step(); //x = 330; - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(1, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(9, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); //a = x < foo(22) ? 3 : 55; - Assert.AreEqual(10, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(10, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(30, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // closing brace of Imperative block - Assert.AreEqual(11, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(11, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Debugger")] - public void TestIfStmtImperativeBlock_Defect_IDE_637_0() - { - string sourceCode = @"x = 330; - -def foo(y : int) -{ - return = y + 222; -} - -[Imperative] -{ - if(x > foo(22)) - { - a = 3; - } - else - { - a = 55; - } -}"; - //Assert.Fail("Regression with if statement"); - fsr.PreStart(sourceCode); - - DebugRunner.VMState vms = fsr.Step(); //x = 330; - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(1, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(9, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); //if(x < foo(22)) - Assert.AreEqual(10, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(10, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(17, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // a = 3; - Assert.AreEqual(12, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(12, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(9, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // closing brace of if - vms = fsr.Step(); // closing brace of Imperative block - Assert.AreEqual(18, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(18, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - - } - - [Test] - [Category("Debugger")] - public void TestIfStmtImperativeBlock_Defect_IDE_637_1() - { - string sourceCode = @"x = 330; - -def foo(y : int) -{ - return = y + 222; -} - -[Imperative] -{ - if(x < foo(22)) - { - a = 3; - } - else - { - a = 55; - } -}"; - fsr.PreStart(sourceCode); - - DebugRunner.VMState vms = fsr.Step(); //x = 330; - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(1, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(9, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); //if(x < foo(22)) - Assert.AreEqual(10, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(10, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(17, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // a = 55; - Assert.AreEqual(16, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(16, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(10, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // closing brace of else - vms = fsr.Step(); // closing brace of Imperative block - Assert.AreEqual(18, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(18, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void TestInlineConditionImperativeBlock_Defect_IDE_637_2() - { - string sourceCode = @"x = 330; - -def foo(y : int) -{ - return = y + 222; -} - -[Imperative] -{ - a = x < foo(22) ? 3 : 55; -}"; - fsr.PreStart(sourceCode); - - DebugRunner.VMState vms = fsr.Step(); //x = 330; - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(1, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(9, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); //a = x < foo(22) ? 3 : 55; - Assert.AreEqual(10, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(10, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(30, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); //return = y + 222; - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(5, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(22, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); //closing brace of foo() - Assert.AreEqual(6, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(6, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); //a = x < foo(22) ? 3 : 55; - Assert.AreEqual(10, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(10, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(30, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // closing brace of Imperative block - Assert.AreEqual(11, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(11, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void TestIfStmtImperativeBlock_Defect_IDE_637_3() - { - string sourceCode = @"x = 330; - -def foo(y : int) -{ - return = y + 222; -} - -[Imperative] -{ - if(x < foo(22)) - { - a = 3; - } - else - { - a = 55; - } -}"; - fsr.PreStart(sourceCode); - - DebugRunner.VMState vms = fsr.Step(); //x = 330; - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(1, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(9, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); //if(x < foo(22)) - Assert.AreEqual(10, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(10, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(17, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // return = y + 222; - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(5, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(22, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // closing brace of foo() - Assert.AreEqual(6, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(6, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); //if(x < foo(22)) - Assert.AreEqual(10, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(10, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(17, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // a = 55; - Assert.AreEqual(16, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(16, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(10, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // closing brace of else statement - vms = fsr.Step(); // closing brace of Imperative block - Assert.AreEqual(18, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(18, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void TestStepInOutLanguageBlockAssociative() - { - string sourceCode = @" -[Imperative] -{ - b = 5; - - c = [Associative] - { - y = b + 2; - return = y; - } - - d = c; -} -"; - - fsr.PreStart(sourceCode); - - DebugRunner.VMState vms = fsr.StepOver(); // "b = 5;" - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(4, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(11, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // "y = b + 2;" - Assert.AreEqual(8, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(9, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(8, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(19, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // "return = y;" - Assert.AreEqual(9, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(9, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(9, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(20, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // "}" of the "Associative" block - Assert.AreEqual(10, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(10, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(6, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // The entire "c = ..." assignment block - Assert.AreEqual(6, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(10, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(6, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // "d = c;" - Assert.AreEqual(12, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(12, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(11, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // "}" of the "Imperative" block - Assert.AreEqual(13, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(13, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); - Assert.AreEqual(true, vms.isEnded); - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void TestStepNestedFunctionsFromLangBlock0() - { - String code = - @" -def f1() -{ - a = 99; - b = f2(); - return = b; -} - -def f2 : int() -{ - return = 2; -} - -v = 90; - -[Imperative] -{ - c = 4; - a = f1(); - b = 98; -} - -p = [ 9, 0 ]; -"; - fsr.PreStart(code); - fsr.Step(); - - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("v"); - string type = vms.mirror.GetType("v"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 90); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("c"); - type = vms.mirror.GetType("c"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 4); - - vms = fsr.Step(); - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("a"); - type = vms.mirror.GetType("a"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 99); - - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 2); - - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("a"); - type = vms.mirror.GetType("a"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 2); - - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 98); - - fsr.Step(); - fsr.Step(); - - o = vms.mirror.GetDebugValue("p"); - type = vms.mirror.GetType("p"); - List lo = UnpackToList(vms.mirror, o); - Assert.IsTrue(type == "array"); - Assert.IsTrue((Int64)lo[0].Payload == 9); - Assert.IsTrue((Int64)lo[1].Payload == 0); - } - - [Test] - [Category("Debugger")] - public void TestRunDebugManyFunctions() - { - String code = - @" -def fadd : int(a : int) -{ - return = a + 1; -} - -x = 1; - -a = fadd(x); -a = fadd(x); -a = fadd(x); -a = fadd(x); -a = fadd(x); -a = fadd(x); -a = fadd(x); -a = fadd(x); -a = fadd(x); -a = fadd(x); -a = fadd(x); -a = fadd(x); -a = fadd(x); -a = fadd(x); -a = fadd(x); -a = fadd(x); -a = fadd(x); -a = fadd(x); -"; - //Assert.Fail("IDE-266: Placing breakpoint and Run (Debug) twice crashes DesignScript"); - - fsr.PreStart(code); - //fsr.Step(); - - fsr.Run(); - Assert.AreEqual(fsr.isEnded, true); - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void TestStepIntoManyFunctions() - { - String code = -@" - def g() - { - a = 9; - return = 0; - } - - def f() - { - a = 5; - return = 7; - } - - a = f(); - b = 2; - c = 3; -"; - fsr.PreStart(code); - fsr.Step(); // "f()" - fsr.Step(); // "a = 5;" - DebugRunner.VMState vms = fsr.Step(); // "return = 7;" - Obj o = vms.mirror.GetDebugValue("a"); - string type = vms.mirror.GetType("a"); - - Assert.IsTrue((Int64)o.Payload == 5); - Assert.IsTrue(type == "int"); - - // Highlight "return = 7;" statement. - Assert.AreEqual(11, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(9, vms.ExecutionCursor.StartInclusive.CharNo); - - vms = fsr.Step(); // Closing "}" of function "f". - Assert.AreEqual(12, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - } - - [Test] - [Category("Debugger")] - public void TestStepOverFunction() - { - // Execute and verify the main script in a debug session - fsr.PreStart( -@" -def f : int(i : int, j : int) -{ - a = 5; - return = 7; -} - -a = f(1, 2); -b = 2; -c = 3; -"); - - // First step should bring the exec cursor to "a = f(1, 2)". - DebugRunner.VMState vms = fsr.StepOver(); - Assert.AreEqual(8, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(8, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(13, vms.ExecutionCursor.EndExclusive.CharNo); - - // Second step should bring it to "b = 2;". - vms = fsr.StepOver(); - Assert.AreEqual(9, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(9, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.CharNo); - - // Third step should bring it to "c = 3;". - vms = fsr.StepOver(); - Assert.AreEqual(10, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(10, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.CharNo); - - // Final step ends the debug session. - vms = fsr.StepOver(); - Assert.AreEqual(true, vms.isEnded); - } - - [Test] - [Category("Debugger")] - public void TestStepInAssocLangBlock() - { - String code = -@" -[Associative] -{ - a = 4; - b = 10; - c = a + b; - d = c; -} -"; - fsr.PreStart(code); - fsr.Step(); - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("a"); - string type = vms.mirror.GetType("a"); - - Assert.IsTrue((Int64)o.Payload == 4); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - - Assert.IsTrue((Int64)o.Payload == 10); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("c"); - type = vms.mirror.GetType("c"); - - Assert.IsTrue((Int64)o.Payload == 14); - Assert.IsTrue(type == "int"); - } - - [Test] - [Category("Debugger")] - public void TestStepWithUpdate() - { - String code = -@" - - a = 4; - b = a; - a = 3; -"; - fsr.PreStart(code); - fsr.Step(); - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("a"); - string type = vms.mirror.GetType("a"); - - Assert.IsTrue((Int64)o.Payload == 4); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - - Assert.IsTrue((Int64)o.Payload == 4); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - type = vms.mirror.GetType("a"); - - Assert.IsTrue((Int64)o.Payload == 3); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - - Assert.IsTrue((Int64)o.Payload == 3); - Assert.IsTrue(type == "int"); - } - - [Test] - [Category("Debugger")] - public void TestStepWithUpdate2() - { - String code = -@" -x = 1; -a = x + 1; - -c = 0; -b = 2; -t = a+c; - -c = a + b; -x = 3;"; - //Assert.Fail("DNL-1467484 wrong execution sequence for update"); - - fsr.PreStart(code); - fsr.Step(); - - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("x"); - Assert.IsTrue((Int64)o.Payload == 1); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - Assert.IsTrue((Int64)o.Payload == 2); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("c"); - Assert.IsTrue((Int64)o.Payload == 0); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - Assert.IsTrue((Int64)o.Payload == 2); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("t"); - Assert.IsTrue((Int64)o.Payload == 2); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("c"); - Assert.IsTrue((Int64)o.Payload == 4); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("t"); - Assert.IsTrue((Int64)o.Payload == 6); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("x"); - Assert.IsTrue((Int64)o.Payload == 3); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - Assert.IsTrue((Int64)o.Payload == 4); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("t"); - Assert.IsTrue((Int64)o.Payload == 8); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("c"); - Assert.IsTrue((Int64)o.Payload == 6); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("t"); - Assert.IsTrue((Int64)o.Payload == 10); - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void TestStepWithUpdateUsingFunctions() - { - String code = -@" -def fadd : int(a : int) -{ - return = a+1; -} - -x = 1; - -a = fadd(x); - -b = 11; -c = a + b; - -x = 10; -"; - //Assert.Fail("IDE-312: Debugger Regression: Debugger fails with update"); - fsr.PreStart(code); - fsr.Step(); - - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("x"); - String type = vms.mirror.GetType("x"); - - Assert.IsTrue((Int64)o.Payload == 1); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - type = vms.mirror.GetType("a"); - - Assert.IsTrue((Int64)o.Payload == 1); - Assert.IsTrue(type == "int"); - - fsr.Step(); - fsr.Step(); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - type = vms.mirror.GetType("a"); - - Assert.IsTrue((Int64)o.Payload == 2); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - - Assert.IsTrue((Int64)o.Payload == 11); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("c"); - type = vms.mirror.GetType("c"); - - Assert.IsTrue((Int64)o.Payload == 13); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("x"); - type = vms.mirror.GetType("x"); - - Assert.IsTrue((Int64)o.Payload == 10); - Assert.IsTrue(type == "int"); - - fsr.Step(); - fsr.Step(); - fsr.Step(); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - type = vms.mirror.GetType("a"); - - Assert.IsTrue((Int64)o.Payload == 11); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("c"); - type = vms.mirror.GetType("c"); - - Assert.IsTrue((Int64)o.Payload == 22); - Assert.IsTrue(type == "int"); - } - - [Test] - [Category("Debugger")] - public void TestStepWithUpdateUsingImperativeLangBlock() - { - String code = -@" -x = 1; -a = x + 1; - -c = 0; -b = 2; -t = a+c; - -[Imperative] -{ - c = a + b; - x = 3; -} -"; - fsr.PreStart(code); - fsr.Step(); - - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("x"); - String type = vms.mirror.GetType("x"); - - Assert.IsTrue((Int64)o.Payload == 1); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - Assert.IsTrue((Int64)o.Payload == 2); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("c"); - Assert.IsTrue((Int64)o.Payload == 0); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - Assert.IsTrue((Int64)o.Payload == 2); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("t"); - Assert.IsTrue((Int64)o.Payload == 2); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("c"); - Assert.IsTrue((Int64)o.Payload == 4); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("x"); - Assert.IsTrue((Int64)o.Payload == 3); - } - - [Test] - [Category("Debugger")] - public void TestStepWithUpdateUsingAssociativeLangBlock() - { - String code = -@" -x = 1; -a = x + 1; - -c = 0; -b = 2; -t = a+c; - -[Associative] -{ - c = a + b; - x = 3; -} -"; - //Assert.Fail("IDE-367 Debugger might fail with update using Assoc Language block in global scope"); - - fsr.PreStart(code); - fsr.Step(); - - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("x"); - Assert.IsTrue((Int64)o.Payload == 1); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - Assert.IsTrue((Int64)o.Payload == 2); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("c"); - Assert.IsTrue((Int64)o.Payload == 0); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - Assert.IsTrue((Int64)o.Payload == 2); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("t"); - Assert.IsTrue((Int64)o.Payload == 2); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("c"); - Assert.IsTrue((Int64)o.Payload == 4); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("x"); - Assert.IsTrue((Int64)o.Payload == 3); - - fsr.Step(); - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - Assert.IsTrue((Int64)o.Payload == 4); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("t"); - Assert.IsTrue((Int64)o.Payload == 8); - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void TestStepWithAssociativeReturnStatements() - { - string source = @" -def MakeItDouble : double(value : int) -{ - return = value * 1.0; -} - -d = MakeItDouble(250); -"; - fsr.PreStart(source); - - DebugRunner.VMState vms = fsr.StepOver(); // "d = MakeItDouble(250)" - Assert.AreEqual(7, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(23, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // "return = value * 1.0;" - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(4, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(26, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // "}" of function "MakeItDouble" - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(5, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // "d = MakeItDouble(250);" - Assert.AreEqual(7, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(23, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // Script execution ended. - Assert.AreEqual(true, vms.isEnded); - } - - [Test] - [Category("Debugger")] - public void TestStepForLoopWithRangeExpression() - { - string sourceCode = @" -[Imperative] -{ - x = 0; - for(index in 1..2) { - x = x + 1; - } -} -"; - - fsr.PreStart(sourceCode); - DebugRunner.VMState vms = fsr.StepOver(); // Highlight "x = 0;" - Assert.AreEqual("4, 5, 4, 11", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "for" - Assert.AreEqual("5, 5, 5, 8", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "1..2" - Assert.AreEqual("5, 18, 5, 22", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "in" - Assert.AreEqual("5, 15, 5, 17", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "index" - Assert.AreEqual("5, 9, 5, 14", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "x = x + 1;" - Assert.AreEqual("6, 9, 6, 19", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); - vms = fsr.StepOver(); // Highlight "in" - Assert.AreEqual("5, 15, 5, 17", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "index" - Assert.AreEqual("5, 9, 5, 14", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "x = x + 1;" - Assert.AreEqual("6, 9, 6, 19", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); - vms = fsr.StepOver(); // Highlight "in" - Assert.AreEqual("5, 15, 5, 17", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "}" of closing Imperative block. - Assert.AreEqual("8, 1, 8, 2", CodeRangeToString(vms.ExecutionCursor)); - - vms = fsr.StepOver(); // Execution ended. - Assert.AreEqual(true, vms.isEnded); - } - - [Test] - [Category("Debugger")] - public void TestStepForLoopWithFunctionCall() - { - string sourceCode = @" -def foo : int[]() { - return = 1..2; -} - -[Imperative] -{ - x = 0; - for(index in foo()) { - x = x + 1; - } -} -"; - - fsr.PreStart(sourceCode); - DebugRunner.VMState vms = fsr.StepOver(); // Highlight "x = 0;" - Assert.AreEqual("8, 5, 8, 11", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "for" - Assert.AreEqual("9, 5, 9, 8", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "foo()" - Assert.AreEqual("9, 18, 9, 23", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "in" - Assert.AreEqual("9, 15, 9, 17", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "index" - Assert.AreEqual("9, 9, 9, 14", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "x = x + 1;" - Assert.AreEqual("10, 9, 10, 19", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "}" - vms = fsr.StepOver(); // Highlight "in" - Assert.AreEqual("9, 15, 9, 17", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "index" - Assert.AreEqual("9, 9, 9, 14", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "x = x + 1;" - Assert.AreEqual("10, 9, 10, 19", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "}" - vms = fsr.StepOver(); // Highlight "in" - Assert.AreEqual("9, 15, 9, 17", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "}" of closing Imperative block. - Assert.AreEqual("12, 1, 12, 2", CodeRangeToString(vms.ExecutionCursor)); - - vms = fsr.StepOver(); // Execution ended. - Assert.AreEqual(true, vms.isEnded); - } - - [Test] - [Category("Debugger")] - public void TestStepForLoopWithIdentifier() - { - string sourceCode = @" -[Imperative] -{ - x = 0; - boo = [ 1, 2 ]; - for(index in boo) { - x = x + 1; - } -} -"; - - fsr.PreStart(sourceCode); - DebugRunner.VMState vms = fsr.StepOver(); // Highlight "x = 0;" - Assert.AreEqual("4, 5, 4, 11", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "boo = { 1, 2 };" - Assert.AreEqual("5, 5, 5, 20", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "for" - Assert.AreEqual("6, 5, 6, 8", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "boo" - Assert.AreEqual("6, 18, 6, 21", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "in" - Assert.AreEqual("6, 15, 6, 17", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "index" - Assert.AreEqual("6, 9, 6, 14", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "x = x + 1;" - Assert.AreEqual("7, 9, 7, 19", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "}" - vms = fsr.StepOver(); // Highlight "in" - Assert.AreEqual("6, 15, 6, 17", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "index" - Assert.AreEqual("6, 9, 6, 14", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "x = x + 1;" - Assert.AreEqual("7, 9, 7, 19", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "}" - vms = fsr.StepOver(); // Highlight "in" - Assert.AreEqual("6, 15, 6, 17", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "}" of closing Imperative block. - Assert.AreEqual("9, 1, 9, 2", CodeRangeToString(vms.ExecutionCursor)); - - vms = fsr.StepOver(); // Execution ended. - Assert.AreEqual(true, vms.isEnded); - } - - [Test] - [Category("Debugger")] - public void TestStepForLoopWithExpressionList() - { - string sourceCode = @" -[Imperative] -{ - x = 0; - for(index in [ 1, 2 ]) { - x = x + 1; - } -} -"; - - fsr.PreStart(sourceCode); - DebugRunner.VMState vms = fsr.StepOver(); // Highlight "x = 0;" - Assert.AreEqual("4, 5, 4, 11", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "for" - Assert.AreEqual("5, 5, 5, 8", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "{ 1, 2 }" - Assert.AreEqual("5, 18, 5, 26", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "in" - Assert.AreEqual("5, 15, 5, 17", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "index" - Assert.AreEqual("5, 9, 5, 14", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "x = x + 1;" - Assert.AreEqual("6, 9, 6, 19", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "}" - vms = fsr.StepOver(); // Highlight "in" - Assert.AreEqual("5, 15, 5, 17", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "index" - Assert.AreEqual("5, 9, 5, 14", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "x = x + 1;" - Assert.AreEqual("6, 9, 6, 19", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "}" - vms = fsr.StepOver(); // Highlight "in" - Assert.AreEqual("5, 15, 5, 17", CodeRangeToString(vms.ExecutionCursor)); - vms = fsr.StepOver(); // Highlight "}" of closing Imperative block. - Assert.AreEqual("8, 1, 8, 2", CodeRangeToString(vms.ExecutionCursor)); - - vms = fsr.StepOver(); // Execution ended. - Assert.AreEqual(true, vms.isEnded); - } - - private string CodeRangeToString(ProtoCore.CodeModel.CodeRange range) - { - return string.Format("{0}, {1}, {2}, {3}", - range.StartInclusive.LineNo, - range.StartInclusive.CharNo, - range.EndExclusive.LineNo, - range.EndExclusive.CharNo); - } - - [Test] - [Category("Debugger")] - public void TestStepInAssocLangBlockWithUpdate() - { - String code = -@" -[Associative] -{ - a = 2; - b = 2 + a; - a = 4; - c = 7; -} - -"; - fsr.PreStart(code); - fsr.Step(); - - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("a"); - string type = vms.mirror.GetType("a"); - - Assert.IsTrue((Int64)o.Payload == 2); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - - Assert.IsTrue((Int64)o.Payload == 4); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - type = vms.mirror.GetType("a"); - - Assert.IsTrue((Int64)o.Payload == 4); - Assert.IsTrue(type == "int"); - - int startLineNo, startCharNo; - - startLineNo = vms.ExecutionCursor.StartInclusive.LineNo; - startCharNo = vms.ExecutionCursor.StartInclusive.CharNo; - - Assert.IsTrue((Int64)startLineNo == 5); - Assert.IsTrue((Int64)startCharNo == 5); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - - Assert.IsTrue((Int64)o.Payload == 6); - Assert.IsTrue(type == "int"); - - startLineNo = vms.ExecutionCursor.StartInclusive.LineNo; - startCharNo = vms.ExecutionCursor.StartInclusive.CharNo; - - Assert.IsTrue((Int64)startLineNo == 7); - Assert.IsTrue((Int64)startCharNo == 5); - } - - [Test] - [Category("Debugger")] - public void TestStepInAssocLangBlockWithUpdate2() - { - String code = -@" -[Associative] -{ - a = 2; - b = 2 * a; - a = 4; - c = 7; -} - -"; - fsr.PreStart(code); - fsr.Step(); - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("a"); - string type = vms.mirror.GetType("a"); - - Assert.IsTrue((Int64)o.Payload == 2); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - - Assert.IsTrue((Int64)o.Payload == 4); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - type = vms.mirror.GetType("a"); - - Assert.IsTrue((Int64)o.Payload == 4); - Assert.IsTrue(type == "int"); - - int startLineNo, startCharNo; - - startLineNo = vms.ExecutionCursor.StartInclusive.LineNo; - startCharNo = vms.ExecutionCursor.StartInclusive.CharNo; - - Assert.IsTrue((Int64)startLineNo == 5); - Assert.IsTrue((Int64)startCharNo == 5); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - - Assert.IsTrue((Int64)o.Payload == 8); - Assert.IsTrue(type == "int"); - - startLineNo = vms.ExecutionCursor.StartInclusive.LineNo; - startCharNo = vms.ExecutionCursor.StartInclusive.CharNo; - - Assert.IsTrue((Int64)startLineNo == 7); - Assert.IsTrue((Int64)startCharNo == 2); - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void TestAddIntToDouble() - { - String code = - @" -[Imperative] -{ - def add:double( n1:int, n2:double ) - { - - return = n1 + n2; - - } - - test = add(2,2.5); - test1 = add(2,1); -}"; - - fsr.PreStart(code); - fsr.Step(); - - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("n1"); - string type = vms.mirror.GetType("n1"); - - Assert.IsTrue((Int64)o.Payload == 2); - Assert.IsTrue(type == "int"); - - o = vms.mirror.GetDebugValue("n2"); - type = vms.mirror.GetType("n2"); - - Assert.IsTrue((Double)o.Payload == 2.5); - Assert.IsTrue(type == "double"); - - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("test"); - type = vms.mirror.GetType("test"); - - Assert.IsTrue((Double)o.Payload == 4.5); - Assert.IsTrue(type == "double"); - - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("n1"); - type = vms.mirror.GetType("n1"); - - Assert.IsTrue((Int64)o.Payload == 2); - Assert.IsTrue(type == "int"); - - o = vms.mirror.GetDebugValue("n2"); - type = vms.mirror.GetType("n2"); - - Assert.IsTrue((Double)o.Payload == 1.0); - Assert.IsTrue(type == "double"); - - vms = fsr.Step(); - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("test1"); - type = vms.mirror.GetType("test1"); - - Assert.IsTrue((Double)o.Payload == 3.0); - Assert.IsTrue(type == "double"); - - } - - [Test] - [Category("Debugger")] - public void TestStepInImpLangBlock() - { - String code = -@" -[Imperative] -{ - a = 4; - b = 10; - c = a + b; - m = c; -} -"; - fsr.PreStart(code); - fsr.Step(); - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("a"); - string type = vms.mirror.GetType("a"); - - Assert.IsTrue((Int64)o.Payload == 4); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - - Assert.IsTrue((Int64)o.Payload == 10); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("c"); - type = vms.mirror.GetType("c"); - - Assert.IsTrue((Int64)o.Payload == 14); - Assert.IsTrue(type == "int"); - } - - [Test] - [Category("Debugger")] - public void TestStepInMultiLangBlocks() - { - String code = -@" -a = 9; -[Associative] -{ - a = 4; - b = 10; - c = a + b; - - [Imperative] - { - a = 5.0; - } -} -"; - fsr.PreStart(code); - - DebugRunner.VMState vms = fsr.Step(); - fsr.Step(); - Obj o = vms.mirror.GetDebugValue("a"); - string type = vms.mirror.GetType("a"); - - Assert.IsTrue((Int64)o.Payload == 9); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - type = vms.mirror.GetType("a"); - - Assert.IsTrue((Int64)o.Payload == 4); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - - Assert.IsTrue((Int64)o.Payload == 10); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("c"); - type = vms.mirror.GetType("c"); - - Assert.IsTrue((Int64)o.Payload == 14); - Assert.IsTrue(type == "int"); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - type = vms.mirror.GetType("a"); - - Assert.IsTrue((double)o.Payload == 5.0); - Assert.IsTrue(type == "double"); - } - - [Test] - [Category("Debugger")] - public void TestSSAassignments0() - { - String code = -@"a = 33; -b = a -2; -a = a + 1; -b = b - 1; -"; - fsr.PreStart(code); - fsr.Step(); - - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("a"); - Assert.IsTrue((Int64)o.Payload == 33); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - Assert.IsTrue((Int64)o.Payload == 31); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - Assert.IsTrue((Int64)o.Payload == 34); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - Assert.IsTrue((Int64)o.Payload == 32); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - Assert.IsTrue((Int64)o.Payload == 31); - } - - [Test] - [Category("Debugger")] - [Category("Failure")] - public void TestUpdateLoopWithNestedDifferentBlocks() - { - String code = @" -a = 7; -b = 3; -s = Print(""a = "" + a + "" b = "" + b); - -[Imperative] -{ - b = 5 * a; - s = Print(""b = "" + b); - c = 0; - d = 0; - - [Associative] - { - s = Print(""aa = "" + a); - c = a + 2; - s = Print(""cc = "" + c); - a = 10; - a = 33; - } - - d = c; - s = Print(""dd = "" + d); -} -"; - // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-3985 - fsr.PreStart(code); - fsr.Step(); // a = 7; - - DebugRunner.VMState vms = fsr.Step(); // b = 3; - - Obj o = vms.mirror.GetDebugValue("a"); - string type = vms.mirror.GetType("a"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 7); - - vms = fsr.Step(); // s = Print(...); - - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 3); - - vms = fsr.StepOver(); - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 35); - - vms = fsr.StepOver(); - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("c"); - type = vms.mirror.GetType("c"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 0); - - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("d"); - type = vms.mirror.GetType("d"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 0); - - vms = fsr.StepOver(); - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("c"); - type = vms.mirror.GetType("c"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 9); - - vms = fsr.StepOver(); - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("a"); - type = vms.mirror.GetType("a"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 10); - - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("c"); - type = vms.mirror.GetType("c"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 12); - - vms = fsr.StepOver(); - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("a"); - type = vms.mirror.GetType("a"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 33); - - vms = fsr.Step(); - vms = fsr.StepOver(); - - o = vms.mirror.GetDebugValue("c"); - type = vms.mirror.GetType("c"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 35); - - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.StepOver(); - - o = vms.mirror.GetDebugValue("d"); - type = vms.mirror.GetType("d"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 35); - - vms = fsr.Step(); - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(4, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(37, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void TestUpdateLoopWithZiggedDifferentBlocks() - { - String code = @" -a = [Imperative] -{ - c = 0; - return = c; -} - -b = a - 1; - -a = [Imperative] -{ - c = 1; - return = c; -} -"; - fsr.PreStart(code); - fsr.Step(); - - DebugRunner.VMState vms = fsr.Step(); - - Obj o = vms.mirror.GetDebugValue("c"); - string type = vms.mirror.GetType("c"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 0); - - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("a"); - type = vms.mirror.GetType("a"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 0); - - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == -1); - - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("c"); - type = vms.mirror.GetType("c"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 1); - - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("a"); - type = vms.mirror.GetType("a"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 1); - - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 0); - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void TestUpdateLoopInsideFunctionInAssociativeBlock() - { - String code = @" -[Associative] -{ - def foo3 : int[] ( a : double ) - { - return = a; - } - - dummyArg = 1.5; - - b2 = foo3 ( dummyArg ); -} - -"; - fsr.PreStart(code); - fsr.Step(); - - DebugRunner.VMState vms = fsr.Step(); - - Obj o = vms.mirror.GetDebugValue("dummyArg"); - string type = vms.mirror.GetType("dummyArg"); - Assert.IsTrue(type == "double"); - Assert.IsTrue((Double)o.Payload == 1.5); - - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("a"); - type = vms.mirror.GetType("a"); - Assert.IsTrue(type == "double"); - Assert.IsTrue((Double)o.Payload == 1.5); - - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("b2"); - type = vms.mirror.GetType("b2"); - List lo = UnpackToList(vms.mirror, o); - Assert.IsTrue(type == "array"); - Assert.IsTrue((Int64)lo[0].Payload == 2); - } - - [Test] - [Category("Debugger")] - public void TestSSAassignments2() - { - String code = - @" -a : int; -b : int; - -[Associative] -{ - a = 10; - b = 2 * a; - a = a+1; -}"; - fsr.PreStart(code); - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("a"); - Assert.AreNotEqual(null, o); - - o = vms.mirror.GetDebugValue("b"); - Assert.AreNotEqual(null, o); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - Assert.IsTrue((Int64)o.Payload == 10); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - Assert.IsTrue((Int64)o.Payload == 20); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - Assert.IsTrue((Int64)o.Payload == 11); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - Assert.IsTrue((Int64)o.Payload == 22); - - vms = fsr.Step(); - Assert.IsTrue(vms.isEnded); - } - - [Test] - [Category("Debugger")] - public void Numeric_Associative() - { - String code = - @" - -a : int; -b : int; - -[Associative] -{ - a = 10; - b = 2 * a; - a = a + 1; -}"; - - fsr.PreStart(code); - - DebugRunner.VMState vms = fsr.Step(); // a = 10; - Obj o = vms.mirror.GetDebugValue("a"); - Assert.IsTrue(null == o.Payload); - - o = vms.mirror.GetDebugValue("b"); - Assert.IsTrue(null == o.Payload); - - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("a"); - string type = vms.mirror.GetType("a"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 10); - - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 20); - - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("a"); - type = vms.mirror.GetType("a"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 11); - - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 22); - } - - [Test] - [Category("Debugger")] - public void Numeric_Imperative() - { - String code = - @" - -a : int; -b : int; - -[Imperative] -{ - a = 10; - b = 2 * a; - a = a + 1; -}"; - - fsr.PreStart(code); - - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("a"); - Assert.IsTrue(null == o.Payload); - - o = vms.mirror.GetDebugValue("b"); - Assert.IsTrue(null == o.Payload); - - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("a"); - string type = vms.mirror.GetType("a"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 10); - - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 20); - - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("a"); - type = vms.mirror.GetType("a"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 11); - } - - [Test] - [Category("Debugger")] - public void MirrorApiTest002() - { - string src = @" - a = [ 1, 2, 3, [ 4, 5, 6 ], 7, 8 ]; - "; - fsr.PreStart(src); - fsr.Step(); - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("a"); - string type = vms.mirror.GetType(o); - List os = UnpackToList(vms.mirror, o); - - Assert.IsTrue(type == "array"); - Assert.IsTrue(os.Count == 6); - Assert.IsTrue((Int64)UnpackToList(vms.mirror, os[3])[1].Payload == 5); - } - - [Test] - [Category("Debugger")] - public void StepOver001() - { - string src = @" - def foo : int(i : int, j : int) - { - return = i + j; - } - b = foo(1, 2);"; - - fsr.PreStart(src); - DebugRunner.VMState vms = fsr.StepOver(); - vms = fsr.StepOver(); - Obj o = vms.mirror.GetDebugValue("b"); - Assert.IsTrue((Int64)o.Payload == 3); - } - - [Test] - [Category("Debugger")] - [Category("Failure")] - public void ToggleBreakPoint001() - { - string src = @" - def foo : int(i : int, j : int) - { - return = i + j; - } - a = 0; - a = 1 + 2 + foo(3, 4) + 5 + foo(5, 6); - "; - - // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-3991 - string defectID = "MAGN-3991 Defects with Toggle breakpoint"; - fsr.PreStart(src); - ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint - { - LineNo = 7, - CharNo = 44 - }; - fsr.ToggleBreakpoint(cp); - cp = new ProtoCore.CodeModel.CodePoint - { - LineNo = 7, - CharNo = 60 - }; - fsr.ToggleBreakpoint(cp); - DebugRunner.VMState vms = fsr.Run(); - Obj o = vms.mirror.GetDebugValue("a"); - vms = fsr.Run(); - Obj o2 = vms.mirror.GetDebugValue("a"); - - Assert.IsTrue((Int64)o.Payload == 0, defectID); - Assert.IsTrue((Int64)o2.Payload == 26, defectID); - } - [Test] - [Category("Debugger")] - public void ToggleBreakPoint_Imperative_003() - { - string src = @" -a : int = 0; -b : int = 0; - -[Imperative] -{ - a = 10; - b = a * 2; - a = 15; -} -"; - - fsr.PreStart(src); - ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint - { - LineNo = 8, - CharNo = 0 - }; - fsr.ToggleBreakpoint(cp); - DebugRunner.VMState vms = fsr.Run(); - vms = fsr.Step(); - Obj o2 = vms.mirror.GetDebugValue("a"); - - Assert.IsTrue((Int64)o2.Payload == 10); - vms = fsr.Run(); - Assert.IsTrue(vms.isEnded); - } - [Test] - [Category("Debugger")] - public void ToggleBreakPoint_Associative_004() - { - string src = @" - a : int = 0; - b : int = 0; - - [Associative] - { - a = 10; - b = a * 2; - a = 15; - } - "; - - fsr.PreStart(src); - ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint - { - LineNo = 8, - CharNo = 8 - }; - fsr.ToggleBreakpoint(cp); - fsr.Step(); - DebugRunner.VMState vms = fsr.Run(); - Obj o2 = vms.mirror.GetDebugValue("a"); - - Assert.IsTrue((Int64)o2.Payload == 10); - vms = fsr.Run(); - vms = fsr.Run(); - Assert.IsTrue(vms.isEnded); - } - [Test] - [Category("Debugger")] - [Category("Failure")] - public void ToggleBreakPoint005() - { - string src = @" - a = 10; // single value - b = a * 2; - - a = [ 1, 4, -2 ]; // arbitrary collection - - a = 1..10; // range expression... assume 1 as increment - - a = 1..10..2; // range expression with defined increment - - a = 1..10..~2; // range expression with 'appropriate' increment - - a = 1..10..#3; // range expression with specified number of cases - - a = 10; // back to single values; - b = 2; - - c = a * b; // define an expression; - - a = 10..12; - b = 2..4; - - c = a<2> * b<1>; // cartesian replication - "; - - // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-3991 - string defectID = "MAGN-3991 Defects with Toggle breakpoint"; - fsr.PreStart(src); - ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint - { - LineNo = 18, - CharNo = 5 - }; - fsr.ToggleBreakpoint(cp); - DebugRunner.VMState vms = fsr.Run(); - Obj o2 = vms.mirror.GetDebugValue("b"); - - Assert.IsTrue((Int64)o2.Payload == 2, defectID); - fsr.Run(); - Assert.IsTrue(vms.isEnded, defectID); - } - [Test] - [Category("Debugger")] - public void ToggleBreakPoint006() - { - string src = @" - a=1; - "; - fsr.PreStart(src); - ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint - { - LineNo = 1, - CharNo = 2 - }; - fsr.ToggleBreakpoint(cp); - DebugRunner.VMState vms = fsr.Run(); - Obj o2 = vms.mirror.GetDebugValue("a"); - Assert.IsTrue((Int64)o2.Payload == 1); - Assert.IsTrue(vms.isEnded); - } - - [Test] - [Category("Debugger")] - public void ToggleBreakPoint002() - { - string src = @" - def foo : int(i : int, j : int) - { - return = i + j; - } - a = 0; - a = 1 + 2 + foo(3, 4) + 5 + foo(5, 6); - "; - - fsr.PreStart(src); - ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint - { - LineNo = 7, - CharNo = 44 - }; - fsr.ToggleBreakpoint(cp); - cp = new ProtoCore.CodeModel.CodePoint - { - LineNo = 7, - CharNo = 60 - }; - fsr.ToggleBreakpoint(cp); - fsr.ToggleBreakpoint(cp); - DebugRunner.VMState vms = fsr.Run(); - Obj o = vms.mirror.GetDebugValue("a"); - vms = fsr.Run(); - Obj o2 = vms.mirror.GetDebugValue("a"); - - Assert.IsTrue((Int64)o.Payload == 0); - Assert.IsTrue((Int64)o2.Payload == 26); - Assert.IsTrue(vms.isEnded); - } - - [Test] - [Category("Debugger")] - public void TestFFISetPropertyImperative() - { - String code = - @" -import(DummyBase from ""FFITarget.dll""); - -[Imperative] -{ - dummy = DummyBase.Create(); - dummy.Value = 868760; - a = dummy.Value; - b = 9; -}"; - - fsr.PreStart(code); - fsr.Step(); - - fsr.Step(); - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("dummy"); - //Verify the returned object type name is fully qualified name. - Assert.IsTrue(vms.mirror.GetType(o) == "FFITarget.DummyBase"); - - fsr.Step(); - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - Assert.IsTrue((Int64)o.Payload == 868760); - } - - [Test] - [Category("Failure")] - [Category("Debugger")] - public void TestFFISetPropertyAssociative() - { - String code = - @" -import(DummyBase from ""FFITarget.dll""); - -dummy = DummyBase.Create(); -dummy.Value = 868760; -a = dummy.Value;"; - - fsr.PreStart(code); - fsr.Step(); - - fsr.Step(); - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("dummy"); - //Verify the returned object type name is fully qualified name. - Assert.IsTrue(vms.mirror.GetType(o) == "FFITarget.DummyBase"); - - fsr.Step(); - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - Assert.IsTrue((Int64)o.Payload == 868760); - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void ImportTest001() - { - string src = - Path.GetFullPath(string.Format("{0}{1}", testPath, "ImportTest001.ds")); - string imp1 = - Path.GetFullPath(string.Format("{0}{1}", testPath, "import001.ds")); - string imp2 = - Path.GetFullPath(string.Format("{0}{1}", testPath, "import002.ds")); - - fsr.LoadAndPreStart(src); - - ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint - { - LineNo = 5, - CharNo = 3, - SourceLocation = new ProtoCore.CodeModel.CodeFile - { - FilePath = src - } - }; - fsr.ToggleBreakpoint(cp); - cp = new ProtoCore.CodeModel.CodePoint - { - LineNo = 3, - CharNo = 9, - SourceLocation = new ProtoCore.CodeModel.CodeFile - { - FilePath = imp1 - } - }; - fsr.ToggleBreakpoint(cp); - fsr.ToggleBreakpoint(cp); - cp = new ProtoCore.CodeModel.CodePoint - { - LineNo = 3, - CharNo = 9, - SourceLocation = new ProtoCore.CodeModel.CodeFile - { - FilePath = imp2 - } - }; - fsr.ToggleBreakpoint(cp); - - DebugRunner.VMState vms = fsr.Run(); - Obj o1 = vms.mirror.GetDebugValue("a"); - Assert.IsTrue(vms.ExecutionCursor.StartInclusive.SourceLocation.FilePath == src); - Assert.IsTrue((Int64)o1.Payload == 10); - vms = fsr.Run(); - Obj o2 = vms.mirror.GetDebugValue("j"); - Assert.IsTrue((Int64)o2.Payload == 20); - Assert.IsTrue(vms.ExecutionCursor.StartInclusive.SourceLocation.FilePath == imp2); - - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void LanguageBlockInsideFunction() - { - string src = @" - def foo : int() - { - return = [Imperative] - { - a = 10; - b = 20; - return = a + b; - } - } - c = foo(); - "; - - fsr.PreStart(src); - fsr.Step(); - - DebugRunner.VMState vms = fsr.Step(); - vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("a"); - string type = vms.mirror.GetType("a"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 10); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("b"); - type = vms.mirror.GetType("b"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 20); - - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("c"); - type = vms.mirror.GetType("c"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 30); - } - - [Test] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void LanguageBlockInsideFunction1() - { - string src = @" -def foo() -{ - [Associative] - { - c = 9; - } - return = 9; -} - -a = foo(); -"; - fsr.PreStart(src); - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - - Obj o = vms.mirror.GetDebugValue("a"); - string type = vms.mirror.GetType("a"); - Assert.IsTrue(type == "int"); - Assert.IsTrue((Int64)o.Payload == 9); - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void LanguageBlockInsideFunction2() - { - string src = @" - def clampRange : int(i : int, rangeMin : int, rangeMax : int) - { - result = [Imperative] - { - clampedValue = i; - if(i < rangeMin) - { - clampedValue = rangeMin; - } - elseif( i > rangeMax ) - { - clampedValue = rangeMax; - } - return = clampedValue; - } - return = result; - } - a = clampRange(101, 10, 100); - "; - - fsr.PreStart(src); - - fsr.Step(); - DebugRunner.VMState vms = fsr.Step(); - Obj o = vms.mirror.GetDebugValue("i"); - Assert.IsTrue((Int64)o.Payload == 101); - o = vms.mirror.GetDebugValue("rangeMin"); - Assert.IsTrue((Int64)o.Payload == 10); - o = vms.mirror.GetDebugValue("rangeMax"); - Assert.IsTrue((Int64)o.Payload == 100); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("clampedValue"); - Assert.IsTrue((Int64)o.Payload == 101); - - int startLineNo, startCharNo; - vms = fsr.Step(); - // test for line (ie the elseif) - startLineNo = vms.ExecutionCursor.StartInclusive.LineNo; - startCharNo = vms.ExecutionCursor.StartInclusive.CharNo; - - Assert.IsTrue((Int64)startLineNo == 11); - Assert.IsTrue((Int64)startCharNo == 34); - - vms = fsr.Step(); - // test for line (ie inside elseif) - startLineNo = vms.ExecutionCursor.StartInclusive.LineNo; - startCharNo = vms.ExecutionCursor.StartInclusive.CharNo; - - Assert.IsTrue((Int64)startLineNo == 13); - Assert.IsTrue((Int64)startCharNo == 35); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("clampedValue"); - Assert.IsTrue((Int64)o.Payload == 100); - - fsr.Step(); - fsr.Step(); - - vms = fsr.Step(); - fsr.Step(); - o = vms.mirror.GetDebugValue("result"); - Assert.IsTrue((Int64)o.Payload == 100); - - fsr.Step(); - - vms = fsr.Step(); - o = vms.mirror.GetDebugValue("a"); - Assert.IsTrue((Int64)o.Payload == 100); - } - - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void LanguageBlockInsideFunction5() - { - string src = -@"gg = 0; - -def foo () -{ - arr = [ [ ] ]; - - [Imperative] - { - - for(i in [0, 1]) - { - [Associative] - { - gg = i; - arr[i] = [1, 2]; - } - } - } - return = arr; -} -test = foo();"; - - fsr.PreStart(src); - fsr.Step(); // gg = 0; - - DebugRunner.VMState vms = fsr.Step(); // test = foo(); - //Obj o = vms.mirror.GetDebugValue("gg"); - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"gg"); - Obj o = mirror.GetWatchValue(); - Assert.IsTrue((Int64)o.Payload == 0); - - fsr.Step(); // arr = { { } }; - - vms = fsr.Step(); - //o = vms.mirror.GetDebugValue("arr"); - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"arr"); - //Assert.IsTrue(vms.mirror.GetType("arr") == "array"); - Assert.IsTrue(mirror.GetType("arr") == "array"); - - fsr.Step(); - fsr.Step(); - fsr.Step(); - - vms = fsr.Step(); // gg = i; - //o = vms.mirror.GetDebugValue("i"); - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"i"); - o = mirror.GetWatchValue(); - Assert.IsTrue((Int64)o.Payload == 0); - - vms = fsr.Step(); // arr[i] = {1, 2}; - //o = vms.mirror.GetDebugValue("gg"); - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"gg"); - o = mirror.GetWatchValue(); - Assert.IsTrue((Int64)o.Payload == 0); - - vms = fsr.Step(); - //o = vms.mirror.GetDebugValue("arr"); - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"arr"); - o = mirror.GetWatchValue(); - - List ol = UnpackToList(vms.mirror, o); - Assert.IsTrue(ol.Count == 1); - List ol_1 = UnpackToList(mirror, ol[0]); - Assert.IsTrue(ol_1.Count == 2); - Assert.IsTrue((Int64)ol_1[0].Payload == 1); - Assert.IsTrue((Int64)ol_1[1].Payload == 2); - - fsr.Step(); - fsr.Step(); - - vms = fsr.Step(); - fsr.Step(); // gg = i; - //o = vms.mirror.GetDebugValue("i"); - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"i"); - o = mirror.GetWatchValue(); - Assert.IsTrue((Int64)o.Payload == 1); - - vms = fsr.Step(); // arr[i] = {1, 2}; - //o = vms.mirror.GetDebugValue("gg"); - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"gg"); - o = mirror.GetWatchValue(); - Assert.IsTrue((Int64)o.Payload == 1); - - vms = fsr.Step(); - //o = vms.mirror.GetDebugValue("arr"); - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"arr"); - o = mirror.GetWatchValue(); - ol = UnpackToList(vms.mirror, o); - //Assert.IsTrue(ol.Count == 2); - List ol_2 = UnpackToList(vms.mirror, ol[1]); - Assert.IsTrue(ol_2.Count == 2); - Assert.IsTrue((Int64)ol_2[0].Payload == 1); - Assert.IsTrue((Int64)ol_2[1].Payload == 2); - - fsr.Step(); - fsr.Step(); - fsr.Step(); - fsr.Step(); - - vms = fsr.Step(); - fsr.Step(); - //o = vms.mirror.GetDebugValue("test"); - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"test"); - o = mirror.GetWatchValue(); - ol = UnpackToList(vms.mirror, o); - Assert.IsTrue(ol.Count == 2); - - ol_1 = UnpackToList(vms.mirror, ol[0]); - Assert.IsTrue(ol_1.Count == 2); - Assert.IsTrue((Int64)ol_1[0].Payload == 1); - Assert.IsTrue((Int64)ol_1[1].Payload == 2); - - ol_2 = UnpackToList(vms.mirror, ol[1]); - Assert.IsTrue(ol_2.Count == 2); - Assert.IsTrue((Int64)ol_2[0].Payload == 1); - Assert.IsTrue((Int64)ol_2[1].Payload == 2); - } - - [Test] - [Category("Debugger")] - public void FunctionPointer1() - { - string src = -@"arr = [ 3, 5, 1, 5, 3, 4, 7, true, 5, null, 12]; -def Compare(x, y) -{ - return = [Imperative] - { - if (null == x) - return = -1; - if (null == y) - return = 1; - - a : int = x; - b : int = y; - if (null == a && null == b) - return = 0; - if (null == a) - return = - 1; - if (null == b) - return = 1; - return = (a - b); - } -} - -sorted = Sort(Compare, arr); //Stepping over this statement throws exception for empty stack. -"; - //Assert.Fail("IDE-390 Stepping into a function throws an index out of range exception (function pointer)"); - fsr.PreStart(src); - fsr.Step(); - - DebugRunner.VMState vms = fsr.Step(); - - Obj o = vms.mirror.GetDebugValue("arr"); - string type = vms.mirror.GetType("arr"); - List lo = UnpackToList(vms.mirror, o); - Assert.IsTrue(type == "array"); - Assert.IsTrue((Int64)lo[0].Payload == 3); - Assert.IsTrue((Int64)lo[1].Payload == 5); - Assert.IsTrue((Int64)lo[2].Payload == 1); - Assert.IsTrue((Int64)lo[3].Payload == 5); - Assert.IsTrue((Int64)lo[4].Payload == 3); - Assert.IsTrue((Int64)lo[5].Payload == 4); - Assert.IsTrue((Int64)lo[6].Payload == 7); - Assert.IsTrue((Boolean)lo[7].Payload == true); - Assert.IsTrue((Int64)lo[8].Payload == 5); - Assert.AreEqual(null, lo[9].Payload); - Assert.IsTrue((Int64)lo[10].Payload == 12); - - fsr.Step(); - vms = fsr.Step(); - - o = vms.mirror.GetDebugValue("sorted"); - type = vms.mirror.GetType("sorted"); - lo = UnpackToList(vms.mirror, o); - Assert.IsTrue(type == "array"); - Assert.AreEqual(null, lo[0].Payload); - Assert.IsTrue((Boolean)lo[1].Payload == true); - Assert.IsTrue((Int64)lo[2].Payload == 1); - Assert.IsTrue((Int64)lo[3].Payload == 3); - Assert.IsTrue((Int64)lo[4].Payload == 3); - Assert.IsTrue((Int64)lo[5].Payload == 4); - Assert.IsTrue((Int64)lo[6].Payload == 5); - Assert.IsTrue((Int64)lo[7].Payload == 5); - Assert.IsTrue((Int64)lo[8].Payload == 5); - Assert.IsTrue((Int64)lo[9].Payload == 7); - Assert.IsTrue((Int64)lo[10].Payload == 12); - } - - [Test] - [Category("Debugger")] - public void HighlightingFunctionsInArrayAssociative1_Defect_IDE_578() - { - string src = - @" -def f(a : int) -{ - return = a; -} - -arr = [ f(99), f(87) ]; -b = 2;"; - fsr.PreStart(src); - DebugRunner.VMState vms = fsr.Step(); - - Assert.AreEqual(7, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(24, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); - - Assert.AreEqual(8, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(8, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Failure")] - [Category("Debugger")] - public void HighlightingFunctionsInArrayImperative_Defect_IDE_578() - { - string src = - @" -def f(a : int) -{ - return = a; -} - -[Imperative] -{ - arr = [ f(99), f(87) ]; - b = 2; -}"; - fsr.PreStart(src); - DebugRunner.VMState vms = fsr.Step(); - - Assert.AreEqual(9, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(9, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(28, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"arr[0]"); - Obj o1 = mirror.GetWatchValue(); - Assert.AreEqual(99, (Int64)o1.Payload); - - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"arr[1]"); - o1 = mirror.GetWatchValue(); - Assert.AreEqual(87, (Int64)o1.Payload); - - Assert.AreEqual(10, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(10, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(11, vms.ExecutionCursor.EndExclusive.CharNo); - } - - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void Defect_IDE_619_1() - { - string src = - @"x = 33; - -def foo(y : int) -{ - return = y + 222; -} - -a = x < foo(22) ? 3 : 55; -"; - - fsr.PreStart(src); - DebugRunner.VMState vms = fsr.Step(); - - // highlights "x = 33;" - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(1, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(8, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); - - // highlights "a = x < foo(22) ? 3 : 55;" - Assert.AreEqual(8, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(8, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(26, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); - - // highlights "return = y + 222;" - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(5, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(22, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); - - // highlights "}" - Assert.AreEqual(6, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(6, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); - - // highlights "a = x < foo(22) ? 3 : 55;" - Assert.AreEqual(8, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(8, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(26, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); - - // close - Assert.AreEqual(0, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(0, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(0, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(0, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Debugger")] - public void SteppingOverinline_Imperative_723() - { - string src = - @"x = 330; - - def foo(y : int) - { - return = y + 222; - } - - [Imperative] - { - a = x > foo(20) ? 44 : foo(55); //Line 10 - b = 2; - }"; - fsr.PreStart(src); - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.StepOver(); - vms = fsr.StepOver(); - - { - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a"); - Obj objExecVal = mirror.GetWatchValue(); - //TestFrameWork.Verify(mirror, "a", 44, 1); - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(44, (Int64)objExecVal.Payload); - - } - vms = fsr.StepOver(); - { - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"b"); - Obj objExecVal = mirror.GetWatchValue(); - //TestFrameWork.Verify(mirror, "b", 2, 1); - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(2, (Int64)objExecVal.Payload); - } - - } - [Test] - [Category("Debugger")] - public void SteppingOverinline_Imperative_723_2() - { - string src = - @"x = 30; - - def foo(y : int) - { - return = y + 222; - } - - [Imperative] - { - a = x > foo(20) ? 44 : foo(55); //Line 10 - b = 2; - }"; - fsr.PreStart(src); - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.StepOver(); - vms = fsr.StepOver(); - - { - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a"); - Obj objExecVal = mirror.GetWatchValue(); - TestFrameWork.Verify(mirror, "a", 277, 1); - - } - vms = fsr.StepOver(); - { - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"b"); - Obj objExecVal = mirror.GetWatchValue(); - TestFrameWork.Verify(mirror, "b", 2, 1); - } - - } - [Test] - [Category("Debugger")] - public void SteppingOverinline_Imperative_723_3() - { - string src = - @"x = 330; - - def foo(y : int) - { - return = y + 222; - } - a; - [Imperative] - { - a = x > 20 ? foo(44) : foo(55); //Line 10 - b = 2; - }"; - fsr.PreStart(src); - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.StepOver(); - vms = fsr.StepOver(); - - { - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a"); - Obj objExecVal = mirror.GetWatchValue(); - //TestFrameWork.Verify(mirror, "a", 266, 1); - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(266, (Int64)objExecVal.Payload); - - } - vms = fsr.StepOver(); - { - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"b"); - Obj objExecVal = mirror.GetWatchValue(); - //TestFrameWork.Verify(mirror, "b", 2, 1); - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(2, (Int64)objExecVal.Payload); - } - - } - [Test] - [Category("Debugger")] - public void SteppingOverinline_Imperative_723_4() - { - string src = - @"x = 10; - - def foo(y : int) - { - return = y + 222; - } - a; - [Imperative] - { - a = x > 20 ? foo(44) : foo(55); //Line 10 - b = 2; - }"; - fsr.PreStart(src); - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.StepOver(); - vms = fsr.StepOver(); - - { - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a"); - Obj objExecVal = mirror.GetWatchValue(); - //TestFrameWork.Verify(mirror, "a", 277, 1); - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(277, (Int64)objExecVal.Payload); - - } - vms = fsr.StepOver(); - { - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"b"); - Obj objExecVal = mirror.GetWatchValue(); - //TestFrameWork.Verify(mirror, "b", 2, 1); - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(2, (Int64)objExecVal.Payload); - } - - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void TestStepInSimpleFunction() - { - string src = - @"def foo : int(a : int) - { - return = a; - } - c1 = foo(10);"; - - fsr.PreStart(src); - DebugRunner.VMState vms = fsr.Step(); // c1 = foo(10); - - vms = fsr.Step(); // return = a; - - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); - { - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a"); - Obj objExecVal = mirror.GetWatchValue(); - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(10, (Int64)objExecVal.Payload); - - } - } - - - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void StepIn_inlineconditional_Imperative_722() - { - string src = - @"def foo : int(a : int, b : int) - { - return = x = a > b ? a : b; - } - c1 = foo(10, 3); - Print(c1);"; - fsr.PreStart(src); - DebugRunner.VMState vms = fsr.Step(); // c1 = foo(10, 3); - - vms = fsr.Step(); // return = x = a > b ? a : b; - - - - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); - { - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a"); - Obj objExecVal = mirror.GetWatchValue(); - //TestFrameWork.Verify(mirror, "a", 10, 0); - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(10, (Int64)objExecVal.Payload); - - } - - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); - { - ExpressionInterpreterRunner watchRunner2 = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror2 = watchRunner2.Execute(@"b"); - Obj objExecVal2 = mirror2.GetWatchValue(); - //TestFrameWork.Verify(mirror2, "b", 3, 0); - Assert.AreNotEqual(null, objExecVal2); - Assert.AreEqual(3, (Int64)objExecVal2.Payload); - } - - vms = fsr.Step(); - vms = fsr.Step(); - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - { - ExpressionInterpreterRunner watchRunner3 = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror3 = watchRunner3.Execute(@"x"); - Obj objExecVal3 = mirror3.GetWatchValue(); - //TestFrameWork.Verify(mirror3, "x", 10, 0); - Assert.AreNotEqual(null, objExecVal3); - Assert.AreEqual(10, (Int64)objExecVal3.Payload); - } - - vms = fsr.Step(); - vms = fsr.Step(); - Assert.AreEqual(6, vms.ExecutionCursor.StartInclusive.LineNo); - { - ExpressionInterpreterRunner watchRunner4 = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror4 = watchRunner4.Execute(@"c1"); - Obj objExecVal4 = mirror4.GetWatchValue(); - //TestFrameWork.Verify(mirror4, "c1", 10, 0); - Assert.AreNotEqual(null, objExecVal4); - Assert.AreEqual(10, (Int64)objExecVal4.Payload); - } - - } - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void StepIn_inlineconditional_Imperative_722_2() - { - string src = - @"def foo : int(a : int, b : int) - { - return = a > b ? a : b; - } - - c1 = foo(10, 3); - Print(c1);"; - fsr.PreStart(src); - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.Step(); - - - - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); - { - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a"); - Obj objExecVal = mirror.GetWatchValue(); - //TestFrameWork.Verify(mirror, "a", 10, 0); - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(10, (Int64)objExecVal.Payload); - - } - - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); - { - ExpressionInterpreterRunner watchRunner2 = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror2 = watchRunner2.Execute(@"b"); - Obj objExecVal2 = mirror2.GetWatchValue(); - // TestFrameWork.Verify(mirror2, "b", 3, 0); - Assert.AreNotEqual(null, objExecVal2); - Assert.AreEqual(3, (Int64)objExecVal2.Payload); - } - - - - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - - { - ExpressionInterpreterRunner watchRunner4 = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror4 = watchRunner4.Execute(@"c1"); - Obj objExecVal4 = mirror4.GetWatchValue(); - TestFrameWork.Verify(mirror4, "c1", 10, 0); - } - - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("Debugger")] - public void StepIn_inlineconditional_Imperative_722_3() - { - string src = - @"[Imperative] - { - def foo : int(a : int, b : int) - { - return = x = a > b ? a : b; - } - c1 = foo(10, 3); - - Print(c1); - }"; - fsr.PreStart(src); - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.Step(); - - - - - { - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a"); - Obj objExecVal = mirror.GetWatchValue(); - //TestFrameWork.Verify(mirror, "a", 10, 2); - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(10, (Int64)objExecVal.Payload); - - } - - - { - ExpressionInterpreterRunner watchRunner2 = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror2 = watchRunner2.Execute(@"b"); - Obj objExecVal2 = mirror2.GetWatchValue(); - //TestFrameWork.Verify(mirror2, "b", 3, 2); - Assert.AreNotEqual(null, objExecVal2); - Assert.AreEqual(3, (Int64)objExecVal2.Payload); - } - - vms = fsr.Step(); - vms = fsr.Step(); - { - ExpressionInterpreterRunner watchRunner3 = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror3 = watchRunner3.Execute(@"x"); - Obj objExecVal3 = mirror3.GetWatchValue(); - //TestFrameWork.Verify(mirror3, "x", 10, 2); - Assert.AreNotEqual(null, objExecVal3); - Assert.AreEqual(10, (Int64)objExecVal3.Payload); - } - - - vms = fsr.Step(); - vms = fsr.Step(); - - { - ExpressionInterpreterRunner watchRunner4 = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror4 = watchRunner4.Execute(@"c1"); - Obj objExecVal4 = mirror4.GetWatchValue(); - TestFrameWork.Verify(mirror4, "c1", 10, 1); - } - - } - [Test, Category("Failure")] - [Category("Debugger")] - public void cyclicdependancy_726() - { - string src = - @"a = 1..3; - c = a; - - b = [ Imperative ] - { - count = 0; - for ( i in a ) - { - if ( i > 0 ) - { - a[count] = i + 1; - } - count = count+1; - } - return = a; - } - - d = [ Imperative ] - { - count2 = 0; - while (count2 <= 2 ) - { - if ( a[count2] > 0 ) - { - a[count2] = a[count2] + 1; - } - count2 = count2+1; - } - return = a; - } - - e = b;"; - fsr.PreStart(src); - DebugRunner.VMState vms = fsr.Step(); - - - fsr.Run(); - Assert.AreEqual(fsr.isEnded, true); - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a"); - TestFrameWork.Verify(mirror, "b", new[] {2, 3, 4}); - TestFrameWork.Verify(mirror, "d", new[] { 2, 3, 4 }); - TestFrameWork.Verify(mirror, "c", new[] { 1, 2, 3 }); - } - [Test] - [Category("Debugger")] - public void cyclicdependancy_726_2() - { - string src = - @"a = 1; - - b = a; - - c = [ Imperative ] - - { - - a = 2; - - return = a; - - } - - d = [ Imperative ] - - { - - a = 3; - - return = a; - - } - - e = c; - - f = d;"; - fsr.PreStart(src); - DebugRunner.VMState vms = fsr.Step(); - fsr.Run(); - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a"); - TestFrameWork.Verify(mirror, "b", 1); - TestFrameWork.Verify(mirror, "c", 2); - TestFrameWork.Verify(mirror, "d", 3); - } - [Test] - [Category("ExpressionInterpreterRunner")] - public void TestWatchExpressionInNestedBlock2_519() - { - // Execute and verify the defect IDE-519 - fsr.PreStart( -@"[Imperative] -{ - i = 3; - -[Associative] -{ - - - f = i; -} - c = f; -} -"); - - DebugRunner.VMState vms = fsr.Step();//Line 5 - - vms = fsr.StepOver();//Line 6 - - { - // Get the value of "i". - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"i"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(3, (Int64)objExecVal.Payload); - } - - vms = fsr.StepOver();//Line 7 - - { - // Get the value of "i". - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"i"); - Obj objExecVal = mirror.GetWatchValue(); - // It should not be available. - object o = vms.mirror.GetDebugValue("f"); - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(3, (Int64)objExecVal.Payload); - - } - } - - [Test, Category("Failure")] - [Category("ExpressionInterpreterRunner")] - public void Testprivatememberpropertyinwatch_544() - { - // Execute and verify the defect IDE-519 - fsr.PreStart( - @"def func(d : int) - { - m : int; - m = 10; - temp = 0; - // Line #5 - [Imperative] - { - temp = m; - // Line #8 - } - return = temp; // Line #10 - } - n = func(1); - - "); - DebugRunner.VMState vms = fsr.Step(); - vms = fsr.Step();//Line 6 - vms = fsr.Step(); - vms = fsr.Step(); - - { - // Get the value of "i". - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"m"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreEqual(10, (Int64)objExecVal.Payload); - } - vms = fsr.Step(); - vms = fsr.Step(); - - { - // Get the value of "i". - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"temp"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreEqual(0, (Int64)objExecVal.Payload); - } - - } - - [Test] - [Category("ExpressionInterpreterRunner")] - public void Testprivatememberpropertyinwatch_544_2() - { - // Execute and verify the defect IDE-519 - fsr.PreStart( - @"def func(d : int) - { - m : int; - m = 10; - temp = 0; - // Line #5 - [Associative] - { - temp = m; - // Line #8 - } - return = temp; // Line #10 - } - n = func(1); - - "); - DebugRunner.VMState vms = fsr.Step(); - vms = fsr.Step();//Line 6 - vms = fsr.Step(); - vms = fsr.Step(); - - { - // Get the value of "i". - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"m"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreEqual(10, (Int64)objExecVal.Payload); - } - vms = fsr.Step(); - vms = fsr.Step(); - - { - // Get the value of "i". - // This is to simulate the refresh of watch window as a result of "Step" button. - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"temp"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreEqual(10, (Int64)objExecVal.Payload); - } - } - - [Test] - [Category("Debugger")] - public void Defect_IDE_543_1() - { - fsr.PreStart( - @"[Imperative] -{ - a = 1..8..1; -}"); - DebugRunner.VMState vms = fsr.Step(); - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(3, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(17, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(4, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Debugger")] - public void Defect_IDE_543_2() - { - fsr.PreStart( - @"[Imperative] -{ - a = 1..8..1; -}"); - DebugRunner.VMState vms = fsr.Step(); - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(3, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(17, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(4, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Debugger")] - public void Defect_IDE_543_3() - { - fsr.PreStart( - @"[Imperative] -{ - a = 0.5..0.25..-0.25; -}"); - DebugRunner.VMState vms = fsr.Step(); - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(3, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(26, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(4, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Debugger")] - public void Defect_IDE_543_4() - { - fsr.PreStart( - @"[Imperative] -{ - a = 0.5..0.25..-0.25; -}"); - DebugRunner.VMState vms = fsr.Step(); - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(3, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(26, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(4, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Debugger")] - public void Defect_IDE_543_5() - { - fsr.PreStart( - @"[Associative] -{ - a = 1..8..1; -}"); - DebugRunner.VMState vms = fsr.Step(); - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(3, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(17, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(4, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Debugger")] - public void Defect_IDE_543_6() - { - fsr.PreStart( - @"[Associative] -{ - a = 1..8..1; -}"); - DebugRunner.VMState vms = fsr.Step(); - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(3, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(17, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(4, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Debugger")] - public void Defect_IDE_543_7() - { - fsr.PreStart( - @"[Associative] -{ - a = 0.5..0.25..-0.25; -}"); - DebugRunner.VMState vms = fsr.Step(); - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(3, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(26, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(4, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Debugger")] - public void Defect_IDE_543_8() - { - fsr.PreStart( - @"[Associative] -{ - a = 0.5..0.25..-0.25; -}"); - DebugRunner.VMState vms = fsr.Step(); - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(3, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(26, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(4, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Debugger")] - public void Defect_IDE_656_4_stepOver() - { - fsr.PreStart( - @"c = [ 1, 2, 20 ]; -def f(a) -{ - return = a; -} -x = f(c) > 5 ? 1 : 2; -b = 2;"); - - DebugRunner.VMState vms = fsr.Step(); // c = { 1, 2, 20 }; - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(1, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(18, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // x = f(c) > 5 ? 1 : 2; - Assert.AreEqual(6, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(6, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(22, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.StepOver(); // b = 2; - Assert.AreEqual(7, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Debugger")] - [Category("Failure")] - public void Defect_IDE_656_4_stepIn() - { - fsr.PreStart( - @"c = [ 1, 2, 20 ]; -def f(a) -{ - return = a; -} -x = f(c) > 5 ? 1 : 2; -b = 2;"); - - // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-3961 - Assert.Fail("Stepping In external functions and replicated functions requires two 'step in's to move to the next line"); - - DebugRunner.VMState vms = fsr.Step(); // c = { 1, 2, 20 }; - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(1, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(18, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // x = f(c) > 5 ? 1 : 2; - Assert.AreEqual(6, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(6, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(22, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // b = 2; - Assert.AreEqual(7, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("Debugger")] - [Category("Failure")] - public void Defect_IDE_722() - { - fsr.PreStart( - @"def foo : int(a : int, b : int) -{ - return = x = a > b ? a : b; -} -c1 = foo(10, 3); -Print(c1);"); - - // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-3962 - Assert.Fail("Cannot Step In to the return statement of a function if it contains a In Line Condition"); - - DebugRunner.VMState vms = fsr.Step(); // c1 = foo(10, 3); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(5, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(17, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // return = x = a > b ? a : b; - Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(3, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(32, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); - Assert.AreEqual(4, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(4, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // c1 = foo(10, 3); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(5, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(17, vms.ExecutionCursor.EndExclusive.CharNo); - - } - - [Test] - [Category("Debugger")] - [Category("Failure")] - public void Defect_IDE_722_1() - { - fsr.PreStart( - @"[Imperative] -{ - def foo : int(a : int, b : int) - { - return = x = a > b ? a : b; - } - c1 = foo(10, 3); - - Print(c1); -}"); - - // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-3962 - Assert.Fail("IDE-722 Cannot Step In to the return statement of a function if it contains a In Line Condition"); - - DebugRunner.VMState vms = fsr.Step(); // c1 = foo(10, 3); - Assert.AreEqual(7, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(21, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // return = x = a > b ? a : b; - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(9, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(5, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(36, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); - - vms = fsr.Step(); // c1 = foo(10, 3); - Assert.AreEqual(7, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(21, vms.ExecutionCursor.EndExclusive.CharNo); - } - - [Test] - [Category("ExpressionInterpreterRunner")] - public void watchinImperative_542_5() - { - // Execute and verify the main script in a debug session - fsr.PreStart( - @" -a;b; -[Associative] -{ - a = 0; - d = a + 1; - [Imperative] - { - b = 2 + a; - a = 1.5; - - } - c = 2; -} - -"); - - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.StepOver(); - - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a"); - Obj objExecVal = mirror.GetWatchValue(); - - TestFrameWork.Verify(mirror, "a", 0); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - - TestFrameWork.Verify(mirror, "b", null); - - } - - [Test, Category("Failure")] - [Category("ExpressionInterpreterRunner")] - - public void watchinImperative_nested_666() - { - // Execute and verify the main script in a debug session - fsr.PreStart( - @" -r = 0; - -[Imperative] -{ - for(i in 0..1) - { - for(k in 0..10) - { - r = k; - } - } -} - -"); - - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"k"); - Obj objExecVal = mirror.GetWatchValue(); - - TestFrameWork.Verify(mirror, "k", 0); - TestFrameWork.Verify(mirror, "r", 0); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - TestFrameWork.Verify(mirror, "k", 0); - TestFrameWork.Verify(mirror, "r", 0); - - } - [Test, Category("Failure")] - [Category("ExpressionInterpreterRunner")] - - public void watchinImperative_nested_666_2() - { - // Execute and verify the main script in a debug session - fsr.PreStart( - @" -r = 0; - -[Imperative] -{ - - for(i in 0..1) - { - for(j in 0..10) - { - for(k in 0..10) - { - r = k; - } - } - } -} -r = 0; - -"); - - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"k"); - Obj objExecVal = mirror.GetWatchValue(); - - TestFrameWork.Verify(mirror, "k", 0, 0); - TestFrameWork.Verify(mirror, "r", 0, 0); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - TestFrameWork.Verify(mirror, "k", 1, 0); - TestFrameWork.Verify(mirror, "r", 1, 0); - - } - [Test, Category("Failure")] - [Category("ExpressionInterpreterRunner")] - - public void watchinImperative_nested_666_3() - { - // Execute and verify the main script in a debug session - fsr.PreStart( - @" -r = 0; - - def foo() - { - [Imperative] - { - for(i in 0..1) - { - for(j in 0..10) - { - for(k in 0..10) - { - r = k; - } - } - } - } - } - - a = foo(); - -"); - - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"k"); - Obj objExecVal = mirror.GetWatchValue(); - - TestFrameWork.Verify(mirror, "k", 0, 0); - TestFrameWork.Verify(mirror, "r", 0, 0); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - - TestFrameWork.Verify(mirror, "k", 1, 0); - TestFrameWork.Verify(mirror, "r", 0, 0); - - } - - [Test] - [Category("ExpressionInterpreterRunner")] - [Category("Failure")] - public void inlineconditional_656_3() - { - // Execute and verify the main script in a debug session - fsr.PreStart( - @" -x = 330; - -def foo(y : int) -{ - return = y + 222; -} -a; -[Imperative] -{ - a = x > foo(20) ? 44 : foo(55); //Line 10 - b = 2; -} - -"); - - // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-1568 - Assert.Fail("IDE-656Regression: Debugging stops at inline condition"); - DebugRunner.VMState vms = fsr.Step(); // x = 330; - - vms = fsr.StepOver(); // a = x > 20 ? foo(44) : 55 ; - - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"x"); - Obj objExecVal = mirror.GetWatchValue(); - TestFrameWork.Verify(mirror, "x", 330, 0); - vms = fsr.StepOver(); - TestFrameWork.Verify(mirror, "a", null, 0); - vms = fsr.StepOver(); // b = 2; - TestFrameWork.Verify(mirror, "a", 44, 0); - vms = fsr.StepOver(); // b = 2; - - TestFrameWork.Verify(mirror, "b", 22, 0); - - - - } - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("ExpressionInterpreterRunner")] - public void inlineconditional_stepin_656_3() - { - fsr.PreStart( // Execute and verify the main script in a debug session - @" -x = 330; - -def foo(y : int) -{ - return = y + 222; -} -a; -b; -[Imperative] -{ - a = x > foo(20) ? 44 : foo(55); //Line 10 - b = 2; -} - -"); - - DebugRunner.VMState vms = fsr.Step(); // x = 330; - - vms = fsr.Step(); // a = x > 20 ? foo(44) : 55 ; - - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"x"); - // Obj objExecVal = mirror.GetWatchValue(); - TestFrameWork.Verify(mirror, "x", 330, 0); - vms = fsr.Step(); - TestFrameWork.Verify(mirror, "a", null, 0); - vms = fsr.Step(); - - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"y"); - Obj objExecVal = mirror.GetWatchValue(); - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(20, objExecVal.Payload); - vms = fsr.Step(); - vms = fsr.Step(); // b = 2; - vms = fsr.Step(); - TestFrameWork.Verify(mirror, "a", 44, 0); - vms = fsr.Step(); // b = 2; - // b = 2; - TestFrameWork.Verify(mirror, "b", 2, 0); - // b = 2; - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("ExpressionInterpreterRunner")] - public void inlineconditional_stepin_656_4() - { - fsr.PreStart( // Execute and verify the main script in a debug session - @" -x = 330; - -def foo(y : int) -{ - return = y + 222; -} -a; -b; -[Imperative] -{ - a = x > 20 ? foo(44) : foo(55); //Line 10 - b = 2; -} - -"); - - DebugRunner.VMState vms = fsr.Step(); // x = 330; - - vms = fsr.Step(); // a = x > 20 ? foo(44) : 55 ; - - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"x"); - // Obj objExecVal = mirror.GetWatchValue(); - TestFrameWork.Verify(mirror, "x", 330, 0); - vms = fsr.Step(); - TestFrameWork.Verify(mirror, "a", null, 0); - vms = fsr.Step(); - - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"y"); - Obj objExecVal = mirror.GetWatchValue(); - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(44, objExecVal.Payload); - vms = fsr.Step(); - vms = fsr.Step(); // b = 2; - vms = fsr.Step(); - TestFrameWork.Verify(mirror, "a", 266, 0); - vms = fsr.Step(); // b = 2; - // b = 2; - TestFrameWork.Verify(mirror, "b", 2, 0); - // b = 2; - - - } - [Test] - [Category("ExpressionInterpreterRunner")] - [Category("Failure")] - public void inlineconditional_656_4() - { - // Execute and verify the main script in a debug session - fsr.PreStart( - @" -x = 330; - -def foo(y : int) -{ - return = y + 222; -} -a; -[Imperative] -{ - a = x > 20 ? foo(44) : foo(55); //Line 10 - b = 2; -} - -"); - - - // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-1568 - Assert.Fail("IDE-656Regression: Debugging stops at inline condition"); - DebugRunner.VMState vms = fsr.Step(); // x = 330; - - vms = fsr.StepOver(); // a = x > 20 ? foo(44) : 55 ; - - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"x"); - Obj objExecVal = mirror.GetWatchValue(); - TestFrameWork.Verify(mirror, "x", 330, 0); - vms = fsr.StepOver(); - TestFrameWork.Verify(mirror, "a", null, 0); - vms = fsr.StepOver(); // b = 2; - TestFrameWork.Verify(mirror, "a", 266, 0); - vms = fsr.StepOver(); // b = 2; - - TestFrameWork.Verify(mirror, "b", 22, 0); - - - - } - [Test] - [Category("ExpressionInterpreterRunner")] - - public void inlineconditional_656_5() - { - // Execute and verify the main script in a debug session - fsr.PreStart( - @" -x = 330; - -def foo(y : int) -{ - return = y + 222; -} - -[Associative] -{ - a = x > 20 ? foo(44) : 55 ; //Line 10 - b = 2; -} - -"); - - DebugRunner.VMState vms = fsr.Step(); // x = 330; - - vms = fsr.StepOver(); // a = x > 20 ? foo(44) : 55 ; - - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"x"); - //Obj objExecVal = mirror.GetWatchValue(); - TestFrameWork.Verify(mirror, "x", 330, 0); - - vms = fsr.StepOver(); // b = 2; - - TestFrameWork.Verify(mirror, "a", 266, 0); - vms = fsr.StepOver(); - TestFrameWork.Verify(mirror, "x", 330, 0); - TestFrameWork.Verify(mirror, "b", 2, 0); - vms = fsr.StepOver(); - - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("ExpressionInterpreterRunner")] - - public void inlineconditional_stepin_656_5() - { - // Execute and verify the main script in a debug session - fsr.PreStart( - @" -x = 330; - -def foo(y : int) -{ - return = y + 222; -} - -[Associative] -{ - a = x > 20 ? foo(44) : 55 ; //Line 10 - b = 2; -} - -"); - - DebugRunner.VMState vms = fsr.Step(); // x = 330; - - vms = fsr.Step(); // a = x > 20 ? foo(44) : 55 ; - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"x"); - //Obj objExecVal = mirror.GetWatchValue(); - TestFrameWork.Verify(mirror, "x", 330, 0); - - vms = fsr.Step(); // return = y + 222; - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"y"); - Obj objExecVal = mirror.GetWatchValue(); - - // It should not be available. - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(44, objExecVal.Payload); - //TestFrameWork.Verify(mirror, "y", 44, 0); - - vms = fsr.Step(); - vms = fsr.Step(); // a = x > 20 ? foo(44) : 55 ; - vms = fsr.Step(); // b = 2; - - TestFrameWork.Verify(mirror, "a", 266, 0); - - vms = fsr.Step(); - - TestFrameWork.Verify(mirror, "x", 330, 0); - - TestFrameWork.Verify(mirror, "a", 266, 0); - - TestFrameWork.Verify(mirror, "b", 2, 0); - } - - [Test] - [Category("ExpressionInterpreterRunner")] - - public void inlineconditional_656_6() - { - // Execute and verify the main script in a debug session - fsr.PreStart( - @" -x = 330; - -def foo(y : int) -{ - return = y + 222; -} - -[Associative] -{ - a = x > foo(20) ? foo(44): 33; //Line 10 - b = 2; -} - -"); - - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.StepOver(); - - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"x"); - //Obj objExecVal = mirror.GetWatchValue(); - TestFrameWork.Verify(mirror, "x", 330, 0); - vms = fsr.StepOver(); - TestFrameWork.Verify(mirror, "a", 266, 0); - vms = fsr.StepOver(); - TestFrameWork.Verify(mirror, "x", 330, 0); - TestFrameWork.Verify(mirror, "b", 2, 0); - - } - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("ExpressionInterpreterRunner")] - - public void inlineconditional_stepin_656_6() - { - // Execute and verify the main script in a debug session - fsr.PreStart( - @" -x = 330; - -def foo(y : int) -{ - return = y + 222; -} - -[Associative] -{ - a = x > foo(20) ? foo(44): 33; //Line 10 - b = 2; -} - -"); - - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.Step(); - - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"x"); - //Obj objExecVal = mirror.GetWatchValue(); - - TestFrameWork.Verify(mirror, "x", 330, 0); - vms = fsr.Step(); - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"y"); - Obj objExecVal = mirror.GetWatchValue(); - - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(20, objExecVal.Payload); - //TestFrameWork.Verify(mirror, "y", 20, 0); - - vms = fsr.Step(); - vms = fsr.Step(); - - vms = fsr.Step(); - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"y"); - objExecVal = mirror.GetWatchValue(); - - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(44, objExecVal.Payload); - //TestFrameWork.Verify(mirror, "y", 44, 0); - - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - TestFrameWork.Verify(mirror, "a", 266, 0); - vms = fsr.Step(); - TestFrameWork.Verify(mirror, "b", 2, 0); - - - - } - [Test] - [Category("ExpressionInterpreterRunner")] - - public void inlineconditional_656_7() - { - // Execute and verify the main script in a debug session - fsr.PreStart( - @" -x = 330; - -def foo(y : int) -{ - return = y + 222; -} - -[Associative] -{ - a = x < foo(20) ? 33 : foo(44); //Line 10 - b = 2; -} - -"); - - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.StepOver(); - - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"x"); - Obj objExecVal = mirror.GetWatchValue(); - TestFrameWork.Verify(mirror, "x", 330, 0); - vms = fsr.StepOver(); - TestFrameWork.Verify(mirror, "a", 266, 0); - vms = fsr.StepOver(); - TestFrameWork.Verify(mirror, "x", 330, 0); - TestFrameWork.Verify(mirror, "b", 2, 0); - - } - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("ExpressionInterpreterRunner")] - - public void inlineconditional_stepin_656_7() - { - // Execute and verify the main script in a debug session - fsr.PreStart( - @" -x = 330; - -def foo(y : int) -{ - return = y + 222; -} - -[Associative] -{ - a = x < foo(20) ? 33 : foo(44); //Line 10 - b = 2; -} - -"); - - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.Step(); - - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"x"); - // Obj objExecVal = mirror.GetWatchValue(); - - TestFrameWork.Verify(mirror, "x", 330, 0); - vms = fsr.Step(); - - //TestFrameWork.Verify(mirror, "y", 20, 0); - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"y"); - Obj objExecVal = mirror.GetWatchValue(); - - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(20, objExecVal.Payload); - - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - //TestFrameWork.Verify(mirror, "y", 44, 0); - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"y"); - objExecVal = mirror.GetWatchValue(); - - Assert.AreNotEqual(null, objExecVal); - Assert.AreEqual(44, objExecVal.Payload); - - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - - TestFrameWork.Verify(mirror, "a", 266, 0); - vms = fsr.Step(); - TestFrameWork.Verify(mirror, "b", 2, 0); - } - - [Test] - [Category("ExpressionInterpreterRunner")] - - public void inlineconditional_stepnext_656_12() - { - // Execute and verify the main script in a debug session - fsr.PreStart( - @" -def GetCoor(type : int) -{ - return = type == 1 ? 10 : 20; -} - -list1 = [ 1, 2 ]; - -list3 = GetCoor(list1); - -"); - - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.StepOver(); - - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"list1"); - // Obj objExecVal = mirror.GetWatchValue(); - - TestFrameWork.Verify(mirror, "list1", new object[] { 1, 2 }, 0); - vms = fsr.StepOver(); - - TestFrameWork.Verify(mirror, "list3", new object[] { 10, 20 }, 0); - - - - - - } - [Test] - [Category("ExpressionInterpreterRunner")] - - public void inlineconditional_stepin_656_12() - { - // Execute and verify the main script in a debug session - fsr.PreStart( - @" -def GetCoor(type : int) -{ - return = type == 1 ? 10 : 20; -} - -list1 = [ 1, 2 ]; - -list3 = GetCoor(list1); - -"); - - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.Step(); - - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"list1"); - // Obj objExecVal = mirror.GetWatchValue(); - - TestFrameWork.Verify(mirror, "list1", new object[] { 1, 2 }, 0); - vms = fsr.Step(); - vms = fsr.Step(); - TestFrameWork.Verify(mirror, "list3", new object[] { 10, 20 }, 0); - - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("ExpressionInterpreterRunner")] - public void inlineconditional_stepin_highlighting_657_1() - { - fsr.PreStart( // Execute and verify the main script in a debug session - @" -x = 330; - -def foo(y : int) -{ - return = y + 222; -} - -[Imperative] -{ - a = x > foo(22) ? foo(1) : 55; //Line 10 -} -"); - - DebugRunner.VMState vms = fsr.Step(); // x = 330; - Assert.AreEqual(2, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(9, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // a = x > foo(22) ? foo(1) : 55; - Assert.AreEqual(11, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(11, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(35, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // return = y + 222; - Assert.AreEqual(6, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(6, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(22, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); - Assert.AreEqual(7, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // a = x > foo(22) ? foo(1) : 55; - Assert.AreEqual(11, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(11, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(35, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // return = y + 222; - Assert.AreEqual(6, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(6, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(22, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); - Assert.AreEqual(7, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // a = x > foo(22) ? foo(1) : 55; - Assert.AreEqual(11, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(11, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(35, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // closing brace of Imperative block - Assert.AreEqual(12, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(12, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - - } - - [Test] - [Category("Failure")] - [Category("PopRxOptimization")] - [Category("ExpressionInterpreterRunner")] - public void inlineconditional_stepin_highlighting_657_2() - { - fsr.PreStart( // Execute and verify the main script in a debug session - @" -x = 330; - -def foo(y : int) -{ - return = y + 222; -} - -[Imperative] -{ - a = x < foo(20) ? 44 : foo(55); //Line 10 -} -"); - - DebugRunner.VMState vms = fsr.Step(); // x = 330; - Assert.AreEqual(2, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(9, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // a = x > foo(22) ? foo(1) : 55; - Assert.AreEqual(11, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(11, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(36, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // return = y + 222; - Assert.AreEqual(6, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(6, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(22, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); - Assert.AreEqual(7, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // a = x > foo(22) ? foo(1) : 55; - Assert.AreEqual(11, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(11, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(36, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // return = y + 222; - Assert.AreEqual(6, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(6, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(22, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); - Assert.AreEqual(7, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(7, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // a = x > foo(22) ? foo(1) : 55; - Assert.AreEqual(11, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(11, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(36, vms.ExecutionCursor.EndExclusive.CharNo); - - vms = fsr.Step(); // closing brace of Imperative block - Assert.AreEqual(12, vms.ExecutionCursor.StartInclusive.LineNo); - Assert.AreEqual(1, vms.ExecutionCursor.StartInclusive.CharNo); - Assert.AreEqual(12, vms.ExecutionCursor.EndExclusive.LineNo); - Assert.AreEqual(2, vms.ExecutionCursor.EndExclusive.CharNo); - - } - - [Test] - [Category("Failure")] - [Category("ExpressionInterpreterRunner")] - public void IDE_Debugger_698_3() - { - fsr.PreStart( // Execute and verify the main script in a debug session - @" -results = [ [ ] ]; - -numCycles = 4; -s; -[Imperative] -{ - k = 0; - while(k < 2) - { - for(i in (0..(numCycles))) - { - results[i] = [ ]; - - for(j in(0..(numCycles-1))) - { - results[i][j] = i * j; - } - - c = j; - } - k = k + 1; - } -} -"); - - DebugRunner.VMState vms = fsr.Step(); // x = 330; - - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - vms = fsr.StepOver(); - - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"c"); - mirror = watchRunner.Execute(@"c"); - Obj objExecVal = mirror.GetWatchValue(); - TestFrameWork.Verify(mirror, "c", null, 0); - - } - - [Test] - [Category("ExpressionInterpreterRunner")] - public void TestWatchExpressionForFFIProperty() - { - string src = @" -import(Dummy from ""FFITarget.dll""); -a = Dummy.Create(2); -b = 2; -"; - - fsr.PreStart(src); - DebugRunner.VMState vms = fsr.Step(); - vms = fsr.StepOver(); - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a.DummyProperty"); - Obj objExecVal = mirror.GetWatchValue(); - Assert.AreEqual(2, (Int64)objExecVal.Payload); - - vms = fsr.Step(); - - watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"a.DummyProperty"); - objExecVal = mirror.GetWatchValue(); - Assert.AreEqual(2, (Int64)objExecVal.Payload); - - } - - [Test] - [Category("ExpressionInterpreterRunner")] - public void TestWatchExpressionForFFIProperty_1() - { - string src = @" -import(Dummy from ""FFITarget.dll""); - - -a : Dummy = null; - -[Associative] -{ - afinal = Dummy.Create(2); - - a = afinal; - -} -"; - - fsr.PreStart(src); - DebugRunner.VMState vms = fsr.Step(); // a : Dummy = null; - fsr.Step(); - fsr.StepOver(); // a = a@final; - - /*ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a@final.DummyProperty"); - Obj objExecVal = mirror.GetWatchValue(); - Assert.AreEqual(2, (Int64)objExecVal.Payload);*/ - - vms = fsr.Step(); // closing brace of assoc block - - /*watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - mirror = watchRunner.Execute(@"a.DummyProperty"); - objExecVal = mirror.GetWatchValue(); - Assert.AreEqual(2, (Int64)objExecVal.Payload);*/ - - fsr.Step(); - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a.DummyProperty"); - Obj objExecVal = mirror.GetWatchValue(); - Assert.AreEqual(2, (Int64)objExecVal.Payload); - } - } - - [TestFixture, Category("Debugger")] - public class BasicUseCaseTests - { - public ProtoCore.Core core; - private DebugRunner fsr; - private string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\"; - - [SetUp] - public void Setup() - { - // Specify some of the requirements of IDE. - var options = new ProtoCore.Options(); - options.ExecutionMode = ProtoCore.ExecutionMode.Serial; - - core = new ProtoCore.Core(options); - core.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(core)); - core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core)); - - fsr = new DebugRunner(core); - - DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); - CLRModuleType.ClearTypes(); - } - - //To test the update order issue in assoc. code, relates to DNL-1467407 - [Test] - [Category("ExpressionInterpreterRunner")] - public void UseCaseTesting_Simple_cross_language_update_Imp_in_Assoc_2() - { - // Execute and verify the main script in a debug session - fsr.PreStart( -@" -a = 7; -[Imperative] -{ - c = 0; - [Associative] - { - s = Print(""aa = "" + a); - c = a + 2; - a = 10; - } -} -"); - - DebugRunner.VMState vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - - Obj o_c = vms.mirror.GetDebugValue("c"); - Obj o_a = vms.mirror.GetDebugValue("a"); - string type_c = vms.mirror.GetType("c"); - string type_a = vms.mirror.GetType("a"); - - - Assert.IsTrue(type_c == "int"); - Assert.IsTrue(type_a == "int"); - Assert.IsTrue((Int64)o_c.Payload == 9); - Assert.IsTrue((Int64)o_a.Payload == 7); - - vms = fsr.Step(); - o_a = vms.mirror.GetDebugValue("a"); - Assert.IsTrue((Int64)o_a.Payload == 10); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - vms = fsr.Step(); - o_c = vms.mirror.GetDebugValue("c"); - Assert.IsTrue((Int64)o_c.Payload == 12); - - } - - //Investigate the color object properties number, relates to IDE-493 - [Test] - [Category("Failure")] - [Category("ExpressionInterpreterRunner")] - public void UseCase_Robert_simple_copy_and_modiy_collection_1() - { - // Execute and verify the main script in a debug session - fsr.PreStart( -@" -a = 0..10; -b = a; -b[2] = 100; // modifying a member of a copy of a collections -c = a; -d = b[0..(Count(b) - 1)..2]; // rnage expression used for indexing into a collection - -"); - - - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.StepOver(); - vms = fsr.StepOver(); - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a"); - - Obj objExecVal = mirror.GetWatchValue(); - - String type = objExecVal.GetType().ToString(); - - TestFrameWork.Verify(mirror, "a", new object[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, 0); - vms = fsr.StepOver(); - TestFrameWork.Verify(mirror, "b", new object[] { 0, 1, 100, 3, 4, 5, 6, 7, 8, 9, 10 }, 0); - vms = fsr.StepOver(); - TestFrameWork.Verify(mirror, "c", new object[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, 0); - vms = fsr.StepOver(); - TestFrameWork.Verify(mirror, "d", new object[] { 0, 100, 4, 6, 8, 10 }, 0); - - - - } - - [Test] - [Category("ExpressionInterpreterRunner")] - public void UseCase_Robert_modifiying_replicated_inline_conditional_1() - { - // Execute and verify the main script in a debug session - fsr.PreStart( -@" - -a = 0..10..2; -a = a < 5 ? 3 : 4; - -"); - - DebugRunner.VMState vms = fsr.Step(); - - vms = fsr.StepOver(); - - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, fsr.runtimeCore); - ExecutionMirror mirror = watchRunner.Execute(@"a"); - - TestFrameWork.Verify(mirror, "a", new object[] { 0, 2, 4, 6, 8, 10 }, 0); - vms = fsr.StepOver(); - TestFrameWork.Verify(mirror, "a", new object[] { 3, 3, 3, 4, 4, 4 }, 0); - } - } -} diff --git a/test/Engine/ProtoTest/DebugTests/RunEqualityTests.cs b/test/Engine/ProtoTest/DebugTests/RunEqualityTests.cs deleted file mode 100644 index 9b2a301c3c1..00000000000 --- a/test/Engine/ProtoTest/DebugTests/RunEqualityTests.cs +++ /dev/null @@ -1,15698 +0,0 @@ -using System; -using NUnit.Framework; -using ProtoTestFx; - -namespace ProtoTest.DebugTests -{ - [TestFixture, Category("Debugger")] - public class RunEqualityTests - { - - [Test] - [Category("Debugger")] - public void DebugEQTestEqualityR1() - { - String src = - @" a = 4;"; - DebugTestFx.CompareDebugAndRunResults(src); - } - - [Test] - [Category("Debugger")] - public void DebugEQTestEqualityImpR1() - { - String src = - @" a = 0; [Imperative] { -a = 4; -} -"; - DebugTestFx.CompareDebugAndRunResults(src); - } - - [Test] - [Category("Debugger")] - public void DebugEQTestEquality0001() - { - String src = - @"[Imperative] -{ - f0 = 5 > 6; - f1 = (5 > 6); - f2 = 5 >= 6; - f3 = (5 >= 6); - t0 = 5 == 5; - t1 = (5 == 5); - t2 = 5 < 6; - t3 = (5 < 6); - - t4 = 5 <= 6; - t5 = (5 <= 6); - t6 = 5 <= 5; - t7 = (5 <= 5); -} -"; - DebugTestFx.CompareDebugAndRunResults(src); - } - - [Test] - public void DebugEQBIM01_SomeNulls() - { - String code = - @" -a = [null,20,30,null,[10,0],0,5,2]; -b = [1,2,3]; -e = [3,20,30,4,[null,0],0,5,2]; -c = SomeNulls(a); -d = SomeNulls(b); -f = SomeNulls(e); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQBIM02_CountTrue() - { - String code = - @"a = [true,true,true,false,[true,false],true,[false,false,[true,[false],true,true,false]]]; -b = [true,true,true,false,true,true]; -c = [true,true,true,true,true,true,true]; -w = CountTrue(a); -x = CountTrue(b); -y = CountTrue(c); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQBIM03_CountFalse() - { - String code = - @"a = [true,true,true,false,[true,false],true,[false,false,[true,[false],true,true,false]]]; -b = [true,true,true,false,true,true]; -c = [true,true,true,true,true,true,true]; -e = CountFalse(a); -f = CountFalse(b); -g = CountFalse(c); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "AllFalse() & AllTrue()" - public void DebugEQBIM04_AllFalse_AllTrue() - { - String code = - @" -a = [true]; -b = [false,false,[false,[false,[false,false,[false],false]]],false]; -c = [true,true,true,true,[true,true],true,[true,true,[true, true,[true],true,true,true]]]; -d = AllTrue(a); -e = AllTrue(b); -f = AllTrue(c); -g = AllFalse(a); -h = AllFalse(b); -i = AllFalse(c); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "IsHomogeneous()" - public void DebugEQBIM05_IsHomogeneous() - { - String code = - @"a = [1,2,3,4,5]; -b = [false, true, false]; -c = [[1],[1.0,2.0]]; -d = [null,1,2,3]; -e = []; -ca = IsHomogeneous(a); -cb = IsHomogeneous(b); -cc = IsHomogeneous(c); -cd = IsHomogeneous(d); -ce = IsHomogeneous(e); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "Sum() & Average()" - public void DebugEQBIM06_SumAverage() - { - String code = - @" -b = [1,2,[3,4,[5,[6,[7],8,[9,10],11]],12,13,14,[15]],16]; -c = [1.2,2.2,[3.2,4.2,[5.2,[6.2,[7.2],8.2,[9.2,10.2],11.2]],12.2,13.2,14.2,[15.2]],16.2]; -x = Average(b); -y = Sum(b); -z = Average(c); -s = Sum(c); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "SomeTrue() & SomeFalse()" - public void DebugEQBIM07_SomeTrue_SomeFalse() - { - String code = - @"a = [true,true,true,[false,false,[true, true,[false],true,true,false]]]; -b = [true,true,[true,true,true,[true,[true],true],true],true]; -c = [true, false, false]; -p = SomeTrue(a); -q = SomeTrue(b); -r = SomeTrue(c); -s = SomeFalse(a); -t = SomeFalse(b); -u = SomeFalse(c); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "Remove() & RemoveDuplicate()" - public void DebugEQBIM08_Remove_RemoveDuplicate() - { - String code = - @"a = [null,20,30,null,20,15,true,true,5,false]; -b = [1,2,3,4,9,4,2,5,6,7,8,7,1,0,2]; -rda = RemoveDuplicates(a); -rdb = RemoveDuplicates(b); -ra = Remove(a,3); -rb = Remove(b,2); -p = rda[3]; -q = rdb[4]; -x = ra[3]; -y = rb[2]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "RemoveNulls()" - public void DebugEQBIM09_RemoveNulls() - { - String code = - @"a = [1,[6,null,7,[null,null]],7,null,2]; -b = [null,[null,[null,[null],null],null],null]; -p = RemoveNulls(a); -q = RemoveNulls(b); -x = p[3]; -y = p[1][1]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "RemoveIfNot()" - public void DebugEQBIM10_RemoveIfNot() - { - String code = - @"a = [""This is "",""a very complex "",""array"",1,2.0,3,false,4.0,5,6.0,true,[2,3.1415926],null,false,'c']; -b = RemoveIfNot(a, ""int""); -c = RemoveIfNot(a, ""double""); -d = RemoveIfNot(a, ""bool""); -e = RemoveIfNot(a, ""array""); -q = b[0]; -r = c[0]; -s = d[0]; -t = e[0][0]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "Reverse()" - public void DebugEQBIM11_Reverse() - { - String code = - @"a = [1,[[1],[3.1415]],null,1.0,12.3]; -b = [1,2,[3]]; -p = Reverse(a); -q = Reverse(b); -x = p[0]; -y = q[0][0]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "Contains()" - public void DebugEQBIM12_Contains() - { - String code = - @"a = [1,[[1],[3.1415]],null,1.0,12.3]; -b = [1,2,[3]]; -x = [[1],[3.1415]]; -r = Contains(a, 3.0); -s = Contains(a, x); -t = Contains(a, null); -u = Contains(b, b); -v = Contains(b, [3]); -w = Contains(b, 3); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "IndexOf()" - public void DebugEQBIM13_IndexOf() - { - String code = - @"a = [1,[[1],[3.1415]],null,1.0,12,3]; -b = [1,2,[3]]; -c = [1,2,[3]]; -d = [[1],[3.1415]]; -r = IndexOf(a, d); -s = IndexOf(a, 1); -t = IndexOf(a, null); -u = IndexOf(b, [3]); -v = IndexOf(b, 3); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "Sort()" - public void DebugEQBIM14_Sort() - { - String code = - @"a = [1,3,5,7,9,8,6,4,2,0]; -b = [1.3,2,0.8,2,null,2,2.0,2,null]; -x = Sort(a); -x1 = Sort(a,true); -x2 = Sort(a,false); -y = Sort(b); -p = x[0]; -p1 = x1[0]; -p2 = x2[0]; -q = x[9]; -s = y[0]; -t = y[7]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "SortIndexByValue()" - public void DebugEQBIM15_SortIndexByValue() - { - String code = - @"a = [1,3,5,7,9,8,6,4,2,0]; -b = [1.3,2,0.8,2,null,2,2.0,2,null]; -x = SortIndexByValue(a); -x1 = SortIndexByValue(a,true); -x2 = SortIndexByValue(a,false); -y = SortIndexByValue(b); -p = x[0]; -p1 = x1[0]; -p2 = x2[0]; -q = x[9]; -s = y[0]; -t = y[7]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "Insert()" - public void DebugEQBIM16_Insert() - { - String code = - @"a = [false,2,3.1415926,null,[false]]; -b = 1; -c = [1]; -d = []; -e = [[1],2,3.0]; -p = Insert(a,b,1); -q = Insert(a,c,1); -r = Insert(a,d,0); -s = Insert(a,e,5); -u = p[1]; -v = q[1][0]; -w = r[1][0]; -x = s[5][0][0]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "SetDifference(), SetUnion() & SetIntersection()" - public void DebugEQBIM17_SetDifference_SetUnion_SetIntersection() - { - String code = - @"a = [false,15,6.0,15,false,null,15.0]; -b = [10,20,false,12,21,6.0,15,null,8.2]; -c = SetDifference(a,b); -d = SetDifference(b,a); -e = SetIntersection(a,b); -f = SetUnion(a,b); -p = c[0]; -q = d[1]; -r = e[1]; -s = f[1]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "Reorder" - public void DebugEQBIM18_Reorder() - { - String code = - @"a = [1,4,3,8.0,2.0,0]; -b = [2,1,0,3,4]; -c = Reorder(a,b); -p = c[0]; -q = c[1]; -r = c[2]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "IsUniformDepth" - public void DebugEQBIM19_IsUniformDepth() - { - String code = - @"a = []; -b = [1,2,3]; -c = [[1],[2,3]]; -d = [1,[2],[[3]]]; -p = IsUniformDepth(a); -q = IsUniformDepth(b); -r = IsUniformDepth(c); -s = IsUniformDepth(d); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "NormailizeDepth" - public void DebugEQBIM20_NormalizeDepth() - { - String code = - @"a = [[1,[2,3,4,[5]]]]; -p = NormalizeDepth(a,1); -q = NormalizeDepth(a,2); -r = NormalizeDepth(a,4); -s = NormalizeDepth(a); -w = p[0]; -x = q[0][0]; -y = r[0][0][0][0]; -z = s[0][0][0][0]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "Map & MapTo" - public void DebugEQBIM21_Map_MapTo() - { - String code = - @"a = Map(80.0, 120.0, 100.0); -b = MapTo(0.0, 100.0 ,25.0, 80.0, 90.0); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "Transpose" - public void DebugEQBIM22_Transpose() - { - String code = - @"a = [[1,2,3],[1,2],[1,2,3,4,5,6,7]]; -p = Transpose(a); -q = Transpose(p); -x = p[6][0]; -y = q[0][6]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "LoadCSV" - public void DebugEQBIM23_LoadCSV() - { - String code = - @"a = ""CSVTestCase/test1.csv""; -b = LoadCSV(a); -c = LoadCSV(a, false); -d = LoadCSV(a, true); -x = b[0][2]; -y = c[0][2]; -z = d[0][2]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "Count" - public void DebugEQBIM24_Count() - { - String code = - @"a = [1, 2, 3, 4]; -b = [ [ 1, [ 2, 3, 4, [ 5 ] ] ] ]; -c = [ [ 2, null ], 1, ""str"", [ 2, [ 3, 4 ] ] ]; -x = Count(a); -y = Count(b); -z = Count(c); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "Rank" - public void DebugEQBIM25_Rank() - { - String code = - @"a = [ [ 1 ], 2, 3, 4 ]; -b = [ ""good"", [ [ null ] ], [ 1, [ 2, 3, 4, [ 5, [ ""good"" ], [ null ] ] ] ] ]; -c = [ [ null ], [ 2, ""good"" ], 1, null, [ 2, [ 3, 4 ] ] ]; -x = Rank(a); -y = Rank(b); -z = Rank(c); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "Flatten" - public void DebugEQBIM26_Flatten() - { - String code = - @"a = [1, 2, 3, 4]; -b = [ ""good"", [ 1, [ 2, 3, 4, [ 5 ] ] ] ]; -c = [ null, [ 2, ""good""], 1, null, [ 2, [ 3, 4 ] ] ]; -q = Flatten(a); -p = Flatten(b); -r = Flatten(c); -x = q[0]; -y = p[2]; -z = r[4]; -s = p[0]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - //Test "CountTrue/CountFalse/Average/Sum/RemoveDuplicate" - public void DebugEQBIM27_Conversion_Resolution_Cases() - { - String code = - @"a = [null,20,30,null,[10,0],true,[false,0,[true,[false],5,2,false]]]; -b = [1,2,[3,4,9],4,2,5,[6,7,[8]],7,1,0,2]; -x = CountTrue(a); -y = CountFalse(a); -z = AllTrue(a); -w = AllFalse(a); -p = SomeTrue(a); -q = SomeTrue(a); -r = Sum(true); -s = Sum(null); -t = RemoveDuplicates(b); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestMethodWithArrayInput2() - { - string code = - @" - class A - { - } - class B extends A - { - } - def Test(arr : A[]) - { - return = 123; - } - a = [B.B(), A.A(), B.B()]; - val = Test(a); - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestAssignment01_002() - { - String code = - @"[Associative] -{ - foo = 5; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestNull01_002() - { - String code = - @" -[Associative] -{ - x = null; - y = x; - a = null; - b = a + 2; - c = 2 + a * x; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestNull02_002() - { - String code = - @" -[Associative] -{ - def foo : int ( a : int ) - { - b = a + 1; - } - - c = foo(1); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestFunctions01() - { - String code = - @"[Associative] -{ - def mult : int( s : int ) - { - return = s * 2; - } - test = mult(5); - test2 = mult(2); - test3 = mult(mult(5)); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestFunctions02() - { - String code = - @" -[Associative] -{ - def test2 : int(b : int) - { - return = b; - } - - def test : int(a : int) - { - return = a + test2(5); - } - - temp = test(2); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestFunctionsOverload01() - { - String code = - @"[Associative] -{ - def m1 : int( s : int ) - { - return = s * 2; - } - def m1 : int( s: int, y : int ) - { - return = s * y; - } - test1 = m1(5); - test2 = m1(5, 10); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestFunctionsOverload02() - { - String code = - @"[Associative] -{ - def f : int( p1 : int ) - { - x = p1 * 10; - return = x; - } - def f : int( p1 : int, p2 : int ) - { - return = p1 + p2; - } - a = 2; - b = 20; - // Pasing variables to function overloads - i = f(a + 10); - j = f(a, b); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestArray001() - { - String code = - @"[Associative] -{ - a = [1001,1002]; - x = a[0]; - y = a[1]; - a[0] = 23; -}"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestArray002() - { - String code = - @" -[Associative] -{ - def foo : int (a : int[]) - { - return = a[0]; - } - - arr = [100, 200]; - b = foo(arr); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestArray003() - { - String code = - @" -a = [0,1,2]; -t = [10,11,12]; -a[0] = t[0]; -t[1] = a[1]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestArrayOverIndexing01_002() - { - string code = - @" -[Imperative] -{ - arr1 = [true, false]; - arr2 = [1, 2, 3]; - arr3 = [false, true]; - t = arr2[1][0]; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestDynamicArray001_002() - { - String code = - @" -a = [10,20]; -a[2] = 100; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestDynamicArray002() - { - String code = - @" -t = []; -t[0] = 100; -t[1] = 200; -t[2] = 300; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestDynamicArray003() - { - String code = - @" -t = []; -t[0][0] = 1; -t[0][1] = 2; -a = t[0][0]; -b = t[0][1]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestDynamicArray004() - { - String code = - @" -t = []; -t[0][0] = 1; -t[0][1] = 2; -t[1][0] = 10; -t[1][1] = 20; -a = t[1][0]; -b = t[1][1]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestDynamicArray005() - { - String code = - @" -t = [0,[20,30]]; -t[1][1] = [40,50]; -a = t[1][1][0]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestDynamicArray006() - { - String code = - @" -[Imperative] -{ - t = []; - t[0][0] = 1; - t[0][1] = 2; - t[1][0] = 3; - t[1][1] = 4; - a = t[0][0]; - b = t[0][1]; - c = t[1][0]; - d = t[1][1]; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestDynamicArray007() - { - String code = @" -a[3] = 3; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestDynamicArray008() - { - String code = @" -a[0] = false; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestDynamicArray009() - { - String code = @" -a = false; -a[3] = 1; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestDynamicArray010() - { - String code = @" -a = false; -a[1][1] = [3]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestDynamicArray011() - { - String code = @" -a[0] = 1; -a[0][1] = 2; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestDynamicArray012() - { - String code = @" -a = 1; -a[-1] = 2; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestDynamicArray013() - { - String code = @" -a = 1; -a[-3] = 2; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestDynamicArray014() - { - String code = @" -a = [1, 2]; -a[3] = 3; -a[-5] = 100; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestDynamicArray015() - { - String code = @" -a = 1; -a[-2][-1] = 3; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestDynamicArray016() - { - String code = @" -a = [[1, 2], [3, 4]]; -a[-3][-1] = 5; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestArrayIndexReplication01() - { - string code = @" -a = 1; -a[1..2] = 2; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestArrayIndexReplication02() - { - string code = @" -a = [1, 2, 3]; -b = a[1..2]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestTypeArrayAssign4() - { - string code = @" -a:int[] = [1, 2, 3]; -a[0] = false; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestTypeArrayAssign5() - { - string code = @" -a = [false, 2, true]; -b:int[] = a; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestTypeArrayAssign6() - { - string code = @" -a:int = 2; -a[1] = 3;; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQNestedBlocks001_002() - { - String code = - @"[Associative] -{ - a = 4; - b = a*2; - - [Imperative] - { - i=0; - temp=1; - //if(i<=a) - //{ - //temp=temp+1; - //} - } - a = 1; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - - [Test] - public void DebugEQLogicalOp001_002() - { - String code = - @" - [Associative] - { - a = true; - b = false; - c = 1; - d = a && b; - e = c && d; - } - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQLogicalOp002_002() - { - String code = - @" - [Associative] - { - a = true; - b = false; - c = 1; - d = a || b; - e = c || d; - } - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQLogicalOp003_002() - { - String code = - @" - [Associative] - { - a = true; - b = false; - c = !(a || !b); - } - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQDoubleOp_002() - { - String code = - @" - [Associative] - { - a = 1 + 2; - b = 2.0; - b = a + b; - } - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQRangeExpr001_002() - { - String code = - @" - [Associative] - { - a = 1..5; - b = a[0]; - c = a[1]; - d = a[2]; - e = a[3]; - f = a[4]; - } - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQRangeExpr002_002() - { - String code = - @" - [Associative] - { - a = 1.5..5..1.1; - b = a[0]; - c = a[1]; - d = a[2]; - e = a[3]; - } - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQRangeExpr003_002() - { - String code = - @" - [Associative] - { - a = 15..10..-1.5; - b = a[0]; - c = a[1]; - d = a[2]; - e = a[3]; - } - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQRangeExpr004_002() - { - String code = - @" - [Associative] - { - a = 0..15..#5; - b = a[0]; - c = a[1]; - d = a[2]; - e = a[3]; - f = a[4]; - } - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQRangeExpr005_002() - { - String code = - @" - [Associative] - { - a = 0..15..~4; - b = a[0]; - c = a[1]; - d = a[2]; - e = a[3]; - f = a[4]; - } - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQInlineCondition001_002() - { - String code = - @" - a = 10; - b = 20; - c = a < b ? a : b; - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQInlineCondition002_002() - { - String code = - @" - a = 10; - b = 20; - c = a > b ? a : a == b ? 0 : b; - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQInlineCondition003_002() - { - String code = - @" -a = [11,12,10]; -t = 10; -b = a > t ? 2 : 1; -x = b[0]; -y = b[1]; -z = b[2]; - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQInlineCondition004() - { - String code = - @" -def f(i : int) -{ - return = i + 1; -} -def g() -{ - return = 1; -} -a = [10,0,10]; -t = 1; -b = a > t ? f(10) : g(); -x = b[0]; -y = b[1]; -z = b[2]; - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQModulo001_002() - { - String code = - @" - a = 10 % 4; // 2 - b = 5 % a; // 1 - c = b + 11 % a * 3 - 4; // 0 - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQModulo002_002() - { - String code = - @" - a = 10 % 4; // 2 - b = 5 % a; // 1 - c = 11 % a == 2 ? 11 % 2 : 11 % 3; // 2 - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQNegativeIndexOnCollection001_002() - { - String code = - @" - a = [1, 2, 3, 4]; - b = a[-2]; // 3 - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQNegativeIndexOnCollection002_002() - { - String code = - @" - a = [ [ 1, 2 ], [ 3, 4 ] ]; - b = a[-1][-2]; // 3 - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestUpdate01() - { - String code = - @" - a = 1; - b = a; - a = 10; - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestUpdate03() - { - String code = - @" -def f : int(p : int) -{ - a = 10; - b = a; - a = p; - return = b; -} -x = 20; -y = f(x); -x = 40; - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestArrayUpdateRedefinition01() - { - String code = - @" -a = 1; -c = 2; -b = a + 1; -b = c + 1; -a = 3; - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestArrayUpdateRedefinition02() - { - String code = - @" - a = 1; - a = a + 1; - a = 10; - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestArrayUpdate01() - { - String code = - @" -a = [10,11,12]; -t = 0; -i = a[t]; -t = 2; - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQTestXLangUpdate01() - { - String code = - @" -[Associative] -{ - a = 1; - b = a; - [Imperative] - { - a = a + 1; - } -} - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestXLangUpdate02() - { - String code = - @" -[Associative] -{ - a = 1; - b = a; - a = 10; - [Imperative] - { - a = a + 1; - } -} - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestXLangUpdate03() - { - String code = - @" -[Associative] -{ - a = 1; - b = a; - c = 100; - d = c; - [Imperative] - { - a = a + 1; - c = 10; - } -} - "; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT001_Simple_Update() - { - string code = @" -a = 1; -b = a + 1; -a = 2; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT001_SomeNulls_IfElse_01() - { - string code = @" -result = -[Imperative] -{ - arr1 = [1,null]; - arr2 = [1,2]; - if(SomeNulls(arr1)) - { - arr2 = arr1; - } - return = SomeNulls(arr2); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT001_SomeNulls_IfElse_02() - { - string code = @" -result = -[Imperative] -{ - arr1 = []; - arr2 = [1,2]; - if(SomeNulls(arr1)) - { - arr2 = arr1; - } - return = SomeNulls(arr2); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT001_implicit_programming_Robert() - { - string code = @" -// no paradigm specified, so assume Associative -// some Associative code .... -a = 10; -b = a*2; -a = a +1; // expanded modifier, therefore the statement on line 7 is calculated after the statement on line 6 is excuted -c = 0; -//some Imperative code .... -[Imperative] -{ - if (a>10) // implicit switch to Imperative paradigm - { - c = b; // so statements are treated in lexical order, therefore the statement on line 13 - b=b/2; // is executed before the statement on line 14 [as would be expected] - } - else - { - [Associative] // explicit switch to Associative paradigm [overrides the Imperative paradigm] - { - c = b; // c references the final state of b, therefore [because we are in an Associative paradigm] - b = b*2; // the statement on line 21 is executed before the statement on line 20 - } - } -} -// some more Associative code .... -a = a + 2; // I am assuming that this statement (on line 27) is executed after the if..else has been evaluated and executed, because... - // effectively, when a Imperative block is nested within an Associative block, lexical order plays a role - // in that the execution order is: - // the part of the Associative graph before the Imperative block - // the Imperative block - // the part of the Associative graph after the Imperative block -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT001_implicit_programming_Robert_2() - { - string code = @" -// no paradigm specified, so assume Associative -// some Associative code .... -a = 10; -b = a*2; -a = a +1; // expanded modifier, therefore the statement on line 7 is calculated after the statement on line 6 is excuted -c = 0; -//some Imperative code .... -[Imperative] -{ - if (a>10) // explicit switch to Imperative paradigm - { - c = b; // so statements are treated in lexical order, therefore the statement on line 13 - b=b/2; // is executed before the statement on line 14 [as would be expected] - } - else - { - [Associative] // explicit switch to Associative paradigm [overrides the Imperative paradigm] - { - c = b; // c references the final state of b, therefore [because we are in an Associative paradigm] - b = b*2; // the statement on line 21 is executed before the statement on line 20 - } - } -} -// some more Associative code .... -a = a + 2; // I am assuming that this statement (on line 27) is executed after the if..else has been evaluated and executed, because... - // effectively, when a Imperative block is nested within an Associative block, lexical order plays a role - // in that the execution order is: - // the part of the Associative graph before the Imperative block - // the Imperative block - // the part of the Associative graph after the Imperative block -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT002_BasicImport_AbsoluteDirectory() - { - - - string code = @" -import (""..\\..\\..\\test\\Engine\\ProtoTest\\ImportFiles\\basicImport.ds""); -a = [1.1,2.2]; -b = 2; -c = Scale(a,b); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - - - [Test] - public void DebugEQT002_SomeNulls_ForLoop() - { - string code = @" -result = -[Imperative] -{ - a = [1,3,5,7,[]]; - b = [null,null,true]; - c = [SomeNulls([1,null])]; - d = [a,b,c]; - j = 0; - e = []; - - for(i in d) - { - - e[j]= SomeNulls(i); - j = j+1; - } - return = e; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT002_Update_Collection() - { - string code = @" -a = 0..4..1; -b = a; -c = b[2]; -a = 10..14..1; -b[2] = b[2] + 1; -a[2] = a[2] + 1; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT002_limits_to_replication_1_Robert() - { - string code = @" -a = 0..10..2; -b = a>5? 0:1; -[Imperative] -{ - c = a * 2; // replication within an Imperative block [OK?] - d = a > 5 ? 0:1; // in-line conditional.. operates on a collection [inside an Imperative block, OK?] - if( c[2] > 4 ) x = 10; // if statement evaluates a single term [OK] - - if( c > 4 ) // but... replication within a regular 'if..else' any support for this? - { - y = 1; - } - else - { - y = -1; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT003_Associative_Function_MultilineFunction() - { - string code = @" -[Associative] -{ - def Divide : int(a:int, b:int) - { - return = a/b; - } - d = Divide (1,3); - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT003_BasicImport_ParentPath() - { - string code = @" -import (""../basicImport.ds""); -a = [1.1,2.2]; -b = 2; -c = Scale(a,b); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT003_Inline_Using_Collection__2_() - { - string code = @" - Passed = 1; - Failed = 0; - Einstein = 56; - BenBarnes = 90; - BenGoh = 5; - Rameshwar = 80; - Jun = 68; - Roham = 50; - Smartness = [ BenBarnes, BenGoh, Jun, Rameshwar, Roham ]; // { 1, 0, 1, 1, 0 } - Results = Smartness > Einstein ? Passed : Failed; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT003_Inline_Using_Collection() - { - string code = @" -[Imperative] -{ - Passed = 1; - Failed = 0; - Einstein = 56; - BenBarnes = 90; - BenGoh = 5; - Rameshwar = 80; - Jun = 68; - Roham = 50; - Smartness = [ BenBarnes, BenGoh, Jun, Rameshwar, Roham ]; // { 1, 0, 1, 1, 0 } - Results = Smartness > Einstein ? Passed : Failed; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT003_LanguageBlockScope_ImperativeNestedAssociative() - { - string code = @" -[Imperative] -{ - a = 10; - b = true; - c = 20.1; - [Associative] - { - a_inner = a; - b_inner = b; - c_inner = c; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT003_SomeNulls_WhileLoop() - { - string code = @" -result = -[Imperative] -{ - a = [1,3,5,7,[]]; - b = [null,null,true]; - c = [[]]; - - d = [a,b,c]; - - i = 0; - j = 0; - e = []; - - while(i b1 ? true : false; // { false, false, false } - c2 = a2 > b2 ? true : false; // { false, false, false } - c3 = a3 > b3 ? true : false; // { false, false, false, null } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT005_Inline_Using_2_Collections_In_Condition() - { - string code = @" -[Imperative] -{ - a1 = 1..3..1; - b1 = 4..6..1; - a2 = 1..3..1; - b2 = 4..7..1; - a3 = 1..4..1; - b3 = 4..6..1; - c1 = a1 > b1 ? true : false; // { false, false, false } - c2 = a2 > b2 ? true : false; // { false, false, false } - c3 = a3 > b3 ? true : false; // { false, false, false, null } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT005_LanguageBlockScope_DeepNested_IAI() - { - string code = @" -[Imperative] -{ - a = 10; - b = true; - c = 20.1; - [Associative] - { - a_inner1 = a; - b_inner1 = b; - c_inner1 = c; - - - [Imperative] - { - a_inner2 = a; - b_inner2 = b; - c_inner2 = c; - - } - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT005_Update_In_collection() - { - string code = @" -a=1; -b=2; -c=4; -collection = [a,b,c]; -collection[1] = collection[1] + 0.5; -d = collection[1]; -d = d + 0.1; // updates the result of accessing the collection -b = b + 0.1; // updates the source member of the collection -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT006_Associative_Function_PassingNullAsArgument() - { - string code = @" -[Associative] -{ - def myFunction : double (a: double, b: double) - { - return = a + b; - } - d1 = null; - d2 = 0.5; - - result = myFunction (d1, d2); - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT006_BasicImport_TestFunction() - { - string code = @" -import (""basicImport.ds""); -a = [1.1,2.2]; -b = 2; -c = Scale(a,b); -d = Sin(30.0); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT006_Inline_Using_Different_Sized_1_Dim_Collections__2_() - { - string code = @" - a = 10 ; - b = ((a - a / 2 * 2) > 0)? a : a+1 ; //11 - c = 5; - d = ((c - c / 2 * 2) > 0)? c : c+1 ; //5 - e1 = ((b>(d-b+d))) ? d : (d+1); //5 - //inline conditional, returning different sized collections - c1 = [1,2,3]; - c2 = [1,2]; - a1 = [1, 2, 3, 4]; - b1 = a1>3?true:a1; // expected : {1, 2, 3, true} - b2 = a1>3?true:c1; // expected : {1, 2, 3} - b3 = a1>3?c1:c2; // expected : {1, 2} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT006_Inline_Using_Different_Sized_1_Dim_Collections() - { - string code = @" -[Imperative] -{ - a = 10 ; - b = ((a - a / 2 * 2) > 0)? a : a+1 ; //11 - c = 5; - d = ((c - c / 2 * 2) > 0)? c : c+1 ; //5 - e1 = ((b>(d-b+d))) ? d : (d+1); //5 - //inline conditional, returning different sized collections - c1 = [1,2,3]; - c2 = [1,2]; - a1 = [1, 2, 3, 4]; - b1 = a1>3?true:a1; // expected : {1, 2, 3, true} - b2 = a1>3?true:c1; // expected : {1, 2, 3} - b3 = a1>3?c1:c2; // expected : {1, 2} -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT006_LanguageBlockScope_DeepNested_AIA() - { - string code = @" -[Associative] -{ - a = 10; - b = true; - c = 20.1; - [Imperative] - { - a_inner1 = a; - b_inner1 = b; - c_inner1 = c; - - - [Associative] - { - a_inner2 = a; - b_inner2 = b; - c_inner2 = c; - - } - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT006_SomeNulls_Inline() - { - string code = @" -[Imperative] -{ -a = [null,1]; -b = []; -c = [1,2,3]; -result = SomeNulls(c)?SomeNulls(b):SomeNulls(a); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT006_grouped_1_Robert() - { - string code = @" -a1 = 10; // =1 -a2 = a1 + b1; // =3 -a = a2 + b; // 6 - -b1 = 20; // =1 -b2 = b1 + a2; // =3 -b = b2 + 2; // 5 -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT007_Associative_Function_NestedFunction() - { - string code = @" -[Associative] -{ - def ChildFunction : double (r1 : double) - { - return = r1; - - } - def ParentFunction : double (r1 : double) - { - return = ChildFunction (r1)*2; - } - d1 = 1.05; - - result = ParentFunction (d1); - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT007_Inline_Using_Collections_And_Replication_CollectionFunctionCall__2_() - { - string code = @" - def even : int(a : int) - { - return = a * 2; - } - a =1..10..1 ; //{1,2,3,4,5,6,7,8,9,10} - i = 1..5; - b = ((a[i] % 2) > 0)? even(a[i]) : a ; // { 1, 6, 3, 10, 5 } - c = ((a[0] % 2) > 0)? even(a[i]) : a ; // { 4, 6, 8, 10, 12 } - d = ((a[-2] % 2) == 0)? even(a[i]) : a ; // { 1, 2,..10} - e1 = (a[-2] == d[9])? 9 : a[1..2]; // { 2, 3 } -"; - // defect : DNL-1467619 Regression : Replication + InlineCondition yields different output in release and debug mode - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT007_LanguageBlockScope_AssociativeParallelImperative() - { - string code = @" -[Associative] -{ - a = 10; - b = true; - c = 20.1; - -} -[Imperative] -{ - aI = a; - bI = b; - cI = c; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT007_SomeNulls_RangeExpression() - { - string code = @" -result = -[Imperative] -{ -i = 0; -arr = [[1,1.2] , [null,0], [true, false] ]; -a1 = 0; -a2 = 2; -d = 1; -a = a1..a2..d; -for(i in a) -{ - if(SomeNulls(arr[i])) - return = i; - -} -return = -1; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT008_Associative_Function_DeclareVariableBeforeFunctionDeclaration() - { - string code = @" -[Associative] -{ - a = 1; - b = 10; - def Sum : int(a : int, b : int) - { - - return = a + b; - } - - sum = Sum (a, b); - - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT008_Inline_Returing_Different_Ranks__2_() - { - string code = @" - a = [ 0, 1, 2, 4]; - x = a > 1 ? 0 : [1,1]; // { 1, 1} ? - x_0 = x[0]; - x_1 = x[1]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT008_Inline_Returing_Different_Ranks() - { - string code = @" -[Imperative] -{ - a = [ 0, 1, 2, 4]; - x = a > 1 ? 0 : [1,1]; // { 1, 1} ? - x_0 = x[0]; - x_1 = x[1]; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT008_LanguageBlockScope_ImperativeParallelAssociative() - { - string code = @" -[Imperative] -{ - a = 10; - b = true; - c = 20.1; -} -[Associative] -{ - aA = a; - bA = b; - cA = c; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT008_SomeNulls_Replication() - { - string code = @" -/* -[Imerative] -{ - a = 1..5; - i = 0..3; - x = a[i]; -} -*/ -a = [ -[[null, 1],1], -[null], -[1,2,false] -]; -i = 0..2; -j = 0; -[Imperative] -{ - if(SomeNulls(a[i])) - { - j = j+1; - } - -} -//Note : the following works fine : -/* -[Imperative] -{ - for ( x in i) - { - if(SomeNulls(a[x])) - { - j = j+1; - } - } -} -*/ -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT009_Associative_Function_DeclareVariableInsideFunction() - { - string code = @" -[Associative] -{ - def Foo : int(input : int) - { - multiply = 5; - divide = 10; - - return = [input*multiply, input/divide]; - } - - input = 20; - sum = Foo (input); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT009_Inline_Using_Function_Call_And_Collection_And_Replication__2_() - { - string code = @" - def even(a : int) - { - return = a * 2; - } - def odd(a : int ) - { - return = a* 2 + 1; - } - x = 1..3; - a = ((even(5) > odd(3)))? even(5) : even(3); //10 - b = ((even(x) > odd(x+1)))?odd(x+1):even(x) ; // {2,4,6} - c = odd(even(3)); // 13 - d = ((a > c))?even(odd(c)) : odd(even(c)); //53 -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT009_LanguageBlockScope_UpdateVariableInNestedLanguageBlock_IA() - { - string code = @" -[Imperative] -{ - a = -10; - b = false; - c = -20.1; - [Associative] - { - a = 1.5; - b = -4; - c = false; - } - - newA = a; - newB = b; - newC = c; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT009_Update_Of_Undefined_Variables() - { - string code = @" -u1 = u2; -u2 = 3; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT010_Associative_Function_PassAndReturnBooleanValue() - { - string code = @" -[Associative] -{ - def Foo : bool (input : bool) - { - return = input; - } - - input = false; - result1 = Foo (input); - result2 = Foo (true); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT010_Defect_1456751_execution_on_both_true_and_false_path_issue() - { - string code = @" -a = 0; -def foo ( ) -{ - a = a + 1; - return = a; -} -x = 1 > 2 ? foo() + 1 : foo() + 2; - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT010_Defect_1456751_replication_issue() - { - string code = @" -[Imperative] -{ - a = [ 0, 1, 2]; - b = [ 3, 11 ]; - c = 5; - d = [ 6, 7, 8, 9]; - e = [ 10 ]; - xx = 1 < a ? a : 5; - yy = 0; - if( 1 < a ) - yy = a; - else - yy = 5; - x1 = a < 5 ? b : 5; - t1 = x1[0]; - t2 = x1[1]; - c1 = 0; - for (i in x1) - { - c1 = c1 + 1; - } - x2 = 5 > b ? b : 5; - t3 = x2[0]; - t4 = x2[1]; - c2 = 0; - for (i in x2) - { - c2 = c2 + 1; - } - x3 = b < d ? b : e; - t5 = x3[0]; - c3 = 0; - for (i in x3) - { - c3 = c3 + 1; - } - x4 = b > e ? d : [ 0, 1]; - t7 = x4[0]; - c4 = 0; - for (i in x4) - { - c4 = c4 + 1; - } -} -/* -Expected : -result1 = { 5, 5, 2 }; -thisTest.Verification(mirror, ""xx"", result1, 1); -thisTest.Verification(mirror, ""t1"", 3, 1); -thisTest.Verification(mirror, ""t2"", 11, 1); -thisTest.Verification(mirror, ""c1"", 2, 1); -thisTest.Verification(mirror, ""t3"", 3, 1); -thisTest.Verification(mirror, ""t4"", 5, 1); -thisTest.Verification(mirror, ""c2"", 2, 1); -thisTest.Verification(mirror, ""t5"", 3, 1); -thisTest.Verification(mirror, ""c3"", 1, 1); -thisTest.Verification(mirror, ""t7"", 0, 1); -thisTest.Verification(mirror, ""c4"", 1, 1);*/ -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT010_Inline_Using_Literal_Values() - { - string code = @" -[Imperative] -{ - a = 1 > 2.5 ? false: 1; - b = 0.55 == 1 ? true : false; - c = (( 1 + 0.5 ) / 2 ) <= (200/10) ? (8/2) : (6/3); - d = true ? true : false; - e = false ? true : false; - f = true == true ? 1 : 0.5; - g = (1/3.0) > 0 ? (1/3.0) : (4/3); - h = (1/3.0) < 0 ? (1/3.0) : (4/3); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT010_LanguageBlockScope_UpdateVariableInNestedLanguageBlock_AI() - { - string code = @" -[Associative] -{ - a = -10; - b = false; - c = -20.1; - [Imperative] - { - a = 1.5; - b = -4; - c = false; - } - - newA = a; - newB = b; - newC = c; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT010_SomeNulls_AssociativeImperative_01() - { - string code = @" -[Imperative] -{ - a = [1,2,null]; - b = [null, null]; - - [Associative] - { - a = [1]; - b = a; - m = SomeNulls(b); - a = [1,null,[]]; - n = m; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - [Test] - public void DebugEQT010_SomeNulls_AssociativeImperative_02() - { - string code = @" -[Imperative] -{ - a = [false]; - if(!SomeNulls(a)) - { - [Associative] - { - - b = a; - a = [null]; - - m = SomeNulls(b);//true,false - [Imperative] - { - c = a; - a = [2]; - n = SomeNulls(c);//true - } - - } - }else - { - m = false; - n = false; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT010_SomeNulls_AssociativeImperative_03() - { - string code = @" - - a = [[]]; - b = a; - - m = SomeNulls(b);//false - [Imperative] - { - c = a; - a = [null,[]]; - m = SomeNulls(c);//false - } - a = [null]; - n = SomeNulls(b);//true; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT010_Update_Of_Singleton_To_Collection() - { - string code = @" -s1 = 3; -s2 = s1 -1; -s1 = [ 3, 4 ] ; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT010_imperative_if_inside_for_loop_1_Robert() - { - string code = @" -[Imperative] -{ - x = 0; - - for ( i in 1..10..2) - { - x = i; - if(i>5) x = i*2; // tis is ignored - // if(i<5) x = i*2; // this causes a crash - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT011_Associative_Function_FunctionWithoutArgument() - { - string code = @" -[Associative] -{ - def Foo1 : int () - { - return = 5; - } - - result1 = Foo1 (); - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT011_Defect_1467281_conditionals() - { - string code = @" - x = 2 == [ ]; - y = []==null; - z = [[1]]==[1]; - z2 = [[1]]==1; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT011_LanguageBlockScope_AssociativeParallelAssociative() - { - string code = @" -[Associative] -{ - a = 10; - b = true; - c = 20.1; - -} -[Associative] -{ - aA = a; - bA = b; - cA = c; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT011_Update_Of_Variable_To_Null() - { - string code = @" -x = 1; -y = 2/x; -x = 0; -v1 = 2; -v2 = v1 * 3; -v1 = null; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT012_Associative_Function_MultipleFunctions() - { - string code = @" -[Associative] -{ - def Foo1 : int () - { - return = 5; - } - - - def Foo2 : int () - { - return = 6; - } - - - result1 = Foo1 (); - result2 = Foo2 (); - - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT012_BaseImportImperative() - { - string code = @" -import (""BaseImportImperative.ds""); -a = 1; -b = a; -[Associative] -{ - c = 3 * b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT012_CountTrue_IfElse() - { - string code = @" -result = -[Imperative] -{ - arr1 = [true,[[[[true]]]],null]; - arr2 = [[true],[false],null]; - if(CountTrue(arr1) > 1) - { - arr2 = arr1; - } - return = CountTrue(arr2); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT012_LanguageBlockScope_ImperativeParallelImperative() - { - string code = @" -[Imperative] -{ - a = 10; - b = true; - c = 20.1; - -} -[Imperative] -{ - aI = a; - bI = b; - cI = c; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT012_Update_Of_Variables_To_Bool() - { - string code = @" -p1 = 1; -p2 = p1 * 2; -p1 = false; -q1 = -3.5; -q2 = q1 * 2; -q1 = true; -s1 = 1.0; -s2 = s1 * 2; -s1 = false; -t1 = -1; -t2 = t1 * 2; -t1 = true; -r1 = 1; -r2 = r1 * 2; -r1 = true; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT013_Associative_Function_FunctionWithSameName_Negative() - { - string code = @" -[Associative] -{ - def Foo1 : int () - { - return = 5; - } - - - - def Foo1 : int () - { - return = 6; - } - - - - result2 = Foo2 (); - - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT013_CountTrue_ForLoop() - { - string code = @" -result = -[Imperative] -{ - a = [1,3,5,7,[]]; - b = [null,null,[1,true]]; - c = [CountTrue([1,null])]; - - d = [a,b,c]; - j = 0; - e = []; - - for(i in d) - { - e[j]= CountTrue(i); - j = j+1; - } - return = e; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT013_LanguageBlockScope_MultipleParallelLanguageBlocks_AIA() - { - string code = @" -[Associative] -{ - a = 10; - b = true; - c = 20.1; - -} -[Imperative] -{ - aI = a; - bI = b; - cI = c; - -} -[Associative] -{ - aA = a; - bA = b; - cA = c; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT014_CountTrue_WhileLoop() - { - string code = @" -result = -[Imperative] -{ - a = [1,3,5,7,[1]];//0 - b = [1,null,true];//1 - c = [[false]];//0 - - d = [a,b,c]; - - i = 0; - j = 0; - e = []; - - while(i b ? b : 5; - t3 = x2[0]; - t4 = x2[1]; - c2 = 0; - for (i in x2) - { - c2 = c2 + 1; - } - - x3 = b < d ? b : e; - t5 = x3[0]; - c3 = 0; - for (i in x3) - { - c3 = c3 + 1; - } - - x4 = b > e ? d : [ 0, 1]; - t7 = x4[0]; - c4 = 0; - for (i in x4) - { - c4 = c4 + 1; - } - - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT014_LanguageBlockScope_MultipleParallelLanguageBlocks_IAI() - { - string code = @" -[Imperative] -{ - a = 10; - b = true; - c = 20.1; -} -[Associative] -{ - aA = a; - bA = b; - cA = c; - -} -[Imperative] -{ - aI = a; - bI = b; - cI = c; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT015_Associative_Function_UnmatchFunctionArgument_Negative() - { - string code = @" -[Associative] -{ - def Foo : int (a : int) - { - return = 5; - } - - result = Foo(1,2); - - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT015_CountTrue_Function() - { - string code = @" -def foo(x:var[]..[]) -{ - a = []; - i = 0; - [Imperative] - { - for(j in x) - { - a[i] = CountTrue(j); - i = i+1; - } - } - return = a; -} -b = [ -[null],//0 -[1,2,3,[true]],//1 -[0],//0 -[true, true,1,true, null],//3 -[x, null]//0 -]; -result = foo(b); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT015_LanguageBlockScope_ParallelInsideNestedBlock_AssociativeNested_II() - { - string code = @" -[Associative] -{ - a = 10; - - [Imperative] - { - aI1 = a; - } - aA1 = a; - - [Imperative] - { - aI2 = a; - } - - aA2 = a; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT016_Associative_Function_ModifyArgumentInsideFunctionDoesNotAffectItsValue() - { - string code = @" -[Associative] -{ - def Foo : int (a : int) - { - a = a + 1; - return = a; - } - input = 3; - result = Foo(input); - originalInput = input; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT016_BaseImportAssociative() - { - string code = @" -import (""BaseImportAssociative.ds""); -a = 10; -b = 20; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT016_Inline_Using_Operators() - { - string code = @" -def foo (a:int ) -{ - return = a; -} -a = 1+2 > 3*4 ? 5-9 : 10/2; -b = a > -a ? 1 : 0; -c = 2> 1 && 4>3 ? 1 : 0; -d = 1 == 1 || (1 == 0) ? 1 : 0; -e1 = a > b && c > d ? 1 : 0; -f = a <= b || c <= d ? 1 : 0; -g = foo([ 1, 2 ]) > 3+ foo([4,5,6]) ? 1 : 3+ foo([4,5,6]); -i = [1,3] > 2 ? 1: 0; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT016_LanguageBlockScope_ParallelInsideNestedBlock_ImperativeNested_AA() - { - string code = @" -[Imperative] -{ - a = 10; - [Associative] - { - aA1 = a; - } - aI1 = a; - - [Associative] - { - aA2 = a; - } - aI2 = a; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT017_Associative_Function_CallingAFunctionBeforeItsDeclaration() - { - string code = @" -[Associative] -{ - def Level1 : int (a : int) - { - return = Level2(a+1); - } - - def Level2 : int (a : int) - { - return = a + 1; - } - input = 3; - result = Level1(input); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT017_BaseImportWithVariableClassInstance_Associativity() - { - string code = @" -import (""BaseImportWithVariableClassInstance.ds""); -c = a + b; -a = 10; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT017_Inline_In_Function_Scope() - { - string code = @" -def foo1 ( b ) -{ - return = b == 0 ? b : b+1; - -} -def foo2 ( x ) -{ - y = [Imperative] - { - if(x > 0) - { - return = x >=foo1(x) ? x : foo1(x); - } - return = x >=2 ? x : 2; - } - x1 = y == 0 ? 0 : y; - return = y + x1; -} -a1 = foo1(4); -a2 = foo2(3); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT018_CountTrue_RangeExpression_01() - { - string code = @" -result = -[Imperative] -{ - a1 = [1,true, null];//1 - a2 = 8; - a3 = [2,[true,[true,1]],[false,x, true]];//3 - a = CountTrue(a1)..a2..CountTrue(a3);//{1,4,7} - - return = CountTrue(a); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT018_CountTrue_RangeExpression_02() - { - string code = @" -result = -[Imperative] -{ - a1 = [1,true, null];//1 - a2 = 8; - a3 = [2,[true,[true,1]],[false,x, true]];//3 - a = CountTrue(a1)..a2..~CountTrue(a3);//{} - return = CountTrue(a); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT018_CountTrue_RangeExpression_03() - { - string code = @" -result = -[Imperative] -{ - a1 = [1,true, null];//1 - a2 = 8; - a3 = [2,[true,[true,1]],[false,x, true]];//3 - a = [1.0,4.0,7.0]; - //a = CountTrue(a1)..a2..#CountTrue(a3);//{} - return = CountTrue(a); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT019_CountTrue_Replication() - { - string code = @" -def foo(x:int) -{ - return = x +1; -} -a = [true,[true],1];//2 -b = [null]; -c = [[[true]]];//1 -d = [[true],[false,[true,true]]];//3 -arr = [CountTrue(a),CountTrue(b),CountTrue(c),CountTrue(d)]; -result = foo(arr); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT019_Defect_1456758() - { - string code = @" -b = true; -a1 = b && true ? -1 : 1; -[Imperative] -{ - a2 = b && true ? -1 : 1; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT019_Update_General() - { - string code = @" -X = 1; -Y = X + 1; -X = X + 1; -X = X + 1; -//Y = X + 1; -//X = X + 1; -test = X + Y; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT01_Arithmatic_List_And_List_Different_Length() - { - string code = @" -list1 = [ 1, 4, 7, 2]; -list2 = [ 5, 8, 3, 6, 7, 9 ]; -list3 = list1 + list2; // { 6, 12, 10, 8 } -list4 = list1 - list2; // { -4, -4, 4, -4} -list5 = list1 * list2; // { 5, 32, 21, 12 } -list6 = list2 / list1; // { 5, 2, 0, 3 } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT01_BasicGlobalFunction() - { - string code = @" -def foo:int(x:int) -{ - return = x; -} -a = foo; -b = foo(3); //b=3; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT01_Function_In_Assoc_Scope() - { - string code = @" -[Associative] -{ - def foo : int( a:int ) - { - return = a * 10; - } - - a = foo( 2 ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT01_SimpleRangeExpression() - { - string code = @" -[Imperative] -{ - a = 1..-6..-2; - a1 = 2..6..~2.5; - a2 = 0.8..1..0.2; - a3 = 0.7..1..0.3; - a4 = 0.6..1..0.4; - a5 = 0.8..1..0.1; - a6 = 1..1.1..0.1; - a7 = 9..10..1; - a8 = 9..10..0.1; - a9 = 0..1..0.1; - a10 = 0.1..1..0.1; - a11 = 0.5..1..0.1; - a12 = 0.4..1..0.1; - a13 = 0.3..1..0.1; - a14 = 0.2..1..0.1; - a17 = (0.5)..(0.25)..(-0.25); - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT01_Simple_1D_Collection_Assignment() - { - string code = @" -[Imperative] -{ - a = [ [1,2], [3,4] ]; - - a[1] = [-1,-2,3]; - - c = a[1][1]; - - d = a[0]; - - b = [ 1, 2 ]; - - b[0] = [2,2]; - e = b[0]; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT01_String_IfElse_1() - { - string code = @" -a = ""word""; -b = ""word ""; -result = -[Imperative] -{ - if(a==b) - { - return = true; - } - else return = false; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT01_String_IfElse_2() - { - string code = @" -a = ""w ord""; -b = ""word""; -result = -[Imperative] -{ - if (a ==b) return = true; - else return = false; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT01_String_IfElse_3() - { - string code = @" -a = "" ""; -b = """"; -result = -[Imperative] -{ - if (a ==b) return = true; - else return = false; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT01_String_IfElse_4() - { - string code = @" -a = ""a""; -b = ""a""; -result = -[Imperative] -{ - if (a ==b) return = true; - else return = false; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT01_String_IfElse_5() - { - string code = @" -a = "" "";//3 whiteSpace -b = "" "";//tab -result = -[Imperative] -{ - if (a ==b) return = true; - else return = false; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT01_String_IfElse_6() - { - string code = @" -a = """"; -b = "" ""; -result = -[Imperative] -{ - if (a ==null && b!=null) return = true; - else return = false; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT01_String_IfElse_7() - { - string code = @" -a = ""a""; -result = -[Imperative] -{ - if (a ==true||a == false) return = true; - else return = false; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT01_TestAllPassCondition() - { - string code = @" -[Imperative] -{ - a1 = 2 ; - a2 = -1; - a3 = 101; - a4 = 0; - - b1 = 1.0; - b2 = 0.0; - b3 = 0.1; - b4 = -101.99; - b5 = 10.0009; - - c1 = [ 0, 1, 2, 3]; - c2 = [ 1, 0.2]; - c3 = [ 0, 1.4, true ]; - c4 = [[0,1], [2,3 ] ]; - - x = [0, 0, 0, 0]; - if(a1 == 2 ) // pass condition - { - x[0] = 1; - } - if(a2 <= -1 ) // pass condition - { - x[1] = 1; - } - if(a3 >= 101 ) // pass condition - { - x[2] = 1; - } - if(a4 == 0 ) // pass condition - { - x[3] = 1; - } - - - y = [0, 0, 0, 0, 0]; - if(b1 == 1.0 ) // pass condition - { - y[0] = 1; - } - if(b2 <= 0.0 ) // pass condition - { - y[1] = 1; - } - if(b3 >= 0.1 ) // pass condition - { - y[2] = 1; - } - if(b4 == -101.99 ) // pass condition - { - y[3] = 1; - } - if(b5 == 10.0009 ) // pass condition - { - y[4] = 1; - } - - - z = [0, 0, 0, 0]; - if(c1[0] == 0 ) // pass condition - { - z[0] = 1; - } - if(c2[1] <= 0.2 ) // pass condition - { - z[1] = 1; - } - if(c3[2] == true ) // pass condition - { - z[2] = 1; - } - if(c4[0][0] == 0 ) // pass condition - { - z[3] = 1; - } - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT01_Update_Variable_Across_Language_Scope() - { - string code = @" -[Associative] -{ - a = 0; - d = a + 1; - [Imperative] - { - b = 2 + a; - a = 1.5; - - } - c = 2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT01_WhileBreakContinue() - { - string code = @" -[Imperative] -{ - x = 0; - y = 0; - while (true) - { - x = x + 1; - if (x > 10) - break; - - if ((x == 1) || (x == 3) || (x == 5) || (x == 7) || (x == 9)) - continue; - - y = y + 1; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT020_LanguageBlockScope_AssociativeNestedImperative_Function() - { - string code = @" -[Associative] -{ - def foo : int(a : int, b : int) - { - return = a - b; - } - [Imperative] - { - x = 20; - y = 10; - z = foo (x, y); - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT020_MultipleImport_WithSameFunctionName() - { - string code = @" -import (""basicImport1.ds""); -import (""basicImport3.ds""); -arr = [ 1.0, 2.0, 3.0 ]; -a1 = Scale( arr, 4.0 ); -b = a * 2; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT020_Nested_And_With_Range_Expr() - { - string code = @" -a1 = 1 > 2 ? true : 2 > 1 ? 2 : 1; -a2 = 1 > 2 ? true : 0..3; -b = [0,1,2,3]; -a3 = 1 > 2 ? true : b; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT021_Defect_1457354() - { - string code = @" -import (""c:\\wrongPath\\test.ds""); -a = 1; -b = a * 2; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT021_Defect_1457354_2() - { - string code = @" -import (""basicImport""); -a = 1; -b = a * 2; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT021_Defect_1457354_3() - { - string code = @" -import (""basicImport12.ds""); -a = 1; -b = a * 2; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT021_Defect_1467166_array_comparison_issue() - { - string code = @" -[Imperative] -{ - a = [ 0, 1, 2]; - xx = a < 1 ? 1 : 0; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT022_Array_Marshal() - { - string code = @" -import (Dummy from ""FFITarget.dll""); -dummy = Dummy.Dummy(); -arr = [0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0]; -sum_1_10 = dummy.SumAll1D(arr); -twice_arr = dummy.Twice(arr); - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT022_CountTrue_ImperativeAssociative() - { - string code = @" -[Imperative] -{ - a1 = [true,0,1,1.0,null]; - a2 = [false, CountTrue(a1),0.0]; - a3 = a1; - [Associative] - { - a1 = [true,[true]]; - a4 = a2; - a2 = [true]; - b = CountTrue(a4);//1 - } - - c = CountTrue(a3);//1 - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT022_Defect_1457740() - { - string code = @" -import (""basicImport1.ds""); -import (""basicImport3.ds""); -arr1 = [ 1, 3, 5 ]; -temp = Scale( arr1, a ); -a = a; -b = 2 * a; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT022_LanguageBlockScope_DeepNested_AIA_Function() - { - string code = @" -[Associative] -{ - def foo : int(a : int, b : int) - { - return = a - b; - } - [Imperative] - { - x_1 = 20; - y_1 = 10; - z_1 = foo (x_1, y_1); - - - [Associative] - { - x_2 = 100; - y_2 = 100; - z_2 = foo (x_2, y_2); - - } - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT023_CountFalse_IfElse() - { - string code = @" -result = -[Imperative] -{ - arr1 = [false,[[[[false]]]],null,0]; - arr2 = [[true],[false],null,null]; - if(CountFalse(arr1) > 1) - { - arr2 = arr1; - } - return = CountFalse(arr2);//2 -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT023_LanguageBlockScope_AssociativeParallelImperative_Function() - { - string code = @" -[Associative] -{ - def foo : int(a : int, b : int) - { - return = a - b; - } - - a = 10; - -} -[Imperative] -{ - x = 20; - y = 0; - z = foo (x, y); - -} -"; - //Assert.Fail(""); - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT024_CountFalse_ForLoop() - { - string code = @" -result = -[Imperative] -{ - a = [1,3,5,7,[]]; - b = [null,null,[0,false]]; - c = [CountFalse([[false],null])]; - - d = [a,b,c]; - j = 0; - e = []; - - for(i in d) - { - e[j]= CountFalse(i); - j = j+1; - } - return = e; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT024_Defect_1459470() - { - string code = @" -a = 0..4..1; -b = a; -c = b[2]; -a = 10..14..1; -b[2] = b[2] + 1; -a[2] = a[2] + 1; -x = a; - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT024_Defect_1459470_3() - { - string code = @" -def foo () -{ - a = 0..4..1; - b = a; - c = b[2]; - a = 10..14..1; - b[2] = b[2] + 1; - a[2] = a[2] + 1; - return = true; - -} -a :int[]; -b : int[]; -c : int; -test = foo(); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT024_Defect_1459470_4() - { - string code = @" -a = [1,2,3,4]; -b = a; -c = b[2]; -d = a[2]; -a[0..1] = [1, 2]; -b[2..3] = 5; - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT025_CountFalse_WhileLoop() - { - string code = @" -result = -[Imperative] -{ - a = [1,3,5,7,[0]];//0 - b = [1,null,false];//1 - c = [[true]];//0 - - d = [a,b,c]; - - i = 0; - j = 0; - e = []; - - while(i=10 ) - { - temp1 = temp1 + 1; - } - - elseif( a1<2 ) - { - temp1 = temp1 + 2; - } - elseif(a1<10) - { - temp1 = temp1 + 3; - } - - - } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT02_SampleTestUsingCodeFromExternalFile__2_() - { - string code = @" -[Associative] -{ - variable = 5; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT02_SampleTestUsingCodeFromExternalFile() - { - string code = @" -[Imperative] -{ - variable = 5; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT02_SimpleRangeExpression() - { - string code = @" -[Imperative] -{ - a15 = 1/2..1/4..-1/4; - a16 = (1/2)..(1/4)..(-1/4); - a18 = 1.0/2.0..1.0/4.0..-1.0/4.0; - a19 = (1.0/2.0)..(1.0/4.0)..(-1.0/4.0); - a20 = 1..3*2; - //a21 = 1..-6; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT02_String_Not() - { - string code = @" -a = ""a""; -result = -[Imperative] -{ - if(a) - { - return = false; - }else if(!a) - { - return = false; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT02_TestAssocInsideImp() - { - string code = @" -[Imperative] -{ - x = 5.1; - z = y; - w = z * 2; - [Associative] - { - y = 5; - z = x; - x = 35; - i = 3; - } - f = i; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT02_Update_Function_Argument_Across_Language_Scope() - { - string code = @" -a = 1; -def foo ( a1 : double ) -{ - return = a1 + 1; -} -b = foo ( c ) ; -c = a + 1; -[Imperative] -{ - a = 2.5; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT02_WhileBreakContinue() - { - string code = @" -[Imperative] -{ - x = 0; - sum = 0; - while (x <= 10) - { - x = x + 1; - if (x >= 5) - break; - - y = 0; - while (true) - { - y = y + 1; - if (y >= 10) - break; - } - // y == 10 - sum = sum + y; - } - // sum == 40 -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT030_CountFalse_Replication() - { - string code = @" -def foo(x:int) -{ - return = x +1; -} -a = [false,[false],0];//2 -b = [CountFalse([a[2]])]; -c = [[[false]]];//1 -d = [[false],[false,[true,false,0]]];//3 -arr = [CountFalse(a),CountFalse(b),CountFalse(c),CountFalse(d)]; -result = foo(arr); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT032_Cross_Language_Variables() - { - string code = @" -a = 5; -b = 2 * a; -[Imperative] { - sum = 0; - arr = 0..b; - for (i in arr) { - sum = sum + 1; - } -} -a = 10; -// expected: sum = 21 -// result: sum = 11 -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT033_CountFalse_ImperativeAssociative() - { - string code = @" -[Imperative] -{ - a1 = [false,0,1,1.0,null]; - a2 = [true, CountFalse(a1),0.0]; - a3 = a1; - [Associative] - { - a1 = [false,[false]]; - a4 = a2; - a2 = [false]; - b = CountFalse(a4);//1 - } - - c = CountFalse(a3);//1 - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT034_AllFalse_IfElse() - { - string code = @" -a = [false, false];//true -b = [[false]];//true -c = [false, 0];//false -result = []; -[Imperative] -{ - if(AllFalse(a)){ - a[2] = 0; - result[0] = AllFalse(a);//false - } - if(!AllFalse(b)){ - - result[1] = AllFalse(b);//false - }else - {result[1]= null;} - if(!AllFalse(c)){ - result[2] = AllFalse(c); - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT035_AllFalse_ForLoop() - { - string code = @" -result = -[Imperative] -{ - a = [false,false0,0,null,x];//false - b = [false,false0,x];//false - c = [];//false - d = [[]];//false - - h = [ - [[0]], - [false] -]; - e = [a,b ,c ,d,h]; - f = []; - j = 0; - for(i in e) - { - if(AllFalse(i)!=true){ - f[j] = AllFalse(i); - j = j+1; - } - - } -return = f; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT036_1_Null_Check() - { - string code = @" -result = null; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT036_AllFalse_WhileLoop() - { - string code = @" -result = -[Imperative] -{ - a = [false,false0,0,null,x];//false - b = [false,false0,x];//false - c = [];//false - d = [[]];//false - e = [a,b ,c ,d]; - i = 0; - f = []; - j = 0; - while(!AllFalse(e[i])&& i < Count(e)) - { - if(AllFalse(e[i])!=true){ - f[j] = AllFalse(e[i]); - j = j+1; - } - i = i+1; - - } -return = f; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT037_AllFalse_Function() - { - string code = @" -def foo( x : bool) -{ - return = !x; -} -a1 = [0]; -a2 = [null]; -a3 = [!true]; -b = [a1,a2,a3]; -result = [foo(AllFalse(a1)),foo(AllFalse(a2)),foo(AllFalse(a3))];//true,true,false -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT039_AllFalse_Inline() - { - string code = @" -a1 = [false,[false]]; -a = AllFalse(a1);//true -b1 = [null,null]; -b = AllFalse(b1);//false -c = AllFalse([b]);//t -result = a? c:b;//t -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT03_Arithmatic_Mixed() - { - string code = @" -list1 = [ 13, 23, 42, 65, 23 ]; -list2 = [ 12, 8, 45, 64 ]; -list3 = 3 * 6 + 3 * (list1 + 10) - list2 + list1 * list2 / 3 + list1 / list2; // { 128, 172, 759, 1566 } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT03_Assignment_Slicing_With_Collection() - { - string code = @" -def foo ( a:int[] ) -{ - a[0] = 0; - return = a; -} - a = [1,2,3]; - c = foo ( a ); - d = c[0]; - e = c[1]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT03_Collection_Assignment_Nested_Block() - { - string code = @" -[Associative] -{ - a = [ [1,2,3],[4,5,6] ]; - - [Imperative] - { - c = a[0]; - d = a[1][2]; - } - - e = c; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT03_ForLoopBreakContinue() - { - string code = @" -[Imperative] -{ - sum = 0; - for (x in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) - { - if (x >= 11) - break; - sum = sum + x; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT03_GlobalFunctionInAssocBlk() - { - string code = @" -[Associative] -{ - def foo:double(x:int, y:double = 2.0) - { - return = x + y; - } - a = foo; - b = foo(3); //b=5.0; - c = foo(2, 4.0); //c = 6.0 -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT03_MultipleIfStatement() - { - string code = @" -[Imperative] -{ - a=1; - b=2; - temp=1; - - if(a==1) - {temp=temp+1;} - - if(b==2) //this if statement is ignored - {temp=4;} - - } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT03_SimpleRangeExpressionUsingCollection() - { - string code = @" -[Imperative] -{ - a = 3 ; - b = 2 ; - c = -1; - w1 = a..b..-1 ; //correct - w2 = a..b..c; //correct - e1 = 1..2 ; //correct - f = 3..4 ; //correct - w3 = e1..f; //correct - w4 = (3-2)..(w3[1][1])..(c+2) ; //correct - w5 = (w3[1][1]-2)..(w3[1][1])..(w3[0][1]-1) ; //correct -} -/* expected results : - Updated variable a = 3 - Updated variable b = 2 - Updated variable c = -1 - Updated variable w1 = { 3, 2 } - Updated variable w2 = { 3, 2 } - Updated variable e1 = { 1, 2 } - Updated variable f = { 3, 4 } - Updated variable w3 = { { 1, 2, 3 }, { 2, 3, 4 } } - Updated variable w4 = { 1, 2, 3 } - Updated variable w5 = { 1, 2, 3 } -*/ -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT03_TestAssignmentToUndefinedVariables_negative__2_() - { - string code = @" -[Associative] -{ - a = b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT03_TestAssignmentToUndefinedVariables_negative() - { - string code = @" -[Imperative] -{ - a = b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT03_TestImpInsideAssoc() - { - string code = @" -[Associative] -{ - x = 5.1; - z = y; - w = z * 2; - [Imperative] - { - y = 5; - z = x; - x = 35; - i = 3; - } - f = i; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - - [Test] - public void DebugEQT03_Update_Function_Argument_Across_Language_Scope() - { - string code = @" -a = 1; -def foo ( a1 : int ) -{ - return = a1 + 1; -} -b = foo ( c ) ; -c = a + 1; -[Imperative] -{ - a = 2.5; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT040_AllFalse_Replication() - { - string code = @" -a = [ - [[0]], - [false] -]; -c = AllFalse(a); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT042_AllFalse_DynamicArray() - { - string code = @" -b = []; -a = [[true],[false],[false], - [false,[true,false]]]; - - i = 0; - result2 = - [Imperative] - { - while(i=0) m[0] = Sum(a); - if(Sum(b)>=0) m[1] = Sum(b); - if(Sum(c)>=0) m[2] = Sum(c); - if(Sum(d)>=0) m[3] = Sum(d); - if(Sum(e)>=0) m[4] = Sum(e); - if(Sum(f)>=0) m[5] = Sum(f); - if(Sum(g)>=0) m[6] = Sum(g); - - return = m; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT047_Sum_ForLoop() - { - string code = @" -result = -[Imperative] -{ - a = [0,0.0]; - b = [[]]; - c = [m,Sum(a),b,10.0]; - - d = [a,b,c]; - j = 0; - - for(i in d) - { - d[j] = Sum(i); - j = j+1; - } - - return = d; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT048_Sum_WhileLoop() - { - string code = @" -result = -[Imperative] -{ - a = [-2,0.0]; - b = [[]]; - c = [m,Sum(a),b,10.0]; - - d = [a,b,c]; - j = 0; - k = 0; - e = []; - - while(j list2; // { false, true, false, true, true } -list4 = list1 < list2; // { true, false, false, false, false } -list5 = list1 >= list2; // { false, true, true, true, true } -list6 = list1 <= list2; // { true, false, true, false, false } -list9 = [ true, false, true ]; -list7 = list9 && list5; // { false, false, true } -list8 = list9 || list6; // { true, false, true } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT05_RangeExpressionWithIncrement() - { - string code = @" -[Imperative] -{ - d = 0.9..1..0.1; - e1 = -0.4..-0.5..-0.1; - f = -0.4..-0.3..0.1; - g = 0.4..1..0.2; - h = 0.4..1..0.1; - i = 0.4..1; - j = 0.6..1..0.4; - k = 0.09..0.1..0.01; - l = 0.2..0.3..0.05; - m = 0.05..0.1..0.04; - n = 0.1..0.9..~0.3; - k = 0.02..0.03..#3; - l = 0.9..1..#5; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT05_TestForLoopInsideNestedBlocks() - { - string code = @" -[Associative] -{ - a = [ 4, 5 ]; - [Imperative] - { - x = 0; - b = [ 2,3 ]; - for( y in b ) - { - x = y + x; - } - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - - [Test] - public void DebugEQT05_TestRepeatedAssignment() - { - string code = @" -[Associative] -{ - b = a = 2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT05_TestRepeatedAssignment_negative__2_() - { - string code = @" -[Associative] -{ - b = a = 2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT05_TestRepeatedAssignment_negative() - { - string code = @" -[Imperative] -{ - b = a = 2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT060_Average_ForLoop() - { - string code = @" -result = -[Imperative] -{ - a = []; - b = [1,[2],[[2],1]]; - c = [true, false, null, 10]; - d = [a,b,c]; - - e = []; - j = 0; - - for(i in d) - { - e[j] = Average(i); - j = j+1; - - } - return = e; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT061_Average_Function() - { - string code = @" -def foo : double (x :var[]..[]) -{ - - return = Average(x); -} -a = [1,2,2,1]; -b = [1,[]]; -c = Average(a); -result = [foo(a),foo(b)]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT063_Average_Inline() - { - string code = @" -a = [1.0,2]; -b = [[0],1.0,[2]]; -result = Average(a)>Average(b)?true:false; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT064_Average_RangeExpression() - { - string code = @" -a = 0..6..3;//0,3,6 -b = 0..10..~3;//0,3.3,6.6,10 -m = Average(a);//3 -n = Average(b);//5.0 -c = Average([m])..Average([n]);//3.0,4.0,5.0 -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT066_Print_String() - { - string code = @" -r1 = Print(""Hello World""); -str = ""Hello World!!""; -r2 = Print(str); -a = 1; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT067_Print_Arr() - { - string code = @" -arr = [ 0, 1 ,2]; -r1 = Print(arr); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT06_Function_Imp_Inside_Assoc() - { - string code = @" -[Associative] -{ - def foo : int( a:int, b : int ) - { - return = a * b; - } - a = 3.5; - b = 3.5; - [Imperative] - { - a = foo( 2, 1 ); - } - b = - [Imperative] - { - c = foo( 2, 1 ); - return = c; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT06_InsideNestedBlock() - { - string code = @" -[Associative] -{ - a = 4; - b = a*2; - temp = 0; - [Imperative] - { - i=0; - temp=1; - while(i<=5) - { - i=i+1; - temp=temp+1; - } - } - a = temp; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT06_Logic_List_And_List_Same_Length() - { - string code = @" -list1 = [ 1, 8, 10, 4, 7 ]; -list2 = [ 2, 6, 10, 3, 5 ]; -list3 = list1 > list2; // { false, true, false, true, true } -list4 = list1 < list2; // { true, false, false, false, false } -list5 = list1 >= list2; // { false, true, true, true, true } -list6 = list1 <= list2; // { true, false, true, false, false } -list7 = list3 && list5; // { false, true, false, true, true } -list8 = list4 || list6; // { true, false, true, false, false } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT06_RangeExpressionWithIncrement() - { - string code = @" -[Imperative] -{ - a = 0.3..0.1..-0.1; - b = 0.1..0.3..0.2; - c = 0.1..0.3..0.1; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT06_TestInsideNestedBlocksUsingCollectionFromAssociativeBlock() - { - string code = @" -[Associative] -{ - a = [ 4,5 ]; - b =[Imperative] - { - - x = 0; - for( y in a ) - { - x = x + y; - } - return = x; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT07_BreakStatement() - { - string code = @" -[Imperative] -{ - i=0; - temp=0; - while( i <= 5 ) - { - i = i + 1; - if ( i == 3 ) - break; - temp=temp+1; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT07_Collection_Assignment_In_Function_Scope() - { - string code = @" -def collection :int[] ( a :int[] , b:int , c:int ) -{ - a[1] = b; - a[2] = c; - return= a; -} - a = [ 1,0,0 ]; - [Imperative] - { - a = collection( a, 2, 3 ); - } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT07_Logic_Mixed() - { - string code = @" -list1 = [ 1, 5, 8, 3, 6 ]; -list2 = [ 4, 1, 6, 3 ]; -list3 = (list1 > 1) && (list2 > list1) || (list2 < 5); // { true, true, false , true } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT07_ScopeVariableInBlocks() - { - string code = @" -[Imperative] -{ - a = 4; - b = a*2; - temp = 0; - if(b==8) - { - i=0; - temp=1; - if(i<=a) - { - temp=temp+1; - } - } - a = temp; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT07_String_Replication() - { - string code = @" -a = ""a""; -bcd = [""b"",""c"",""d""]; -r = a +bcd; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT07_String_Replication_1() - { - string code = @" -a = [""a""]; -bc = [""b"",""c""]; -str = a + bc; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT07_String_Replication_2() - { - string code = @" -a = ""a""; -b = [[""b""],[""c""]]; -str = a +b; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT07_TestForLoopUsingLocalVariable() - { - string code = @" -[Imperative] -{ - a = [ 1, 2, 3, 4, 5 ]; - x = 0; - for( y in a ) - { - local_var = y + x; - x = local_var + y; - } - z = local_var; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT07_TestOutsideBlock__2_() - { - string code = @" -b = 2; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT07_TestOutsideBlock() - { - string code = @" -b = 2; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT07_Update_Array_Variable() - { - string code = @" -a = 1..3; -c = a; -b = [ Imperative ] -{ - count = 0; - for ( i in a ) - { - a[count] = i + 1; - count = count+1; - } - return = a; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT08_Collection_Assignment_In_Function_Scope_2() - { - string code = @" -def foo ( a ) -{ - return= a; -} - a = [ 1, foo( 2 ) , 3 ]; - - [Imperative] - { - b = [ foo( 4 ), 5, 6 ]; - } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT08_ContinueStatement() - { - string code = @" -[Imperative] -{ - i = 0; - temp = 0; - while ( i <= 5 ) - { - i = i + 1; - if( i <= 3 ) - { - continue; - } - temp=temp+1; - - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT08_FunctionPointerUpdateTest() - { - string code = @" -def foo1:int(x:int) -{ - return = x; -} -def foo2:double(x:int, y:double = 2.0) -{ - return = x + y; -} -a = foo1; -b = a(3); -a = foo2; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT08_Logic_Single_List_And_Value() - { - string code = @" -list1 = [ 1, 2, 3, 4, 5 ]; -a = 3; -list2 = a > list1; // { true, true, false, false, false } -list3 = list1 > a; // { false, false, false, true, true } -list4 = a >= list1; // { true, true, true, false, false } -list5 = list1 >= a; // { false, false, true, true, true } -list6 = a < list1; // { false, false, false, true, true } -list7 = list1 < a; // { true, true, false, false, false } -list8 = a <= list1; // { false, false, true, true, true } -list9 = list1 <= a; // { true, true, true, false, false } -list10 = list2 && true; // { true, true, false, false, false } -list11 = false && list2; // { false, false, false, false, false } -list12 = list2 || true; // { true, true, true, true, true } -list13 = false || list2; // { true, true, false, false, false } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT08_NestedBlocks() - { - string code = @" -[Associative] -{ - a = 4; - - [Imperative] - { - i=10; - temp=1; - if(i>=-2) - { - temp=2; - } - } - b=2*a; - a=2; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT08_String_Inline() - { - string code = @" -a = ""a""; -b = ""b""; -r = a>b? a:b; -r1 = a==b? ""Equal"":""!Equal""; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT08_String_Inline_2() - { - string code = @" -a = ""a""; -b = ""b""; -r = a>b? a:b; -r1 = a==b? ""Equal"":""!Equal""; -b = ""a""; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT08_TestCyclicReference__2_() - { - string code = @" -[Associative] -{ - a = 2; - b = a *3; - a = 6.5; - a = b / 3; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT08_TestCyclicReference() - { - string code = @" -[Imperative] -{ - a = 2; - b = a *3; - a = 6.5; - a = b / 3; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT08_Update_Array_Variable() - { - string code = @" -a = 1..3; -c = a; -b = [ Imperative ] -{ - count = 0; - for ( i in a ) - { - if ( i > 0 ) - { - a[count] = i + 1; - } - count = count+1; - } - return = a; -} -d = [ Imperative ] -{ - count2 = 0; - while (count2 <= 2 ) - { - if ( a[count2] > 0 ) - { - a[count2] = a[count2] + 1; - } - count2 = count2+1; - } - return = a; -} -e = b; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT09_Defect_1449829() - { - string code = @" -[Associative] -{ - a = 2; -[Imperative] -{ - b = 1; - if(a == 2 ) - { - b = 2; - } - else - { - b = 4; - } -} -} - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT09_NegativeTest_Non_FunctionPointer() - { - string code = @" -def foo:int(x:int) -{ - return = x; -} -a = 2; -b = a(); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT09_NestedIfElseInsideWhileStatement() - { - string code = @" -[Imperative] -{ - i=0; - temp=0; - while(i<=5) - { - i=i+1; - if(i<=3) - { - temp=temp+1; - } - elseif(i==4) - { - temp = temp+1; - if(temp==i) - { - temp=temp+1; - } - } - else - { - if (i==5) - { temp=temp+1; - } - } - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT09_NestedWhileStatement() - { - string code = @" -[Imperative] -{ - i = 1; - a = 0; - p = 0; - - temp = 0; - - while( i <= 5 ) - { - a = 1; - while( a <= 5 ) - { - p = 1; - while( p <= 5 ) - { - temp = temp + 1; - p = p + 1; - } - a = a + 1; - } - i = i + 1; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT09_Replication_On_Operators_In_Range_Expr() - { - string code = @" -[Imperative] -{ - z5 = 4..1; // { 4, 3, 2, 1 } - z2 = 1..8; // { 1, 2, 3, ... , 6, 7, 8 } - z6 = z5 - z2 + 0.3; // { 3.3, 1.3, -1.7, -2.7 } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT09_String_DynamicArr() - { - string code = @" -a[1] = foo(""1"" + 1); -a[2] = foo(""2""); -a[10] = foo(""10""); -a[ - 2] = foo("" - 2"");//smart formatting -r = -[Imperative] -{ - i = 5; - while(i < 7) - { - a[i] = foo(""whileLoop""); - i = i + 1; - } - return = a; -} -def foo(x:var) -{ - return = x + ""!!""; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT09_TestForLoopWithBreakStatement() - { - string code = @" -[Imperative] -{ - a = [ 1,2,3 ]; - x = 0; - for( i in a ) - { - x = x + 1; - break; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT09_TestInNestedBlock__2_() - { - string code = @" -[Associative] -{ - a = 4; - b = a + 2; - [Imperative] - { - b = 0; - c = 0; - if ( a == 4 ) - { - b = 4; - } - else - { - c = 5; - } - d = b; - e = c; - g2 = g1; - } - f = a * 2; - g1 = 3; - g3 = g2; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT09_TestInNestedBlock() - { - string code = @" -[Imperative] -{ - a = 4; - b = a + 2; - [Associative] - { - [Imperative] - { - b = 0; - c = 0; - if ( a == 4 ) - { - b = 4; - } - else - { - c = 5; - } - d = b; - e = c; - g2 = g1; - } - } - f = a * 2; - g1 = 3; - g3 = g2; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - [Test] - public void DebugEQT09_Update_Across_Multiple_Imperative_Blocks() - { - string code = @" -a = 1; -b = a; -c = [ Imperative ] -{ - a = 2; - return = a; -} -d = [ Imperative ] -{ - a = 3; - return = a; -} -e = c; -f = d; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT10_2D_Collection_Assignment_In_Function_Scope() - { - string code = @" - def foo( a:int[] ) - { - a[0][0] = 1; - return= a; - } - b = [ [0,2,3], [4,5,6] ]; - d = foo( b ); - c = d[0]; - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT10_TestInFunctionScope__2_() - { - string code = @" -[Associative] -{ - def add:double( n1:int, n2:double ) - { - - return = n1 + n2; - } - test = add(2,2.5); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT10_TestNestedForLoops() - { - string code = @" -[Imperative] -{ - a = [ 1,2,3 ]; - x = 0; - for ( i in a ) - { - for ( j in a ) - { - x = x + j; - } - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT10_TypeConversion() - { - string code = @" -[Imperative] -{ - temp = 0; - a=4.0; - if(a==4) - temp=1; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT10_Update_Array_Across_Multiple_Imperative_Blocks() - { - string code = @" -a = 1..3; -b = a; -c = [Imperative ] -{ - x = [ 10, a[1], a[2] ]; - a[0] = 10; - return = x; -} -d = [ Imperative ] -{ - a[1] = 20; - return = a; -} -e = c; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT11_2D_Collection_Assignment_Heterogeneous() - { - string code = @" -[Imperative] -{ - a = [ [1,2,3], [4], [5,6] ]; - b = a[1]; - a[1] = 2; - a[1] = a[1] + 1; - a[2] = [7,8]; - c = a[1]; - d = a[2][1]; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT11_String_Imperative() - { - string code = @" -r = -[Imperative] -{ - a = ""a""; - b = a; - -} -c = b; -b = ""b1""; -a = ""a1""; -m = ""m""; -n = m; -n = ""n""; -m = m+n; -//a =""a1"" -//b = ""b1"" -//c = ""b1""; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT11_TestForLoopWithSingleton() - { - string code = @" -[Imperative] -{ - a = [1]; - b = 1; - x = 0; - - for ( y in a ) - { - x = x + 1; - } - - for ( y in b ) - { - x = x + 1; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT11_Update_Undefined_Variables() - { - string code = @" -b = a; -[Imperative] -{ - a = 3; -} -[Associative] -{ - a = 4; -} -c = b; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT11_WhilewithLogicalOperators() - { - string code = @" -[Imperative] -{ - i1 = 5; - temp1 = 1; - while( i >= 2) - { - i1=i1-1; - temp1=temp1+1; - } - - i2 = 5; - temp2 = 1; - while ( i2 != 1 ) - { - i2 = i2 - 1; - temp2 = temp2 + 1; - } - - temp3 = 2; - while( i2 == 1 ) - { - temp3 = temp3 + 1; - i2 = i2 - 1; - } - while( ( i2 == 1 ) && ( i1 == 1 ) ) - { - temp3=temp3+1; - i2=i2-1; - } - temp4 = 3; - while( ( i2 == 1 ) || ( i1 == 5 ) ) - { - i1 = i1 - 1; - temp4 = 4; - } - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT12_Collection_Assignment_Block_Return_Statement() - { - string code = @" -a;b;c1;c2; -[Associative] -{ - a = 3; - - b = [Imperative] - { - c = [ 1,2,3 ]; - if( c[1] <= 3 ) - return= c; - } - - b[2] = 4; - a = b; - c1 = a[1]; - c2 = a[2]; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT12_Function_From_Inside_Function() - { - string code = @" -def add_1 : double( a:double ) -{ - return = a + 1; -} -[Associative] -{ - def add_2 : double( a:double ) - { - return = add_1( a ) + 1; - } - - a = 1.5; - b = add_2 (a ); - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT12_RangeExpressionUsingNestedRangeExpressions() - { - string code = @" -[Imperative] -{ - x = 1..5..2; // {1,3,5} - y = 0..6..2; // {0,2,4,6} - a = (3..12..3)..(4..16..4); // {3,6,9,12} .. {4..8..12..16} - b = 3..00.6..#5; // {3.0,2.4,1.8,1.2,0.6} - //c = b[0]..7..#1; //This indexed case works - c = 5..7..#1; //Compile error here , 5 - d = 5.5..6..#3; // {5.5,5.75,6.0} - e1 = -6..-8..#3; //{-6,-7,-8} - f = 1..0.8..#2; //{1,0.8} - g = 1..-0.8..#3; // {1.0,0.1,-0.8} - h = 2.5..2.75..#4; //{2.5,2.58,2.67,2.75} - i = x[0]..y[3]..#10;//1..6..#10 - j = 1..0.9..#4;// {1.0, 0.96,.93,0.9} - k= 1..3..#0;//null -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT12_TestForLoopWith2DCollection() - { - string code = @" -[Imperative] -{ - a = [[1],[2,3],[4,5,6]]; - x = 0; - i = 0; - for (y in a) - { - x = x + y[i]; - i = i + 1; - } - z = 0; - for (i1 in a) - { - for(j1 in i1) - { - z = z + j1; - } - } - - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT12_TestUsingMathAndLogicalExpr() - { - string code = @" -[Imperative] -{ - e = 0; - a = 1 + 2; - b = 0.1 + 1.9; - b = a + b; - c = b - a - 1; - d = a + b -c; - if( c < a ) - { - e = 1; - } - else - { - e = 2; - } - if( c < a || b > d) - { - e = 3; - } - else - { - e = 4; - } - if( c < a && b > d) - { - e = 3; - } - else - { - e = 4; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT12_Update_Undefined_Variables() - { - string code = @" -b = a; -[Imperative] -{ - a = 3; -} -[Associative] -{ - a = 4; - d = b + 1; -} -c = b; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT13_2D_Collection_Assignment_Block_Return_Statement() - { - string code = @" -a; -b; -c1;c2; -[Associative] -{ - a = 3; - - b = [Imperative] - { - c = [ [ 1,2,3 ] , [ 4,5,6 ] ] ; - return= c; - } - - b[0][0] = 0; - a = b; - c1 = a[0]; - c2 = a[1][2]; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT13_Defect_1450527() - { - string code = @" -[Associative] -{ - a = 1; - temp=0; - [Imperative] - { - i = 0; - if(i <= a) - { - temp = temp + 1; - } - } - a = 2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT13_IfElseIf() - { - string code = @" -[Imperative] -{ - a1 = -7.5; - - temp1 = 10.5; - - if( a1>=10.5 ) - { - temp1 = temp1 + 1; - } - - elseif( a1<2 ) - { - temp1 = temp1 + 2; - } - - - } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT13_TestForLoopWithNegativeAndDecimalCollection() - { - string code = @" -[Imperative] -{ - a = [ -1,-3,-5 ]; - b = [ 2.5,3.5,4.2 ]; - x = 0; - y = 0; - for ( i in a ) - { - x = x + i; - } - - for ( i in b ) - { - y = y + i; - } - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT13_TestUsingMathAndLogicalExpr__2_() - { - string code = @" -[Associative] -{ - a = 3.5; - b = 1.5; - c = a + b; - d = a - c; - e = a * d; - f = a / e; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT13_TestUsingMathAndLogicalExpr() - { - string code = @" -[Imperative] -{ - a = 3.5; - b = 1.5; - b = a + b; - b = a - b; - b = a * b; - b = a / b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - [Test] - public void DebugEQT13_Update_Variables_Across_Blocks() - { - string code = @" -a = 3; -b = a * 3; -c = [Imperative] -{ - d = b + 3; - a = 4; - return = d; -} -f = c + 1; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT14_2D_Collection_Assignment_Using_For_Loop() - { - string code = @" -pts = [[0,1,2],[0,1,2]]; -x = [1,2]; -y = [1,2,3]; -[Imperative] -{ - c1 = 0; - for ( i in x ) - { - c2 = 0; - for ( j in y ) - { - pts[c1][c2] = i+j; - c2 = c2+1; - } - c1 = c1 + 1; - } - -} -p1 = pts[1][1]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT14_IfElseStatementExpressions() - { - string code = @" -[Imperative] -{ - a=1; - b=2; - temp1=1; - if((a/b)==1) - { - temp1=0; - } - elseif ((a*b)==2) - { temp1=2; - } - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT14_NegativeTest_UsingFunctionNameInNonAssignBinaryExpr() - { - string code = @" -def foo:int(x:int) -{ - return = x; -} -a = foo + 2; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT14_TestFactorialUsingWhileStmt() - { - string code = @" -[Imperative] -{ - a = 1; - b = 1; - while( a <= 5 ) - { - a = a + 1; - b = b * (a-1) ; - } - factorial_a = b * a; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT14_TestForLoopWithBooleanCollection() - { - string code = @" -[Imperative] -{ - a = [ true, false, true, true ]; - x = false; - - for( i in a ) - { - x = x + i; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT14_TestUsingMathAndLogicalExpr__2_() - { - string code = @" -[Associative] -{ - a = 3; - b = -4; - c = a + b; - d = a - c; - e = a * d; - f = a / e; - - c1 = 1 && 2; - c2 = 1 && 0; - c3 = null && true; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT14_TestUsingMathAndLogicalExpr() - { - string code = @" -[Imperative] -{ - a = 3; - b = -4; - b = a + b; - b = a - b; - b = a * b; - b = a / b; - - c1 = 1 && 2; - c2 = 1 && 0; - c3 = null && true; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT15_2D_Collection_Assignment_Using_While_Loop() - { - string code = @" -[Imperative] -{ - pts = [[0,1,2],[0,1,2]]; - x = [1,2,3]; - y = [1,2,3]; - i = 0; - while ( i < 2 ) - { - j = 0; - while ( j < 3 ) - { - pts[i][j] = i+j; - j = j + 1; - } - i = i + 1; - } - p1 = pts[1][1]; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT15_Defect_1452044() - { - string code = @" -[Associative] -{ - a = 2; - [Imperative] - { - b = 2 * a; - } - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT15_Defect_1460935_3() - { - string code = @" -x = 1; -y = x; -x = true; //if x = false, the update mechanism works fine -yy = y; -x = false; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT15_SimpleRangeExpression_1() - { - string code = @" -[Imperative] -{ - a = 1..2.2..#3; - b = 0.1..0.2..#4; - c = 1..3..~0.2; - d = (a[0]+1)..(c[2]+0.9)..0.1; - e1 = 6..0.5..~-0.3; - f = 0.5..1..~0.3; - g = 0.5..0.6..0.01; - h = 0.51..0.52..0.01; - i = 0.95..1..0.05; - j = 0.8..0.99..#10; - //k = 0.9..1..#1; - l = 0.9..1..0.1; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT15_TestEmptyIfStmt() - { - string code = @" -[Imperative] -{ - a = 0; - b = 1; - if(a == b); - else a = 1; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT15_TestForLoopWithMixedCollection() - { - string code = @" -[Imperative] -{ - a = [ -2, 3, 4.5 ]; - x = 1; - for ( y in a ) - { - x = x * y; - } - - a = [ -2, 3, 4.5, true ]; - y = 1; - for ( i in a ) - { - y = i * y; - } - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT15_TestWhileWithDecimalvalues() - { - string code = @" -[Imperative] -{ - a = 1.5; - b = 1; - while(a <= 5.5) - { - a = a + 1; - b = b * (a-1) ; - } - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - - [Test] - public void DebugEQT16_Defect_1460623() - { - string code = @" -a2 = 1.0; -test2 = a2; -a2 = 3.0; -a2 = 3.3; -t2 = test2; // expected : 3.3; recieved : 3.0 -a1 = [ 1.0, 2.0]; -test1 = a1[1]; -a1[1] = 3.0; -a1[1] = 3.3; -t1 = test1; // expected : 3.3; recieved : 3.0 -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT16_Defect_1460623_2() - { - string code = @" -def foo ( a ) -{ - return = a; -} -x = 1; -y = foo (x ); -x = 2; -x = 3; -[Imperative] -{ - x = 4; -} -z = x; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT16_Defect_1460623_3() - { - string code = @" -def foo ( a ) -{ - x = a; - y = x + 3; - x = a + 1; - x = a + 2; - return = y; -} -x = 1; -y = foo (x ); -[Imperative] -{ - x = 2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT16_SimpleRangeExpression_2() - { - string code = @" -[Imperative] -{ - a = 1.2..1.3..0.1; - b = 2..3..0.1; - c = 1.2..1.5..0.1; - //d = 1.3..1.4..~0.5; //incorrect - d = 1.3..1.4..0.5; - e1 = 1.5..1.7..~0.2; - f = 3..3.2..~0.2; - g = 3.6..3.8..~0.2; - h = 3.8..4..~0.2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT16_TestForLoopInsideIfElseStatement() - { - string code = @" -[Imperative] -{ - a = 1; - b = [ 2,3,4 ]; - if( a == 1 ) - { - for( y in b ) - { - a = a + y; - } - } - - else if( a !=1) - { - for( y in b ) - { - a = a + 1; - } - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT16_TestIfConditionWithNegation_Negative() - { - string code = @" -[Imperative] -{ - a = 3; - b = -3; - if ( a == !b ) - { - a = 4; - } - -} - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT16_TestWhileWithLogicalOperators() - { - string code = @" -[Imperative] -{ - a = 1.5; - b = 1; - while(a <= 5.5 && b < 20) - { - a = a + 1; - b = b * (a-1) ; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT16__Defect_1452588() - { - string code = @" -[Imperative] -{ - a = [ 1,2,3,4,5 ]; - for( y in a ) - { - x = 5; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT17_Assigning_Collection_And_Updating() - { - string code = @" -a = [1, 2, 3]; -b = a; -b[0] = 100; -t = a[0]; // t = 100, as expected - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT17_Defect_1459759_2() - { - string code = @" -a1 = [ 1, 2 ]; -y = a1[1] + 1; -a1[1] = 3; -a1 = 5; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT17_Function_From_Parallel_Blocks() - { - string code = @" -[Associative] -{ - def foo : int( n : int ) - { - return = n * n; - } - - - -} -[Associative] -{ - a = 3; - b = foo (a ); - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT17_PassFunctionPointerAsArg() - { - string code = @" -def foo:int(x:int) -{ - return = x; -} -def foo1:int(f:function, x:int) -{ - return = f(x); -} -a = foo1(foo, 2); -b = foo; -c = foo1(b, 3); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT17_SimpleRangeExpression_3() - { - string code = @" -[Imperative] -{ - a = 1..2.2..~0.2; - b = 1..2..#3; - c = 2.3..2..#3; - d = 1.2..1.4..~0.2; - e1 = 0.9..1..0.1; - f = 0.9..0.99..~0.01; - g = 0.8..0.9..~0.1; - h = 0.8..0.9..0.1; - i = 0.9..1.1..0.1; - j = 1..0.9..-0.05; - k = 1.2..1.3..~0.1; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT17_TestForLoopInsideNestedIfElseStatement() - { - string code = @" -[Imperative] -{ - a = 1; - b = [ 2,3,4 ]; - c = 1; - if( a == 1 ) - { - if(c ==1) - { - for( y in b ) - { - a = a + y; - } - } - } - - else if( a !=1) - { - for( y in b ) - { - a = a + 1; - } - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - - [Test] - public void DebugEQT17_TestWhileWithBool() - { - string code = @" -[Imperative] -{ - a = 0; - while(a == false) - { - a = 1; - } - - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT17_WhileInsideElse() - { - string code = @" -[Imperative] -{ - i=1; - a=3; - temp=0; - if(a==4) - { - i = 4; - } - else - { - while(i<=4) - { - if(i>10) - temp=4; - else - i=i+1; - } - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT17__Defect_1452588_2() - { - string code = @" -[Imperative] -{ - a = 1; - - if( a == 1 ) - { - if( a + 1 == 2) - b = 2; - } - - c = a; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT18_Assigning_Collection_In_Function_And_Updating() - { - string code = @" -def A (a: int []) -{ - return = a; -} -val = [1,2,3]; -b = A(val); -t = b; -t[0] = 100; // -y = b[0]; -z = val[0]; // val[0] is still 1 - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT18_FunctionPointerAsReturnVal() - { - string code = @" -def foo:int(x:int) -{ - return = x; -} -def foo1:int(f : function, x:int) -{ - return = f(x); -} -def foo2:function() -{ - return = foo; -} -a = foo2(); -b = a(2); -c = foo1(a, 3); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT18_SimpleRangeExpression_4() - { - string code = @" -[Imperative] -{ - a = 2.3..2.6..0.3; - b = 4.3..4..-0.3; - c= 3.7..4..0.3; - d = 4..4.3..0.3; - e1 = 3.2..3.3..0.3; - f = 0.4..1..0.1; - g = 0.4..0.45..0.05; - h = 0.4..0.45..~0.05; - g = 0.4..0.6..~0.05; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT18_TestForLoopInsideWhileStatement() - { - string code = @" -[Imperative] -{ - a = 1; - b = [ 1,1,1 ]; - x = 0; - - if( a == 1 ) - { - while( a <= 5 ) - { - for( i in b ) - { - x = x + 1; - } - a = a + 1; - } - } -} - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT18_TestMethodCallInExpr__2_() - { - string code = @" -[Associative] -{ - def mul : double ( n1 : int, n2 : int ) - { - return = n1 * n2; - } - def add : double( n1 : int, n2 : double ) - { - return = n1 + n2; - } - test0 = add (-1 , 7.5 ) ; - test1 = add (mul(1,2), 4.5 ) ; - test2 = add (mul(1,2.5), 4 ) ; - test3 = add (add(1.5,0.5), 4.5 ) ; - test4 = add (1+1, 4.5 ) ; - test5 = add ( add(1,1) + add(1,0.5), 3.0 ) ; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT18_TestWhileWithNull() - { - string code = @" -[Imperative] -{ - a = null; - c = null; - - while(a == 0) - { - a = 1; - } - while(null == c) - { - c = 1; - } - while(a == b) - { - a = 2; - } - - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - [Test] - public void DebugEQT18_Update_Variables_In_Inner_Assoc() - { - string code = @" -c = 2; -b = c * 2; -x = b; -[Imperative] -{ - c = 1; - b = c + 1; - d = b + 1; - y = 1; - [Associative] - { - b = c + 2; - c = 4; - z = 1; - } -} -b = c + 3; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT18_WhileInsideIf() - { - string code = @" -[Imperative] -{ - i=1; - a=3; - temp=0; - if(a==3) //when the if statement is removed, while loop works fine, otherwise runs only once - { - while(i<=4) - { - if(i>10) - temp=4; - else - i=i+1; - } - } -} - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT19_Assigning_Collection_In_Function_And_Updating() - { - string code = @" -def A (a: int []) -{ - return = a; -} -val = [1,2,3]; -b = A(val); -b[0] = 100; -z = val[0]; - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT19_BasicIfElseTestingWithNumbers() - { - string code = @" -[Imperative] -{ - a = 0; - b = 0; - c = 0; - d = 0; - if(1) - { - a = 1; - } - else - { - a = 2; - } - - - if(0) - { - b = 1; - } - else - { - b = 2; - } - - if(0) - { - c = 1; - } - elseif(1) - { - c = 3; - } - - if(0) - { - d = 1; - } - elseif(0) - { - d = 2; - } - else - { - d = 4; - } - -} - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT19_SimpleRangeExpression_5() - { - string code = @" -[Imperative] -{ - //a = 0.1..0.2..#1; //giving error - b = 0.1..0.2..#2; - c = 0.1..0.2..#3; - d = 0.1..0.1..#4; - e1 = 0.9..1..#5; - f = 0.8..0.89..#3; - g = 0.9..0.8..#3; - h = 0.9..0.7..#5; - i = 0.6..1..#4; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT19_TestAssignmentToCollection__2_() - { - string code = @" -[Associative] -{ - a = [[1,2],3.5]; - c = a[1]; - d = a[0][1]; - a[0][1] = 5; - b = a[0][1] + a[1]; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT19_TestAssignmentToCollection() - { - string code = @" -[Imperative] -{ - a = [[1,2],3.5]; - c = a[1]; - d = a[0][1]; - a[0][1] = 5; - b = a[0][1] + a[1]; - a = 2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT19_TestForLoopInsideNestedWhileStatement() - { - string code = @" -[Imperative] -{ - i = 1; - a = [1,2,3,4,5]; - x = 0; - - while( i <= 5 ) - { - j = 1; - while( j <= 5 ) - { - for( y in a ) - { - x = x + 1; - } - j = j + 1; - } - i = i + 1; - } -} - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT19_TestWhileWithIf() - { - string code = @" -[Imperative] -{ - a = 2; - b = a; - while ( a <= 4) - { - if(a < 4) - { - b = b + a; - } - else - { - b = b + 2*a; - } - a = a + 1; - } - - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT20_BasicIfElseTestingWithNumbers() - { - string code = @" -[Imperative] -{ - a = 0; - b = 0; - c = 0; - d = 0; - e = 0; - f = 0; - if(1.5) - { - a = 1; - } - else - { - a = 2; - } - - - if(-1) - { - b = 1; - } - else - { - b = 2; - } - - if(0) - { - c = 1; - } - elseif(20) - { - c = 3; - } - - if(0) - { - d = 1; - } - elseif(0) - { - d = 2; - } - else - { - d = 4; - } - - if(true) - { - e = 5; - } - - if(false) - { - f = 1; - } - else - { - f = 6; - } - -} - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT20_Defect_1458567() - { - string code = @" -a = 1; -b = a[1]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT20_Defect_1461391() - { - string code = @" -a = 1; -def foo ( a1 : double ) -{ - return = a1 + 1; -} -b = foo ( c ) ; -c = a + 1; -[Imperative] -{ - a = 2.5; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT20_Defect_1461391_2() - { - string code = @" -a = 1; -def foo ( a1 : double[] ) -{ - return = a1[0] + a1[1]; -} -b = foo ( c ) ; -c = [ a, a ]; -[Imperative] -{ - a = 2.5; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT20_Defect_1461391_3() - { - string code = @" -a = 1; -def foo ( a1 : double ) -{ - return = a1 + 1; -} -b = foo ( a ) ; -[Imperative] -{ - a = foo(2); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT20_Defect_1461391_6() - { - string code = @" -def foo ( a : int) -{ - return = a; -} -y1 = [ 1, 2 ]; -y2 = foo ( y1); -[Imperative] -{ - count = 0; - for ( i in y1) - { - y1[count] = y1[count] + 1; - count = count + 1; - } -} -t1 = y2[0]; -t2 = y2[1]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT20_Function_From_Imperative_If_Block() - { - string code = @" -[Associative] -{ - def foo : int( n : int ) - { - return = n * n; - } - - [Imperative] - { - - a = [ 0, 1, 2, 3, 4, 5 ]; - x = 0; - for ( i in a ) - { - x = x + foo ( i ); - } - - y = 0; - j = 0; - while ( a[j] <= 4 ) - { - y = y + foo ( a[j] ); - j = j + 1; - } - - z = 0; - - if( x == 55 ) - { - x = foo (x); - } - - if ( x == 50 ) - { - x = 2; - } - elseif ( y == 30 ) - { - y = foo ( y ); - } - - if ( x == 50 ) - { - x = 2; - } - elseif ( y == 35 ) - { - x = 3; - } - else - { - z = foo (5); - } - } - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT20_TestForLoopWithoutBracket() - { - string code = @" -[Imperative] -{ - a = [ 1, 2, 3 ]; - x = 0; - - for( y in a ) - x = y; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT20_TestInvalidSyntax__2_() - { - string code = @" -[Associative] -{ - a = 2;;;;; - b = 3; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT20_TestInvalidSyntax() - { - string code = @" -[Imperative] -{ - a = 2;;;;; - b = 3; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT20_TestWhileToCreate2DimArray() - { - string code = @" -def Create2DArray( col : int) -{ - result = [Imperative] - { - array = [ 1, 2 ]; - counter = 0; - while( counter < col) - { - array[counter] = [ 1, 2]; - counter = counter + 1; - } - return = array; - } - return = result; -} -x = Create2DArray( 2) ; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT21_Defect_1460891() - { - string code = @" -[Imperative] -{ - b = [ ]; - count = 0; - a = 1..5..2; - for ( i in a ) - { - b[count] = i + 1; - count = count + 1; - } - c = b ; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT21_Defect_1460891_2() - { - string code = @" -def CreateArray ( x : var[] , i ) -{ - x[i] = i; - return = x; -} -b = [0, 1]; -count = 0..1; -b = CreateArray ( b, count ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT21_Defect_1461390() - { - string code = @" -[Associative] -{ - a = 0; - d = a + 1; - [Imperative] - { - b = 2 + a; - a = 1.5; - - } - c = a + 2; // fail : runtime assertion -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - [Test] - public void DebugEQT21_Defect_1461390_2() - { - string code = @" -a = 1; -b = a + 1; -[Imperative] -{ - a = 2; - c = b + 1; - b = a + 2; - [Associative] - { - a = 1.5; - d = c + 1; - b = a + 3; - a = 2.5; - } - b = a + 4; - a = 3; -} -f = a + b; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT21_IfElseWithArray_negative() - { - string code = @" -[Imperative] -{ - a = [ 0, 4, 2, 3 ]; - b = 1; - c = 0; - if(a > b) - { - c = 0; - } - else - { - c = 1; - } -} - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT21_TestAssignmentToBool__2_() - { - string code = @" -[Associative] -{ - a = true; - b = false; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT21_TestAssignmentToBool() - { - string code = @" -[Imperative] -{ - a = true; - b = false; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT21_TestIfElseStatementInsideForLoop() - { - string code = @" -[Imperative] -{ - a = [ 1,2,3,4,5 ]; - x = 0; - - for ( i in a ) - { - if( i >=4 ) - x = x + 3; - - else if ( i ==1 ) - x = x + 2; - - else - x = x + 1; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT21_TestWhileToCallFunctionWithNoReturnType() - { - string code = @" -def foo () -{ - return = 0; -} -def test () -{ - temp = [Imperative] - { - t1 = foo(); - t2 = 2; - while ( t2 > ( t1 + 1 ) ) - { - t1 = t1 + 1; - } - return = t1; - } - return = temp; -} -x = test(); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT22_Create_Multi_Dim_Dynamic_Array() - { - string code = @" -[Imperative] -{ - d = [[]]; - r = c = 0; - a = [ 0, 1, 2 ]; - b = [ 3, 4, 5 ]; - for ( i in a ) - { - c = 0; - for ( j in b) - { - d[r][c] = i + j; - c = c + 1; - } - r = r + 1; - } - test = d; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT22_Defect_1463683() - { - string code = @" -def foo () -{ - return = 1; -} -def test () -{ - temp = [Imperative] - { - t1 = foo(); - t2 = 3; - if ( t2 < ( t1 + 1 ) ) - { - t1 = t1 + 2; - } - else - { - t1 = t1 ; - } - return = t1; - } - return = temp; -} -x = test(); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT22_Defect_1463683_4() - { - string code = @" -def foo () -{ - return = 1; -} -def test (t2) -{ - temp = [Imperative] - { - t1 = foo(); - if ( (t2 > ( t1 + 1 )) && (t2 >=3) ) - { - t1 = t1 + 2; - } - else - { - t1 = t1 ; - } - return = t1; - } - return = temp; -} -x1 = test(3); -x2 = test(0); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT22_IfElseWithArrayElements() - { - string code = @" -[Imperative] -{ - a = [ 0, 4, 2, 3 ]; - b = 1; - c = 0; - if(a[0] > b) - { - c = 0; - } - elseif( b < a[1] ) - { - c = 1; - } -} - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT22_TestAssignmentToNegativeNumbers__2_() - { - string code = @" -[Associative] -{ - a = -1; - b = -111; - c = -0.1; - d = -1.99; - e = 1.99; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT22_TestAssignmentToNegativeNumbers() - { - string code = @" -[Imperative] -{ - a = -1; - b = -111; - c = -0.1; - d = -1.99; - e = 1.99; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT22_TestWhileStatementInsideForLoop() - { - string code = @" -[Imperative] -{ - a = [ 1,2,3 ]; - x = 0; - - for( y in a ) - { - i = 1; - while( i <= 5 ) - { - j = 1; - while( j <= 5 ) - { - x = x + 1; - j = j + 1; - } - i = i + 1; - } - } -} - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT23_Function_Call_As_Function_Call_Arguments() - { - string code = @" -[Associative] -{ - def foo : double ( a : double , b :double ) - { - return = a + b ; - } - - def foo2 : double ( a : double , b :double ) - { - return = foo ( a , b ) + foo ( a, b ); - } - - a1 = 2; - b1 = 4; - c1 = foo2( foo (a1, b1 ), foo ( a1, foo (a1, b1 ) ) ); - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT23_TestForLoopWithDummyCollection() - { - string code = @" -[Imperative] -{ - a = [0, 0, 0, 0, 0, 0]; - b = [5, 4, 3, 2, 1, 0, -1, -2]; - i = 5; - for( x in b ) - { - if(i >= 0) - { - a[i] = x; - i = i - 1; - } - } - a1 = a[0]; - a2 = a[1]; - a3 = a[2]; - a4 = a[3]; - a5 = a[4]; - a6 = a[5]; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT23_TestUsingMathAndLogicalExpr__2_() - { - string code = @" -[Associative] -{ - a = -3.5; - b = -4; - c1 = a + b; - c2 = a - b; - c3 = a * b; - c4 = a / b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT23_TestUsingMathAndLogicalExpr() - { - string code = @" -[Imperative] -{ - a = -3.5; - b = -4; - c1 = a + b; - c2 = a - b; - c3 = a * b; - c4 = a / b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT24_Dynamic_Array_Argument_Function_1465802_1() - { - string code = @" - def foo : int(i:int[]) - { - return = 1; - } -[Associative] -{ -cy=[]; -cy[0]=10; -cy[1]=12; -b1=foo(cy); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT24_Dynamic_Array_Argument_Function_1465802_2() - { - string code = @" - def foo : int(i:int[]) - { - return = 1; - } -[Associative] -{ -cy=[]; -cy[0]=10; -cy[1]=null; -b1=foo(cy); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT24_Dynamic_Array_Imperative_Function_Scope() - { - string code = @" -def createArray( p : int[] ) -{ - a = [Imperative] - { - collection = []; - lineCnt = 0; - while ( lineCnt < 2 ) - { - collection [ lineCnt ] = p [ lineCnt ] * -1; - lineCnt = lineCnt + 1; - } - return = collection; - } - return = a; -} -x = createArray ( [ 1, 2, 3, 4 ] ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT24_Dynamic_Array_Imperative_Scope() - { - string code = @" -t = [Imperative] -{ - d = [ [ ] ]; - r = c = 0; - a = [ 0, 1, 2 ]; - b = [ 3, 4, 5 ]; - for ( i in a ) - { - c = 0; - for ( j in b) - { - d[r][c] = i + j; - c = c + 1; - } - r = r + 1; - } - test = d; - return = test; -} -// expected : test = { { 3, 4, 5 }, {4, 5, 6}, {5, 6, 7} } -// received : test = { { 3, 4, 5 }, , } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT24_Dynamic_Array_Inside_Function() - { - string code = @" -def foo ( d : var[] ) -{ - [Imperative] - { - r = c = 0; - a = [ 0, 1, 2 ]; - b1 = [ 3, 4, 5 ]; - for ( i in a ) - { - c = 0; - for ( j in b1) - { - d[r][c] = i + j; - c = c + 1; - } - r = r + 1; - } - } - return = d; -} -b = []; -b = foo ( b ) ; -a = b; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT24_Dynamic_Array_Inside_Function_2() - { - string code = @" -def foo ( d : var[]..[] ) -{ - [Imperative] - { - r = c = 0; - a = [ 0, 1, 2 ]; - b1 = [ 3, 4, 5 ]; - for ( i in a ) - { - c = 0; - for ( j in b1) - { - d[r][c] = i + j; - c = c + 1; - } - r = r + 1; - } - } - return = d; -} -b = [ [] ]; -b = foo ( b ) ; -a = b; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT24_TestForLoopToModifyCollection() - { - string code = @" -[Imperative] -{ - a = [1,2,3,4,5,6,7]; - i = 0; - for( x in a ) - { - - a[i] = a[i] + 1; - i = i + 1; - - } - a1 = a[0]; - a2 = a[1]; - a3 = a[2]; - a4 = a[3]; - a5 = a[4]; - a6 = a[5]; - a7 = a[6]; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT24_TestUsingMathematicalExpr__2_() - { - string code = @" -[Associative] -{ - a = 3; - b = 2; - c1 = a + b; - c2 = a - b; - c3 = a * b; - c4 = a / b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT24_TestUsingMathematicalExpr() - { - string code = @" -[Imperative] -{ - a = 3; - b = 2; - c1 = a + b; - c2 = a - b; - c3 = a * b; - c4 = a / b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT25_Adding_Elements_To_Array() - { - string code = @" -a = 0..2; -a[3] = 3; -b = a; -x = [ [ 0, 0 ] , [ 1, 1 ] ]; -x[1][2] = 1; -x[2] = [2,2,2,2]; -y = x; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT25_Adding_Elements_To_Array_Function() - { - string code = @" -def add ( x : var[]..[] ) -{ - x[1][2] = 1; - x[2] = [ 2, 2, 2, 2 ]; - return = x; -} -x = [ [ 0, 0 ] , [ 1, 1 ] ]; -x = add(x); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT25_Defect_1459759() - { - string code = @" -p1 = 2; -p2 = p1+2; -p1 = true; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT25_Defect_1459759_2() - { - string code = @" -a1 = [ 1, 2 ]; -y = a1[1] + 1; -a1[1] = 3; -a1 = 5; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT25_Defect_1459759_3() - { - string code = @" -a = [ 2 , b ,3 ]; -b = 3; -c = a[1] + 2; -d = c + 1; -b = [ 1,2 ]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT25_Defect_1459759_4() - { - string code = @" -[Imperative] -{ - [Associative] - { - p1 = 2; - p2 = p1+2; - p1 = true; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT25_Defect_1459759_5() - { - string code = @" -[Imperative] -{ - a = 2; - x = [Associative] - { - b = [ 2, 3 ]; - c = b[1] + 1; - b = 2; - return = c; - } - a = x; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT25_Defect_1459759_6() - { - string code = @" - def foo ( a, b ) - { - a = b + 1; - b = true; - return = [ a , b ]; - } -[Imperative] -{ - c = 3; - d = 4; - e = foo( c , d ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT25_RangeExpression_WithDefaultDecrement() - { - string code = @" -a=5..1; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT25_RangeExpression_WithDefaultDecrement_1467121() - { - string code = @" -a=5..1; -b=-5..-1; -c=1..0.5; -d=1..-0.5; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT25_RangeExpression_WithDefaultDecrement_nested_1467121_2() - { - string code = @" -a=(5..1).. (1..5); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT25_TestForLoopEmptyCollection() - { - string code = @" -[Imperative] -{ - a = []; - x = 0; - for( i in a ) - { - x = x + 1; - } - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT25_TestUsingMathematicalExpr__2_() - { - string code = @" -[Associative] -{ - a = 3.0; - b = 2; - c1 = a + b; - c2 = a - b; - c3 = a * b; - c4 = a / b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT25_TestUsingMathematicalExpr() - { - string code = @" -[Imperative] -{ - a = 3.0; - b = 2; - c1 = a + b; - c2 = a - b; - c3 = a * b; - c4 = a / b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT26_Defct_DNL_1459616() - { - string code = @" -a=1; -a=[a,2]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT26_Defct_DNL_1459616_2() - { - string code = @" -a=[1,2]; -[Imperative] -{ - a=[a,2]; -} -b = a; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT26_Defct_DNL_1459616_3() - { - string code = @" -a=[1,2]; -[Imperative] -{ - a=[a,2]; -} -b = [ 1, 2 ]; -def foo ( ) -{ - b = [ b[1], b[1] ]; - return = null; -} -dummy = foo (); -c = b; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT26_IfElseWithNegatedCondition() - { - string code = @" -[Imperative] -{ - a = 1; - b = 1; - c = 0; - if( !(a == b) ) - { - c = 1; - } - else - { - c = 2; - } - -} - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT26_Negative_TestPropertyAccessOnPrimitive() - { - string code = @" -x = 1; -y = x.a; -[Imperative] -{ - x1 = 1; - y1 = x1.a; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT26_RangeExpression_Function_tilda_associative_1457845_3() - { - string code = @" -[Associative] -{ - def square : double ( x: double ) - { - return = x * x; - } -} -[Imperative] -{ - x = 0.1; - a = 0..2..~0.5; - b = 0..0.1..~square(0.1); - f = 0..0.1..~x; - g = 0.2..0.3..~x; - h = 0.3..0.2..~-0.1; - - j = 0.8..0.5..~-0.3; - k = 0.5..0.8..~0.3; - l = 0.2..0.3..~0.0; - m = 0.2..0.3..~1/2; // division -} - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT26_RangeExpression_Function_tilda_multilanguage_1457845_2() - { - string code = @" -[Associative] -{ - def square : double ( x: double ) - { - return = x * x; - } -[Imperative] -{ - x = 0.1; - a = 0..2..~0.5; - b = 0..0.1..~square(0.1); - f = 0..0.1..~x; - g = 0.2..0.3..~x; - h = 0.3..0.2..~-0.1; - - j = 0.8..0.5..~-0.3; - k = 0.5..0.8..~0.3; - l = 0.2..0.3..~0.0; - m = 0.2..0.3..~1/2; // division -} - } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT26_TestForLoopOnNullObject() - { - string code = @" -[Imperative] -{ - x = 0; - - for ( i in b ) - { - x = x + 1; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT26_defect_1464429_DynamicArray() - { - string code = @" -def CreateArray ( x : var[] , i ) -{ -x[i] = i; -return = x; -} -b = [ ]; // Note : b = { 0, 0} works fine -count = 0..1; -t2 = CreateArray ( b, count ); -t1=b; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT27_DynamicArray_Invalid_Index_1465614_1() - { - string code = @" -a=[]; -b=a[2]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT27_RangeExpression_Function_Associative_1463472() - { - string code = @" -[Associative] -{ - def twice : double( a : double ) - { - return = 2 * a; - } - z1 = 1..twice(4)..twice(1); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT27_RangeExpression_Function_Associative_1463472_2() - { - string code = @" -[Associative] -{ - def twice : int []( a : double ) - { - c=1..a; - return = c; - } -d=1..4; -c=twice(4); -// z1 = 1..twice(4)..twice(1); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT27_RangeExpression_Function_Associative_replication() - { - string code = @" -[Associative] -{ - def twice : int[]( a : int ) - { - c=2*(1..a); - return = c; - } - d=[1,2,3,4]; - z1=twice(d); -// z1 = 1..twice(4)..twice(1); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT27_RangeExpression_Function_return_1463472() - { - string code = @" -[Associative] -{ - def twice : int []( a : double ) - { - c=1..a; - return = c; - } -d=1..4; -c=twice(4); -// z1 = 1..twice(4)..twice(1); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT27_defect_1464429_DynamicArray() - { - string code = @" -def CreateArray ( x : var[] , i ) -{ -x[i] = i; -return = x; -} -b = [ ]; // Note : b = { 0, 0} works fine -count = 0..1; -t2 = CreateArray ( b, count ); -t1=b; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT27_defect_1464429_DynamicArray_update() - { - string code = @" -def CreateArray ( x : var[] , i ) -{ -x[i] = i; -return = x; -} -b = [ ]; // Note : b = { 0, 0} works fine -count = 0..1; -t2 = CreateArray ( b, count ); -t1=b; -count = -2..-1; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT28_Defect_1452966() - { - string code = @" -[Imperative] -{ - a = [ 1,2,3 ]; - x = 0; - for ( i in a ) - { - for ( j in a ) - { - x = x + j; - } - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT28_Update_With_Inline_Condition() - { - string code = @" -x = 3; -a1 = 1; -a2 = 2; -a = x > 2 ? a1: a2; -a1 = 3; -a2 = 4; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT28_Update_With_Inline_Condition_2() - { - string code = @" -x = 3; -a1 = [ 1, 2]; -a2 = 3; -a = x > 2 ? a2: a1; -a2 = 5; -x = 1; -a1[0] = 0; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT29_Defect_1452966_2() - { - string code = @" -[Imperative] -{ - a = [[6],[5,4],[3,2,1]]; - x = 0; - - for ( i in a ) - { - for ( j in i ) - { - x = x + j; - } - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT29_DynamicArray_Using_Out_Of_Bound_Indices() - { - string code = @" - - basePoint = [ ]; - - basePoint [ 4 ] =3; - test = basePoint; - - a = basePoint[0] + 1; - b = basePoint[ 4] + 1; - c = basePoint [ 8 ] + 1; - - d = [ 0,1 ]; - e1 = d [ 8] + 1; - - x = [ ]; - y = [ ]; - t = [Imperative] - { - k = [ ]; - for ( i in 0..1 ) - { - x[i] = i; - } - k[0] = 0; - for ( i in x ) - { - y[i] = x[i] + x[i+1]; - k[i+1] = x[i] + x[i+1]; - - } - return = k; - } - z = y; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT30_ForLoopNull() - { - string code = @" -[Imperative] -{ - a = [ 1,null,null ]; - x = 1; - - for( i in a ) - { - x = x + 1; - } -} - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT30_Update_Global_Variables_Imperative_Scope() - { - string code = @" -x = [0,0,0,0]; -count = 0; -i = 0; -sum = 0; -test = sum; -[Imperative] -{ - for ( i in x ) - { - x[count] = count; - count = count + 1; - } - j = 0; - while ( j < count ) - { - sum = x[j]+ sum; - j = j + 1; - } -} -y = x; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT30_Update_Global_Variables_Imperative_Scope_2() - { - string code = @" -count = 0; -i = 0; -sum = 0; -test = sum; -[Imperative] -{ - for ( i in x ) - { - x[count] = count; - count = count + 1; - } - j = 0; - while ( j < count ) - { - sum = x[j]+ sum; - j = j + 1; - } -} -x = [0,0,0,0]; -y = x; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT31_Defect_1449877__2_() - { - string code = @" -[Associative] -{ - a = -1; - b = -2; - c = -3; - c = a * b * c; - d = c * b - a; - e = b + c / a; - f = a * b + c; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT31_Defect_1449877() - { - string code = @" -[Imperative] -{ - a = -1; - b = -2; - c = -3; - c = a * b * c; - d = c * b - a; - e = b + c / a; - f = a * b + c; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT32_Defect_1449877_2__2_() - { - string code = @" -[Associative] -{ - def func:int(a:int,b:int) - { - return = b + a; - } - a = 3; - b = -1; - d = func(a,b); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT32_Update_With_Range_Expr() - { - string code = @" -y = 1; -y1 = 0..y; -y = 2; -z1 = y1; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT33_Defect_1450003__2_() - { - string code = @" -[Associative] -{ - def check:double( _a:double, _b:int ) - { - _c = _a * _b; - return = _c; - } - _a_test = check(2.5,5); - _b = 4.5; - _c = true; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT33_ForLoopToReplaceReplicationGuides() - { - string code = @" -a = [ 1, 2 ]; -b = [ 3, 4 ]; -//c = a<1> + b <2>; -dummyArray = [ [ 0, 0 ], [ 0, 0 ] ]; -counter1 = 0; -counter2 = 0; -[Imperative] -{ - for ( i in a ) - { - counter2 = 0; - - for ( j in b ) - { - dummyArray[ counter1 ][ counter2 ] = i + j; - - counter2 = counter2 + 1; - } - counter1 = counter1 + 1; - } - -} -a1 = dummyArray[0][0]; -a2 = dummyArray[0][1]; -a3 = dummyArray[1][0]; -a4 = dummyArray[1][1]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT34_Defect_1450727__2_() - { - string code = @" -[Associative] -{ - x = -5.5; - y = -4.2; - - z = x + y; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT34_Defect_1450727() - { - string code = @" -[Imperative] -{ - x = -5.5; - y = -4.2; - - z = x + y; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT34_Defect_1452966() - { - string code = @" -[Imperative] -{ - a = [ 1, 2, 3, 4 ]; - sum = 0; - - for(i in a ) - { - for ( i in a ) - { - sum = sum + i; - } - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT34_Function_With_Mismatching_Return_Type() - { - string code = @" -[Associative] -{ - def foo1 : double ( a : double ) - { - return = true; - } - - dummyArg = 1.5; - - b1 = foo1 ( dummyArg ); - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT35_Defect_1450727_2__2_() - { - string code = @" -[Associative] -{ - def neg_float:double(x:double,y:double) - { - a = x; - b = y; - return = a + b; - } - z = neg_float(-2.3,-5.8); - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT35_Defect_1452966_2() - { - string code = @" -[Imperative] -{ - a = [ [1, 2, 3], [4], [5,6] ]; - sum = 0; - - for(i in a ) - { - for ( j in i ) - { - sum = sum + j; - } - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT35_Function_With_Mismatching_Return_Type() - { - string code = @" -[Associative] -{ - def foo2 : double ( a : double ) - { - return = 5; - } - - dummyArg = 1.5; - - b2 = foo2 ( dummyArg ); - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT35_IfElseWithEmptyBody() - { - string code = @" -[Imperative] -{ - c = 0; - if(0) - { - - } - elseif (1) { c = 2; } - else { } - - - -} - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - - [Test] - public void DebugEQT36_Defect_1450555() - { - string code = @" -[Imperative] -{ - a = true; - b = 2; - c = 2; - - if( a ) - b = false; - - if( b==0 ) - c = 1; - } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT36_Defect_1452966_3() - { - string code = @" -[Associative] -{ - a = [ [1, 2, 3], [4], [5,6] ]; - - def forloop :int ( a: int[]..[] ) - { - sum = 0; - sum = [Imperative] - { - for(i in a ) - { - for ( j in i ) - { - sum = sum + j; - } - } - return = sum; - } - return = sum; - } - - b =forloop(a); - - - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT36_Function_With_Mismatching_Return_Type() - { - string code = @" -[Associative] -{ - def foo3 : int ( a : double ) - { - return = 5.5; - } - - dummyArg = 1.5; - - b2 = foo3 ( dummyArg ); - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT37_Defect_1450920() - { - string code = @" -[Imperative] -{ - a = 0; - b = 0; - c = 0; - d = 0; - if(true) - { - a = 1; - } - - if(false) - { - b = 1; - } - elseif(true) - { - b = 2; - } - - if(false) - { - c = 1; - } - elseif(false) - { - c = 2; - } - else - { - c = 3; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT37_Defect_1454517() - { - string code = @" - a = [ 4,5 ]; - - b =[Imperative] - { - x = 0; - for( y in a ) - { - x = x + y; - } - - return = x; - } - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT37_Modify_Collections_Referencing_Each_Other() - { - string code = @" -a = [1,2,3]; -b = a; -c1 = a[0]; -b[0] = 10; -c2 = a[0]; -testArray = a; -testArrayMember1 = c1; -testArrayMember2 = c2; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT37_TestOperationOnNullAndBool__2_() - { - string code = @" -[Associative] -{ - a = true; - b = a + 1; - c = null + 2; - } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT37_TestOperationOnNullAndBool() - { - string code = @" -[Imperative] -{ - a = true; - b = a + 1; - c = null + 2; - } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT38_Defect_1449928__2_() - { - string code = @" -[Associative] -{ - a = 2.3; - b = -6.9; - c = a / b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT38_Defect_1449928() - { - string code = @" -[Imperative] -{ - a = 2.3; - b = -6.9; - c = a / b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT38_Defect_1454517_2() - { - string code = @" - a = [ 4,5 ]; - x = 0; - - [Imperative] - { - x = 0; - for( y in a ) - { - x = x + y; - } - } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT38_Defect_1454517_3() - { - string code = @" -def foo ( a : int [] ) -{ - x = 0; - x = [Imperative] - { - for( y in a ) - { - x = x + y; - } - return =x; - } - return = x; -} -a = [ 4,5 ]; -[Imperative] -{ - b = foo(a); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT38_Function_With_Mismatching_Return_Type() - { - string code = @" -[Associative] -{ - def foo3 : int[] ( a : double ) - { - return = a; - } - - dummyArg = 1.5; - - b2 = foo3 ( dummyArg ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT39_Defect_1449704__2_() - { - string code = @" -[Associative] -{ - a = b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT39_Defect_1449704() - { - string code = @" -[Imperative] -{ - a = b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT39_Defect_1450920_2() - { - string code = @" -[Imperative] -{ -a=0; -b=0; -c=0; -d=0; - if(0.4) - { - d = 4; - } - - if(1.4) - { - a = 1; - } - - if(0) - { - b = 1; - } - elseif(-1) - { - b = 2; - } - - if(0) - { - c = 1; - } - elseif(0) - { - c = 2; - } - else - { - c = 3; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT39_Defect_1452951() - { - string code = @" -[Associative] -{ - a = [ 4,5 ]; - - [Imperative] - { - //a = { 4,5 }; // works fine - x = 0; - for( y in a ) - { - x = x + y; - } - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT39_Function_With_Mismatching_Return_Type() - { - string code = @" -[Associative] -{ - def foo3 : int ( a : double ) - { - return = [1, 2]; - } - - dummyArg = 1.5; - - b2 = foo3 ( dummyArg ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT40_Create_3_Dim_Collection_Using_For_Loop() - { - string code = @" -x = [ [ [ 0, 0] , [ 0, 0] ], [ [ 0, 0 ], [ 0, 0] ]]; -a = [ 0, 1 ]; -b = [ 2, 3]; -c = [ 4, 5 ]; -y = [Imperative] -{ - c1 = 0; - for ( i in a) - { - c2 = 0; - for ( j in b ) - { - c3 = 0; - for ( k in c ) - { - x[c1][c2][c3] = i + j + k; - c3 = c3 + 1; - } - c2 = c2+ 1; - } - c1 = c1 + 1; - } - - return = x; - -} -p1 = y[0][0][0]; -p2 = y[0][0][1]; -p3 = y[0][1][0]; -p4 = y[0][1][1]; -p5 = y[1][0][0]; -p6 = y[1][0][1]; -p7 = y[1][1][0]; -p8 = y[1][1][1]; -p9 = x [1][1][1]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT40_Defect_1450552__2_() - { - string code = @" -[Associative] -{ - a = b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT40_Defect_1450552() - { - string code = @" -[Imperative] -{ - a = b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT40_Defect_1450843() - { - string code = @" -[Imperative] -{ - a = null; - b1 = 0; - b2 = 0; - b3 = 0; - if(a!=1); - else - b1 = 2; - - if(a==1); - else - b2 = 2; - - if(a==1); - elseif(a ==3); - else b3 = 2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT40_Function_With_Mismatching_Return_Type() - { - string code = @" -[Associative] -{ - def foo3 : int[][] ( a : double ) - { - return = [ [2.5], [3.5]]; - } - - dummyArg = 1.5; - - b2 = foo3 ( dummyArg ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT40_Index_usingFunction_1467064() - { - string code = @" -def foo() -{ -return = 0; -} -x = [ 1, 2 ]; -x[foo()] = 3; -y = x; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT41_Create_3_Dim_Collection_Using_For_Loop_In_Func_Call() - { - string code = @" -def foo :int[]..[]( a : int[], b:int[], c :int[]) -{ - y = [Imperative] - { - x = [ [ [ 0, 0] , [ 0, 0] ], [ [ 0, 0 ], [ 0, 0] ]]; - c1 = 0; - for ( i in a) - { - c2 = 0; - for ( j in b ) - { - c3 = 0; - for ( k in c ) - { - x[c1][c2][c3] = i + j + k; - c3 = c3 + 1; - } - c2 = c2+ 1; - } - c1 = c1 + 1; - } - return = x; - } - return = y; -} -a = [ 0, 1 ]; -b = [ 2, 3]; -c = [ 4, 5 ]; -y = foo ( a, b, c ); -p1 = y[0][0][0]; -p2 = y[0][0][1]; -p3 = y[0][1][0]; -p4 = y[0][1][1]; -p5 = y[1][0][0]; -p6 = y[1][0][1]; -p7 = y[1][1][0]; -p8 = y[1][1][1]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT41_Defect_1450778() - { - string code = @" -[Imperative] -{ - a=1; - b=2; - c=2; - d = 2; - - if(a==1) - { - c = 1; - } - - if(b==2) - { - d = 1; - } - - } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT41_Function_With_Mismatching_Return_Type() - { - string code = @" -[Associative] -{ - def foo3 : int[][] ( a : double ) - { - return = [ [2.5], 3]; - } - - dummyArg = 1.5; - - b2 = foo3 ( dummyArg ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT41_Pass_3x3_List_And_2x4_List() - { - string code = @" -def foo : int(a : int, b : int) -{ - return = a * b; -} -list1 = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]; -list2 = [ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ]; -list3 = foo(list1, list2); // { { 1, 4, 9 }, { 20, 30, 42 } } -x = list3[0]; -y = list3[1]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT41__Defect_1452423__2_() - { - string code = @" -[Associative] -{ - b = true; - c = 4.5; - d = c * b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT41__Defect_1452423() - { - string code = @" -[Imperative] -{ - b = true; - c = 4.5; - d = c * b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT42_Defect_1449707() - { - string code = @" -[Imperative] -{ - a = 1; - b = 1; - c = 1; - if( a < 1 ) - c = 6; - - else if( b >= 2 ) - c = 5; - - else - c = 4; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT42_Defect_1466071_Cross_Update_2() - { - string code = @" -i = 5; -totalLength = 6; -[Associative] -{ - x = totalLength > i ? 1 : 0; - - [Imperative] - { - for (j in 0..3) - { - i = i + 1; - } - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT42_Defect_1466071_Cross_Update_3() - { - string code = @" -y = 1; -a = 2; -x = a > y ? 1 : 0; -y = [Imperative] -{ - while (y < 2) // create a simple outer loop - { - y = y + 1; - } - return = y; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT42_Function_With_Mismatching_Return_Type() - { - string code = @" -[Associative] -{ - def foo3 : bool[]..[] ( a : double ) - { - return = [ [2], 3]; - } - - dummyArg = 1.5; - - b2 = foo3 ( dummyArg ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT42_Pass_3_List_Different_Length() - { - string code = @" -def foo : int(a : int, b : int, c : int) -{ - return = a * b - c; -} -list1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; -list2 = [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3 ]; -list3 = [1, 4, 7, 2, 5, 8, 3 ]; -list4 = foo(list1, list2, list3); // { 9, 14, 17, 26, 25, 22, 25 } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT42__Defect_1452423_2() - { - string code = @" -[Imperative] -{ - a = [ -2,3,4.5,true ]; - x = 1; - for ( y in a ) - { - x = x *y; //incorrect result - } - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT43_Defect_1450706() - { - string code = @" -[Imperative] -{ - a1 = 7.3; - a2 = -6.5 ; - - temp1 = 10; - temp2 = 10; - - if( a1 <= 7.5 ) - temp1 = temp1 + 2; - - if( a2 >= -9.5 ) - temp2 = temp2 + 2; - } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT43_Defect_1463498() - { - string code = @" -[Associative] -{ -def foo : int ( a : int, b : int ) -{ - a = a + b; - b = 2 * b; - return = a + b; -} -a = 1; -b = 2; -c = foo (a, b ); // expected 9, received -3 -d = a + b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT43_Function_With_Matching_Return_Type() - { - string code = @" -[Associative] -{ - def foo3 : int[]..[] ( a : double ) - { - return = [ [ 0, 2 ], [ 1 ] ]; - } - - dummyArg = 1.5; - - b2 = foo3 ( dummyArg )[0][0]; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT43_Pass_3_List_Different_Length_2_Integers() - { - string code = @" -def foo : int(a : int, b : int, c : int, d : int, e : int) -{ - return = a * b - c / d + e; -} -list1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; -list2 = [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3 ]; -list3 = [1, 4, 7, 2, 5, 8, 3 ]; -list4 = foo(list1, list2, list3, 4, 23); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - - [Test] - public void DebugEQT43__Defect_1452423_3() - { - string code = @" -[Imperative] -{ - a = 0; - while ( a == false ) - { - a = 1; - } - - b = a; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT44_Pass_3_List_Same_Length() - { - string code = @" -def foo : int(a : int, b : int, c : int) -{ - return = a * b - c; -} -list1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; -list2 = [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ]; -list3 = [1, 4, 7, 2, 5, 8, 3, 6, 9, 0 ]; -list4 = foo(list1, list2, list3); // { 9, 14, 17, 26, 25, 22, 25, 18, 9, 10 } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT44_Use_Bracket_Around_Range_Expr_In_For_Loop() - { - string code = @" -[Imperative] { -s = 0; -for (i in (0..10)) { - s = s + i; -} -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT44__Defect_1452423_4__2_() - { - string code = @" -[Associative] -{ - y = true; - x = 1 + y; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT44__Defect_1452423_4() - { - string code = @" -[Imperative] -{ - y = true; - x = 1 + y; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT45_Defect_1450506() - { - string code = @" -[Imperative] -{ - i1 = 2; - i2 = 3; - i3 = 4.5; - - temp = 2; - - while(( i2 == 3 ) && ( i1 == 2 )) - { - temp = temp + 1; - i2 = i2 - 1; - } - - if(( i2 == 3 ) || ( i3 == 4.5 )) - { - temp = temp + 1; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT45_Function_With_Mismatching_Argument_Type() - { - string code = @" -[Associative] -{ - def foo : double ( a : double ) - { - return = 1.5; - } - - b2 = foo ( 1 ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT45_Pass_3_List_Same_Length_2_Integers() - { - string code = @" -def foo : int(a : int, b : int, c : int, d : int, e : int) -{ - return = a * b - c * d + e; -} -list1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; -list2 = [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ]; -list3 = [1, 4, 7, 2, 5, 8, 3, 6, 9, 0 ]; -list4 = foo(list1, list2, list3, 26, 43); // { 27, -43, -115, 19, -57, -135, -7, -89, -173, 53 } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT45__Defect_1452423_5__2_() - { - string code = @" -[Associative] -{ - a = 4 + true; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT45__Defect_1452423_5() - { - string code = @" -[Imperative] -{ - a = 4 + true; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT46_Pass_FunctionCall_Reutrn_List() - { - string code = @" -def foo : int(a : int) -{ - return = a * a; -} -list1 = [ 1, 2, 3, 4, 5 ]; -list3 = foo(foo(foo(list1))); // { 1, 256, 6561, 65536, 390625 } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT46_TestBooleanOperationOnNull__2_() - { - string code = @" -[Imperative] -{ - a = null; - b = a * 2; - c = a && 2; - d = 0; - if ( a && 2 == 0) - { - d = 1; - } - else - { - d = 2; - } - - if( !a ) - { - d = d + 2; - } - else - { - d = d + 1; - } - if( a ) - { - d = d + 3; - } - - - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT46_TestBooleanOperationOnNull() - { - string code = @" -[Imperative] -{ - a = null; - b = a * 2; - c = a && 2; - d = 0; - if ( a && 2 == 0) - { - d = 1; - } - else - { - d = 2; - } - - if( !a ) - { - d = d + 2; - } - if( a ) - { - d = d + 1; - } - - - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT46_TestIfWithNull() - { - string code = @" -[Imperative] -{ - a = null; - c = null; - - if(a == 0) - { - a = 1; - } - if(null == c) - { - c = 1; - } - if(a == b) - { - a = 2; - } - - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT47_Defect_1450858() - { - string code = @" -[Imperative] -{ - i = 1; - a = 3; - if( a==3 ) - { - while( i <= 4 ) - { - if( i > 10 ) - temp = 4; - else - i = i + 1; - } - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT47_Function_With_Mismatching_Argument_Type() - { - string code = @" -[Associative] -{ - def foo : double ( a : double ) - { - return = 1.5; - } - - b2 = foo ( true); - c = 3; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT47_Pass_Single_3x3_List() - { - string code = @" -def foo : int(a : int) -{ - return = a * a; -} -list1 = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]; -list2 = foo(list1); // { { 1, 4, 9 }, { 16, 25, 36 }, { 49, 64, 81 } } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT47_TestBooleanOperationOnNull() - { - string code = @" -[Imperative] -{ - a = false; - b = 0; - d = 0; - if( a == null) - { - d = d + 1; - } - if( b == null) - { - d = d + 1; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT48_Pass_Single_List() - { - string code = @" -def foo : int(num : int) -{ - return = num * num; -} -list1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; -list2 = foo(list1); // { 1, 4, 9, 16, 25, 36, 49, 64, 81, 100 } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT49_Defect_1450783() - { - string code = @" -[Imperative] -{ - a = 4; - if( a == 4 ) - { - i = 0; - } - a = i; - b = i; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT49_Pass_Single_List_2_Integers() - { - string code = @" -def foo : int(num : int, num2 : int, num3 : int) -{ - return = num * num2 - num3; -} -list1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; -list2 = foo(list1, 34, 18); // { 16, 50, 84, 118, 152, 186, 220, 254, 288, 322 } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT49_TestForStringObjectType() - { - string code = @" -[Associative] -{ - def foo : string (x : string ) - { - return = x; - } - a = ""sarmistha""; - b = foo ( a ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT50_1_of_3_Exprs_is_List() - { - string code = @" -list1 = [ true, false, true, false, true ]; -list2 = list1 ? 1 : 0; // { 1, 0, 1, 0, 1 } -list3 = true ? 10 : list2; // { 10, 10, 10, 10, 10 } -list4 = false ? 10 : list2; // { 1, 0, 1, 0, 1 } -a = [ 1, 2, 3, 4, 5 ]; -b = [5, 4, 3, 2, 1 ]; -c = [ 4, 3, 2, 1 ]; -list5 = a > b ? 1 : 0; // { 0, 0, 0, 1, 1 } -list6 = c > a ? 1 : 0; // { 1, 1, 0, 0 } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT50_Defect_1456713() - { - string code = @" -a = 2.3; -b = a * 3; -//Expected : b = 6.9; -//Recieved : b = 6.8999999999999995; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT50_Function_With_Mismatching_Argument_Type() - { - string code = @" -[Associative] -{ - def foo : double ( a : int[] ) - { - return = 1.5; - } - aa = [ ]; - b2 = foo ( aa ); - c = 3; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT51_2_of_3_Exprs_are_Lists_Different_Length() - { - string code = @" -list1 = [ 1, 2, 3, 4, 5 ]; -list2 = [ true, false, true, false ]; -list3 = list2 ? list1 : 0; // { 1, 0, 3, 0 } -list4 = list2 ? 0 : list1; // { 0, 2, 0, 4 } -list5 = [ -1, -2, -3, -4, -5, -6 ]; -list6 = true ? list1 : list5; // { 1, 2, 3, 4, 5 } -list7 = false ? list1 : list5; // { -1, -2, -3, -4, -5 } -a = [ 1, 2, 3, 4 ]; -b = [ 5, 4, 3, 2, 1 ]; -c = [ 1, 4, 7 ]; -list8 = a >= b ? a + c : 10; // { 10, 10, 10 } -list9 = a < b ? 10 : a + c; // { 10, 10, 10 } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT51_Assignment_Using_Negative_Index() - { - string code = @" -a = [ 0, 1, 2, 3 ]; -c1 = a [-1]; -c2 = a [-2]; -c3 = a [-3]; -c4 = a [-4]; -c5 = a [-5]; -c6 = a [-1.5]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT51_Defect_1452588() - { - string code = @" -[Imperative] -{ - a = 0; - - if ( a == 0 ) - { - b = 2; - } - c = a; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT51_Function_With_Mismatching_Argument_Type() - { - string code = @" -[Associative] -{ - def foo : double ( a : double[] ) - { - return = 1.5; - } - aa = [1, 2 ]; - b2 = foo ( aa ); - c = 3; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT52_2_of_3_Exprs_are_Lists_Same_Length() - { - string code = @" -list1 = [ 1, 2, 3, 4, 5 ]; -list2 = [ true, false, true, false, true ]; -list3 = list2 ? list1 : 0; // { 1, 0, 3, 0, 5 } -list4 = list2 ? 0 : list1; // { 0, 2, 0, 4, 0 } -list5 = true ? list3 : list4; // { 1, 0, 3, 0, 5 } -list6 = true ? list4 : list3; // {0, 2, 0, 4, 0 } -a = [ 1, 2, 3, 4, 5 ]; -b = [ 5, 4, 3, 2 ]; -list7 = a > b ? a + b : 10; // { 10, 10, 10, 6 } -list8 = a <= b ? 10 : a + b; // { 10, 10, 10, 6 } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT52_Defect_1449889() - { - string code = @" -[Imperative] -{ - a = b; - c = foo(); - d = 1; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT52_Defect_1452588_2() - { - string code = @" -[Associative] -{ - [Imperative] - { - g2 = g1; - } - g1 = 3; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT52_Function_With_Mismatching_Argument_Type() - { - string code = @" -[Associative] -{ - def foo : double ( a : double[] ) - { - return = 1.5; - } - aa = 1.5; - b2 = foo ( aa ); - c = 3; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQT53_3_of_3_Exprs_are_different_dimension_list() - { - string code = @" -a = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; -b = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]; -c = [ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ], [ 9, 10, 11, 12 ] ]; -list = a > b ? b + c : a + c; // { { 2, 4, }, { 8, 10 } } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT53_Collection_Indexing_On_LHS_Using_Function_Call() - { - string code = @" -def foo() -{ - return = 0; -} -x = [ 1, 2 ]; -x[foo()] = 3; -y = x; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT53_Function_Updating_Argument_Values() - { - string code = @" -[Associative] -{ - def foo : double ( a : double ) - { - a = 4.5; - return = a; - } - aa = 1.5; - b2 = foo ( aa ); - c = 3; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT53_Undefined_Class_negative_1467107_10() - { - string code = @" -def foo(x:int) -{ -return = x + 1; -} -//y1 = test.foo(2); -m=null; -y2 = m.foo(2); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT53_Undefined_Class_negative_associative_1467091_13() - { - string code = @" -def foo ( x : int) -{ -return = x + 1; -} -y = test.foo (1); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT54_3_of_3_Exprs_are_Lists_Different_Length() - { - string code = @" -list1 = [ true, false, true, true, false ]; -list2 = [ 1, 2, 3, 4 ]; -list3 = [ -1, -2, -3, -4, -5, -6 ]; -list4 = list1 ? list2 : list3; // { 1, -2, 3, 4 } -list5 = !list1 ? list2 : list4; // { 1, 2, 3, 4 } -list6 = [ -1, -2, -3, -4, -5 ]; -list7 = list1 ? list2 : list6; // { 1, -2, 3, 4 } -a = [ 3, 0, -1 ]; -b = [ 2, 1, 0, 3 ]; -c = [ -2, 4, 1, 2, 0 ]; -list8 = a < c ? b + c : a + c; // { 1, 4, 1 } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT55_3_of_3_Exprs_are_Lists_Same_Length() - { - string code = @" -list1 = [ true, false, false, true ]; -list2 = [ 1, 2, 3, 4 ]; -list3 = [ -1, -2, -3, -4 ]; -list4 = list1 ? list2 : list3; // { 1, -2, -3, 4 } -list5 = !list1 ? list2 : list3; // { -1, 2, 3, -4 } -a = [ 1, 4, 7 ]; -b = [ 2, 8, 5 ]; -c = [ 6, 9, 3 ]; -list6 = a > b ? b + c : b - c; // { -4, -1, 8 } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT55_Associative_assign_If_condition_1467002() - { - string code = @" -[Associative] -{ - x = [] == null; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT55_Defect_1450506() - { - string code = @" -[Imperative] -{ - i1 = 1.5; - i2 = 3; - temp = 2; - while( ( i2==3 ) && ( i1 <= 2.5 )) - { - temp = temp + 1; - i2 = i2 - 1; - } - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT56_Function_Updating_Argument_Values() - { - string code = @" -[Associative] -{ - def foo : int[] ( a : int[] ) - { - a[0] = 0; - return = a; - } - aa = [ 1, 2 ]; - bb = foo ( aa ); - - c = 3; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT56_UnaryOperator() - { - string code = @" -list1 = [ true, true, false, false, true, false ]; -list2 = !list1; // { false, false, true, true, false, true } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT57_Function_Using_Local_Var_As_Same_Name_As_Arg() - { - string code = @" -[Associative] -{ - def foo : int ( a : int ) - { - a = 3; - b = a + 1; - return = b; - } - - aa = 1; - bb = foo ( aa ); - c = 3; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT58_Defect_1450932_comparing_collection_with_singleton_Associative() - { - string code = @" -[Associative] -{ - a2 = [ 0, 1 ]; - b2 = 1; - d2 = a2 > b2 ? true : [ false, false]; - //f2 = a2 > b2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT58_Defect_1450932_comparing_collection_with_singleton_Associative_2() - { - string code = @" -[Associative] -{ - a2 = [ 0, 1 ]; - b2 = 1; - f2 = a2 > b2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT58_Defect_1450932_comparing_collection_with_singleton_Associative_3() - { - string code = @" -[Associative] -{ - a2 = [ 0, 1 ]; - b2 = 1; - d2 = a2 > b2 ? true : [ false, false]; - f2 = a2 > b2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT58_Defect_1450932_comparing_collection_with_singleton_Imperative() - { - string code = @" -[Imperative] -{ - a = [ 0, 1 ]; - b = 1; - c = -1; - if(a > b) - { - c = 0; - } - else - { - c = 1; - } - d = a > b ? true : [ false, false]; - f = a > b; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT58_Function_With_No_Argument() - { - string code = @" - def foo : int ( ) - { - return = 3; - } - - [Associative] - { - c = foo(); - } - - [Imperative] - { - c = foo(); - } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT59_Defect_1453881() - { - string code = @" -d2 = ( null == 0 ) ? 1 : 0; -[Imperative] -{ - a = false; - b = 0.5; - d = 0; - if( a == null) - { - d = d + 1; - } - else - { - d = d + 2; - } - if( b == null) - { - b = b + 1; - } - else - { - b = b + 2; - } - - if( b != null) - { - b = b + 3; - } - else - { - b = b + 4; - } - - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT59_Defect_1453881_2() - { - string code = @" -def foo () -{ - c = - [Imperative] - { - a = false; - b = 0.5; - d = 0; - if( a == null) - { - d = d + 1; - } - else - { - d = d + 2; - } - if( b == null) - { - b = b + 1; - } - else - { - b = b + 2; - } - - if( b != null) - { - b = b + 3; - } - else - { - b = b + 4; - } - return = [ b, d ]; - } - return = c; -} -test = foo(); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT59_Defect_1455590() - { - string code = @" - a = b = 2; - [Imperative] - { - c = d = e = 4+1; - } - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT59_Function_With_No_Return_Stmt() - { - string code = @" - def foo : int ( a : int ) - { - b = a + 1; - } - - [Associative] - { - c = foo(1); - } - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT60_Defect_1455590_2() - { - string code = @" -def foo ( a ) -{ - b = c = a ; - return = a + b + c; -} -x = foo ( 3 ); -[Imperative] -{ - y = foo ( 4 ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT60_Function_With_No_Return_Stmt() - { - string code = @" - def foo : int ( a : int ) - { - b = a + 1; - } - - [Imperative] - { - c = foo(1); - } - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT61_TestBooleanOperationOnNull() - { - string code = @" -[Imperative] -{ - a = null; - - b1 = 0; - b2 = 1; - b3 = -1; - - if( a == b1 ) - { - b1 = 10; - } - if ( a < b2 ) - { - b2 = 10; - } - if ( a > b3 ) - { - b3 = 10; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT62_Change_Avariable_To_Dynamic_Array_OnTheFly() - { - string code = @" -def func(a:int) -{ -a=5; -return = a; -} -c=1; -b= func(c[0]); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT62_Condition_Not_Evaluate_ToBool() - { - string code = @" -[Imperative] -{ - A = 1; - if (0) - A = 2; - else - A= 3; -} -//expected A=1;//Received A=3; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT62_Create_Dynamic_Array_OnTheFly() - { - string code = @" -z=[Imperative] -{ -for (i in 0..7) -{ -b[i] = i; -} -return=b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT62_Create_Dynamic_Array_OnTheFly_AsFunctionArgument() - { - string code = @" -def func(a:int) -{ -a=5; -return = a; -} -b= func(c[0]); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT62_Create_Dynamic_Array_OnTheFly_passargument_function() - { - string code = @" - - def test(a:int[]) - { - b=1; - return=b; - } -d[0]=5; -a=test(d); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT62_Defect_1456721() - { - string code = @" -b = true; -a = 2 * b; -c = 3; -b1 = null; -a1 = 2 * b1; -c1 = 3; -a2 = 1 + true; -b2 = 2 * true; -c2 = 3 - true; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT63_Create_MultiDimension_Dynamic_Array_OnTheFly() - { - string code = @" -def func(a:int[]..[]) -{ -a[0][1]=5; -a[2][3]=6; -return = a; -} -c=1; -b= func(c); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - - [Test] - public void DebugEQT63_Dynamic_array_onthefly_1467066() - { - string code = @" -z=[Imperative] -{ -b[5]=0; -for (i in 0..7) -{ -b[i] = i; -} -return=b; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT63_Dynamic_array_onthefly_aliastoanother() - { - string code = @" -a=5; -b=a; -a[2]=3; -b[2]=-5; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT63_Dynamic_array_onthefly_function_1467139() - { - string code = @" -def foo(a:int[]) -{ -} -x[0]=5; -a = foo(x); -c = [100]; -t = x; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT63_Dynamic_array_onthefly_update() - { - string code = @" -z=true; -b=z; -z[0]=[1]; -z=5; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT64_Defect_1450715() - { - string code = @" -[Imperative] -{ - a = [ 1, 0.5, null, [2,3 ] ,[[0.4, 5], true ] ]; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT64_Modify_itemInAnArray_1467093() - { - string code = @" -a = [1, 2, 3]; -a[1] = a; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT64_Modify_itemInAnArray_1467093_2() - { - string code = @" -[Imperative] -{ -a = []; -b = a; -a[0] = b; -//hangs here -c = a; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT65_Array_Alias_ByVal_1467165() - { - string code = @" -a = [0,1,2,3]; -b=a; -a[0]=9; -b[0]=10; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT65_Array_Alias_ByVal_1467165_3() - { - string code = @" -a = [0,1,2,3]; -b=a; -a[0]=9; -b[0]=false; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT65_Array_Alias_ByVal_1467165_6() - { - string code = @" -a = [0,1,2,3]; -b=a; -a[0]=null; -b[0]=false; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT66_Array_CannotBeUsedToIndex1467069() - { - string code = @" -[Imperative] -{ - a = [3,1,2]; - x = [10,11,12,13,14,15]; - x[a] = 2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT66_Array_CannotBeUsedToIndex1467069_2() - { - string code = @" -[Imperative] -{ - a = [3,1,2]; - x = [10,11,12,13,14,15]; - x[a] = 2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT67_Array_Remove_Item() - { - string code = @" -a=[1,2,3,4,5,6,7]; -a=Remove(a,0);// expected :{2,3,4,5,6,7} -a=Remove(a,4);//expected {1,2,3,4,6,7} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT67_Array_Remove_Item_2() - { - string code = @" -a=[1,2,3,4,5,6,7]; -a=Remove(a,0);// expected :{2,3,4,5,6,7} -a=Insert(a,4,6);//expected {1,2,3,4,6,7} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT68_copy_byreference_1467105() - { - string code = @" -[Associative] -{ -a = [ 1, 2, 3]; -b = a; -b[0] = 10; -test = a[0]; //= 10Ö i.e. a change in ëbí causes a change to ëaí -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT74_Function_With_Simple_Replication_Associative() - { - string code = @" -[Associative] -{ - def foo : int ( a : int ) - { - return = a + 1; - } - - x = [ 1, 2, 3 ]; - y = foo(x); - -} - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT75_Function_With_Replication_In_Two_Args() - { - string code = @" -[Associative] -{ - def foo : int ( a : int, b : int ) - { - return = a + b; - } - - x1 = [ 1, 2, 3 ]; - x2 = [ 1, 2, 3 ]; - - y = foo ( x1, x2 ); - -} - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT76_Function_With_Replication_In_One_Arg() - { - string code = @" -[Associative] -{ - def foo : int ( a : int, b : int ) - { - return = a + b; - } - - x1 = [ 1, 2, 3 ]; - x2 = 1; - - y = foo ( x1, x2 ); - -} - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT77_Defect_1460274_Class_Update() - { - string code = @" -b = 1; -a = b + 1; -b = a; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT77_Defect_1460274_Class_Update_4() - { - string code = @" -[Imperative] -{ - a = []; - b = a; - a[0] = b; - c = Count(a); -} -[Associative] -{ - a1 = [0]; - b1 = a1; - a1[0] = b1; - c1 = Count(a1); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT77_Function_With_Simple_Replication_Guide() - { - string code = @" -[Associative] -{ - def foo : int ( a : int, b : int ) - { - return = a + b; - } - - x1 = [ 1, 2 ]; - x2 = [ 1, 2 ]; - y = foo( x1<1> , x2<2> ); - a1 = y[0][0]; - a2 = y[0][1]; - a3 = y[1][0]; - a4 = y[1][1]; - -} - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT78_Function_call_By_Reference() - { - string code = @" -[Associative] -{ - def foo : int ( a : int, b : int ) - { - a = a + b; - b = 2; - return = a + b; - } - - a = 1; - b = 2; - c = foo (a, b ); - d = a + b; - -} - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT80_Function_call_By_Reference() - { - string code = @" -[Associative] -{ - def foo : int ( a : int, b : int ) - { - c = [Imperative] - { - d = 1; - return = d; - } - a = a + c; - b = b + c; - return = a + b; - } - - a = 2; - b = 1; - c = foo (a, b ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT81_Function_Calling_Imp_From_Assoc() - { - string code = @" -[Associative] -{ - def foo : int ( a : int ) - { - c = [Imperative] - { - d = 0; - if( a > 1 ) - { - d = 1; - } - return = d; - } - return = a + c; - } - - a = 2; - b = foo (a ); -} - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT83_Function_With_Null_Arg() - { - string code = @" -def foo:int ( a : int ) -{ - return = a; -} -[Associative] -{ - b = foo( null ); -} - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT87_Function_Returning_From_Imp_Block_Inside_Assoc() - { - string code = @" -def foo : int( a : int) -{ - temp = [Imperative] - { - if ( a == 0 ) - { - return = 0; - } - return = a ; - } - return = temp; -} -x = foo( 0 ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT88_Function_With_Collection_Argument() - { - string code = @" -def foo : double (arr : double[]) -{ - return = 0; -} -arr = [1,2,3,4]; -sum = foo(arr); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT89_Function_With_Replication() - { - string code = @" -def foo : double (arr1 : double[], arr2 : double[] ) -{ - return = arr1[0] + arr2[0]; -} -arr = [ [2.5,3], [1.5,2] ]; -two = foo (arr, arr); -t1 = two[0]; -t2 = two[1]; -//arr1 = {2.5,3}; -//arr2 = {1.5,2}; -//two = foo(arr1, arr2); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT91_Function_With_Default_Arg() - { - string code = @" -def foo:double(x:int = 2, y:double = 5.0) -{ - return = x + y; -} -a = foo(); -b = foo(1, 3.0); -c = foo(); -[Imperative] -{ - d = foo(); - e = foo(1, 3.0); - f = foo(); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQT92_Function_With_Default_Arg_Overload() - { - string code = @" -def foo:double() -{ - return = 0.0; -} -def foo:double(x : int = 1, y : double = 2.0) -{ - return = x + y; -} -a = foo(); -b = foo(3); -c = foo(3.4); // not found, null -d = foo(3, 4.0); -e = foo(1, 2.0, 3); // not found, null -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA01_RangeExpressionWithIntegerIncrement() - { - string code = @" -[Imperative] -{ - a1 = 1..5..2; - a2 = 12.5..20..2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA02_RangeExpressionWithDecimalIncrement() - { - string code = @" -[Imperative] -{ - a1 = 2..9..2.7; - a2 = 10..11.5..0.3; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA03_RangeExpressionWithNegativeIncrement() - { - string code = @" -[Imperative] -{ - a = 10..-1..-2; - b = -2..-10..-1; - c = 10..3..-1.5; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA04_RangeExpressionWithNullIncrement() - { - string code = @" -[Imperative] -{ - a = 1..5..null; - b = 0..6..(null); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA05_RangeExpressionWithBooleanIncrement() - { - string code = @" -[Imperative] -{ - a = 2.5..6..(true); - b = 3..7..false; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA06_RangeExpressionWithIntegerTildeValue() - { - string code = @" -[Imperative] -{ - a = 1..10..~4; - b = -2.5..10..~5; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA07_RangeExpressionWithDecimalTildeValue() - { - string code = @" -[Imperative] -{ - a = 0.2..0.3..~0.2; //divide by zero error - b = 6..13..~1.3; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA08_RangeExpressionWithNegativeTildeValue() - { - string code = @" -[Imperative] -{ - a = 3..1..~-0.5; - b = 18..13..~-1.3; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA09_RangeExpressionWithNullTildeValue() - { - string code = @" -[Imperative] -{ - a = 1..5..~null; - b = 5..2..~(null); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA10_RangeExpressionWithBooleanTildeValue() - { - string code = @" -[Imperative] -{ - a = 1..3..(true); - b = 2..2..false; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA11_RangeExpressionWithIntegerHashValue() - { - string code = @" -[Imperative] -{ - a = 1..3.3..#5; - b = 3..3..#3; - c = 3..3..#1; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA12_RangeExpressionWithDecimalHashValue() - { - string code = @" -[Imperative] -{ - a = 1..7..#2.5; - b = 2..10..#2.4; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA13_RangeExpressionWithNegativeHashValue() - { - string code = @" -[Imperative] -{ - a = 7.5..-2..#-9; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA14_RangeExpressionWithNullHashValue() - { - string code = @" -[Imperative] -{ - a = 2..10..#null; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA15_RangeExpressionWithBooleanHashValue() - { - string code = @" -[Imperative] -{ - b = 12..12..#false; - a = 12..12..#(true); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA16_RangeExpressionWithIncorrectLogic_1() - { - string code = @" -[Imperative] -{ - a = 5..1..2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA17_RangeExpressionWithIncorrectLogic_2() - { - string code = @" -[Imperative] -{ - a = 5.5..10.7..-2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA18_RangeExpressionWithIncorrectLogic_3() - { - string code = @" -[Imperative] -{ - a = 7..7..5; - b = 8..8..~3; - c = 9..9..#1; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA19_RangeExpressionWithIncorrectLogic_4() - { - string code = @" -[Imperative] -{ - a = null..8..2; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQTA21_Defect_1454692() - { - string code = @" -[Imperative] -{ - x = 0; - b = 0..3; //{ 0, 1, 2, 3 } - for( y in b ) - { - x = y + x; - } - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA21_Defect_1454692_2() - { - string code = @" -def length : int (pts : double[]) -{ - numPts = [Imperative] - { - counter = 0; - for(pt in pts) - { - counter = counter + 1; - } - - return = counter; - } - return = numPts; -} - -arr = 0.0..3.0;//{0.0,1.0,2.0,3.0}; -num = length(arr); - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA21_Defect_1454692_4() - { - string code = @" -def foo(i : int[]) -{ - count = 0; - count = [Imperative] - { - for ( x in i ) - { - count = count + 1; - } - return = count; - } - return = count; - -} - -arr = 0.0..3.0;//{0.0,1.0,2.0,3.0}; -[Imperative] -{ - x = 0; - b = 0..3; //{ 0, 1, 2, 3 } - for( y in arr ) - { - x = y + x; - } - x1 = 0..3; - c = foo(x1); - -} - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA22_Range_Expression_floating_point_conversion_1467127() - { - string code = @" -a = 1..6..#10; -b = 0.1..0.6..#10; -c = 0.01..-0.6..#10; -d= -0.1..0.06..#10; - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA22_Range_Expression_floating_point_conversion_1467127_2() - { - string code = @" -a = 0..7..~0.75; -b = 0.1..0.7..~0.075; -c = 0.01..-7..~0.75; -d= -0.1..7..~0.75; -e = 1..-7..~1; - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA23_Defect_1466085_Update_In_Range_Expr() - { - string code = @" -y = 1; -y1 = 0..y; -y = 2; -z1 = y1; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA23_Defect_1466085_Update_In_Range_Expr_2() - { - string code = @" -a = 0; -b = 10; -c = 2; -y1 = a..b..c; -a = 7; -b = 14; -c = 7; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTA23_Defect_1466085_Update_In_Range_Expr_3() - { - string code = @" -def foo ( x : int[] ) -{ - return = Count(x); -} -a = 0; -b = 10; -c = 2; -y1 = a..b..c; -z1 = foo ( y1 ); -z2 = Count( y1 ); -c = 5; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV101_Indexing_IntoArray_InFunctionCall_1463234() - { - string code = @" -def foo() -{ -return = [1,2]; -} -t = foo()[0]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV101_Indexing_IntoNested_FunctionCall_1463234_5() - { - string code = @" - def foo() - { - return = [foo2()[0],foo2()[1]]; - } -def foo2() -{ -return = [1,2]; -} -a=test.test()[0]; -t = foo()[0]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV101_Indexing_Intoemptyarray_InFunctionCall_1463234_3() - { - string code = @" -def foo() -{ -return = []; -} -t = foo()[0]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV101_Indexing_Intosingle_InFunctionCall_1463234_() - { - string code = @" -def foo() -{ -return = [1,2]; -} -t = foo()[0]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV101_Indexing_Intosingle_InFunctionCall_1463234_2() - { - string code = @" -def foo() -{ -return = [1]; -} -t = foo()[0]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV101_Indexing_Intovariablenotarray_InFunctionCall_1463234_4() - { - string code = @" -def foo() -{ -return = 1; -} -t = foo()[0]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV12_Function_With_Argument_Update_Associative() - { - string code = @" -[Associative] -{ - def update:int( a:int, b:int ) - { - a = a + 1; - b = b + 1; - return = a + b; - } - - c = 5; - d = 5; - e = update(c,d); - e = c; - f = d; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV14_Empty_Functions_Associative() - { - string code = @" -[Associative] -{ - def foo:int ( a : int ) - { - } - - b = foo( 1 ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - - [Test] - public void DebugEQTV16_Function_With_No_Return_Statement_DS() - { - string code = @" - def foo : int( a : int ) - { - a = a + 1; - } - [Imperative] - { - b = foo( 1 ); - } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV17_Function_Access_Local_Variables_Outside() - { - string code = @" - def foo: int ( a : int ) - { - b = a + 1; - c = a * 2; - return = a; - } -[Imperative] -{ - d = foo( 1 ); - e = b; - f = c; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV18_Function_Access_Global_Variables_Inside() - { - string code = @" - global = 5; - global2 = 6; - - def foo: int ( a : int ) - { - b = a + global; - c = a * 2 * global2; - return = b + c; - } -[Imperative] -{ - d = foo( 1 ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV19_Function_Modify_Global_Variables_Inside() - { - string code = @" - global = 5; - - def foo: int ( a : int ) - { - global = a + global; - - return = a; - } -[Imperative] -{ - d = foo( 1 ); - e = global; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - - [Test] - public void DebugEQTV23_Defect_1455152() - { - string code = @" -def foo : int ( a : int ) -{ - b = a + 1; -} -[Associative] -{ - c = foo(1); -} -[Imperative] -{ - d = foo(1); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV24_Defect_1454958() - { - string code = @" -def foo: int( a : int , b : int) -{ - return = a + b; -} -[Associative] -{ - b = Foo( 1,2 ); -} -[Imperative] -{ - c = foo( 1 ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV26_Defect_1454923_2() - { - string code = @" -def function1: int ( a : int, b : int ) -{ - return = -1 * (a * b ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV27_Defect_1454688() - { - string code = @" -[Associative] -{ - a = function1(1,2,3); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV28_Defect_1454688_2() - { - string code = @" -[Imperative] -{ - a = function(1,2,3); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV29_Overloading_Different_Number_Of_Parameters() - { - string code = @" -def foo:int ( a : int ) -{ - return = a + 1; -} -def foo:int ( a : int, b : int, c: int ) -{ - return = a + b + c ; -} -c = foo( 1 ); -d = foo( 3, 2, 0 ); -[Imperative] -{ - a = foo( 1, 2, 3 ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV30_Overloading_Different_Parameter_Types() - { - string code = @" -def foo:int ( a : int ) -{ - return = 2 * a; -} -def foo:int ( a : double ) -{ - return = 2; -} - b = foo( 2 ); - c = foo(3.4); -[Imperative] -{ - d = foo(-2.4); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV31_Overloading_Different_Return_Types() - { - string code = @" -def foo: int( a: int ) -{ - return = 1; -} -// This is the same definition regardless of return type -def foo: double( a : int ) -{ - return = 2.3; -} -b = foo ( 1 ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV32_Function_With_Default_Argument_Value() - { - string code = @" -def foo : int ( a = 5, b = 5 ) -{ - return = a + b; -} -[Imperative] -{ - c1 = foo ( ); - c2 = foo ( 1 ); - c3 = foo ( 1, 2 ); - c4 = foo ( 1, 2, 3 ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV32_Function_With_Default_Argument_Value_2() - { - string code = @" -def foo ( a : int = 5, b : double = 5.5, c : bool = true ) -{ - return = c == true ? a : b; -} -def foo ( a : double = 5, b : double = 5.5, c : bool = true ) -{ - return = c == true ? a : b; -} -[Imperative] -{ - c1 = foo ( ); - c2 = foo ( 1 ); - c3 = foo ( 1.5, 2 ); - c4 = foo ( 1, 2, 0 ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV32_Function_With_Default_Argument_Value_3() - { - string code = @" -def foo ( a : int, b : double = 5, c : bool = true) -{ - return = c == true ? a : b; -} -def foo2 ( a , b = 5, c = true) -{ - return = c == true ? a : b; -} -d1 = foo2 ( ); -d2 = foo2 ( 1 ); -d3 = foo2 ( 2, 3 ); -d4 = foo2 ( 4, 5, false ); -d5 = -[Imperative] -{ - c1 = foo ( ); - c2 = foo ( 1 ); - c3 = foo ( 2, 3 ); - c4 = foo ( 4, 5, false ); - return = [ c1, c2, c3, c4 ]; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV33_Function_Overloading() - { - string code = @" -def foo ( a : int = 5, b : double = 5.5, c : bool = true ) -{ - return = c == true ? a : b; -} -def foo ( a : double = 6, b : double = 5.5, c : bool = true ) -{ - return = c == true ? a : b; -} -[Imperative] -{ - c1 = foo ( ); - c2 = foo ( 1 ); - c3 = foo ( 1.5, 2 ); - c4 = foo ( 1, 2, 0 ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV33_Function_Overloading_2() - { - string code = @" -def foo ( a : int , b : double , c : bool ) -{ - return = a; -} -def foo ( a : double, b : double , c : int ) -{ - return = b; -} -[Imperative] -{ - c4 = foo ( 1, 2, 0 ); - c5 = foo ( 1.5, 2.5, 0 ); - c6 = foo ( 1.5, 2.5, true ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV33_Overloading_Different_Order_Of_Parameters() - { - string code = @" -def foo : int ( a :int, b : double ) -{ - return = 2; -} -def foo : int( c : double, d : int ) -{ - return = 3; -} -c = foo( 1,2.5 ); -d = foo ( 2.5, 1 ); -//e = foo ( 2.5, 2.5 ); -f = foo ( 1, 2 ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV35_Implicit_Conversion_Int_To_Double() - { - string code = @" -def foo : double ( a: double ) -{ - return = a + 2.5; -} - b = foo( 2 ); -[Imperative] -{ - c = foo( 3 ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV36_Implicit_Conversion_Return_Type() - { - string code = @" -def foo: bool ( a : double, b : double ) -{ - return = 0.5; -} -c = foo ( 2.3 , 3 ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV37_Overloading_With_Type_Conversion() - { - string code = @" -def foo : int ( a : double, b : double ) -{ - return = 1; -} -def foo : int ( a : int, b : int ) -{ - return = 2; -} -def foo : int ( a : int, b : double ) -{ - return = 3; -} -a = foo ( 1,2 ); -b = foo ( 2,2 ); -c = foo ( 1, 2.3 ); -d = foo ( 2.3, 2 ); - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV40_Defect_1449956_3() - { - string code = @" -[Associative] -{ - def recursion : int( a : int) - { - temp = [Imperative] - { - if ( a ==0 || a < 0) - { - return = 0; - } - return = a + recursion( a - 1 ); - } - return = temp; - } - x = recursion( 4 ); - y = recursion( -1 ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV42_Defect_1454959() - { - string code = @" -def Level1 : int (a : int) -{ - return = Level2(a+1); -} - -def Level2 : int (a : int) -{ - return = a + 1; -} -input = 3; -result = Level1(input); -[Associative] -{ - a = Level1(4); - b = foo (a); - c = [Imperative] - { - return = foo2( foo (a ) ); - } -} -def foo ( a ) -{ - return = a + foo2(a); -} -def foo2 ( a ) -{ - return = a; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV47_Defect_1456087() - { - string code = @" -def foo : int ( a : double, b : double ) -{ - return = 2; -} -def foo : int ( a : int, b : int ) -{ - return = 1; -} -def foo : int ( a : int, b : double ) -{ - return = 3; -} -[Imperative] -{ - a = foo ( 1, 2 ); - b = foo ( 2.5, 2.5 ); - c = foo ( 1, 2.3 ); - d = foo ( 2.3, 2 ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV48_Defect_1456110() - { - string code = @" -def foo : int( a : int) -{ - temp = [Imperative] - { - if ( a == 0 ) - { - return = 0; - } - return = a ; - } - return = temp; -} -x = foo( 0 ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - [Test] - public void DebugEQTV49_Defect_1456110() - { - string code = @" -def recursion : int(a : int) -{ - loc = [Imperative] - { - if (a <= 0) - { - return = 0; - } - return = a + recursion(a - 1); - } - return = loc; -} -a = 10; -[Imperative] -{ - x = recursion(a); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQTV49_Defect_1456110_2() - { - string code = @" -def recursion : int(a : int) -{ - loc = [Imperative] - { - if (a <= 0) - { - return = 0; - } - return = a + recursion(a - 1); - } - return = loc; -} -a = 10; -[Imperative] -{ - x = recursion(a); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV55_Defect_1456571() - { - string code = @" -def foo(arr) -{ - retArr = 3; - [Imperative] - { - retArr = 5; - } - return = retArr; -} - x = 0.5; - x = foo(x); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - - [Test] - public void DebugEQTV58_Defect_1455090() - { - string code = @" - def foo( a:int[] ) - { - a[0][0] = 1; - return = a; - } - b = [ [0,2,3], [4,5,6] ]; - d = foo( b ); - c = d[0]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV59_Defect_1455278_2() - { - string code = @" -def multiply : double[] (a : double[]) -{ - temp = [Imperative] - { - b = [0, 10]; - counter = 0; - - for( y in a ) - { - b[counter] = y * y; - counter = counter + 1; - } - - return = b; - } - return = temp; -} - - x = [2.5,10.0]; - x_squared = multiply( x ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV60_Defect_1455278_2() - { - string code = @" -def multiply : double[] (a : double[]) -{ - temp = [Imperative] - { - b = [0, 10]; - counter = 0; - - for( y in a ) - { - b[counter] = y * y; - counter = counter + 1; - } - - return = b; - } - return = temp; -} - - x = [2.5,10]; - x_squared = multiply( x ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV60_Defect_1455278_3() - { - string code = @" - def power(num : double, exponent : int) - { - temp = [Imperative] - { - result = 1.0; - counter = 0; - while(counter < exponent ) - { - result = result * num; - counter = counter + 1; - } - return = result; - } - return = temp; - } - - x = power(3.0, 2); - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV61_Defect_1455278_3() - { - string code = @" - def power(num : double, exponent : int) - { - temp = [Imperative] - { - result = 1.0; - counter = 0; - while(counter < exponent ) - { - result = result * num; - counter = counter + 1; - } - return = result; - } - return = temp; - } - - x = power(3.0, 2); - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV61_Defect_1455278_4() - { - string code = @" - def power(num : double, exponent : int) - { - temp = [Imperative] - { - result = 1.0; - counter = 0; - if(num > exponent) - { - while(counter < exponent ) - { - result = result * num; - counter = counter + 1; - } - } - return = result; - } - return = temp; - } - - x = power(3.0, 2); - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV62_Defect_1455090() - { - string code = @" - def foo:int[]..[] ( a:int[]..[] ) - { - a[0][0] = 1; - return = a; - } - b = [ [0,2,3], [4,5,6] ]; - d = foo( b ); - c = d[0]; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV63_Defect_1455090_2() - { - string code = @" - def foo ( a : double[]..[] ) - { - a[0][0] = 2.5; - return = a; - } - - a = [ [2.3,3.5],[4.5,5.5] ]; - - a = foo( a ); - c = a[0]; - - [Imperative] - { - b = [ [2.3], [2.5] ]; - b = foo( b ); - d = b[0]; - } - - - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV71_Defect_1456108_2() - { - string code = @" - def collectioninc: int[]( a : int[] ) - { - j = 0; - a = [Imperative] - { - for( i in a ) - { - a[j] = a[j] + 1; - j = j + 1; - } - return = a; - } - return = a; - } - d = [ 1,2,3 ]; - c = collectioninc( d ); - b; - [Imperative] - { - b = collectioninc( d ); - } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV73_Defect_1451831() - { - string code = @" -[Associative] -{ - - a = 1; - b = 1; - - def test:int( a:int, b:int, c : int, d : int ) - { - - y = [Imperative] - { - if( a == b ) - { - return = 1; - } - else - { - return = 0; - } - } - - return = y + c + d; - } - - c = 1; - d = 1; - - y = test ( a , b, c, d); - - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV75_Defect_1456870() - { - string code = @" -def foo1 ( b ) -{ - return = b == 0 ? 0 : b+1; - -} -def foo2 ( x ) -{ - y = [Imperative] - { - if(x > 0) - { - return = x >=foo1(x) ? x : foo1(x); - } - return = x >=2 ? x : 2; - } - x1 = y == 0 ? 0 : y; - return = x1 + y; -} -a1 = foo1(4); -a2 = foo2(3); -//thisTest.Verification(mirror, ""a1"", 5, 0); // fails -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV76_Defect_1456112() - { - string code = @" -def foo1 : double (arr : double[]) -{ - return = 0; -} -arr = [1,2,3,4]; -sum = foo1(arr); -def foo2 : double (arr : double) -{ - return = 0; -} -arr1 = [1.0,2.0,3.0,4.0]; -sum1 = foo2(arr1); -sum2 = foo1(arr); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV76_Defect_1456112_2() - { - string code = @" -def foo1 : double (arr : double[][]) -{ - return = arr[0][0]; -} -[Imperative] -{ - arr1 = [ [1, 2.0], [true, 4] ]; - sum1 = foo1(arr); - x = 1; - arr2 = [ [1, 2.0], [x, 4] ]; - sum2 = foo1(arr2); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV81_Defect_1458187() - { - string code = @" -def foo ( a ) -{ - x = [Imperative] - { - if ( a == 0 ) - return = a; - else - return = a + 1; - } - return = x; -} -a = foo( 2 ); -b = foo(false); -c = foo(true); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV81_Defect_1458187_2() - { - string code = @" -def foo ( a ) -{ - x = (a == 1)?a:0; - return = x + a; -} -a = foo( 2 ); -b = foo(false); -c = foo(true); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV82_Defect_1460892() - { - string code = @" -def foo ( a : int ) -{ - return = a + 1; -} -def foo2 ( b : int, f1 : function ) -{ - return = f1( b ); -} -a = foo2 ( 10, foo ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV83_Function_Pointer() - { - string code = @" -def foo ( a : bool ) -{ - return = a ; -} -def foo2 ( b : int, f1 : function ) -{ - return = f1( b ); -} -a = foo2 ( 0, foo ); -def poo ( a : int ) -{ - return = a ; -} -def poo2 ( b : bool, f1 : function ) -{ - return = f1( b ); -} -a2 = poo2 ( false, poo ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV83_Function_Pointer_Collection() - { - string code = @" -def count ( a : bool[]..[] ) -{ - c = 0; - c = [Imperative] - { - for ( i in a ) - { - c = c + 1; - } - return = c; - } - return = c ; -} -def foo ( b : bool[]..[], f1 : function ) -{ - return = count( b ); -} -a = foo ( [ true, false, [ true, true ] ], count ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV84_Function_Pointer_Implicit_Conversion() - { - string code = @" -def count ( a : int[] ) -{ - c = 0; - x = [Imperative] - { - for ( i in a ) - { - c = c + 1; - } - return = c; - } - return = x ; -} -def foo ( b : double[], f1 : function ) -{ - return = count( b ); -} -a = foo ( [ 1.0, 2.6 ], count ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV84_Function_Pointer_Implicit_Conversion_2() - { - string code = @" -def count ( a : double[]..[] ) -{ - c = 0; - x = [Imperative] - { - for ( i in a ) - { - c = c + 1; - } - return = c; - } - return = x ; -} -def foo ( b : int[]..[], f1 : function ) -{ - return = count( b ); -} -a = foo ( [ 1, 2 , [3, 4] ], count ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV84_Function_Pointer_Implicit_Conversion_3() - { - string code = @" -def count ( a : double[] ) -{ - c = 0; - x = [Imperative] - { - for ( i in a ) - { - c = c + 1; - } - return = c; - } - return = x ; -} -def foo ( b : int[], f1 : function ) -{ - return = count( b ); -} -a = foo ( [ 1, 2, [ 3, 4 ] ], count ); -d = foo ( [ 2, 2.5, [ 1, 1.5 ], 1 , false], count ); -// boolean can't be converted to double, so the following statement -// will generate a method resultion fail exception -// b = foo ( { true, false }, count ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV84_Function_Pointer_Implicit_Conversion_4() - { - string code = @" -def count ( a : double[] ) -{ - c = 0; - x = [Imperative] - { - for ( i in a ) - { - c = c + 1; - } - return = c; - } - return = x ; -} -def foo ( b : int[], f1 : function ) -{ - return = count( b ); -} -[Imperative] -{ - a = foo ( [ 1, 2, [ 3, 4 ] ], count ); - d = foo ( [ 2, 2.5, [ 1, 1.5 ], 1 , false], count ); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV84_Function_Pointer_Negative() - { - string code = @" -def greater ( a , b ) -{ - c = [Imperative] - { - if ( a > b ) - return = a; - else - return = b; - } - return = c ; -} -def greatest ( a : double[], f : function ) -{ - c = a[0]; - [Imperative] - { - for ( i in a ) - { - c = f( i, c ); - } - } - return = c ; -} -[Imperative] -{ - a = greatest ( [ 1.5, 6, 3, -1, 0 ], greater2 ); - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV84_Function_Pointer_Using_2_Functions() - { - string code = @" -def greater ( a , b ) -{ - c = [Imperative] - { - if ( a > b ) - return = a; - else - return = b; - } - return = c ; -} -def greatest ( a : double[], greater : function ) -{ - c = a[0]; - [Imperative] - { - for ( i in a ) - { - c = greater( i, c ); - } - } - return = c ; -} -def foo ( a : double[], greatest : function , greater : function) -{ - return = greatest ( a, greater ); -} -[Imperative] -{ - a = foo ( [ 1.5, 6, 3, -1, 0 ], greatest, greater ); - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV86_Defect_1456728() - { - string code = @" -def f1 (arr : double[] ) -{ - return = arr; -} -def f2 (arr : double[] ) -{ - return = [ arr[0], arr[1] ]; -} -a = f1( [ null, null ] ); -b = f2( [ null, null ] ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV88_Defect_1463489() - { - string code = @" -def foo: bool ( ) -{ - return = 0.24; -} -c = foo ( ); //expected true, received -d = [Imperative] -{ - return = foo(); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV88_Defect_1463489_2() - { - string code = @" -def foo: bool ( x : bool ) -{ - return = x && true; -} -c = foo ( 0.6 ); -c1 = foo ( 0.0 ); -d = [Imperative] -{ - return = foo(-3.5); -} -d1 = [Imperative] -{ - return = foo(0.0); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV89_typeConversion_FunctionArguments_1467060() - { - string code = @" -def foo ( x : double[]) -{ - return = x; -} -a2 = [ 2, 4, 3.5 ]; -b2 = foo (a2); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV89_typeConversion_FunctionArguments_1467060_2() - { - string code = @" -def foo ( x : double[]) -{ - return = x; -} -a2 = [ 2, 4, 3]; -b2 = foo ( a2 ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV89_typeConversion_FunctionArguments_1467060_3() - { - string code = @" -def foo ( x : int[]) -{ - return = x; -} -a1 = [ 2, 4.1, 3.5]; -b1 = foo ( a1 ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV89_typeConversion_FunctionArguments_1467060_4() - { - string code = @" -def foo ( x : int) -{ - return = x; -} -a1 = [ 2, 4.1, false]; -b1 = foo ( a1 ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV89_typeConversion_FunctionArguments_1467060_5() - { - string code = @" -def foo ( x : int[]) -{ - return = x; -} -a1 = [ 2, 4.1, [1,2]]; -b1 = foo ( a1 ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV89_typeConversion_FunctionArguments_1467060_6() - { - string code = @" -def foo ( x : int[]) -{ - return = x; -} -a1 = [ null, 5, 6.0]; -b1 = foo ( a1 ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV89_typeConversion_FunctionArguments_1467060_7() - { - string code = @" -def foo ( x : int[]) -{ - return = x; -} -a1 = [ null, null, null]; -b1 = foo ( a1 ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV89_typeConversion_FunctionArguments_1467060_8() - { - string code = @" -def foo:int[]( x : int[]) -{ - return = x; -} -a1 = [1.1,2.0,3]; -b1 = foo ( a1 ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV89_typeConversion_FunctionArguments_1467060_9() - { - string code = @" -def foo ( x : int[]) -{ - return = x; -} -a1 = [ 1, null, 6.0]; -b1 = foo ( a1 ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV90_Defect_1463474_2() - { - string code = @" -a = 3; -def foo : void ( ) -{ - a = 2; -} -foo(); -b1 = a; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV90_Defect_1463474_3() - { - string code = @" -a = 3; -def foo : void ( ) -{ - a = 2; - return = -3; -} -c1 = foo(); -b1 = a; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV97_Heterogenous_Objects_As_Function_Arguments_With_Replication() - { - string code = @" -def foo ( x : double) -{ - return = x; -} -a1 = [ 2.5, 4 ]; -b1 = foo ( a1 ); -a2 = [ 3, 4, 2.5 ]; -b2 = foo ( a2 ); -a3 = [ 3, 4, 2 ]; -b3 = foo ( a3 ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV98_Method_Overload_Over_Rank_Of_Array() - { - string code = @" -def foo(x : int[]) -{ - return = 1; -} -def foo(x : int[]..[]) -{ - return = 2; -} -def foo(x : int[][]) -{ - return = 0; -} - -x = foo ( [ [ 0,1], [2, 3] ] ); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTV99_Defect_1463456_Array_By_Reference_Issue_2() - { - string code = @" -def A (a: int []) -{ -return = a; -} -val = [1,2,3]; -b = A(val); -b[0] = 100; -t = val[0]; //expected 100, received 1 -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestBasicArrayMethods() - { - string code = @" -a = [ 1, 2, [ 3, 4, 5, [ 6, 7, [ 8, 9, [ [ 11 ] ] ] ] ], [ 12, 13 ] ]; -c = Count(a); -r = Rank(a); -a2 = Flatten(a); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestHostentityType() - { - string code = @" -[Associative] -{ - def factorial_local : hostentityid() - { - return = 11; - } - x = factorial_local(); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestImport() - { - string code = @" -def dc_sqrt : double (val : double ) -{ - return = val/2.0; -} -def dc_factorial : int (val : int ) -{ - return = val * val ; -} -def dc_sin : double (val : double) -{ - return = val + val; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQTestStringConcatenation01__2_() - { - string code = @" -s1='a'; -s2=""bcd""; -s3=s1+s2; -s4=""abc""; -s5='d'; -s6=s4+s5; -s7=""ab""; -s8=""cd""; -s9=s7+s8; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestStringConcatenation01() - { - string code = @" -[Imperative] -{ - s1='a'; - s2=""bcd""; - s3=s1+s2; - s4=""abc""; - s5='d'; - s6=s4+s5; - s7=""ab""; - s8=""cd""; - s9=s7+s8; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestStringOperations() - { - string code = @" -[Imperative] -{ - s = ""ab""; - r1 = s + 3; - r2 = s + false; - r3 = s + null; - r4 = !s; - r5 = s == ""ab""; - r6 = s == s; - r7 = ""ab"" == ""ab""; - ns = s; - ns[0] = 1; - r8 = ns == [1, 'b']; - //r9 = """" == """"; - //r10 = ("""" == null); - r9 = s != ""ab""; - ss = ""abc""; - ss[0] = 'x'; - r10 = """" == null; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTestStringTypeConversion__2_() - { - string code = @" -def foo:bool(x:bool) -{ - return=x; -} -r1 = foo('h'); -r2 = 'h' && true; -r3 = 'h' + 1; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTest_4_10_contains() - { - string code = @" -a = 5; -b = 7; -c = 9; -d = [a, b]; -f = Contains(d, a); // true -g = Contains(d, c); // false -h = Contains([10,11],11); // true collection built ëon the flyí - // with ëliteralí values -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTest_4_11_indexOf() - { - string code = @" -a = 5; -b = 7; -c = 9; -d = [a, b, c]; -f = IndexOf(d, b); // 1 -g = d[f+1]; // c -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTest_4_13_Transpose() - { - string code = @" -a =[[1,2],[3,4]]; -b = a[0][0]; // b = 1 -c = a [0][1]; // c = 2 -a = Transpose(a); // b = 1; c =3 -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTest_4_14_isUniformDepth() - { - string code = @" -myNonUniformDepth2Dcollection = [[1, 2, 3], [4, 5], 6]; -individualMemberB = myNonUniformDepth2Dcollection [0][1]; // OK, = B -individualMemberD = myNonUniformDepth2Dcollection [2][0]; // would fail -individualMemberE = myNonUniformDepth2Dcollection [2]; // OK, = 6 -// Various collection manipulation functions are provided to assist with these issues, one of these functions is: -testDepthUniform = IsUniformDepth(myNonUniformDepth2Dcollection); // = false -testForDeepestDepth = Rank(myNonUniformDepth2Dcollection); // = 2; current limitation : 1 - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQTest_4_9_count() - { - string code = @" -count_test1=Count([1,2]); // 2 .. count of collection -a = [[1,2],3]; // define a nested/ragged collection -count_test2=Count(a); // 2 .. count of collection -count_test3=Count(a[0]); // 2 .. count of sub collection -count_test4=Count(a[0][0]); // 0 .. count of single member -count_test5=Count(a[1]); // 0 .. count of single member -count_test6=Count([]); // 0 .. count of an empty collection -count_test7=Count(3); // 0 .. count of single value -count_test8=Count(null); // 0 .. count of null -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQUse_Keyword_Array_1463672() - { - string code = @" -def Create2DArray( col : int) -{ - result = [Imperative] - { - array = [ 1, 2 ]; - counter = 0; - while( counter < col) - { - array[counter] = [ 1, 2]; - counter = counter + 1; - } - return = array; - } - return = result; -} -x = Create2DArray( 2) ; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQZ001_Associative_Function_Regress_1454696() - { - string code = @" - def Twice : double(array : double[]) - { - return = array[0]; - } - - arr = [1.0,2.0,3.0]; - arr2 = Twice(arr); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQZ001_LanguageBlockScope_Defect_1453539() - { - string code = @" -[Associative] -{ - a = 10; - b = true; - c = 20.1; -} -// [Imperative] -// { -// aI = a; -// bI = a; -// cI = a; -// } -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQZ003_Defect_1456728() - { - string code = @" -def function1 (arr : double[] ) -{ - return = [ arr[0], arr [1] ]; -} -a = function1([null,null]); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQZ017_Defect_1456898_2() - { - string code = @" -def foo ( a : int[] ) -{ - y = [Associative] - { - return = a[0]; - } - x = [Imperative] - { - if ( a[0] == 0 ) - { - return = 0; - } - else - { - return = a[0]; - } - } - return = x + y; -} -[Imperative] -{ - a1 = foo( [ 0, 1 ] ); - b1 = foo( [ 1, 2 ] ); - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQZ021_Defect_1458785_3() - { - string code = @" -def foo ( i:int[]) -{ -return = i; -} -x = 1; -a1 = foo(x); -a2 = 3; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - - - [Test] - public void DebugEQarray__2_() - { - string code = @" -x :int = 0; -y :int = 0; -xSize :int = 2; -ySize :int = 3; -result :int = 0; -somelist : int[] = [11,102,1003,1004]; -somelist2 : int[] = [x, y, xSize * 4, 1004 * ySize]; -// Populate a multi-dimensional array -list2d[2][3]; -list2d[0][0] = 10; -list2d[0][1] = 20; -list2d[0][2] = 30; -list2d[1][0] = 40; -list2d[1][1] = 50; -list2d[1][2] = 60; -// do somthing with those values -[Imperative] -{ - while( x < xSize ) - { - while( y < ySize ) - { - - result = result + list2d[x][y]; - y = y + 1; - } - x = x + 1; - y = 0; - } -} -result = result * 10; -// Populate an array of integers and compute its average -// Populate an array of ints -list[5]; -list[0] = 10; -list[1] = 20; -list[2] = 30; -list[3] = 40; -list[4] = 50; -// Declare counters and result storage -n :int = 0; -size :int = 5; -result = 0; -// Summation of elements in 'list' and storing them in 'result' -[Imperative] -{ - while( n < size ) - { - result = result + list[n]; - n = n + 1; - } -} -// Get the average -result = result / size; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQarray() - { - string code = @" -[Associative] -{ -/* - a = {1001,1002}; - a[0] = 1234; - a[1] = 5678; - x = a[1]; - y = a[0]; - - - b = {101, 102, {103, 104}, 105}; - b[2][1] = 100001; - - c = { - 101, - 102, - {103, 104}, - {{1001, 2002}, 1}, - 5 - }; - c[2][1] = 111111; - c[3][0][1] = 222222; - c[3][0][0] = 333333; - - d = { - {1, 0, 0, 0}, - {0, 1, 0, 0}, - {0, 0, 1, 0}, - {0, 0, 0, 1} - }; - d[0][0] = c[2][1]; - d[1][1] = 2; - d[2][2] = 2; - d[3][3] = x; - */ - e = [10,[20,30]]; - e[1][1] = 40; - dd = e[0]; - dd = e[1][0]; - dd = e[1][1]; - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQarrayargs() - { - string code = @" -[Associative] -{ - //def inc : int( s : int ) - //{ - // return = s + 1; - //} - def scale2 : int( s : int ) - { - i = 2; - return = s * i; - } - a = scale2(20); - //b = scale2(20) + inc(2); - //c = scale2(20) + inc(inc(2)); - //d = scale2(20) + inc(inc(inc(inc(inc(inc(inc(inc(inc(inc(inc(inc(2)))))))))))); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQbasicImport__2_() - { - string code = @" -def Scale (arr : double[], scalingFactor : double) -{ - scaledArr = [Imperative] - { - counter = 0; - for(val in arr) - { - arr[counter] = scalingFactor * val; - counter = counter + 1; - } - return = arr; - } - return = scaledArr; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQbasicImport1() - { - string code = @" -def Scale (arr : double[], scalingFactor : double) -{ - scaledArr = [Imperative] - { - counter = 0; - for(val in arr) - { - arr[counter] = scalingFactor * val; - counter = counter + 1; - } - return = arr; - } - return = scaledArr; -} -a = 1; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQbasicImport3() - { - string code = @" -def Scale (arr : double[], scalingFactor : double) -{ - scaledArr = [Imperative] - { - counter = 0; - for(val in arr) - { - arr[counter] = scalingFactor * val; - counter = counter + 1; - } - return = arr; - } - return = scaledArr * 2; -} -a = 3; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQblockassign_associative() - { - string code = @" -[Associative] -{ - def DoSomthing : int(p : int) - { - ret = p; - d = [Imperative] - { - loc = 20; - return = loc; - } - return = ret * 100 + d; - } - a = DoSomthing(10); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQblockassign_imperative() - { - string code = @" -[Imperative] -{ - d = [Associative] - { - aa = 20; - return = aa; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQbranching() - { - string code = @" -def branchw() -{ - y : int; - y = 0; - [Imperative]{ - while(y < 10) - { - y = y + 2; - } - } -} -def branch1() -{ - x : int; - y : int; - x = 2; - y = 20; - [Imperative] - { - if (x > y) - { - y = 2; - } - } - return = y; -} -def branch2() -{ - x : int; - y : int; - x = 1600; - y = 201; - [Imperative] - { - if( x > 2 ) - { - y = 2; - if (y > 200) - { - y = 200; - } - } - } -} -def branch3() -{ - x : int; - y : int; - x = 64; - y = 20; - - [Imperative] - { - if( x == 4 ) - { - y = 2; - if( y > 200 ) - { - y = 200; - } - } - - elseif( x > 20 ) - { - x = 20000; - } - } -} -def branch4() -{ - x : int; - y : int; - x = 2; - - [Imperative] - { - if( x > 2 ) - { - y = 2; - } - else - { - x = 100; - } - y = 2000; - if( x > 2 ) - { - y = 2; - } - } -} -def branch5 (p : int) -{ - x : int; - y : int; - a = 4000; - x = a; - [Imperative] - { - if ( x > p ) - { - x = 0; - } - elseif( x > a ) - { - x = p; - } - else - { - x = 20; - } - } - x = a; -} -def branch6() -{ - x : int; - y : int; - x = 100; - y = 200; - [Imperative] - { - if( y > 0 ) - { - y = 0; - } - elseif( y > x ) - { - y = 10; - } - elseif( y > 20 ) - { - y = 20; - } - else - { - y = 3000; - if( x > y ) - { - y = 2000; - } - else - { - x = 2000; - } - } - } - y = 40; -} -def branch7(p:int) -{ - x : int; - y : int; - x = 100; - y = 200; - - [Imperative] - { - if( y > 0 ) - { - y = 0; - } - elseif( y > x ) - { - if( x > y ) - { - y = 2000; - } - elseif( y > p ) - { - y = 20; - if( p == y * x ) - { - y = 2000 * 3 / p + 2; - } - } - } - elseif( y > 20 ) - { - y = 20; - } - else - { - y = 3000; - if( x > y ) - { - y = 2000; - } - else - { - x = 2000; - } - } - } - y = 40; -} -def branch55(p:int) -{ - x : int; - a : int; - a = 16; - x = a; - [Imperative] - { - if( x > 64 ) - { - x = 64; - } - elseif( x > 32 ) - { - x = 32; - } - elseif( x > 16 ) - { - x = 16; - } - else - { - x = 12345; - } - } - a = x + p; -} -n : int; -n = branch1(); -n = branch2(); -n = branch3(); -n = branch4(); -n = branch5(100); -n = branch6(); -n = branch7(10); -n = branch55(100); -count : int; -count = 10; -[Imperative] -{ - while(count > 2) - { - count = count - 1; - branchw(); - } -}"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQdemo() - { - string code = @" -[Imperative] -{ - a = 10; - b = 20; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQforloop() - { - string code = @" -[Imperative] -{ - a = [10,20,30,40]; - x = 0; - for (val in a) - { - x = x + val; - } - x = 0; - for (val in [100,200,300,400]) - { - x = x + val; - } - x = 0; - for (val in [[100,101],[200,201],[300,301],[400,401]]) - { - x = x + val[1]; - } - x = 0; - for (val in 10) - { - x = x + val; - } - - y = 0; - b = 11; - for (val in b) - { - y = y + val; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQfunctionoverload() - { - string code = @" -[Associative] -{ - def f : int( p1 : int ) - { - x = p1 * 10; - return = x; - } - def f : int( p1 : int, p2 : int ) - { - return = p1 + p2; - } - a = 2; - b = 20; - i = f(a + 10); - j = f(a, b); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQfusionarray() - { - string code = @" -[Imperative] -{ - x = 0; - y = 0; - xSize = 2; - ySize = 3; - result = 0; - - somelist = [11,102,1003,1004]; - somelist2 = [x, y, xSize * 4, 1004 * ySize]; - // Populate a multi-dimensional array - list2d = [[10,20,30],[40,50,60]]; - // do somthing with those values - while( x < xSize ) - { - while( y < ySize ) - { - result = result + list2d[x][y]; - y = y + 1; - } - x = x + 1; - y = 0; - } - result = result * 10; - - // Populate an array of ints - list = [10, 20, 30, 40, 50]; - - // Declare counters and result storage - n = 0; - size = 5; - result = 0; - - - // Summation of elements in 'list' and storing them in 'result' - while( n < size ) - { - result = result + list[n]; - n = n + 1; - } - // Get the average - result = result / size; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQheader1() - { - string code = @" -// import other module -import (""./include/header2.ds""); -x = 100; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQimport001() - { - string code = @" -def add : int(i : int, j : int) -{ - return = i + j; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQimport002() - { - string code = @" -def mul : int(i : int, j : int) -{ - return = i * j; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQimporttest() - { - string code = @" -import (""./header1.ds""); -import (""./include/header2.ds""); -a = 1; -b = 2; -[Associative] -{ - c = 3; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQmultilang() - { - string code = @" -[Associative] -{ - a = 100; - b = 200; - [Imperative] - { - n = 300; - n = n + 2; - } - c = b + b; -} -[Imperative] -{ - n = 32; - b = 64; - if( n < b ) - { - n = 1; - } - n = n + b; -} -[Associative] -{ - a = 80; - b = 160; - - [Imperative] - { - n = 320; - z = 640; - if( n < z ) - { - n = 1; - } - [Associative] - { - x = 10; - y = 20; - z = x + y * 2; - } - n = 20000; - } - c = b + 2; -} -[Associative] -{ - a = 80; - b = 160; - - [Imperative] - { - n = 320; - z = 640; - if( n < z ) - { - n = 1; - } - [Associative] - { - xx = 1010; - yy = xx + 2; - [Imperative] - { - n = 3200; - z = 6400; - if( n < z ) - { - n = 1000000; - } - [Associative] - { - x = 1111; - y = 2222; - z = x + y * 2; - } - n = 12345; - } - } - n = n + 1; - } - c = b + 2; -} - -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQnesting() - { - string code = @" -[Imperative] -{ - a = 10; - if(a >= 10) - { - x = a * 2; - [Associative] - { - loc = x * a; - } - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQnull() - { - string code = @" -[Associative] -{ - x = 1; - a1 = null; - b1 = a1 + 2; - c1 = 2 + a1 * x; - [Imperative] - { - a = 2; - b = null + 2; - c = b * 3; - } -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQreplication() - { - string code = @" -[Associative] -{ - def sum : int(p1 : int, p2 : int) - { - return = p1 + p2; - } - //a = {1,2,3}; - //b = {4,5,6}; - //c = sum(a<1>, b<2>); - c = sum(5, 2); -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQsimple() - { - string code = @" -[Imperative] -{ - b = 2 + 10.12345; - c = 2 + 10; - d = 2.12 + 10.12345 * 2; - - e = 2.000001 == 2; - f = 2 == 2.000001; - g = 2.000001 == 2.000001; - h = 2.000001 != 2; - i = 2 != 2.000001; - j = 2.000001 != 2.000001; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQsimple2() - { - string code = @" -[Imperative] -{ - a = 2.12 + 100; -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - - [Test] - public void DebugEQtemp() - { - string code = @" -[Associative] -{ - def Level1 : int (a : int) - { - return = Level2(a+1); - } - - def Level2 : int (a : int) - { - return = a + 1; - } - input = 3; - result = Level1(input); - -} -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQtest__2_() - { - string code = @" -def length : int (pts : int[]) -{ - numPts = [Imperative] - { - counter = 0; - for(pt in pts) - { - counter = counter + 1; - } - return = counter; - } - return = numPts; -} -z=length([1,2]); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQtest__4_() - { - string code = @" -a = []; -b = Average(a); -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQtest__5_() - { - string code = @" -a = 1; -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - [Test] - public void DebugEQupdate() - { - string code = @" -/* -a = 1; -b = a; -a = 10; -*/ -/* -a = 1; -a = a + 1; -a = 10; -*/ -/* -a = 1; -a = 10 + 20 * a; -a = 10; -*/ -/* -a = 2; -x = 20; -y = 30; -a = x + y * a; -*/ -/* -a = 2; -x = 20; -y = 30; -a = x * y + a; -*/ -/* -def f : int(p : int) -{ - return = p + 1; -} -a = 10; -b = f(a); -*/ -/* -def doo : int() -{ - d = 12; - return = d; -} -def f : int(p : int) -{ - a = 10; - b = a; - a = p; - return = b; -} -x = 20; -y = f(x); -x = 40; -*/ -/* -a = 10; -b = 20; -c = a < b ? a : b; -*/ -/* -a = 5; -b = ++a; -*/ -"; - DebugTestFx.CompareDebugAndRunResults(code); - } - - } - - [TestFixture, Category("Debugger")] - public class DebugUseCaseTesting - { - [Test] - [Category("Debugger")] - public void DebugEQtest_Copy_and_modiy_collection_1() - { - String src = - @" -a = 0..10; -b = a; -b[2] = 100; // modifying a member of a copy of a collections -c = a; -d = b[0..(Count(b) - 1)..2]; // rnage expression used for indexing into a collection - "; - DebugTestFx.CompareDebugAndRunResults(src); - } - - - [Test] - [Category("Debugger")] - public void DebugEQtest_Simple_numeric_associative_2() - { - String src = - @" -a : int; -b : int; -[Associative] -{ - a = 10; - b = 2 * a; - a = a + 1; -} - "; - DebugTestFx.CompareDebugAndRunResults(src); - } - - [Test] - [Category("Debugger")] - public void DebugEQtest_Simple_numeric_imperative_2() - { - String src = - @" -import(""ProtoGeometry.dll""); -a : int; -b : int; -[Imperative] -{ - a = 10; - b = 2 * a; - a = a + 1; -} - "; - DebugTestFx.CompareDebugAndRunResults(src); - } - - [Test] - [Category("Debugger")] - public void DebugEQtest_2D_array_from_imperative_associative_code_1() - { - String src = - @" -results = [ [ ] ]; -numCycles = 4; -[Imperative] -{ - for(i in(0..(numCycles-1))) - { - s = Print(""i = "" + i); - - [Associative] - { - results[i] = (0..5) * i; - - s = Print(results[i]); - } - } -} - "; - DebugTestFx.CompareDebugAndRunResults(src); - } - - [Test] - [Category("Debugger")] - public void DebugEQtest_2D_array_from_imperative_imperative_code_1() - { - String src = - @" -results = [ [ ] ]; -numCycles = 4; -[Imperative] -{ - for(i in (0..(numCycles))) - { - results[i] = [ ]; - - for(j in(0..(numCycles-1))) - { - results[i][j] = i * j; - - s = Print(results[i][j]); - } - s = Print(results[i]); - } -} -s = Print(results); - "; - DebugTestFx.CompareDebugAndRunResults(src); - } - - [Test] - [Category("Debugger")] - public void DebugEQtest_Set_operation_functions_test_1() - { - String src = - @" -set = [ true, [ false, true ] ]; -allFalseSet = AllFalse(set); -someFalseSet = SomeFalse(set); -someTrueSet = SomeTrue(set); -someNullsSet = SomeNulls(set); -setInsert = Insert(set, null, -1); -allFalseSetInsert = AllFalse(setInsert); -someFalseSetInsert = SomeFalse(setInsert); -someTrueSetInsert = SomeTrue(setInsert); -someNullsSetInsert = SomeNulls(setInsert); -countFalse = CountFalse(setInsert); -countTrue = CountTrue(setInsert); -containsNull = Contains(setInsert, null); -removeSetInsert = Remove(setInsert, 2); -removeNullsSetInsert = RemoveNulls(setInsert); -removeDuplicatesSetInsert = RemoveDuplicates(setInsert); -flattenSetInsert = Flatten(setInsert); -removeDuplicatesSetInsertFalttened = RemoveDuplicates(flattenSetInsert); -removeIfNotSetInsert = RemoveIfNot(flattenSetInsert, ""bool""); // (={})... this looks incorrect -one1Dcollection = [ 3, 1 ]; -other1Dcollection = [ 0, 1, 2, 3, 4 ]; -setDifferenceA = SetDifference(one1Dcollection, other1Dcollection); -setDifferenceB = SetDifference(other1Dcollection, one1Dcollection); -setIntersection = SetIntersection(other1Dcollection, one1Dcollection); -setUnion = SetUnion(other1Dcollection, one1Dcollection); - "; - DebugTestFx.CompareDebugAndRunResults(src); - } - } -} - diff --git a/test/Engine/ProtoTest/DebugTests/RunWatchTestsIncluded.cs b/test/Engine/ProtoTest/DebugTests/RunWatchTestsIncluded.cs deleted file mode 100644 index 4e8fb3ecfc0..00000000000 --- a/test/Engine/ProtoTest/DebugTests/RunWatchTestsIncluded.cs +++ /dev/null @@ -1,16856 +0,0 @@ -using System.Collections.Generic; -using NUnit.Framework; -using ProtoTestFx; -namespace ProtoTest.DebugTests -{ - [TestFixture, Category("WatchFx Tests")] - public class RunWatchTests - { - - string importpath = "..\\..\\..\\test\\Engine\\ProtoTest\\ImportFiles\\"; - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch0_array() - { - Dictionary> map = new Dictionary>(); - string src = @" -[Associative] -{ -/* - a = {1001,1002}; - a[0] = 1234; - a[1] = 5678; - x = a[1]; - y = a[0]; - - - b = {101, 102, {103, 104}, 105}; - b[2][1] = 100001; - - c = { - 101, - 102, - {103, 104}, - {{1001, 2002}, 1}, - 5 - }; - c[2][1] = 111111; - c[3][0][1] = 222222; - c[3][0][0] = 333333; - - d = { - {1, 0, 0, 0}, - {0, 1, 0, 0}, - {0, 0, 1, 0}, - {0, 0, 0, 1} - }; - d[0][0] = c[2][1]; - d[1][1] = 2; - d[2][2] = 2; - d[3][3] = x; - */ - e = [10,[20,30]]; - e[1][1] = 40; - dd = e[0]; - dd = e[1][0]; - dd = e[1][1]; - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1_arrayargs() - { - Dictionary> map = new Dictionary>(); - string src = @" -[Associative] -{ - //def inc : int( s : int ) - //{ - // return = s + 1; - //} - def scale2 : int( s : int ) - { - i = 2; - return = s * i; - } - a = scale2(20); - //b = scale2(20) + inc(2); - //c = scale2(20) + inc(inc(2)); - //d = scale2(20) + inc(inc(inc(inc(inc(inc(inc(inc(inc(inc(inc(inc(2)))))))))))); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch2_blockassign_associative() - { - Dictionary> map = new Dictionary>(); - string src = @" -[Associative] -{ - def DoSomthing : int(p : int) - { - ret = p; - d = [Imperative] - { - loc = 20; - return = loc; - } - return = ret * 100 + d; - } - a = DoSomthing(10); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch3_blockassign_imperative() - { - Dictionary> map = new Dictionary>(); - string src = @"[Imperative] -{ - d = [Associative] - { - aa = 20; - return = aa; - } -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch16_demo() - { - Dictionary> map = new Dictionary>(); - string src = @"[Imperative] -{ - a = 10; - b = 20; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch18_forloop() - { - Dictionary> map = new Dictionary>(); - string src = @" -[Imperative] -{ - a = [10,20,30,40]; - x = 0; - for (val in a) - { - x = x + val; - } - x = 0; - for (val in [100,200,300,400]) - { - x = x + val; - } - x = 0; - for (val in [[100,101],[200,201],[300,301],[400,401]]) - { - x = x + val[1]; - } - x = 0; - for (val in 10) - { - x = x + val; - } - - y = 0; - b = 11; - for (val in b) - { - y = y + val; - } -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch19_functionoverload() - { - Dictionary> map = new Dictionary>(); - string src = @" -[Associative] -{ - def f : int( p1 : int ) - { - x = p1 * 10; - return = x; - } - def f : int( p1 : int, p2 : int ) - { - return = p1 + p2; - } - a = 2; - b = 20; - i = f(a + 10); - j = f(a, b); -} "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch20_fusionarray() - { - Dictionary> map = new Dictionary>(); - string src = @"[Imperative] -{ - x = 0; - y = 0; - xSize = 2; - ySize = 3; - result = 0; - - somelist = [11,102,1003,1004]; - somelist2 = [x, y, xSize * 4, 1004 * ySize]; - // Populate a multi-dimensional array - list2d = [[10,20,30],[40,50,60]]; - // do somthing with those values - while( x < xSize ) - { - while( y < ySize ) - { - result = result + list2d[x][y]; - y = y + 1; - } - x = x + 1; - y = 0; - } - result = result * 10; - - // Populate an array of ints - list = [10, 20, 30, 40, 50]; - - // Declare counters and result storage - n = 0; - size = 5; - result = 0; - - - // Summation of elements in 'list' and storing them in 'result' - while( n < size ) - { - result = result + list[n]; - n = n + 1; - } - // Get the average - result = result / size; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch21_header1() - { - Dictionary> map = new Dictionary>(); - string src = @"// import other module -import (""./include/header2.ds""); -x = 100; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch22_importtest() - { - Dictionary> map = new Dictionary>(); - string src = @"import (""./header1.ds""); -import (""./include/header2.ds""); -a = 1; -b = 2; -[Associative] -{ - c = 3; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch25_libmath() - { - Dictionary> map = new Dictionary>(); - string src = @" -[Associative] -{ - def add : int(p1 : int, p2 : int) - { - return = p1 + p2; - } - - def sub : int(p1 : int, p2 : int) - { - return = p1 - p2; - } - - def mul : int(p1 : int, p2 : int) - { - return = p1 * p2; - } - def div : int(p1 : int, p2 : int) - { - return = p1 / p2; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch26_nesting() - { - Dictionary> map = new Dictionary>(); - string src = @" -[Imperative] -{ - a = 10; - if(a >= 10) - { - x = a * 2; - [Associative] - { - loc = x * a; - } - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch27_null() - { - Dictionary> map = new Dictionary>(); - string src = @" -[Associative] -{ - x = 1; - a1 = null; - b1 = a1 + 2; - c1 = 2 + a1 * x; - [Imperative] - { - a = 2; - b = null + 2; - c = b * 3; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch28_replication() - { - Dictionary> map = new Dictionary>(); - string src = @"[Associative] -{ - def sum : int(p1 : int, p2 : int) - { - return = p1 + p2; - } - //a = {1,2,3}; - //b = {4,5,6}; - //c = sum(a<1>, b<2>); - c = sum(5, 2); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch29_simple() - { - Dictionary> map = new Dictionary>(); - string src = @" -[Imperative] -{ - b = 2 + 10.12345; - c = 2 + 10; - d = 2.12 + 10.12345 * 2; - - e = 2.000001 == 2; - f = 2 == 2.000001; - g = 2.000001 == 2.000001; - h = 2.000001 != 2; - i = 2 != 2.000001; - j = 2.000001 != 2.000001; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch30_simple2() - { - Dictionary> map = new Dictionary>(); - string src = @" -[Imperative] -{ - a = 2.12 + 100; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch32_update() - { - Dictionary> map = new Dictionary>(); - string src = @" -/* -a = 1; -b = a; -a = 10; -*/ -/* -a = 1; -a = a + 1; -a = 10; -*/ -/* -a = 1; -a = 10 + 20 * a; -a = 10; -*/ -/* -a = 2; -x = 20; -y = 30; -a = x + y * a; -*/ -/* -a = 2; -x = 20; -y = 30; -a = x * y + a; -*/ -/* -def f : int(p : int) -{ - return = p + 1; -} -a = 10; -b = f(a); -*/ -/* -def doo : int() -{ - d = 12; - return = d; -} -def f : int(p : int) -{ - a = 10; - b = a; - a = p; - return = b; -} -x = 20; -y = f(x); -x = 40; -*/ -/* -a = 10; -b = 20; -c = a < b ? a : b; -*/ -/* -a = 5; -b = ++a; -*/"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch54_TestBasicArrayMethods() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [ 1, 2, [ 3, 4, 5, [ 6, 7, [ 8, 9, [ [ 11 ] ] ] ] ], [ 12, 13 ] ]; -c = Count(a); -r = Rank(a); -a2 = Flatten(a);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch55_TestStringConcatenation01() - { - Dictionary> map = new Dictionary>(); - string src = @"s1='a'; -s2=""bcd""; -s3=s1+s2; -s4=""abc""; -s5='d'; -s6=s4+s5; -s7=""ab""; -s8=""cd""; -s9=s7+s8;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch57_TestStringTypeConversion() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo:bool(x:bool) -{ - return=x; -} -r1 = foo('h'); -r2 = 'h' && true; -r3 = 'h' + 1;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch58_import001() - { - Dictionary> map = new Dictionary>(); - string src = @"def add : int(i : int, j : int) -{ - return = i + j; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch59_import002() - { - Dictionary> map = new Dictionary>(); - string src = @"def mul : int(i : int, j : int) -{ - return = i * j; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch60_ImportTest001() - { - Dictionary> map = new Dictionary>(); - string src = @"import(""import001.ds""); -import(""import002.ds""); -a = 10; -b = 20; -c = add(a, b); -d = mul(a, b);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch70_TestHostentityType() - { - Dictionary> map = new Dictionary>(); - string src = @"[Associative] -{ - def factorial_local : hostentityid() - { - return = 11; - } - x = factorial_local(); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch75_multilang() - { - Dictionary> map = new Dictionary>(); - string src = @" -[Associative] -{ - a = 100; - b = 200; - [Imperative] - { - n = 300; - n = n + 2; - } - c = b + b; -} -[Imperative] -{ - n = 32; - b = 64; - if( n < b ) - { - n = 1; - } - n = n + b; -} -[Associative] -{ - a = 80; - b = 160; - - [Imperative] - { - n = 320; - z = 640; - if( n < z ) - { - n = 1; - } - [Associative] - { - x = 10; - y = 20; - z = x + y * 2; - } - n = 20000; - } - c = b + 2; -} -[Associative] -{ - a = 80; - b = 160; - - [Imperative] - { - n = 320; - z = 640; - if( n < z ) - { - n = 1; - } - [Associative] - { - xx = 1010; - yy = xx + 2; - [Imperative] - { - n = 3200; - z = 6400; - if( n < z ) - { - n = 1000000; - } - [Associative] - { - x = 1111; - y = 2222; - z = x + y * 2; - } - n = 12345; - } - } - n = n + 1; - } - c = b + 2; -} - -[Associative] -{ - n : int; - x = v; -} -[Imperative] -{ - n : int; - x = v; -} - - -// TODO Jun: Debug this - double update issue -[Associative] -{ - a = 80; - b = 160; - - [Imperative] - { - n = 320; - z = 640; - if( n < z ) - { - n = 1; - } - [Associative] - { - x = 10; - y = 20; - z = x + y * 2; - } - - [Associative] - { - xx = 1000; - yy = 2000; - zz = xx + yy * 2000; - } - n = 20000; - } - c = b + 2; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch82_relational() - { - Dictionary> map = new Dictionary>(); - string src = @" - -n : int; -n = 100 > 10; // 1 -n = 100 < 10; // 0 -n = 100 == 10; // 0 -n = 100 != 10; // 1 -n = 100 >= 10; // 1 -n = 100 <= 10; // 0 -a : int; -b : int; -i : int; -a = 1000; -b = 1000; -i = a > b; // 0 -i = a < b; // 0 -i = a == b; // 1 -i = a != b; // 0 -i = a >= b; // 1 -i = a <= b; // 1 -j : int; -j = n > 100 + 1; -j = n < 100 + 1; -j = n == 100 + 1; -j = n != 100 + 1; -j = n >= 100 + 1; -j = n <= 100 + 1; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch86_TestStringConcatenation01() - { - Dictionary> map = new Dictionary>(); - string src = @"s3;s6;s9; -[Imperative] -{ - s1='a'; - s2=""bcd""; - s3=s1+s2; - s4=""abc""; - s5='d'; - s6=s4+s5; - s7=""ab""; - s8=""cd""; - s9=s7+s8; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch87_TestStringOperations() - { - string defectID = "MAGN-3988 Defects with Expression Interpreter Test Framework"; - Dictionary> map = new Dictionary>(); - string src = @"[Imperative] -{ - s = ""ab""; - r1 = s + 3; - r2 = s + false; - r3 = s + null; - r4 = !s; - r5 = s == ""ab""; - r6 = s == s; - r7 = ""ab"" == ""ab""; - ns = s; - ns[0] = 1; - r8 = ns == [1, 'b']; - //r9 = """" == """"; - //r10 = ("""" == null); - r9 = s != ""ab""; - ss = ""abc""; - ss[0] = 'x'; - r10 = """" == null; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map, defectID: defectID); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch93_header2() - { - Dictionary> map = new Dictionary>(); - string src = @"z = 200; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch95_T01_BasicGlobalFunction() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo:int(x:int) -{ - return = x; -} -a = foo; -b = foo(3); //b=3;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch96_T02_GlobalFunctionWithDefaultArg() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo:double(x:int, y:double = 2.0) -{ - return = x + y; -} -a = foo; -b = foo(3); //b=5.0; -c = foo(2, 4.0); //c = 6.0"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch97_T03_GlobalFunctionInAssocBlk() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -c; -[Associative] -{ - def foo:double(x:int, y:double = 2.0) - { - return = x + y; - } - a = foo; - b = foo(3); //b=5.0; - c = foo(2, 4.0); //c = 6.0 -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch103_T08_FunctionPointerUpdateTest() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo1:int(x:int) -{ - return = x; -} -def foo2:double(x:int, y:double = 2.0) -{ - return = x + y; -} -a = foo1; -b = a(3); -a = foo2;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch104_T09_NegativeTest_Non_FunctionPointer() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo:int(x:int) -{ - return = x; -} -a = 2; -b = a();"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch109_T14_NegativeTest_UsingFunctionNameInNonAssignBinaryExpr() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo:int(x:int) -{ - return = x; -} -a = foo + 2;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch112_T17_PassFunctionPointerAsArg() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo:int(x:int) -{ - return = x; -} -def foo1:int(f:function, x:int) -{ - return = f(x); -} -a = foo1(foo, 2); -b = foo; -c = foo1(b, 3);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch113_T18_FunctionPointerAsReturnVal() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo:int(x:int) -{ - return = x; -} -def foo1:int(f : function, x:int) -{ - return = f(x); -} -def foo2:function() -{ - return = foo; -} -a = foo2(); -b = a(2); -c = foo1(a, 3);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch133_T02_SampleTestUsingCodeFromExternalFile() - { - Dictionary> map = new Dictionary>(); - string src = @"variable; -[Associative] -{ - variable = 5; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch135_T03_TestAssignmentToUndefinedVariables_negative() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Associative] -{ - a = b; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch137_T05_TestRepeatedAssignment() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -[Associative] -{ - b = a = 2; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch138_T05_TestRepeatedAssignment_negative() - { - Dictionary> map = new Dictionary>(); - string src = @"[Associative] -{ - b = a = 2; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch140_T07_TestOutsideBlock() - { - Dictionary> map = new Dictionary>(); - string src = @"b = 2; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch141_T08_TestCyclicReference() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -[Associative] -{ - a = 2; - b = a *3; - a = 6.5; - a = b / 3; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch142_T09_TestInNestedBlock() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -f; -g1; -g3; -d; -c; -e; -[Associative] -{ - a = 4; - b = a + 2; - [Imperative] - { - b = 0; - c = 0; - if ( a == 4 ) - { - b = 4; - } - else - { - c = 5; - } - d = b; - e = c; - g2 = g1; - } - f = a * 2; - g1 = 3; - g3 = g2; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch143_T10_TestInFunctionScope() - { - Dictionary> map = new Dictionary>(); - string src = @"test; -[Associative] -{ - def add:double( n1:int, n2:double ) - { - - return = n1 + n2; - } - test = add(2,2.5); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch146_T13_TestUsingMathAndLogicalExpr() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -f; -[Associative] -{ - a = 3.5; - b = 1.5; - c = a + b; - d = a - c; - e = a * d; - f = a / e; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch147_T14_TestUsingMathAndLogicalExpr() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -f; -c1; -c2; -c3; -[Associative] -{ - a = 3; - b = -4; - c = a + b; - d = a - c; - e = a * d; - f = a / e; - - c1 = 1 && 2; - c2 = 1 && 0; - c3 = null && true; - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch151_T18_TestMethodCallInExpr() - { - Dictionary> map = new Dictionary>(); - string src = @"test0; -test1; -test2; -test3; -test4; -test5; -[Associative] -{ - def mul : double ( n1 : int, n2 : int ) - { - return = n1 * n2; - } - def add : double( n1 : int, n2 : double ) - { - return = n1 + n2; - } - test0 = add (-1 , 7.5 ) ; - test1 = add (mul(1,2), 4.5 ) ; - test2 = add (mul(1,2.5), 4 ) ; - test3 = add (add(1.5,0.5), 4.5 ) ; - test4 = add (1+1, 4.5 ) ; - test5 = add ( add(1,1) + add(1,0.5), 3.0 ) ; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch152_T19_TestAssignmentToCollection() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -[Associative] -{ - a = [[1,2],3.5]; - c = a[1]; - d = a[0][1]; - a[0][1] = 5; - b = a[0][1] + a[1]; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch153_T20_TestInvalidSyntax() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -[Associative] -{ - a = 2;;;;; - b = 3; - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch154_T21_TestAssignmentToBool() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -[Associative] -{ - a = true; - b = false; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch155_T22_TestAssignmentToNegativeNumbers() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -c; -d; -e; -[Associative] -{ - a = -1; - b = -111; - c = -0.1; - d = -1.99; - e = 1.99; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch156_T23_TestUsingMathAndLogicalExpr() - { - Dictionary> map = new Dictionary>(); - string src = @"c1; -c2; -c3; -c4; -[Associative] -{ - a = -3.5; - b = -4; - c1 = a + b; - c2 = a - b; - c3 = a * b; - c4 = a / b; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch157_T24_TestUsingMathematicalExpr() - { - Dictionary> map = new Dictionary>(); - string src = @"c1; -c2; -c3; -c4; -[Associative] -{ - a = 3; - b = 2; - c1 = a + b; - c2 = a - b; - c3 = a * b; - c4 = a / b; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch158_T25_TestUsingMathematicalExpr() - { - Dictionary> map = new Dictionary>(); - string src = @"c1; -c2; -c3; -c4; -[Associative] -{ - a = 3.0; - b = 2; - c1 = a + b; - c2 = a - b; - c3 = a * b; - c4 = a / b; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch160_T26_Negative_TestPropertyAccessOnPrimitive() - { - Dictionary> map = new Dictionary>(); - string src = @"x = 1; -y = x.a; -x1; -y1; -[Imperative] -{ - x1 = 1; - y1 = x1.a; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch164_T31_Defect_1449877() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -d; -e; -[Associative] -{ - a = -1; - b = -2; - c = -3; - c = a * b * c; - d = c * b - a; - e = b + c / a; - f = a * b + c; -} "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch165_T32_Defect_1449877_2() - { - Dictionary> map = new Dictionary>(); - string src = @"d; -[Associative] -{ - def func:int(a:int,b:int) - { - return = b + a; - } - a = 3; - b = -1; - d = func(a,b); -} "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch166_T33_Defect_1450003() - { - Dictionary> map = new Dictionary>(); - string src = @"_a_test; -_b; -_c; -[Associative] -{ - def check:double( _a:double, _b:int ) - { - _c = _a * _b; - return = _c; - } - _a_test = check(2.5,5); - _b = 4.5; - _c = true; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch167_T34_Defect_1450727() - { - Dictionary> map = new Dictionary>(); - string src = @"z; -[Associative] -{ - x = -5.5; - y = -4.2; - - z = x + y; - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch168_T35_Defect_1450727_2() - { - Dictionary> map = new Dictionary>(); - string src = @"z; -[Associative] -{ - def neg_float:double(x:double,y:double) - { - a = x; - b = y; - return = a + b; - } - z = neg_float(-2.3,-5.8); - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch170_T37_TestOperationOnNullAndBool() - { - Dictionary> map = new Dictionary>(); - string src = @"b; -[Associative] -{ - a = true; - b = a + 1; - c = null + 2; - }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch171_T38_Defect_1449928() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -[Associative] -{ - a = 2.3; - b = -6.9; - c = a / b; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch172_T39_Defect_1449704() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Associative] -{ - a = b; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch173_T40_Defect_1450552() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Associative] -{ - a = b; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch174_T41__Defect_1452423() - { - Dictionary> map = new Dictionary>(); - string src = @"d; -[Associative] -{ - b = true; - c = 4.5; - d = c * b; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch177_T44__Defect_1452423_4() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Associative] -{ - y = true; - x = 1 + y; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch178_T45__Defect_1452423_5() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Associative] -{ - a = 4 + true; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch179_T46_TestBooleanOperationOnNull() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -c; -d; -[Imperative] -{ - a = null; - b = a * 2; - c = a && 2; - d = 0; - if ( a && 2 == 0) - { - d = 1; - } - else - { - d = 2; - } - - if( !a ) - { - d = d + 2; - } - else - { - d = d + 1; - } - if( a ) - { - d = d + 3; - } - - - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch183_T50_Defect_1456713() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 2.3; -b = a * 3; -//Expected : b = 6.9; -//Recieved : b = 6.8999999999999995; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch184_T51_Using_Special_Characters_In_Identifiers() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 1; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch186_T53_Collection_Indexing_On_LHS_Using_Function_Call() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo() -{ - return = 0; -} -x = [ 1, 2 ]; -x[foo()] = 3; -y = x; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch188_T55_Associative_assign_If_condition_1467002() - { - Dictionary> map = new Dictionary>(); - string src = @"[Associative] -{ - x = [] == null; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch265_Z017_Defect_1456898_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( a : int[] ) -{ - y = [Associative] - { - return = a[0]; - } - x = [Imperative] - { - if ( a[0] == 0 ) - { - return = 0; - } - else - { - return = a[0]; - } - } - return = x + y; -} -a1; -b1; -[Imperative] -{ - a1 = foo( [ 0, 1 ] ); - b1 = foo( [ 1, 2 ] ); - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch292_T001_Associative_Function_DeclareAfterAssignment() - { - Dictionary> map = new Dictionary>(); - string src = @"[Associative] -{ - a = 1; - b = 10; - - sum = Sum (a, b); - - def Sum : int(a : int, b : int) - { - - return = a + b; - } - - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch293_T001_Associative_Function_Simple() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -sum; -[Associative] -{ - def Sum : int(a : int, b : int) - { - - return = a + b; - } - - a = 1; - b = 10; - - sum = Sum (a, b); - - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch295_T003_Associative_Function_MultilineFunction() - { - Dictionary> map = new Dictionary>(); - string src = @"[Associative] -{ - def Divide : int(a:int, b:int) - { - return = a/b; - } - d = Divide (1,3); - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch296_T004_Associative_Function_SpecifyReturnType() - { - Dictionary> map = new Dictionary>(); - string src = @"d; -[Associative] -{ - def Divide : double (a:int, b:int) - { - return = a/b; - } - d = Divide (1,3); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch297_T005_Associative_Function_SpecifyArgumentType() - { - Dictionary> map = new Dictionary>(); - string src = @"result; -[Associative] -{ - def myFunction : int (a:int, b:int) - { - return = a + b; - } - d1 = 1.12; - d2 = 0.5; - - result = myFunction (d1, d2); - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch298_T006_Associative_Function_PassingNullAsArgument() - { - Dictionary> map = new Dictionary>(); - string src = @"[Associative] -{ - def myFunction : double (a: double, b: double) - { - return = a + b; - } - d1 = null; - d2 = 0.5; - - result = myFunction (d1, d2); - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch299_T007_Associative_Function_NestedFunction() - { - Dictionary> map = new Dictionary>(); - string src = @"result; -[Associative] -{ - def ChildFunction : double (r1 : double) - { - return = r1; - - } - def ParentFunction : double (r1 : double) - { - return = ChildFunction (r1)*2; - } - d1 = 1.05; - - result = ParentFunction (d1); - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch300_T008_Associative_Function_DeclareVariableBeforeFunctionDeclaration() - { - Dictionary> map = new Dictionary>(); - string src = @"sum; -[Associative] -{ - a = 1; - b = 10; - def Sum : int(a : int, b : int) - { - - return = a + b; - } - - sum = Sum (a, b); - - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch301_T009_Associative_Function_DeclareVariableInsideFunction() - { - Dictionary> map = new Dictionary>(); - string src = @"[Associative] -{ - def Foo : int(input : int) - { - multiply = 5; - divide = 10; - - return = [input*multiply, input/divide]; - } - - input = 20; - sum = Foo (input); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch302_T010_Associative_Function_PassAndReturnBooleanValue() - { - Dictionary> map = new Dictionary>(); - string src = @"result1; -result2; -[Associative] -{ - def Foo : bool (input : bool) - { - return = input; - } - - input = false; - result1 = Foo (input); - result2 = Foo (true); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch303_T011_Associative_Function_FunctionWithoutArgument() - { - Dictionary> map = new Dictionary>(); - string src = @"result1; -[Associative] -{ - def Foo1 : int () - { - return = 5; - } - - result1 = Foo1 (); - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch304_T012_Associative_Function_MultipleFunctions() - { - Dictionary> map = new Dictionary>(); - string src = @"result1; -result2; -[Associative] -{ - def Foo1 : int () - { - return = 5; - } - - - def Foo2 : int () - { - return = 6; - } - - - result1 = Foo1 (); - result2 = Foo2 (); - - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch305_T013_Associative_Function_FunctionWithSameName_Negative() - { - Dictionary> map = new Dictionary>(); - string src = @"[Associative] -{ - def Foo1 : int () - { - return = 5; - } - - - - def Foo1 : int () - { - return = 6; - } - - - - result2 = Foo2 (); - - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch307_T015_Associative_Function_UnmatchFunctionArgument_Negative() - { - Dictionary> map = new Dictionary>(); - string src = @"[Associative] -{ - def Foo : int (a : int) - { - return = 5; - } - - result = Foo(1,2); - - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch308_T016_Associative_Function_ModifyArgumentInsideFunctionDoesNotAffectItsValue() - { - Dictionary> map = new Dictionary>(); - string src = @"input; -result; -originalInput; -[Associative] -{ - def Foo : int (a : int) - { - a = a + 1; - return = a; - } - input = 3; - result = Foo(input); - originalInput = input; - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch309_T017_Associative_Function_CallingAFunctionBeforeItsDeclaration() - { - Dictionary> map = new Dictionary>(); - string src = @"input; -result; -[Associative] -{ - def Level1 : int (a : int) - { - return = Level2(a+1); - } - - def Level2 : int (a : int) - { - return = a + 1; - } - input = 3; - result = Level1(input); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch310_temp() - { - Dictionary> map = new Dictionary>(); - string src = @"[Associative] -{ - def Level1 : int (a : int) - { - return = Level2(a+1); - } - - def Level2 : int (a : int) - { - return = a + 1; - } - input = 3; - result = Level1(input); - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch311_Z001_Associative_Function_Regress_1454696() - { - Dictionary> map = new Dictionary>(); - string src = @" def Twice : double(array : double[]) - { - return = array[0]; - } - - arr = [1.0,2.0,3.0]; - arr2 = Twice(arr);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch314_Z003_Defect_1456728() - { - Dictionary> map = new Dictionary>(); - string src = @"def function1 (arr : double[] ) -{ - return = [ arr[0], arr [1] ]; -} -a = function1([null,null]); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch315_T001_Inline_Using_Function_Call() - { - Dictionary> map = new Dictionary>(); - string src = @" - def fo1 : int(a1 : int) - { - return = a1 * a1; - } - a = 10; - b = 20; - - smallest1 = a < b ? a : b; - largest1 = a > b ? a : b; - d = fo1(a); - smallest2 = (fo1(a)) < (fo1(b)) ? (fo1(a)) : (fo1(a)); //100 - largest2 = (fo1(a)) > (fo1(b)) ? (fo1(a)) : (fo1(b)); //400 -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch317_T003_Inline_Using_Collection() - { - Dictionary> map = new Dictionary>(); - string src = @" - Passed = 1; - Failed = 0; - Einstein = 56; - BenBarnes = 90; - BenGoh = 5; - Rameshwar = 80; - Jun = 68; - Roham = 50; - Smartness = [ BenBarnes, BenGoh, Jun, Rameshwar, Roham ]; // { 1, 0, 1, 1, 0 } - Results = Smartness > Einstein ? Passed : Failed; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch319_T005_Inline_Using_2_Collections_In_Condition() - { - Dictionary> map = new Dictionary>(); - string src = @" - a1 = 1..3..1; - b1 = 4..6..1; - a2 = 1..3..1; - b2 = 4..7..1; - a3 = 1..4..1; - b3 = 4..6..1; - c1 = a1 > b1 ? true : false; // { false, false, false } - c2 = a2 > b2 ? true : false; // { false, false, false } - c3 = a3 > b3 ? true : false; // { false, false, false, null } -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch320_T006_Inline_Using_Different_Sized_1_Dim_Collections() - { - Dictionary> map = new Dictionary>(); - string src = @" - a = 10 ; - b = ((a - a / 2 * 2) > 0)? a : a+1 ; //11 - c = 5; - d = ((c - c / 2 * 2) > 0)? c : c+1 ; //5 - e1 = ((b>(d-b+d))) ? d : (d+1); //5 - //inline conditional, returning different sized collections - c1 = [1,2,3]; - c2 = [1,2]; - a1 = [1, 2, 3, 4]; - b1 = a1>3?true:a1; // expected : {1, 2, 3, true} - b2 = a1>3?true:c1; // expected : {1, 2, 3} - b3 = a1>3?c1:c2; // expected : {1, 2} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch321_T007_Inline_Using_Collections_And_ReplicationCollectionFunctionCall() - { - Dictionary> map = new Dictionary>(); - string src = @" - def even : int(a : int) - { - return = a * 2; - } - a =1..10..1 ; //{1,2,3,4,5,6,7,8,9,10} - i = 1..5; - b = ((a[i] % 2) > 0)? even(a[i]) : a ; // { 1, 6, 3, 10, 5 } - c = ((a[0] % 2) > 0)? even(a[i]) : a ; // { 4, 6, 8, 10, 12 } - d = ((a[-2] % 2) == 0)? even(a[i]) : a ; // { 1, 2,..10} - e1 = (a[-2] == d[9])? 9 : a[1..2]; // { 2, 3 } -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch322_T008_Inline_Returing_Different_Ranks() - { - Dictionary> map = new Dictionary>(); - string src = @" - a = [ 0, 1, 2, 4]; - x = a > 1 ? 0 : [1,1]; // { 1, 1} ? - x_0 = x[0]; - x_1 = x[1]; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch323_T009_Inline_Using_Function_Call_And_Collection_And_Replication() - { - Dictionary> map = new Dictionary>(); - string src = @" - def even(a : int) - { - return = a * 2; - } - def odd(a : int ) - { - return = a* 2 + 1; - } - x = 1..3; - a = ((even(5) > odd(3)))? even(5) : even(3); //10 - b = ((even(x) > odd(x+1)))?odd(x+1):even(x) ; // {2,4,6} - c = odd(even(3)); // 13 - d = ((a > c))?even(odd(c)) : odd(even(c)); //53 -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch324_T010_Defect_1456751_execution_on_both_true_and_false_path_issue() - { - Dictionary> map = new Dictionary>(); - string src = @" -a = 0; -def foo ( ) -{ - a = a + 1; - return = a; -} -x = 1 > 2 ? foo() + 1 : foo() + 2; - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch325_T010_Defect_1456751_replication_issue() - { - Dictionary> map = new Dictionary>(); - string src = @"xx; -x1; -x2; -x3; -x4; -[Imperative] -{ - a = [ 0, 1, 2]; - b = [ 3, 11 ]; - c = 5; - d = [ 6, 7, 8, 9]; - e = [ 10 ]; - xx = 1 < a ? a : 5; // expected:5 - yy = 0; - if( 1 < a ) - yy = a; - else - yy = 5; - x1 = a < 5 ? b : 5; // expected:5 - t1 = x1[0]; - t2 = x1[1]; - c1 = 0; - for (i in x1) - { - c1 = c1 + 1; - } - x2 = 5 > b ? b : 5; // expected:f - t3 = x2[0]; - t4 = x2[1]; - c2 = 0; - for (i in x2) - { - c2 = c2 + 1; - } - x3 = b < d ? b : e; // expected: {10} - t5 = x3[0]; - c3 = 0; - for (i in x3) - { - c3 = c3 + 1; - } - x4 = b > e ? d : [ 0, 1]; // expected {0,1} - t7 = x4[0]; - c4 = 0; - for (i in x4) - { - c4 = c4 + 1; - } -} -/* -Expected : -result1 = { 5, 5, 2 }; -thisTest.Verification(mirror, ""xx"", result1, 1); -thisTest.Verification(mirror, ""t1"", 3, 1); -thisTest.Verification(mirror, ""t2"", 11, 1); -thisTest.Verification(mirror, ""c1"", 2, 1); -thisTest.Verification(mirror, ""t3"", 3, 1); -thisTest.Verification(mirror, ""t4"", 5, 1); -thisTest.Verification(mirror, ""c2"", 2, 1); -thisTest.Verification(mirror, ""t5"", 3, 1); -thisTest.Verification(mirror, ""c3"", 1, 1); -thisTest.Verification(mirror, ""t7"", 0, 1); -thisTest.Verification(mirror, ""c4"", 1, 1);*/"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch326_T011_Defect_1467281_conditionals() - { - Dictionary> map = new Dictionary>(); - string src = @" x = 2 == [ ]; - y = []==null; - z = [[1]]==[1]; - z2 = [[1]]==1; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch328_T01_Arithmatic_List_And_List_Different_Length() - { - Dictionary> map = new Dictionary>(); - string src = @"list1 = [ 1, 4, 7, 2]; -list2 = [ 5, 8, 3, 6, 7, 9 ]; -list3 = list1 + list2; // { 6, 12, 10, 8 } -list4 = list1 - list2; // { -4, -4, 4, -4} -list5 = list1 * list2; // { 5, 32, 21, 12 } -list6 = list2 / list1; // { 5, 2, 0, 3 }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch329_T02_Arithmatic_List_And_List_Same_Length() - { - Dictionary> map = new Dictionary>(); - string src = @"list1 = [ 1, 4, 7, 2]; -list2 = [ 5, 8, 3, 6 ]; -list3 = list1 + list2; // { 6, 12, 10, 8 } -list4 = list1 - list2; // { -4, -4, 4, -4} -list5 = list1 * list2; // { 5, 32, 21, 12 } -list6 = list2 / list1; // { 5, 2, 0, 3 } -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch330_T03_Arithmatic_Mixed() - { - Dictionary> map = new Dictionary>(); - string src = @"list1 = [ 13, 23, 42, 65, 23 ]; -list2 = [ 12, 8, 45, 64 ]; -list3 = 3 * 6 + 3 * (list1 + 10) - list2 + list1 * list2 / 3 + list1 / list2; // { 128, 172, 759, 1566 }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch331_T04_Arithmatic_Single_List_And_Integer() - { - Dictionary> map = new Dictionary>(); - string src = @"list1 = [ 1, 2, 3, 4, 5 ]; -a = 5; -list2 = a + list1; // { 6, 7, 8, 9, 10 } -list3 = list1 + a; // { 6, 7, 8, 9, 10 } -list4 = a - list1; // { 4, 3, 2, 1, 0 } -list5 = list1 - a; // { -4, -3, -2, -1, 0 } -list6 = a * list1; // { 5, 10, 15, 20, 25 } -list7 = list1 * a; // { 5, 10, 15, 20, 25 } -list8 = a / list1; -list9 = list1 / a; "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch332_T05_Logic_List_And_List_Different_Value() - { - Dictionary> map = new Dictionary>(); - string src = @"list1 = [ 1, 8, 10, 4, 7 ]; -list2 = [ 2, 6, 10, 3, 5, 20 ]; -list3 = list1 > list2; // { false, true, false, true, true } -list4 = list1 < list2; // { true, false, false, false, false } -list5 = list1 >= list2; // { false, true, true, true, true } -list6 = list1 <= list2; // { true, false, true, false, false } -list9 = [ true, false, true ]; -list7 = list9 && list5; // { false, false, true } -list8 = list9 || list6; // { true, false, true }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch333_T06_Logic_List_And_List_Same_Length() - { - Dictionary> map = new Dictionary>(); - string src = @"list1 = [ 1, 8, 10, 4, 7 ]; -list2 = [ 2, 6, 10, 3, 5 ]; -list3 = list1 > list2; // { false, true, false, true, true } -list4 = list1 < list2; // { true, false, false, false, false } -list5 = list1 >= list2; // { false, true, true, true, true } -list6 = list1 <= list2; // { true, false, true, false, false } -list7 = list3 && list5; // { false, true, false, true, true } -list8 = list4 || list6; // { true, false, true, false, false } -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch334_T07_Logic_Mixed() - { - Dictionary> map = new Dictionary>(); - string src = @"list1 = [ 1, 5, 8, 3, 6 ]; -list2 = [ 4, 1, 6, 3 ]; -list3 = (list1 > 1) && (list2 > list1) || (list2 < 5); // { true, true, false , true }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch335_T08_Logic_Single_List_And_Value() - { - Dictionary> map = new Dictionary>(); - string src = @"list1 = [ 1, 2, 3, 4, 5 ]; -a = 3; -list2 = a > list1; // { true, true, false, false, false } -list3 = list1 > a; // { false, false, false, true, true } -list4 = a >= list1; // { true, true, true, false, false } -list5 = list1 >= a; // { false, false, true, true, true } -list6 = a < list1; // { false, false, false, true, true } -list7 = list1 < a; // { true, true, false, false, false } -list8 = a <= list1; // { false, false, true, true, true } -list9 = list1 <= a; // { true, true, true, false, false } -list10 = list2 && true; // { true, true, false, false, false } -list11 = false && list2; // { false, false, false, false, false } -list12 = list2 || true; // { true, true, true, true, true } -list13 = false || list2; // { true, true, false, false, false }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch336_T09_Replication_On_Operators_In_Range_Expr() - { - Dictionary> map = new Dictionary>(); - string src = @"[Imperative] -{ - z5 = 4..1; // { 4, 3, 2, 1 } - z2 = 1..8; // { 1, 2, 3, ... , 6, 7, 8 } - z6 = z5 - z2 + 0.3; // { 3.3, 1.3, -1.7, -2.7 } -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch369_T41_Pass_3x3_List_And_2x4_List() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : int(a : int, b : int) -{ - return = a * b; -} -list1 = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]; -list2 = [ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ]; -list3 = foo(list1, list2); // { { 1, 4, 9 }, { 20, 30, 42 } } -x = list3[0]; -y = list3[1];"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch370_T42_Pass_3_List_Different_Length() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : int(a : int, b : int, c : int) -{ - return = a * b - c; -} -list1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; -list2 = [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3 ]; -list3 = [1, 4, 7, 2, 5, 8, 3 ]; -list4 = foo(list1, list2, list3); // { 9, 14, 17, 26, 25, 22, 25 }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch371_T43_Pass_3_List_Different_Length_2_Integers() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : int(a : int, b : int, c : int, d : int, e : int) -{ - return = a * b - c / d + e; -} -list1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; -list2 = [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3 ]; -list3 = [1, 4, 7, 2, 5, 8, 3 ]; -list4 = foo(list1, list2, list3, 4, 23);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch372_T44_Pass_3_List_Same_Length() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : int(a : int, b : int, c : int) -{ - return = a * b - c; -} -list1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; -list2 = [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ]; -list3 = [1, 4, 7, 2, 5, 8, 3, 6, 9, 0 ]; -list4 = foo(list1, list2, list3); // { 9, 14, 17, 26, 25, 22, 25, 18, 9, 10 }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch373_T45_Pass_3_List_Same_Length_2_Integers() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : int(a : int, b : int, c : int, d : int, e : int) -{ - return = a * b - c * d + e; -} -list1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; -list2 = [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ]; -list3 = [1, 4, 7, 2, 5, 8, 3, 6, 9, 0 ]; -list4 = foo(list1, list2, list3, 26, 43); // { 27, -43, -115, 19, -57, -135, -7, -89, -173, 53 } "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch374_T46_Pass_FunctionCall_Reutrn_List() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : int(a : int) -{ - return = a * a; -} -list1 = [ 1, 2, 3, 4, 5 ]; -list3 = foo(foo(foo(list1))); // { 1, 256, 6561, 65536, 390625 }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch375_T47_Pass_Single_3x3_List() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : int(a : int) -{ - return = a * a; -} -list1 = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]; -list2 = foo(list1); // { { 1, 4, 9 }, { 16, 25, 36 }, { 49, 64, 81 } } -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch376_T48_Pass_Single_List() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : int(num : int) -{ - return = num * num; -} -list1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; -list2 = foo(list1); // { 1, 4, 9, 16, 25, 36, 49, 64, 81, 100 }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch377_T49_Pass_Single_List_2_Integers() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : int(num : int, num2 : int, num3 : int) -{ - return = num * num2 - num3; -} -list1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; -list2 = foo(list1, 34, 18); // { 16, 50, 84, 118, 152, 186, 220, 254, 288, 322 }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch380_T50_1_of_3_Exprs_is_List() - { - Dictionary> map = new Dictionary>(); - string src = @"list1 = [ true, false, true, false, true ]; -list2 = list1 ? 1 : 0; // { 1, 0, 1, 0, 1 } -list3 = true ? 10 : list2; // { 10, 10, 10, 10, 10 } -list4 = false ? 10 : list2; // { 1, 0, 1, 0, 1 } -a = [ 1, 2, 3, 4, 5 ]; -b = [5, 4, 3, 2, 1 ]; -c = [ 4, 3, 2, 1 ]; -list5 = a > b ? 1 : 0; // { 0, 0, 0, 1, 1 } -list6 = c > a ? 1 : 0; // { 1, 1, 0, 0 }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch381_T51_2_of_3_Exprs_are_Lists_Different_Length() - { - Dictionary> map = new Dictionary>(); - string src = @"list1 = [ 1, 2, 3, 4, 5 ]; -list2 = [ true, false, true, false ]; -list3 = list2 ? list1 : 0; // { 1, 0, 3, 0 } -list4 = list2 ? 0 : list1; // { 0, 2, 0, 4 } -list5 = [ -1, -2, -3, -4, -5, -6 ]; -list6 = true ? list1 : list5; // { 1, 2, 3, 4, 5 } -list7 = false ? list1 : list5; // { -1, -2, -3, -4, -5 } -a = [ 1, 2, 3, 4 ]; -b = [ 5, 4, 3, 2, 1 ]; -c = [ 1, 4, 7 ]; -list8 = a >= b ? a + c : 10; // { 10, 10, 10 } -list9 = a < b ? 10 : a + c; // { 10, 10, 10 }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch382_T52_2_of_3_Exprs_are_Lists_Same_Length() - { - Dictionary> map = new Dictionary>(); - string src = @"list1 = [ 1, 2, 3, 4, 5 ]; -list2 = [ true, false, true, false, true ]; -list3 = list2 ? list1 : 0; // { 1, 0, 3, 0, 5 } -list4 = list2 ? 0 : list1; // { 0, 2, 0, 4, 0 } -list5 = true ? list3 : list4; // { 1, 0, 3, 0, 5 } -list6 = true ? list4 : list3; // {0, 2, 0, 4, 0 } -a = [ 1, 2, 3, 4, 5 ]; -b = [ 5, 4, 3, 2 ]; -list7 = a > b ? a + b : 10; // { 10, 10, 10, 6 } -list8 = a <= b ? 10 : a + b; // { 10, 10, 10, 6 }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch383_T53_3_of_3_Exprs_are_different_dimension_list() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; -b = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]; -c = [ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ], [ 9, 10, 11, 12 ] ]; -list = a > b ? b + c : a + c; // { { 2, 4, }, { 8, 10 } } "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch384_T54_3_of_3_Exprs_are_Lists_Different_Length() - { - Dictionary> map = new Dictionary>(); - string src = @"list1 = [ true, false, true, true, false ]; -list2 = [ 1, 2, 3, 4 ]; -list3 = [ -1, -2, -3, -4, -5, -6 ]; -list4 = list1 ? list2 : list3; // { 1, -2, 3, 4 } -list5 = !list1 ? list2 : list4; // { 1, 2, 3, 4 } -list6 = [ -1, -2, -3, -4, -5 ]; -list7 = list1 ? list2 : list6; // { 1, -2, 3, 4 } -a = [ 3, 0, -1 ]; -b = [ 2, 1, 0, 3 ]; -c = [ -2, 4, 1, 2, 0 ]; -list8 = a < c ? b + c : a + c; // { 1, 4, 1 }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch385_T55_3_of_3_Exprs_are_Lists_Same_Length() - { - Dictionary> map = new Dictionary>(); - string src = @"list1 = [ true, false, false, true ]; -list2 = [ 1, 2, 3, 4 ]; -list3 = [ -1, -2, -3, -4 ]; -list4 = list1 ? list2 : list3; // { 1, -2, -3, 4 } -list5 = !list1 ? list2 : list3; // { -1, 2, 3, -4 } -a = [ 1, 4, 7 ]; -b = [ 2, 8, 5 ]; -c = [ 6, 9, 3 ]; -list6 = a > b ? b + c : b - c; // { -4, -1, 8 }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch386_T56_UnaryOperator() - { - Dictionary> map = new Dictionary>(); - string src = @"list1 = [ true, true, false, false, true, false ]; -list2 = !list1; // { false, false, true, true, false, true } -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch387_T001_Simple_Update() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 1; -b = a + 1; -a = 2;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch388_T002_Update_Collection() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 0..4..1; -b = a; -c = b[2]; -a = 10..14..1; -b[2] = b[2] + 1; -a[2] = a[2] + 1;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch389_T003_Update_In_Function_Call() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo1 ( a : int ) -{ - return = a + 1; -} -def foo2 ( a : int[] ) -{ - a[0] = a[1] + 1; - return = a; -} -def foo3 ( a : int[] ) -{ - b = a; - b[0] = b[1] + 1; - return = b; -} -a = 0..4..1; -b = a[0]; -c = foo1(b); -d = foo2(a); -e1 = foo3(a); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch390_T004_Update_In_Function_Call_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo1 ( a : int ) -{ - return = a + 1; -} -def foo3 ( a : int[] ) -{ - b = a; - b[0] = b[1] + 1; - return = b; -} -a = 0..4..1; -b = a[0]; -c = foo1(b); -e1 = foo3(a); -a = 10..14..1; -a[1] = a[1] + 1;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch391_T005_Update_In_collection() - { - Dictionary> map = new Dictionary>(); - string src = @"a=1; -b=2; -c=4; -collection = [a,b,c]; -collection[1] = collection[1] + 0.5; -d = collection[1]; -d = d + 0.1; // updates the result of accessing the collection -b = b + 0.1; // updates the source member of the collection"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch395_T009_Update_Of_Undefined_Variables() - { - Dictionary> map = new Dictionary>(); - string src = @"u1 = u2; -u2 = 3; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch396_T010_Update_Of_Singleton_To_Collection() - { - Dictionary> map = new Dictionary>(); - string src = @"s1 = 3; -s2 = s1 -1; -s1 = [ 3, 4 ] ;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch397_T011_Update_Of_Variable_To_Null() - { - Dictionary> map = new Dictionary>(); - string src = @"x = 1; -y = 2/x; -x = 0; -v1 = 2; -v2 = v1 * 3; -v1 = null;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch398_T012_Update_Of_Variables_To_Bool() - { - Dictionary> map = new Dictionary>(); - string src = @"p1 = 1; -p2 = p1 * 2; -p1 = false; -q1 = -3.5; -q2 = q1 * 2; -q1 = true; -s1 = 1.0; -s2 = s1 * 2; -s1 = false; -t1 = -1; -t2 = t1 * 2; -t1 = true; -r1 = 1; -r2 = r1 * 2; -r1 = true; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch406_T019_Update_General() - { - Dictionary> map = new Dictionary>(); - string src = @"X = 1; -Y = X + 1; -X = X + 1; -X = X + 1; -//Y = X + 1; -//X = X + 1; -test = X + Y; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch423_T024_Defect_1459470() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 0..4..1; -b = a; -c = b[2]; -a = 10..14..1; -b[2] = b[2] + 1; -a[2] = a[2] + 1; -x = a; - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch425_T024_Defect_1459470_3() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo () -{ - a = 0..4..1; - b = a; - c = b[2]; - a = 10..14..1; - b[2] = b[2] + 1; - a[2] = a[2] + 1; - return = true; - -} -a :int[]; -b : int[]; -c : int; -test = foo(); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch426_T024_Defect_1459470_4() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [1,2,3,4]; -b = a; -c = b[2]; -d = a[2]; -a[0..1] = [1, 2]; -b[2..3] = 5; - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch427_T025_Defect_1459704() - { - Dictionary> map = new Dictionary>(); - string src = @"a = b; -b = 3; -c = a; - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch435_T029_Defect_1460139_Update_In_Class() - { - Dictionary> map = new Dictionary>(); - string src = @"X = 1; -Y = X + 1; -X = X + 1; -X = X + 1; // this line causing the problem -test = X + Y; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch438_T031_Defect_1467491_ImportUpdate_Main() - { - Dictionary> map = new Dictionary>(); - string src = @"import(""T031_Defect_1467491_ImportUpdate_Sub.ds""); -t = 5; -z = a.x; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch462_T022_Array_Marshal() - { - Dictionary> map = new Dictionary>(); - string src = @"import (Dummy from ""FFITarget.dll""); -dummy = Dummy.Dummy(); -arr = [0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0]; -sum_1_10 = dummy.SumAll1D(arr); -twice_arr = dummy.Twice(arr); - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch465_T02_SampleTestUsingCodeFromExternalFile() - { - Dictionary> map = new Dictionary>(); - string src = @"variable; -[Imperative] -{ - variable = 5; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch466_T03_TestAssignmentToUndefinedVariables_negative() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Imperative] -{ - a = b; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch468_T05_TestRepeatedAssignment_negative() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -[Imperative] -{ - b = a = 2; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch470_T07_TestOutsideBlock() - { - Dictionary> map = new Dictionary>(); - string src = @"b = 2; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch471_T08_TestCyclicReference() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -[Imperative] -{ - a = 2; - b = a *3; - a = 6.5; - a = b / 3; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch472_T09_TestInNestedBlock() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -f; -g1; -g3; -d; -c; -e; -[Imperative] -{ - a = 4; - b = a + 2; - [Associative] - { - [Imperative] - { - b = 0; - c = 0; - if ( a == 4 ) - { - b = 4; - } - else - { - c = 5; - } - d = b; - e = c; - g2 = g1; - } - } - f = a * 2; - g1 = 3; - g3 = g2; - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch475_T12_TestUsingMathAndLogicalExpr() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -c; -d; -e; -[Imperative] -{ - e = 0; - a = 1 + 2; - b = 0.1 + 1.9; - b = a + b; - c = b - a - 1; - d = a + b -c; - if( c < a ) - { - e = 1; - } - else - { - e = 2; - } - if( c < a || b > d) - { - e = 3; - } - else - { - e = 4; - } - if( c < a && b > d) - { - e = 3; - } - else - { - e = 4; - } -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch476_T13_TestUsingMathAndLogicalExpr() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -[Imperative] -{ - a = 3.5; - b = 1.5; - b = a + b; - b = a - b; - b = a * b; - b = a / b; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch477_T14_TestUsingMathAndLogicalExpr() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -f; -c1; -c2; -c3; -[Imperative] -{ - a = 3; - b = -4; - b = a + b; - b = a - b; - b = a * b; - b = a / b; - - c1 = 1 && 2; - c2 = 1 && 0; - c3 = null && true; - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch482_T19_TestAssignmentToCollection() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -[Imperative] -{ - a = [[1,2],3.5]; - c = a[1]; - d = a[0][1]; - a[0][1] = 5; - b = a[0][1] + a[1]; - a = 2; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch483_T20_TestInvalidSyntax() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -[Imperative] -{ - a = 2;;;;; - b = 3; - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch484_T21_TestAssignmentToBool() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -[Imperative] -{ - a = true; - b = false; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch485_T22_TestAssignmentToNegativeNumbers() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -c; -d; -e; -[Imperative] -{ - a = -1; - b = -111; - c = -0.1; - d = -1.99; - e = 1.99; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch486_T23_TestUsingMathAndLogicalExpr() - { - Dictionary> map = new Dictionary>(); - string src = @"c1; -c2; -c3; -c4; -[Imperative] -{ - a = -3.5; - b = -4; - c1 = a + b; - c2 = a - b; - c3 = a * b; - c4 = a / b; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch487_T24_TestUsingMathematicalExpr() - { - Dictionary> map = new Dictionary>(); - string src = @"c1; -c2; -c3; -c4; -[Imperative] -{ - a = 3; - b = 2; - c1 = a + b; - c2 = a - b; - c3 = a * b; - c4 = a / b; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch488_T25_TestUsingMathematicalExpr() - { - Dictionary> map = new Dictionary>(); - string src = @"c1; -c2; -c3; -c4; -[Imperative] -{ - a = 3.0; - b = 2; - c1 = a + b; - c2 = a - b; - c3 = a * b; - c4 = a / b; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch493_T31_Defect_1449877() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -d; -e; -[Imperative] -{ - a = -1; - b = -2; - c = -3; - c = a * b * c; - d = c * b - a; - e = b + c / a; - f = a * b + c; -} "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch496_T34_Defect_1450727() - { - Dictionary> map = new Dictionary>(); - string src = @"z; -[Imperative] -{ - x = -5.5; - y = -4.2; - - z = x + y; - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch498_T36_Defect_1450555() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -[Imperative] -{ - a = true; - b = 2; - c = 2; - - if( a ) - b = false; - - if( b==0 ) - c = 1; - }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch499_T37_TestOperationOnNullAndBool() - { - Dictionary> map = new Dictionary>(); - string src = @"b; -[Imperative] -{ - a = true; - b = a + 1; - c = null + 2; - }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch500_T38_Defect_1449928() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -[Imperative] -{ - a = 2.3; - b = -6.9; - c = a / b; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch501_T39_Defect_1449704() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Imperative] -{ - a = b; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch502_T40_Defect_1450552() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Imperative] -{ - a = b; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch503_T41__Defect_1452423() - { - Dictionary> map = new Dictionary>(); - string src = @"d; -[Imperative] -{ - b = true; - c = 4.5; - d = c * b; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch504_T42__Defect_1452423_2() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - a = [ -2,3,4.5,true ]; - x = 1; - for ( y in a ) - { - x = x *y; //incorrect result - } - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch505_T43__Defect_1452423_3() - { - Dictionary> map = new Dictionary>(); - string src = @"b; -[Imperative] -{ - a = 0; - while ( a == false ) - { - a = 1; - } - - b = a; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch506_T44__Defect_1452423_4() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - y = true; - x = 1 + y; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch507_T45__Defect_1452423_5() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Imperative] -{ - a = 4 + true; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch508_T46_TestBooleanOperationOnNull() - { - Dictionary> map = new Dictionary>(); - string src = @"[Imperative] -{ - a = null; - b = a * 2; - c = a && 2; - d = 0; - if ( a && 2 == 0) - { - d = 1; - } - else - { - d = 2; - } - - if( !a ) - { - d = d + 2; - } - if( a ) - { - d = d + 1; - } - - - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch509_T47_TestBooleanOperationOnNull() - { - Dictionary> map = new Dictionary>(); - string src = @"d; -[Imperative] -{ - a = false; - b = 0; - d = 0; - if( a == null) - { - d = d + 1; - } - if( b == null) - { - d = d + 1; - } -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch511_T49_TestForStringObjectType() - { - Dictionary> map = new Dictionary>(); - string src = @"b; -[Associative] -{ - def foo : string (x : string ) - { - return = x; - } - a = ""sarmistha""; - b = foo ( a ); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch513_T51_Assignment_Using_Negative_Index() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [ 0, 1, 2, 3 ]; -c1 = a [-1]; -c2 = a [-2]; -c3 = a [-3]; -c4 = a [-4]; -c5 = a [-5]; -c6 = a [-1.5]; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch514_T52_Defect_1449889() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -c; -d; -[Imperative] -{ - a = b; - c = foo(); - d = 1; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch521_T59_Defect_1455590() - { - Dictionary> map = new Dictionary>(); - string src = @" - a = b = 2; -c;d;e; - [Imperative] - { - c = d = e = 4+1; - } - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch522_T60_Defect_1455590_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( a ) -{ - b = c = a ; - return = a + b + c; -} -x = foo ( 3 ); -y; -[Imperative] -{ - y = foo ( 4 ); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch523_T61_TestBooleanOperationOnNull() - { - Dictionary> map = new Dictionary>(); - string src = @"b1; -b2; -b3; -[Imperative] -{ - a = null; - - b1 = 0; - b2 = 1; - b3 = -1; - - if( a == b1 ) - { - b1 = 10; - } - if ( a < b2 ) - { - b2 = 10; - } - if ( a > b3 ) - { - b3 = 10; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch524_T62_Defect_1456721() - { - Dictionary> map = new Dictionary>(); - string src = @"b = true; -a = 2 * b; -c = 3; -b1 = null; -a1 = 2 * b1; -c1 = 3; -a2 = 1 + true; -b2 = 2 * true; -c2 = 3 - true; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch526_T64_Defect_1450715() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Imperative] -{ - a = [ 1, 0.5, null, [2,3 ] ,[[0.4, 5], true ] ]; - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch528_T02_TestAssocInsideImp() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -y; -z; -w; -f; -[Imperative] -{ - x = 5.1; - z = y; - w = z * 2; - [Associative] - { - y = 5; - z = x; - x = 35; - i = 3; - } - f = i; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch529_T03_TestImpInsideAssoc() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -y; -z; -w; -f; -[Associative] -{ - x = 5.1; - z = y; - w = z * 2; - [Imperative] - { - y = 5; - z = x; - x = 35; - i = 3; - } - f = i; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch535_T09_Defect_1449829() - { - Dictionary> map = new Dictionary>(); - string src = @"b; -[Associative] -{ - a = 2; -[Imperative] -{ - b = 1; - if(a == 2 ) - { - b = 2; - } - else - { - b = 4; - } -} -} - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch539_T13_Defect_1450527() - { - Dictionary> map = new Dictionary>(); - string src = @"temp; -[Associative] -{ - a = 1; - temp=0; - [Imperative] - { - i = 0; - if(i <= a) - { - temp = temp + 1; - } - } - a = 2; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch541_T15_Defect_1452044() - { - Dictionary> map = new Dictionary>(); - string src = @"b; -[Associative] -{ - a = 2; - [Imperative] - { - b = 2 * a; - } - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch542_T16__Defect_1452588() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - a = [ 1,2,3,4,5 ]; - for( y in a ) - { - x = 5; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch543_T17__Defect_1452588_2() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -[Imperative] -{ - a = 1; - - if( a == 1 ) - { - if( a + 1 == 2) - b = 2; - } - - c = a; - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch546_T01_WhileBreakContinue() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -y; -[Imperative] -{ - x = 0; - y = 0; - while (true) - { - x = x + 1; - if (x > 10) - break; - - if ((x == 1) || (x == 3) || (x == 5) || (x == 7) || (x == 9)) - continue; - - y = y + 1; - } -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch547_T02_WhileBreakContinue() - { - Dictionary> map = new Dictionary>(); - string src = @"sum; -[Imperative] -{ - x = 0; - sum = 0; - while (x <= 10) - { - x = x + 1; - if (x >= 5) - break; - - y = 0; - while (true) - { - y = y + 1; - if (y >= 10) - break; - } - // y == 10 - sum = sum + y; - } - // sum == 40 -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch548_T03_ForLoopBreakContinue() - { - Dictionary> map = new Dictionary>(); - string src = @"sum; -[Imperative] -{ - sum = 0; - for (x in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) - { - if (x >= 11) - break; - sum = sum + x; - } -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch549_T04_ForLoopBreakContinue() - { - Dictionary> map = new Dictionary>(); - string src = @"sum; -[Imperative] -{ - sum = 0; - for (x in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) - { - sum = sum + x; - if (x <= 5) - continue; - sum = sum + 1; - } -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch555_T05_TestForLoopInsideNestedBlocks() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Associative] -{ - a = [ 4, 5 ]; - [Imperative] - { - x = 0; - b = [ 2,3 ]; - for( y in b ) - { - x = y + x; - } - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch556_T06_TestInsideNestedBlocksUsingCollectionFromAssociativeBlock() - { - Dictionary> map = new Dictionary>(); - string src = @"b; -[Associative] -{ - a = [ 4,5 ]; - b =[Imperative] - { - - x = 0; - for( y in a ) - { - x = x + y; - } - return = x; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch557_T07_TestForLoopUsingLocalVariable() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - a = [ 1, 2, 3, 4, 5 ]; - x = 0; - for( y in a ) - { - local_var = y + x; - x = local_var + y; - } - z = local_var; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch559_T09_TestForLoopWithBreakStatement() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - a = [ 1,2,3 ]; - x = 0; - for( i in a ) - { - x = x + 1; - break; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch560_T10_TestNestedForLoops() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - a = [ 1,2,3 ]; - x = 0; - for ( i in a ) - { - for ( j in a ) - { - x = x + j; - } - } -} "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch561_T11_TestForLoopWithSingleton() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - a = [1]; - b = 1; - x = 0; - - for ( y in a ) - { - x = x + 1; - } - - for ( y in b ) - { - x = x + 1; - } -} "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch562_T12_TestForLoopWith2DCollection() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -z; -[Imperative] -{ - a = [[1],[2,3],[4,5,6]]; - x = 0; - i = 0; - for (y in a) - { - x = x + y[i]; - i = i + 1; - } - z = 0; - for (i1 in a) - { - for(j1 in i1) - { - z = z + j1; - } - } - - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch563_T13_TestForLoopWithNegativeAndDecimalCollection() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -y; -[Imperative] -{ - a = [ -1,-3,-5 ]; - b = [ 2.5,3.5,4.2 ]; - x = 0; - y = 0; - for ( i in a ) - { - x = x + i; - } - - for ( i in b ) - { - y = y + i; - } - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch564_T14_TestForLoopWithBooleanCollection() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - a = [ true, false, true, true ]; - x = false; - - for( i in a ) - { - x = x + i; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch565_T15_TestForLoopWithMixedCollection() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -y; -[Imperative] -{ - a = [ -2, 3, 4.5 ]; - x = 1; - for ( y in a ) - { - x = x * y; - } - - a = [ -2, 3, 4.5, true ]; - y = 1; - for ( i in a ) - { - y = i * y; - } - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch566_T16_TestForLoopInsideIfElseStatement() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Imperative] -{ - a = 1; - b = [ 2,3,4 ]; - if( a == 1 ) - { - for( y in b ) - { - a = a + y; - } - } - - else if( a !=1) - { - for( y in b ) - { - a = a + 1; - } - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch567_T17_TestForLoopInsideNestedIfElseStatement() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Imperative] -{ - a = 1; - b = [ 2,3,4 ]; - c = 1; - if( a == 1 ) - { - if(c ==1) - { - for( y in b ) - { - a = a + y; - } - } - } - - else if( a !=1) - { - for( y in b ) - { - a = a + 1; - } - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch568_T18_TestForLoopInsideWhileStatement() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - a = 1; - b = [ 1,1,1 ]; - x = 0; - - if( a == 1 ) - { - while( a <= 5 ) - { - for( i in b ) - { - x = x + 1; - } - a = a + 1; - } - } -} - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch569_T19_TestForLoopInsideNestedWhileStatement() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - i = 1; - a = [1,2,3,4,5]; - x = 0; - - while( i <= 5 ) - { - j = 1; - while( j <= 5 ) - { - for( y in a ) - { - x = x + 1; - } - j = j + 1; - } - i = i + 1; - } -} - - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch570_T20_TestForLoopWithoutBracket() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - a = [ 1, 2, 3 ]; - x = 0; - - for( y in a ) - x = y; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch571_T21_TestIfElseStatementInsideForLoop() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - a = [ 1,2,3,4,5 ]; - x = 0; - - for ( i in a ) - { - if( i >=4 ) - x = x + 3; - - else if ( i ==1 ) - x = x + 2; - - else - x = x + 1; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch572_T22_TestWhileStatementInsideForLoop() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - a = [ 1,2,3 ]; - x = 0; - - for( y in a ) - { - i = 1; - while( i <= 5 ) - { - j = 1; - while( j <= 5 ) - { - x = x + 1; - j = j + 1; - } - i = i + 1; - } - } -} - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch573_T23_TestForLoopWithDummyCollection() - { - Dictionary> map = new Dictionary>(); - string src = @"a1; -a2; -a3; -a4; -a5; -a6; -[Imperative] -{ - a = [0, 0, 0, 0, 0, 0]; - b = [5, 4, 3, 2, 1, 0, -1, -2]; - i = 5; - for( x in b ) - { - if(i >= 0) - { - a[i] = x; - i = i - 1; - } - } - a1 = a[0]; - a2 = a[1]; - a3 = a[2]; - a4 = a[3]; - a5 = a[4]; - a6 = a[5]; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch574_T24_TestForLoopToModifyCollection() - { - Dictionary> map = new Dictionary>(); - string src = @"a6; -a7; -[Imperative] -{ - a = [1,2,3,4,5,6,7]; - i = 0; - for( x in a ) - { - - a[i] = a[i] + 1; - i = i + 1; - - } - a1 = a[0]; - a2 = a[1]; - a3 = a[2]; - a4 = a[3]; - a5 = a[4]; - a6 = a[5]; - a7 = a[6]; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch575_T25_TestForLoopEmptyCollection() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - a = []; - x = 0; - for( i in a ) - { - x = x + 1; - } - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch576_T26_TestForLoopOnNullObject() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - x = 0; - - for ( i in b ) - { - x = x + 1; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch578_T28_Defect_1452966() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - a = [ 1,2,3 ]; - x = 0; - for ( i in a ) - { - for ( j in a ) - { - x = x + j; - } - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch579_T29_Defect_1452966_2() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - a = [[6],[5,4],[3,2,1]]; - x = 0; - - for ( i in a ) - { - for ( j in i ) - { - x = x + j; - } - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch580_T30_ForLoopNull() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - a = [ 1,null,null ]; - x = 1; - - for( i in a ) - { - x = x + 1; - } -} - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch583_T33_ForLoopToReplaceReplicationGuides() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [ 1, 2 ]; -b = [ 3, 4 ]; -//c = a<1> + b <2>; -dummyArray = [ [ 0, 0 ], [ 0, 0 ] ]; -counter1 = 0; -counter2 = 0; -[Imperative] -{ - for ( i in a ) - { - counter2 = 0; - - for ( j in b ) - { - dummyArray[ counter1 ][ counter2 ] = i + j; - - counter2 = counter2 + 1; - } - counter1 = counter1 + 1; - } - -} -a1 = dummyArray[0][0]; -a2 = dummyArray[0][1]; -a3 = dummyArray[1][0]; -a4 = dummyArray[1][1];"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch584_T34_Defect_1452966() - { - Dictionary> map = new Dictionary>(); - string src = @"sum; -[Imperative] -{ - a = [ 1, 2, 3, 4 ]; - sum = 0; - - for(i in a ) - { - for ( i in a ) - { - sum = sum + i; - } - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch585_T35_Defect_1452966_2() - { - Dictionary> map = new Dictionary>(); - string src = @"sum; -[Imperative] -{ - a = [ [1, 2, 3], [4], [5,6] ]; - sum = 0; - - for(i in a ) - { - for ( j in i ) - { - sum = sum + j; - } - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch586_T36_Defect_1452966_3() - { - Dictionary> map = new Dictionary>(); - string src = @"b; -[Associative] -{ - a = [ [1, 2, 3], [4], [5,6] ]; - - def forloop :int ( a: int[]..[] ) - { - sum = 0; - sum = [Imperative] - { - for(i in a ) - { - for ( j in i ) - { - sum = sum + j; - } - } - return = sum; - } - return = sum; - } - - b =forloop(a); - - - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch587_T37_Defect_1454517() - { - Dictionary> map = new Dictionary>(); - string src = @" a = [ 4,5 ]; - - b =[Imperative] - { - x = 0; - for( y in a ) - { - x = x + y; - } - - return = x; - } - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch588_T38_Defect_1454517_2() - { - Dictionary> map = new Dictionary>(); - string src = @" a = [ 4,5 ]; - x = 0; - - [Imperative] - { - x = 0; - for( y in a ) - { - x = x + y; - } - }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch589_T38_Defect_1454517_3() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( a : int [] ) -{ - x = 0; - x = [Imperative] - { - for( y in a ) - { - x = x + y; - } - return =x; - } - return = x; -} -a = [ 4,5 ]; -b; -[Imperative] -{ - b = foo(a); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch590_T39_Defect_1452951() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Associative] -{ - a = [ 4,5 ]; - - [Imperative] - { - //a = { 4,5 }; // works fine - x = 0; - for( y in a ) - { - x = x + y; - } - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch594_T40_Create_3_Dim_Collection_Using_For_Loop() - { - Dictionary> map = new Dictionary>(); - string src = @"x = [ [ [ 0, 0] , [ 0, 0] ], [ [ 0, 0 ], [ 0, 0] ]]; -a = [ 0, 1 ]; -b = [ 2, 3]; -c = [ 4, 5 ]; -y = [Imperative] -{ - c1 = 0; - for ( i in a) - { - c2 = 0; - for ( j in b ) - { - c3 = 0; - for ( k in c ) - { - x[c1][c2][c3] = i + j + k; - c3 = c3 + 1; - } - c2 = c2+ 1; - } - c1 = c1 + 1; - } - - return = x; - -} -p1 = y[0][0][0]; -p2 = y[0][0][1]; -p3 = y[0][1][0]; -p4 = y[0][1][1]; -p5 = y[1][0][0]; -p6 = y[1][0][1]; -p7 = y[1][1][0]; -p8 = y[1][1][1]; -p9 = x [1][1][1];"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch595_T41_Create_3_Dim_Collection_Using_For_Loop_In_Func_Call() - { - Dictionary> map = new Dictionary>(); - string src = @" -def foo :int[]..[]( a : int[], b:int[], c :int[]) -{ - y = [Imperative] - { - x = [ [ [ 0, 0] , [ 0, 0] ], [ [ 0, 0 ], [ 0, 0] ]]; - c1 = 0; - for ( i in a) - { - c2 = 0; - for ( j in b ) - { - c3 = 0; - for ( k in c ) - { - x[c1][c2][c3] = i + j + k; - c3 = c3 + 1; - } - c2 = c2+ 1; - } - c1 = c1 + 1; - } - return = x; - } - return = y; -} -a = [ 0, 1 ]; -b = [ 2, 3]; -c = [ 4, 5 ]; -y = foo ( a, b, c ); -p1 = y[0][0][0]; -p2 = y[0][0][1]; -p3 = y[0][1][0]; -p4 = y[0][1][1]; -p5 = y[1][0][0]; -p6 = y[1][0][1]; -p7 = y[1][1][0]; -p8 = y[1][1][1]; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch600_T44_Use_Bracket_Around_Range_Expr_In_For_Loop() - { - Dictionary> map = new Dictionary>(); - string src = @"s; -[Imperative] { -s = 0; -for (i in (0..10)) { - s = s + i; -} -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch602_T01_TestAllPassCondition() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -y; -z; -[Imperative] -{ - a1 = 2 ; - a2 = -1; - a3 = 101; - a4 = 0; - - b1 = 1.0; - b2 = 0.0; - b3 = 0.1; - b4 = -101.99; - b5 = 10.0009; - - c1 = [ 0, 1, 2, 3]; - c2 = [ 1, 0.2]; - c3 = [ 0, 1.4, true ]; - c4 = [[0,1], [2,3 ] ]; - - x = [0, 0, 0, 0]; - if(a1 == 2 ) // pass condition - { - x[0] = 1; - } - if(a2 <= -1 ) // pass condition - { - x[1] = 1; - } - if(a3 >= 101 ) // pass condition - { - x[2] = 1; - } - if(a4 == 0 ) // pass condition - { - x[3] = 1; - } - - - y = [0, 0, 0, 0, 0]; - if(b1 == 1.0 ) // pass condition - { - y[0] = 1; - } - if(b2 <= 0.0 ) // pass condition - { - y[1] = 1; - } - if(b3 >= 0.1 ) // pass condition - { - y[2] = 1; - } - if(b4 == -101.99 ) // pass condition - { - y[3] = 1; - } - if(b5 == 10.0009 ) // pass condition - { - y[4] = 1; - } - - - z = [0, 0, 0, 0]; - if(c1[0] == 0 ) // pass condition - { - z[0] = 1; - } - if(c2[1] <= 0.2 ) // pass condition - { - z[1] = 1; - } - if(c3[2] == true ) // pass condition - { - z[2] = 1; - } - if(c4[0][0] == 0 ) // pass condition - { - z[3] = 1; - } - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch603_T02_IfElseIf() - { - Dictionary> map = new Dictionary>(); - string src = @"temp1; -[Imperative] -{ - a1 = 7.5; - - temp1 = 10; - - if( a1>=10 ) - { - temp1 = temp1 + 1; - } - - elseif( a1<2 ) - { - temp1 = temp1 + 2; - } - elseif(a1<10) - { - temp1 = temp1 + 3; - } - - - }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch604_T03_MultipleIfStatement() - { - Dictionary> map = new Dictionary>(); - string src = @"temp; -[Imperative] -{ - a=1; - b=2; - temp=1; - - if(a==1) - {temp=temp+1;} - - if(b==2) //this if statement is ignored - {temp=4;} - - }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch605_T04_IfStatementExpressions() - { - Dictionary> map = new Dictionary>(); - string src = @"temp1; -[Imperative] -{ - a=1; - b=2; - temp1=1; - if((a/b)==0) - { - temp1=0; - if((a*b)==2) - { temp1=2; - } - } -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch608_T07_ScopeVariableInBlocks() - { - Dictionary> map = new Dictionary>(); - string src = @"temp; -a; -[Imperative] -{ - a = 4; - b = a*2; - temp = 0; - if(b==8) - { - i=0; - temp=1; - if(i<=a) - { - temp=temp+1; - } - } - a = temp; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch609_T08_NestedBlocks() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -temp; -[Associative] -{ - a = 4; - - [Imperative] - { - i=10; - temp=1; - if(i>=-2) - { - temp=2; - } - } - b=2*a; - a=2; - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch610_T09_NestedIfElseInsideWhileStatement() - { - Dictionary> map = new Dictionary>(); - string src = @"temp; -[Imperative] -{ - i=0; - temp=0; - while(i<=5) - { - i=i+1; - if(i<=3) - { - temp=temp+1; - } - elseif(i==4) - { - temp = temp+1; - if(temp==i) - { - temp=temp+1; - } - } - else - { - if (i==5) - { temp=temp+1; - } - } - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch611_T10_TypeConversion() - { - Dictionary> map = new Dictionary>(); - string src = @"temp; -[Imperative] -{ - temp = 0; - a=4.0; - if(a==4) - temp=1; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch614_T13_IfElseIf() - { - Dictionary> map = new Dictionary>(); - string src = @"temp1; -[Imperative] -{ - a1 = -7.5; - - temp1 = 10.5; - - if( a1>=10.5 ) - { - temp1 = temp1 + 1; - } - - elseif( a1<2 ) - { - temp1 = temp1 + 2; - } - - - }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch615_T14_IfElseStatementExpressions() - { - Dictionary> map = new Dictionary>(); - string src = @"temp1; -[Imperative] -{ - a=1; - b=2; - temp1=1; - if((a/b)==1) - { - temp1=0; - } - elseif ((a*b)==2) - { temp1=2; - } - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch616_T15_TestEmptyIfStmt() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -[Imperative] -{ - a = 0; - b = 1; - if(a == b); - else a = 1; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch617_T16_TestIfConditionWithNegation_Negative() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -[Imperative] -{ - a = 3; - b = -3; - if ( a == !b ) - { - a = 4; - } - -} - - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch618_T17_WhileInsideElse() - { - Dictionary> map = new Dictionary>(); - string src = @"i; -[Imperative] -{ - i=1; - a=3; - temp=0; - if(a==4) - { - i = 4; - } - else - { - while(i<=4) - { - if(i>10) - temp=4; - else - i=i+1; - } - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch619_T18_WhileInsideIf() - { - Dictionary> map = new Dictionary>(); - string src = @"i; -[Imperative] -{ - i=1; - a=3; - temp=0; - if(a==3) //when the if statement is removed, while loop works fine, otherwise runs only once - { - while(i<=4) - { - if(i>10) - temp=4; - else - i=i+1; - } - } -} - - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch620_T19_BasicIfElseTestingWithNumbers() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -c; -d; -[Imperative] -{ - a = 0; - b = 0; - c = 0; - d = 0; - if(1) - { - a = 1; - } - else - { - a = 2; - } - - - if(0) - { - b = 1; - } - else - { - b = 2; - } - - if(0) - { - c = 1; - } - elseif(1) - { - c = 3; - } - - if(0) - { - d = 1; - } - elseif(0) - { - d = 2; - } - else - { - d = 4; - } - -} - - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch621_T20_BasicIfElseTestingWithNumbers() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -c; -d; -e; -f; -[Imperative] -{ - a = 0; - b = 0; - c = 0; - d = 0; - e = 0; - f = 0; - if(1.5) - { - a = 1; - } - else - { - a = 2; - } - - - if(-1) - { - b = 1; - } - else - { - b = 2; - } - - if(0) - { - c = 1; - } - elseif(20) - { - c = 3; - } - - if(0) - { - d = 1; - } - elseif(0) - { - d = 2; - } - else - { - d = 4; - } - - if(true) - { - e = 5; - } - - if(false) - { - f = 1; - } - else - { - f = 6; - } - -} - - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch622_T21_IfElseWithArray_negative() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -[Imperative] -{ - a = [ 0, 4, 2, 3 ]; - b = 1; - c = 0; - if(a > b) - { - c = 0; - } - else - { - c = 1; - } -} - - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch623_T22_IfElseWithArrayElements() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -[Imperative] -{ - a = [ 0, 4, 2, 3 ]; - b = 1; - c = 0; - if(a[0] > b) - { - c = 0; - } - elseif( b < a[1] ) - { - c = 1; - } -} - - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch627_T26_IfElseWithNegatedCondition() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -[Imperative] -{ - a = 1; - b = 1; - c = 0; - if( !(a == b) ) - { - c = 1; - } - else - { - c = 2; - } - -} - - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch636_T35_IfElseWithEmptyBody() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -[Imperative] -{ - c = 0; - if(0) - { - - } - elseif (1) { c = 2; } - else { } - - - -} - - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch638_T37_Defect_1450920() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -c; -[Imperative] -{ - a = 0; - b = 0; - c = 0; - d = 0; - if(true) - { - a = 1; - } - - if(false) - { - b = 1; - } - elseif(true) - { - b = 2; - } - - if(false) - { - c = 1; - } - elseif(false) - { - c = 2; - } - else - { - c = 3; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch640_T39_Defect_1450920_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -c; -d; -[Imperative] -{ -a=0; -b=0; -c=0; -d=0; - if(0.4) - { - d = 4; - } - - if(1.4) - { - a = 1; - } - - if(0) - { - b = 1; - } - elseif(-1) - { - b = 2; - } - - if(0) - { - c = 1; - } - elseif(0) - { - c = 2; - } - else - { - c = 3; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch641_T40_Defect_1450843() - { - Dictionary> map = new Dictionary>(); - string src = @"b2; -b3; -[Imperative] -{ - a = null; - b1 = 0; - b2 = 0; - b3 = 0; - if(a!=1); - else - b1 = 2; - - if(a==1); - else - b2 = 2; - - if(a==1); - elseif(a ==3); - else b3 = 2; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch642_T41_Defect_1450778() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -d; -[Imperative] -{ - a=1; - b=2; - c=2; - d = 2; - - if(a==1) - { - c = 1; - } - - if(b==2) - { - d = 1; - } - - } -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch643_T42_Defect_1449707() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -[Imperative] -{ - a = 1; - b = 1; - c = 1; - if( a < 1 ) - c = 6; - - else if( b >= 2 ) - c = 5; - - else - c = 4; -} "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch644_T43_Defect_1450706() - { - Dictionary> map = new Dictionary>(); - string src = @"temp1; -temp2; -[Imperative] -{ - a1 = 7.3; - a2 = -6.5 ; - - temp1 = 10; - temp2 = 10; - - if( a1 <= 7.5 ) - temp1 = temp1 + 2; - - if( a2 >= -9.5 ) - temp2 = temp2 + 2; - }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch646_T45_Defect_1450506() - { - Dictionary> map = new Dictionary>(); - string src = @"temp; -[Imperative] -{ - i1 = 2; - i2 = 3; - i3 = 4.5; - - temp = 2; - - while(( i2 == 3 ) && ( i1 == 2 )) - { - temp = temp + 1; - i2 = i2 - 1; - } - - if(( i2 == 3 ) || ( i3 == 4.5 )) - { - temp = temp + 1; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch647_T46_TestIfWithNull() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -c; -[Imperative] -{ - a = null; - c = null; - - if(a == 0) - { - a = 1; - } - if(null == c) - { - c = 1; - } - if(a == b) - { - a = 2; - } - - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch648_T47_Defect_1450858() - { - Dictionary> map = new Dictionary>(); - string src = @"i; -[Imperative] -{ - i = 1; - a = 3; - if( a==3 ) - { - while( i <= 4 ) - { - if( i > 10 ) - temp = 4; - else - i = i + 1; - } - } -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch650_T49_Defect_1450783() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Imperative] -{ - a = 4; - if( a == 4 ) - { - i = 0; - } - a = i; - b = i; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch652_T51_Defect_1452588() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Imperative] -{ - a = 0; - - if ( a == 0 ) - { - b = 2; - } - c = a; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch653_T52_Defect_1452588_2() - { - Dictionary> map = new Dictionary>(); - string src = @"g1; -[Associative] -{ - [Imperative] - { - g2 = g1; - } - g1 = 3; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch656_T55_Defect_1450506() - { - Dictionary> map = new Dictionary>(); - string src = @"temp; -[Imperative] -{ - i1 = 1.5; - i2 = 3; - temp = 2; - while( ( i2==3 ) && ( i1 <= 2.5 )) - { - temp = temp + 1; - i2 = i2 - 1; - } - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch659_T58_Defect_1450932_comparing_collection_with_singleton_Associative() - { - Dictionary> map = new Dictionary>(); - string src = @"d2; -[Associative] -{ - a2 = [ 0, 1 ]; - b2 = 1; - d2 = a2 > b2 ? true : [ false, false]; - //f2 = a2 > b2; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch660_T58_Defect_1450932_comparing_collection_with_singleton_Associative_2() - { - Dictionary> map = new Dictionary>(); - string src = @"f2; -[Associative] -{ - a2 = [ 0, 1 ]; - b2 = 1; - f2 = a2 > b2; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch661_T58_Defect_1450932_comparing_collection_with_singleton_Associative_3() - { - Dictionary> map = new Dictionary>(); - string src = @"f2; -[Associative] -{ - a2 = [ 0, 1 ]; - b2 = 1; - d2 = a2 > b2 ? true : [ false, false]; - f2 = a2 > b2; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch662_T58_Defect_1450932_comparing_collection_with_singleton_Imperative() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -d; -f; -[Imperative] -{ - a = [ 0, 1 ]; - b = 1; - c = -1; - if(a > b) - { - c = 0; - } - else - { - c = 1; - } - d = a > b ? true : [ false, false]; - f = a > b; - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch663_T59_Defect_1453881() - { - Dictionary> map = new Dictionary>(); - string src = @"b; -d; -d2 = ( null == 0 ) ? 1 : 0; -[Imperative] -{ - a = false; - b = 0.5; - d = 0; - if( a == null) - { - d = d + 1; - } - else - { - d = d + 2; - } - if( b == null) - { - b = b + 1; - } - else - { - b = b + 2; - } - - if( b != null) - { - b = b + 3; - } - else - { - b = b + 4; - } - - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch664_T59_Defect_1453881_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo () -{ - c = - [Imperative] - { - a = false; - b = 0.5; - d = 0; - if( a == null) - { - d = d + 1; - } - else - { - d = d + 2; - } - if( b == null) - { - b = b + 1; - } - else - { - b = b + 2; - } - - if( b != null) - { - b = b + 3; - } - else - { - b = b + 4; - } - return = [ b, d ]; - } - return = c; -} -test = foo(); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch668_T62_Condition_Not_Evaluate_ToBool() - { - Dictionary> map = new Dictionary>(); - string src = @" -A; -[Imperative] -{ - A = 1; - if (0) - A = 2; - else - A= 3; -} -//expected A=1;//Received A=3;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch672_T003_Inline_Using_Collection() - { - Dictionary> map = new Dictionary>(); - string src = @"[Imperative] -{ - Passed = 1; - Failed = 0; - Einstein = 56; - BenBarnes = 90; - BenGoh = 5; - Rameshwar = 80; - Jun = 68; - Roham = 50; - Smartness = [ BenBarnes, BenGoh, Jun, Rameshwar, Roham ]; // { 1, 0, 1, 1, 0 } - Results = Smartness > Einstein ? Passed : Failed; - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch673_T005_Inline_Using_2_Collections_In_Condition() - { - Dictionary> map = new Dictionary>(); - string src = @"[Imperative] -{ - a1 = 1..3..1; - b1 = 4..6..1; - a2 = 1..3..1; - b2 = 4..7..1; - a3 = 1..4..1; - b3 = 4..6..1; - c1 = a1 > b1 ? true : false; // { false, false, false } - c2 = a2 > b2 ? true : false; // { false, false, false } - c3 = a3 > b3 ? true : false; // { false, false, false, null } -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch674_T006_Inline_Using_Different_Sized_1_Dim_Collections() - { - Dictionary> map = new Dictionary>(); - string src = @"[Imperative] -{ - a = 10 ; - b = ((a - a / 2 * 2) > 0)? a : a+1 ; //11 - c = 5; - d = ((c - c / 2 * 2) > 0)? c : c+1 ; //5 - e1 = ((b>(d-b+d))) ? d : (d+1); //5 - //inline conditional, returning different sized collections - c1 = [1,2,3]; - c2 = [1,2]; - a1 = [1, 2, 3, 4]; - b1 = a1>3?true:a1; // expected : {1, 2, 3, true} - b2 = a1>3?true:c1; // expected : {1, 2, 3} - b3 = a1>3?c1:c2; // expected : {1, 2} -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch676_T008_Inline_Returing_Different_Ranks() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - a = [ 0, 1, 2, 4]; - x = a > 1 ? 0 : [1,1]; // { 1, 1} ? - x_0 = x[0]; - x_1 = x[1]; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch678_T010_Inline_Using_Literal_Values() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -c; -d; -e; -f; -g; -h; -[Imperative] -{ - a = 1 > 2.5 ? false: 1; - b = 0.55 == 1 ? true : false; - c = (( 1 + 0.5 ) / 2 ) <= (200/10) ? (8/2) : (6/3); - d = true ? true : false; - e = false ? true : false; - f = true == true ? 1 : 0.5; - g = (1/3.0) > 0 ? (1/3.0) : (4/3); - h = (1/3.0) < 0 ? (1/3.0) : (4/3); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch682_T014_Inline_Using_Collections() - { - Dictionary> map = new Dictionary>(); - string src = @"t1;t2;t3;t4;t5;t7; -c1;c2;c3;c4; -[Imperative] -{ - a = [ 0, 1, 2]; - b = [ 3, 11 ]; - c = 5; - d = [ 6, 7, 8, 9]; - e = [ 10 ]; - x1 = a < 5 ? b : 5; - t1 = x1[0]; - t2 = x1[1]; - c1 = 0; - for (i in x1) - { - c1 = c1 + 1; - } - - x2 = 5 > b ? b : 5; - t3 = x2[0]; - t4 = x2[1]; - c2 = 0; - for (i in x2) - { - c2 = c2 + 1; - } - - x3 = b < d ? b : e; - t5 = x3[0]; - c3 = 0; - for (i in x3) - { - c3 = c3 + 1; - } - - x4 = b > e ? d : [ 0, 1]; - t7 = x4[0]; - c4 = 0; - for (i in x4) - { - c4 = c4 + 1; - } - - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch684_T016_Inline_Using_Operators() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo (a:int ) -{ - return = a; -} -a = 1+2 > 3*4 ? 5-9 : 10/2; -b = a > -a ? 1 : 0; -c = 2> 1 && 4>3 ? 1 : 0; -d = 1 == 1 || (1 == 0) ? 1 : 0; -e1 = a > b && c > d ? 1 : 0; -f = a <= b || c <= d ? 1 : 0; -g = foo([ 1, 2 ]) > 3+ foo([4,5,6]) ? 1 : 3+ foo([4,5,6]); -i = [1,3] > 2 ? 1: 0;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch685_T017_Inline_In_Function_Scope() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo1 ( b ) -{ - return = b == 0 ? b : b+1; - -} -def foo2 ( x ) -{ - y = [Imperative] - { - if(x > 0) - { - return = x >=foo1(x) ? x : foo1(x); - } - return = x >=2 ? x : 2; - } - x1 = y == 0 ? 0 : y; - return = y + x1; -} -a1 = foo1(4); -a2 = foo2(3); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch687_T019_Defect_1456758() - { - Dictionary> map = new Dictionary>(); - string src = @"b = true; -a1 = b && true ? -1 : 1; -a2; -[Imperative] -{ - a2 = b && true ? -1 : 1; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch688_T020_Nested_And_With_Range_Expr() - { - Dictionary> map = new Dictionary>(); - string src = @" -a1 = 1 > 2 ? true : 2 > 1 ? 2 : 1; -a2 = 1 > 2 ? true : 0..3; -b = [0,1,2,3]; -a3 = 1 > 2 ? true : b;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch689_T021_Defect_1467166_array_comparison_issue() - { - Dictionary> map = new Dictionary>(); - string src = @"[Imperative] -{ - a = [ 0, 1, 2]; - xx = a < 1 ? 1 : 0; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch696_T06_InsideNestedBlock() - { - Dictionary> map = new Dictionary>(); - string src = @"temp; -a; -b; -[Associative] -{ - a = 4; - b = a*2; - temp = 0; - [Imperative] - { - i=0; - temp=1; - while(i<=5) - { - i=i+1; - temp=temp+1; - } - } - a = temp; - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch697_T07_BreakStatement() - { - Dictionary> map = new Dictionary>(); - string src = @"temp; -i; -[Imperative] -{ - i=0; - temp=0; - while( i <= 5 ) - { - i = i + 1; - if ( i == 3 ) - break; - temp=temp+1; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch698_T08_ContinueStatement() - { - Dictionary> map = new Dictionary>(); - string src = @"temp; -i; -[Imperative] -{ - i = 0; - temp = 0; - while ( i <= 5 ) - { - i = i + 1; - if( i <= 3 ) - { - continue; - } - temp=temp+1; - - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch699_T09_NestedWhileStatement() - { - Dictionary> map = new Dictionary>(); - string src = @"temp; -i; -a; -p; -[Imperative] -{ - i = 1; - a = 0; - p = 0; - - temp = 0; - - while( i <= 5 ) - { - a = 1; - while( a <= 5 ) - { - p = 1; - while( p <= 5 ) - { - temp = temp + 1; - p = p + 1; - } - a = a + 1; - } - i = i + 1; - } -} "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch701_T11_WhilewithLogicalOperators() - { - Dictionary> map = new Dictionary>(); - string src = @"temp1;temp2;temp3;temp4; -[Imperative] -{ - i1 = 5; - temp1 = 1; - while( i >= 2) - { - i1=i1-1; - temp1=temp1+1; - } - - i2 = 5; - temp2 = 1; - while ( i2 != 1 ) - { - i2 = i2 - 1; - temp2 = temp2 + 1; - } - - temp3 = 2; - while( i2 == 1 ) - { - temp3 = temp3 + 1; - i2 = i2 - 1; - } - while( ( i2 == 1 ) && ( i1 == 1 ) ) - { - temp3=temp3+1; - i2=i2-1; - } - temp4 = 3; - while( ( i2 == 1 ) || ( i1 == 5 ) ) - { - i1 = i1 - 1; - temp4 = 4; - } - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch704_T14_TestFactorialUsingWhileStmt() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -factorial_a; -[Imperative] -{ - a = 1; - b = 1; - while( a <= 5 ) - { - a = a + 1; - b = b * (a-1) ; - } - factorial_a = b * a; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch705_T15_TestWhileWithDecimalvalues() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b; -[Imperative] -{ - a = 1.5; - b = 1; - while(a <= 5.5) - { - a = a + 1; - b = b * (a-1) ; - } - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch706_T16_TestWhileWithLogicalOperators() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b; -[Imperative] -{ - a = 1.5; - b = 1; - while(a <= 5.5 && b < 20) - { - a = a + 1; - b = b * (a-1) ; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch707_T17_TestWhileWithBool() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Imperative] -{ - a = 0; - while(a == false) - { - a = 1; - } - - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch708_T18_TestWhileWithNull() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b;c; -[Imperative] -{ - a = null; - c = null; - - while(a == 0) - { - a = 1; - } - while(null == c) - { - c = 1; - } - while(a == b) - { - a = 2; - } - - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch709_T19_TestWhileWithIf() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b; -[Imperative] -{ - a = 2; - b = a; - while ( a <= 4) - { - if(a < 4) - { - b = b + a; - } - else - { - b = b + 2*a; - } - a = a + 1; - } - - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch710_T20_TestWhileToCreate2DimArray() - { - Dictionary> map = new Dictionary>(); - string src = @"def Create2DArray( col : int) -{ - result = [Imperative] - { - array = [ 1, 2 ]; - counter = 0; - while( counter < col) - { - array[counter] = [ 1, 2]; - counter = counter + 1; - } - return = array; - } - return = result; -} -x = Create2DArray( 2) ; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch711_T21_TestWhileToCallFunctionWithNoReturnType() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo () -{ - return = 0; -} -def test () -{ - temp = [Imperative] - { - t1 = foo(); - t2 = 2; - while ( t2 > ( t1 + 1 ) ) - { - t1 = t1 + 1; - } - return = t1; - } - return = temp; -} -x = test(); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch712_T22_Defect_1463683() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo () -{ - return = 1; -} -def test () -{ - temp = [Imperative] - { - t1 = foo(); - t2 = 3; - if ( t2 < ( t1 + 1 ) ) - { - t1 = t1 + 2; - } - else - { - t1 = t1 ; - } - return = t1; - } - return = temp; -} -x = test();"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch715_T22_Defect_1463683_4() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo () -{ - return = 1; -} -def test (t2) -{ - temp = [Imperative] - { - t1 = foo(); - if ( (t2 > ( t1 + 1 )) && (t2 >=3) ) - { - t1 = t1 + 2; - } - else - { - t1 = t1 ; - } - return = t1; - } - return = temp; -} -x1 = test(3); -x2 = test(0);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch716_test() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 1; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch719_T03_Assignment_Slicing_With_Collection() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( a:int[] ) -{ - a[0] = 0; - return = a; -} - a = [1,2,3]; - c = foo ( a ); - d = c[0]; - e = c[1];"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch721_80574Transpose() - { - Dictionary> map = new Dictionary>(); - string src = @"//testing Transpose -x = [[1,2],[3,4]]; -y = Transpose(x) ; -a=[1,2]; -b = Transpose(a); -a1 = [[[1,2]],[[3,4]]]; -b1 = Transpose(a1); -x1 = [[1,2],[3,4,5]]; -y1 = Transpose(x1); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch723_80576allFalse() - { - Dictionary> map = new Dictionary>(); - string src = @"//testing AllFalse -w = false ; -x = [1,2,3,false]; -y = [-1,-2,3,4]; -z = [w,w,w,w]; -a = AllFalse(a);//false -b = AllFalse(y); //false -c = AllFalse(z) ; //true -w1 = [P1, ""s"", [1,2,3],true,false]; -a1 = AllFalse(w1); -a2 = AllFalse(3); -w2 = 5.0; -a3 = AllFalse(w2); -a4 = AllFalse(null); -w3 = []; -a5 = AllFalse(w3); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch732_80586countFalse() - { - Dictionary> map = new Dictionary>(); - string src = @"//testing CountFalse -w = false ; -x = [1,2,3,false]; -y = [-1,-2,3,4]; -z = [w,w,w,true]; -a = CountFalse(x);//1 -b = CountFalse(y); //0 -c = CountFalse(z) ; //3 -g = [false]; -h = CountFalse(g); //1 -x1 = [[true,false],true,false,[[[false]]],[false,false]]; -y1 = CountFalse(x1); -//negative testing -a1 = ""s""; -b1 = CountFalse(a1); //0 -b2 = CountFalse(a2); //0 -b3 = CountFalse(null); //0 -a4 = []; -b4 = CountFalse(a4); //0"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch733_80587countTrue() - { - Dictionary> map = new Dictionary>(); - string src = @"//testing countTrue -w = true ; -x = [1,2,3,true]; -y = [-1,-2,3,4]; -z = [w,w,w,w]; -a = countTrue(x);//1 -b = countTrue(y); //0 -c = countTrue(z) ; //4 -x1 = [[true,false],true,false,[[[false]]],[false,false]]; -y1 = countTrue(x1); -//negative testing -a1 = ""s""; -b1 = countTrue(a1); //0 -b2 = countTrue(a2); //0 -b3 = countTrue(null); //0 -a4 = []; -b4 = countTrue(a4); //0"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch735_80589flatten() - { - Dictionary> map = new Dictionary>(); - string src = @"//testing flatten() -x = [[1.1],[2.3,3]]; -y = [[[-1,2,-3]],6]; -a = Flatten(x); -b = Flatten(y); -c = Flatten(y * 0.1); -d = Flatten(2); -e1 = Flatten(-0.2); -//negative testing -a1 = ""s""; -b1 = Flatten(a1); //b1 = ""s"" -b3 = Flatten(null); // b3 = null -a4 = []; -b4 = Flatten(a4); //b4 = null -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch736_80590floor() - { - Dictionary> map = new Dictionary>(); - string src = @"//testing floor() -x = 1.5 ; -y = 0.01 ; -z = -0.1 ; -a = floor(x) ;//1 -b = floor(y) ;//0 -c = floor(z) ; //-1 -d = floor(-1.5) ;//-2 -e1 = floor(-2);//-2 -g = floor(2.1);//2 -h = floor([0.2*0.2 , 1.2 , -1.2 , 3.4 , 3.6 , -3.6]);//{0,1,-2,3,2,-4} -//negative testing -a1 = ""s""; -b1 = floor(a1); //null -b2 = floor(a2); //null -b3 = floor(null); //null -a4 = []; -b4 = floor(a4); //null"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch738_80592log10() - { - Dictionary> map = new Dictionary>(); - string src = @"//testing log1010() -x =1 ; -y = 10000; -a = log10(x) ;//0 -b = log10(10) ; //1 -c = log10([0.1,-1,-0.9,0.9,y]);//{ -1, -1.#IO, -1.#IO, -0.105, 4.000 } -d = log10(a); // expected -1.#IO(invalid output) but then d = -2147483648 -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch739_80593map() - { - Dictionary> map = new Dictionary>(); - string src = @"//testing map(rangeMin: double, rangeMax: double, inputValue: double) -a = map(3,8,12); //1 -b = map(4,5,12); //1 -c = map(2.3,5,9); //1 -d = map(2.3,5,0.2); //0 -e1 = map(2.3,5.2,0.2); //0 -f = map([1,2.2,3,4],[2,4.2,3.4,5],1.2);//{0.200, 0, 0, 0 } -g = map([1,2],[3.4,4.5],[0,1]); // {0,0} -g1 = map([1,2,3],[4,5],[0,1]); // -g2 = map(4,4,2); // -g3 = map(4,4,4); // -//negative testing -g4 = map([[1,2],[2,3]],[1,2],3); -b1 = map(""s"",8,12); //1 -b3 = map(null,4,5); //null -b4 = map(null,null,null); //null -b5 = map(4,null,5); //null -b6 = map(5,4,null); //null -b7 = map([],5,4); //null -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch740_80594mapto() - { - Dictionary> map = new Dictionary>(); - string src = @"//testing mapTo( rangeMin: double, rangeMax: double, inputValue: double, targeRangeMin: double, targetRangeMax: double) -a = mapTo(3,8,12,4,5); //5 -b = mapTo(4,5,12,3,4); //4 -c = mapTo(2.3,5,9,10,12); //12 -d = mapTo(2.3,5,0.2,[1,2,3,4],5); //{1,2,3,4} -e1 = mapTo(-2.3,5.2,0.2,[-2.3,3.4],[4.5,5.6]); //{-0.033,4.133} -f = mapTo([1,2],[3.4,4.5],[0,1],2,3); // {2,2} -//negative testing -g4 = map([[1,2],[2,3]],[1,2],3,4,5); -b1 = map(""s"",8,12,14,15); //1 -b3 = map(null,4,5,5,6); //null -b4 = map(null,null,null,null,null); //null -b5 = map(4,null,5,6,7); //null -b6 = map(5,4,null,7,8); //null -b7 = map([],5,4,8,9); //null -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch741_80595max() - { - Dictionary> map = new Dictionary>(); - string src = @"//testing max() -a = max(4.5,6.5); //6.5 -b = 10; -c = 3 ; -d = max(b,c); //10 -e1 = [a,b,c];//{ 6.5, 10, 3 } -f = max(e,[2,3.5,4]); //{ 6.5, 10, 4 } -g = max(e<2>,f<1>); //{ { 6.5, 10, 6.5 }, { 10, 10, 10 }, { 6.500, 10, 4 } } -e = max(-1,-2); //-1 , g = { { 2 }, { 3.5 }, { 4 } } and f = {2,3.5,4} -a1 = max(4/5,4.0/5.0); -//negative testing -a1 = ""s""; -b1 = max(a1,4); //null -b2 = max(a2,5); //null -b3 = max(null,5); //null -a4 = []; -b4 = max(a4,[1,2]); //null"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch742_80596min() - { - Dictionary> map = new Dictionary>(); - string src = @"//testing min() -a = min(5,6); //5 -b = 10.5; -c = 3.5 ; -d = min(b,c); //3.5 -e1 = [a,b,c];//{ 5, 10.500, 3.500 } -f = min(e,[2,3.5,4]); //{ 2, 3.500, 3.500 } -g = min(e<2>,f<1>); //{ { 2, 2, 2 }, { 3.500, 3.500, 3.500 }, { 3.500, 3.500, 3.500 } } -e = min(-1,-2); //-2 , g = { { -2 }, { -2 }, { -2 } } and f = { -2, -2, -2 } -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch743_80597rand() - { - Dictionary> map = new Dictionary>(); - string src = @"//testing rand() -x = 1 ; -y = [1,3,5]; -z = [8,7,6]; -a = rand(x,10) ; -b = rand(2,10); -c = rand(9,9.5);//No method found matching the given argument(s) in global context - //Updated variable c = null*/ -d = rand([1,2,3,4,5],10); -e1 = rand([1,2,3],[4,5,6]); -f = rand(y<1> ,z<2>); -//negative testing -a1 = ""s""; -b1 = rand(a1,3); //null -b2 = rand(5,a2); //null -b3 = rand(3,null); //null -a4 = []; -b4 = rand(a4,6); //null -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch744_80598sin() - { - Dictionary> map = new Dictionary>(); - string src = @"// testing using sin() -a = 90 ; -b = sin(a); -c = a * 3 ; -d = sin(c); -e1 = [0,30,45,60,90]; -f = sin(e); -/* -testBSplineCurve = BSplineCurve.ByPoint(points); -tControlVertices = testBSplineCurve.ControlVertices; -update the parameter -Ondemand: property will not be shown unless we query it. -Gurantee: should never be null -Super class should be included - Updated variable a = 90 - Updated variable b = 0.894 -*/ -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch745_80599someFalse() - { - Dictionary> map = new Dictionary>(); - string src = @"//testing someFalse -w = false ; -x = [1,2,3,false]; -y = [-1,-2,3,4]; -z = [w,w,w,w]; -a = someFalse(x);//true -b = someFalse(y); //false -c = someFalse(z) ; //true "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch746_80600someNulls() - { - Dictionary> map = new Dictionary>(); - string src = @"//testing someNulls -w = null ; -x = [1,2,3,null]; -y = [-1,-2,3,4]; -z = [w,w,w,w]; -a = someNulls(x);//false -b = someNulls(y); //false -c = someNulls(z) ; //true "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch747_80601someTrue() - { - Dictionary> map = new Dictionary>(); - string src = @"//testing someTrue -w = true ; -x = [1,2,3,true]; -y = [-1,-2,3,4]; -z = [w,w,w,w]; -a = someTrue(x);//true -b = someTrue(y); //false -c = someTrue(z) ; //true "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch749_80603tan() - { - Dictionary> map = new Dictionary>(); - string src = @"//testing tan() -a = 90 ; -b = tan(a); -c = a * 3 ; -d = tan(c); -e = [0,30,45,60,90]; -f = tan(e); -g = tan([180,360]); //{-0,-0} -h = tan(-90); -i = tan(10); -j = tan(135); //-1 -k = tan(-45); //-1 -l = tan(0); //0"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch759_T001_SomeNulls_IfElse_01() - { - Dictionary> map = new Dictionary>(); - string src = @"result = -[Imperative] -{ - arr1 = [1,null]; - arr2 = [1,2]; - if(SomeNulls(arr1)) - { - arr2 = arr1; - } - return = SomeNulls(arr2); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch760_T001_SomeNulls_IfElse_02() - { - Dictionary> map = new Dictionary>(); - string src = @"result = -[Imperative] -{ - arr1 = []; - arr2 = [1,2]; - if(SomeNulls(arr1)) - { - arr2 = arr1; - } - return = SomeNulls(arr2); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch761_T002_SomeNulls_ForLoop() - { - Dictionary> map = new Dictionary>(); - string src = @"result = -[Imperative] -{ - a = [1,3,5,7,[]]; - b = [null,null,true]; - c = [SomeNulls([1,null])]; - d = [a,b,c]; - j = 0; - e = []; - - for(i in d) - { - - e[j]= SomeNulls(i); - j = j+1; - } - return = e; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch762_T003_SomeNulls_WhileLoop() - { - Dictionary> map = new Dictionary>(); - string src = @"result = -[Imperative] -{ - a = [1,3,5,7,[]]; - b = [null,null,true]; - c = [[]]; - - d = [a,b,c]; - - i = 0; - j = 0; - e = []; - - while(i> map = new Dictionary>(); - string src = @"def foo(x:var[]..[]) -{ - a = []; - i = 0; - [Imperative] - { - for(j in x) - { - if(SomeNulls(j)) - { - a[i] = j; - i = i+1; - } - } - } - return = Count(a); -} -b = [ -[null], -[1,2,3,[]], -[0] -]; -result = foo(b); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch765_T006_SomeNulls_Inline() - { - Dictionary> map = new Dictionary>(); - string src = @"result; -[Imperative] -{ -a = [null,1]; -b = []; -c = [1,2,3]; -result = SomeNulls(c)?SomeNulls(b):SomeNulls(a); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch766_T007_SomeNulls_RangeExpression() - { - Dictionary> map = new Dictionary>(); - string src = @"result = -[Imperative] -{ -i = 0; -arr = [[1,1.2] , [null,0], [true, false] ]; -a1 = 0; -a2 = 2; -d = 1; -a = a1..a2..d; -for(i in a) -{ - if(SomeNulls(arr[i])) - return = i; - -} -return = -1; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch767_T008_SomeNulls_Replication() - { - Dictionary> map = new Dictionary>(); - string src = @"/* -[Imerative] -{ - a = 1..5; - i = 0..3; - x = a[i]; -} -*/ -a = [ -[[null, 1],1], -[null], -[1,2,false] -]; -i = 0..2; -j = 0; -[Imperative] -{ - if(SomeNulls(a[i])) - { - j = j+1; - } - -} -//Note : the following works fine : -/* -[Imperative] -{ - for ( x in i) - { - if(SomeNulls(a[x])) - { - j = j+1; - } - } -} -*/"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch769_T010_SomeNulls_AssociativeImperative_01() - { - Dictionary> map = new Dictionary>(); - string src = @"m; -n; -[Imperative] -{ - a = [1,2,null]; - b = [null, null]; - - [Associative] - { - a = [1]; - b = a; - m = SomeNulls(b); - a = [1,null,[]]; - n = m; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch770_T010_SomeNulls_AssociativeImperative_02() - { - Dictionary> map = new Dictionary>(); - string src = @"[Imperative] -{ - a = [false]; - if(!SomeNulls(a)) - { - [Associative] - { - - b = a; - a = [null]; - - m = SomeNulls(b);//true,false - [Imperative] - { - c = a; - a = [2]; - n = SomeNulls(c);//true - } - - } - }else - { - m = false; - n = false; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch771_T010_SomeNulls_AssociativeImperative_03() - { - Dictionary> map = new Dictionary>(); - string src = @" - - a = [[]]; - b = a; - - m = SomeNulls(b);//false - [Imperative] - { - c = a; - a = [null,[]]; - m = SomeNulls(c);//false - } - a = [null]; - n = SomeNulls(b);//true; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch774_T012_CountTrue_IfElse() - { - Dictionary> map = new Dictionary>(); - string src = @"result = -[Imperative] -{ - arr1 = [true,[[[[true]]]],null]; - arr2 = [[true],[false],null]; - if(CountTrue(arr1) > 1) - { - arr2 = arr1; - } - return = CountTrue(arr2); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch775_T013_CountTrue_ForLoop() - { - Dictionary> map = new Dictionary>(); - string src = @"result = -[Imperative] -{ - a = [1,3,5,7,[]]; - b = [null,null,[1,true]]; - c = [CountTrue([1,null])]; - - d = [a,b,c]; - j = 0; - e = []; - - for(i in d) - { - e[j]= CountTrue(i); - j = j+1; - } - return = e; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch776_T014_CountTrue_WhileLoop() - { - Dictionary> map = new Dictionary>(); - string src = @"result = -[Imperative] -{ - a = [1,3,5,7,[1]];//0 - b = [1,null,true];//1 - c = [[false]];//0 - - d = [a,b,c]; - - i = 0; - j = 0; - e = []; - - while(i> map = new Dictionary>(); - string src = @"def foo(x:var[]..[]) -{ - a = []; - i = 0; - [Imperative] - { - for(j in x) - { - a[i] = CountTrue(j); - i = i+1; - } - } - return = a; -} -b = [ -[null],//0 -[1,2,3,[true]],//1 -[0],//0 -[true, true,1,true, null],//3 -[x, null]//0 -]; -result = foo(b); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch780_T018_CountTrue_RangeExpression_01() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -result = -[Imperative] -{ - a1 = [1,true, null];//1 - a2 = 8; - a3 = [2,[true,[true,1]],[false,x, true]];//3 - a = CountTrue(a1)..a2..CountTrue(a3);//{1,4,7} - - return = CountTrue(a); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch781_T018_CountTrue_RangeExpression_02() - { - Dictionary> map = new Dictionary>(); - string src = @"result = -[Imperative] -{ - a1 = [1,true, null];//1 - a2 = 8; - a3 = [2,[true,[true,1]],[false,x, true]];//3 - a = CountTrue(a1)..a2..~CountTrue(a3);//{} - return = CountTrue(a); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch782_T018_CountTrue_RangeExpression_03() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -result = -[Imperative] -{ - a1 = [1,true, null];//1 - a2 = 8; - a3 = [2,[true,[true,1]],[false,x, true]];//3 - a = [1.0,4.0,7.0]; - //a = CountTrue(a1)..a2..#CountTrue(a3);//{} - return = CountTrue(a); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch783_T019_CountTrue_Replication() - { - Dictionary> map = new Dictionary>(); - string src = @" -def foo(x:int) -{ - return = x +1; -} -a = [true,[true],1];//2 -b = [null]; -c = [[[true]]];//1 -d = [[true],[false,[true,true]]];//3 -arr = [CountTrue(a),CountTrue(b),CountTrue(c),CountTrue(d)]; -result = foo(arr);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch786_T022_CountTrue_ImperativeAssociative() - { - Dictionary> map = new Dictionary>(); - string src = @"b; -c; -[Imperative] -{ - a1 = [true,0,1,1.0,null]; - a2 = [false, CountTrue(a1),0.0]; - a3 = a1; - [Associative] - { - a1 = [true,[true]]; - a4 = a2; - a2 = [true]; - b = CountTrue(a4);//1 - } - - c = CountTrue(a3);//1 - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch787_T023_CountFalse_IfElse() - { - Dictionary> map = new Dictionary>(); - string src = @"result = -[Imperative] -{ - arr1 = [false,[[[[false]]]],null,0]; - arr2 = [[true],[false],null,null]; - if(CountFalse(arr1) > 1) - { - arr2 = arr1; - } - return = CountFalse(arr2);//2 -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch788_T024_CountFalse_ForLoop() - { - Dictionary> map = new Dictionary>(); - string src = @"result = -[Imperative] -{ - a = [1,3,5,7,[]]; - b = [null,null,[0,false]]; - c = [CountFalse([[false],null])]; - - d = [a,b,c]; - j = 0; - e = []; - - for(i in d) - { - e[j]= CountFalse(i); - j = j+1; - } - return = e; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch789_T025_CountFalse_WhileLoop() - { - Dictionary> map = new Dictionary>(); - string src = @"result = -[Imperative] -{ - a = [1,3,5,7,[0]];//0 - b = [1,null,false];//1 - c = [[true]];//0 - - d = [a,b,c]; - - i = 0; - j = 0; - e = []; - - while(i> map = new Dictionary>(); - string src = @"def foo(x:var[]..[]) -{ - a = []; - i = 0; - [Imperative] - { - for(j in x) - { - a[i] = CountFalse(j); - i = i+1; - } - } - return = a; -} -b = [ -[null],//0 -[1,2,3,[false]],//1 -[0],//0 -[false, false,0,false, null],//3 -[x, null]//0 -]; -result = foo(b); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch793_T029_CountFalse_RangeExpression_01() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -result = -[Imperative] -{ - a1 = [0,false, null];//1 - a2 = 8; - a3 = [2,[false,[false,1]],[false,x, true]];//3 - a = CountFalse(a1)..a2..CountFalse(a3);//{1,4,7} - - return = CountFalse(a); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch794_T029_CountFalse_RangeExpression_02() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -result = -[Imperative] -{ - a1 = [1,false, null];//1 - a2 = 8; - a3 = [2,[false,[false,1]],[false,x, true]];//3 - a = [1.0,4.0,7.0]; - //a = CountFalse(a1)..a2..#CountFalse(a3);//{} - return = CountFalse(a); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch795_T030_CountFalse_Replication() - { - Dictionary> map = new Dictionary>(); - string src = @" -def foo(x:int) -{ - return = x +1; -} -a = [false,[false],0];//2 -b = [CountFalse([a[2]])]; -c = [[[false]]];//1 -d = [[false],[false,[true,false,0]]];//3 -arr = [CountFalse(a),CountFalse(b),CountFalse(c),CountFalse(d)]; -result = foo(arr);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch798_T033_CountFalse_ImperativeAssociative() - { - Dictionary> map = new Dictionary>(); - string src = @"b; -c; -[Imperative] -{ - a1 = [false,0,1,1.0,null]; - a2 = [true, CountFalse(a1),0.0]; - a3 = a1; - [Associative] - { - a1 = [false,[false]]; - a4 = a2; - a2 = [false]; - b = CountFalse(a4);//1 - } - - c = CountFalse(a3);//1 - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch799_T034_AllFalse_IfElse() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [false, false];//true -b = [[false]];//true -c = [false, 0];//false -result = []; -[Imperative] -{ - if(AllFalse(a)){ - a[2] = 0; - result[0] = AllFalse(a);//false - } - if(!AllFalse(b)){ - - result[1] = AllFalse(b);//false - }else - {result[1]= null;} - if(!AllFalse(c)){ - result[2] = AllFalse(c); - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch800_T035_AllFalse_ForLoop() - { - Dictionary> map = new Dictionary>(); - string src = @" -result = -[Imperative] -{ - a = [false,false0,0,null,x];//false - b = [false,false0,x];//false - c = [];//false - d = [[]];//false - - h = [ - [[0]], - [false] -]; - e = [a,b ,c ,d,h]; - f = []; - j = 0; - for(i in e) - { - if(AllFalse(i)!=true){ - f[j] = AllFalse(i); - j = j+1; - } - - } -return = f; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch801_T036_1_Null_Check() - { - Dictionary> map = new Dictionary>(); - string src = @"result = null;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch802_T036_AllFalse_WhileLoop() - { - Dictionary> map = new Dictionary>(); - string src = @" -result = -[Imperative] -{ - a = [false,false0,0,null,x];//false - b = [false,false0,x];//false - c = [];//false - d = [[]];//false - e = [a,b ,c ,d]; - i = 0; - f = []; - j = 0; - while(!AllFalse(e[i])&& i < Count(e)) - { - if(AllFalse(e[i])!=true){ - f[j] = AllFalse(e[i]); - j = j+1; - } - i = i+1; - - } -return = f; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch803_T037_AllFalse_Function() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo( x : bool) -{ - return = !x; -} -a1 = [0]; -a2 = [null]; -a3 = [!true]; -b = [a1,a2,a3]; -result = [foo(AllFalse(a1)),foo(AllFalse(a2)),foo(AllFalse(a3))];//true,true,false -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch805_T039_AllFalse_Inline() - { - Dictionary> map = new Dictionary>(); - string src = @"a1 = [false,[false]]; -a = AllFalse(a1);//true -b1 = [null,null]; -b = AllFalse(b1);//false -c = AllFalse([b]);//t -result = a? c:b;//t"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch807_T040_AllFalse_Replication() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [ - [[0]], - [false] -]; -c = AllFalse(a); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch808_T042_AllFalse_DynamicArray() - { - Dictionary> map = new Dictionary>(); - string src = @"b = []; -a = [[true],[false],[false], - [false,[true,false]]]; - - i = 0; - result2 = - [Imperative] - { - while(i> map = new Dictionary>(); - string src = @"m; -n; -[Imperative] -{ - a = [false||true]; - b = [""false""]; - c = a; - a = [false]; - [Associative] - { - - d = b; - - b = [false]; - - m = AllFalse(c);//f - n = AllFalse(d);//t - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch811_T045_Defect_CountArray_1() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [0,1,null]; -b = [m,[],a]; -c=[]; -c[0] = 1; -c[1] = true; -c[2] = 0; -c[3] = 0; -a1 = Count(a); -b1 = Count(b); -c1 = Count(c); -result = [a1,b1,c1];"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch812_T045_Defect_CountArray_2() - { - Dictionary> map = new Dictionary>(); - string src = @"result= -[Imperative] -{ -a = []; -b = a; -a[0] = b; -a[1] = ""true""; -c = Count(a); -a[2] = c; -return = Count(a); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch813_T045_Defect_CountArray_3() - { - Dictionary> map = new Dictionary>(); - string src = @"a = []; -b = [null,1+2]; -a[0] = b; -a[1] = b[1]; -result = Count(a);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch814_T046_Sum_IfElse() - { - Dictionary> map = new Dictionary>(); - string src = @"result = -[Imperative] -{ - a = [1,2,3,4]; - b = [1.0,2.0,3.0,4.0]; - c = [1.0,2,3,4.0]; - d = []; - e = [[1,2,3,4]]; - f = [true,1,2,3,4]; - g = [null]; - - m= [-1,-1,-1,-1,-1,-1,-1]; - - if(Sum(a)>=0) m[0] = Sum(a); - if(Sum(b)>=0) m[1] = Sum(b); - if(Sum(c)>=0) m[2] = Sum(c); - if(Sum(d)>=0) m[3] = Sum(d); - if(Sum(e)>=0) m[4] = Sum(e); - if(Sum(f)>=0) m[5] = Sum(f); - if(Sum(g)>=0) m[6] = Sum(g); - - return = m; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch815_T047_Sum_ForLoop() - { - string defectID = "MAGN-3988 Defects with Expression Interpreter Test Framework"; - Dictionary> map = new Dictionary>(); - string src = @"import(""FFITarget.dll""); -result = -[Imperative] -{ - a = [0,0.0]; - b = [[]]; - c = [m, DummyMath.Sum(a), b, 10.0]; - - d = [a,b,c]; - j = 0; - - for(i in d) - { - d[j] = DummyMath.Sum(i); - j = j+1; - } - - return = d; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map, defectID: defectID); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch816_T048_Sum_WhileLoop() - { - string defectID = "MAGN-3988 Defects with Expression Interpreter Test Framework"; - Dictionary> map = new Dictionary>(); - string src = @"import(""FFITarget.dll""); -result = -[Imperative] -{ - a = [-2,0.0]; - b = [[]]; - c = [m, DummyMath.Sum(a), b, 10.0]; - - d = [a,b,c]; - j = 0; - k = 0; - e = []; - - while(j> map = new Dictionary>(); - string src = @"def foo(x:var[]) -{ - return = - [Imperative] - { - return = Sum(x); - } -} -a = [-0.1,true,[],null,1]; -b = [m+n,[[[1]]]]; -c = [Sum(a),Sum(b)]; -result = foo(c); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch819_T051_Sum_Inline() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [1,[2,-3.00]];//0.0 -sum = Sum(a); -b = Sum(a) -1;//-1.0 -c = Sum([a,b,-1]);//-2.0; -result = Sum(a)==0&& b==-1.00? b :c; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch820_T052_Sum_RangeExpression() - { - Dictionary> map = new Dictionary>(); - string src = @"result = -[Imperative] -{ - a1 = [1,true, null];//1 - a2 = 8; - a3 = [2,[true,[true,1.0]],[false,x, true]];//3.0 - a = Sum(a1)..a2..Sum(a3);//{1,4,7} - - return = Sum(a);//12.0 -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch821_T053_Sum_Replication() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [1,2,3]; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch822_T054_Sum_DynamicArr() - { - Dictionary> map = new Dictionary>(); - string src = @"a = []; -b = [1.0,2,3.0]; -c = [null,m,""1""]; -a[0]=Sum(b);//6.0 -a[1] = Sum(c);//0 -a[2] = Sum([a[0],a[1]]);//6.0 -result = Sum(a);//12.0"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch824_T056_Sum_AssociativeImperative() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [1,0,0.0]; -b = [2.0,0,true]; -b1 = [b,1]; -[Imperative] -{ - c = a[2]; - a[1] = 1; - m = a; - sum1 = Sum([c]);//0.0 - [Associative] - { - b[1] = 1; - sum2 = Sum( b1);////4.0 - } - - a[2] =1; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch825_T057_Average_DataType_01() - { - Dictionary> map = new Dictionary>(); - string src = @"a = []; -b = [1,2,3]; -c = [0.1,0.2,0.3,1]; -d = [true, false, 1]; -a1 = Average(a); -b1 = Average(b); -c1 = Average(c); -d1 = Average(d);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch827_T059_Defect_Flatten_RangeExpression() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 0..10..5; -b = 20..30..2; -c = [a, b]; -d = Flatten([a,b]); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch828_T059_Defect_Flatten_RangeExpression_1() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [[null]]; -b = [1,2,[3]]; -c = [a,b]; -d = Flatten(c);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch829_T060_Average_ForLoop() - { - Dictionary> map = new Dictionary>(); - string src = @"result = -[Imperative] -{ - a = []; - b = [1,[2],[[2],1]]; - c = [true, false, null, 10]; - d = [a,b,c]; - - e = []; - j = 0; - - for(i in d) - { - e[j] = Average(i); - j = j+1; - - } - return = e; - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch830_T061_Average_Function() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : double (x :var[]..[]) -{ - - return = Average(x); -} -a = [1,2,2,1]; -b = [1,[]]; -c = Average(a); -result = [foo(a),foo(b)];"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch832_T063_Average_Inline() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [1.0,2]; -b = [[0],1.0,[2]]; -result = Average(a)>Average(b)?true:false;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch833_T064_Average_RangeExpression() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 0..6..3;//0,3,6 -b = 0..10..~3;//0,3.3,6.6,10 -m = Average(a);//3 -n = Average(b);//5.0 -c = Average([m])..Average([n]);//3.0,4.0,5.0"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch835_T066_Print_String() - { - Dictionary> map = new Dictionary>(); - string src = @"r1 = Print(""Hello World""); -str = ""Hello World!!""; -r2 = Print(str); -str = ""Hello + World"";"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch836_T067_Print_Arr() - { - Dictionary> map = new Dictionary>(); - string src = @"arr = [ 0, 1 ,2]; -r1 = Print(arr); -arr2 = [0,[1],[[]]]; -r2 = Print(arr2);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch848_test() - { - Dictionary> map = new Dictionary>(); - string src = @"a = []; -b = Average(a);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch927_T53_Undefined_Class_negative_1467107_10() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo(x:int) -{ -return = x + 1; -} -//y1 = test.foo(2); -m=null; -y2 = m.foo(2); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch928_T53_Undefined_Class_negative_associative_1467091_13() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( x : int) -{ -return = x + 1; -} -y = test.foo (1); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch960_T77_Defect_1460274_Class_Update() - { - Dictionary> map = new Dictionary>(); - string src = @"b = 1; -a = b + 1; -b = a;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch963_T77_Defect_1460274_Class_Update_4() - { - Dictionary> map = new Dictionary>(); - string src = @"[Imperative] -{ - a = []; - b = a; - a[0] = b; - c = Count(a); -} -[Associative] -{ - a1 = [0]; - b1 = a1; - a1[0] = b1; - c1 = Count(a1); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch976_Collection_Assignment_1() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -d; -e; -[Imperative] -{ - a = [ [1,2], [3,4] ]; - - a[1] = [-1,-2,3]; - - c = a[1][1]; - - d = a[0]; - - b = [ 1, 2 ]; - - b[0] = [2,2]; - e = b[0]; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch977_Collection_Assignment_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo: int[]( a: int,b: int ) -{ - return = [ a,b ]; -} - c = foo( 1, 2 ); -d; -[Imperative] -{ - d = foo( 3 , -4 ); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch978_Collection_Assignment_3() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo: int[]( a: int,b: int ) -{ - return = [ a+1,b-2 ]; -} - c = foo( 1, 2 ); - d; -[Imperative] -{ - d = foo( 2+1 , -3-1 ); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch980_Collection_Assignment_5() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo: int[] ( a : int[], b: int, c:int ) -{ - a[b] = c; - return = a; -} -d = [ 1,2,2 ]; -b = foo( d,2,3 ); -e; -c; -[Imperative] -{ - e = [ -2,1,2 ]; - c = foo( e,0,0 ); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch981_T01_Simple_1D_Collection_Assignment() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -c; -d; -e; -[Imperative] -{ - a = [ [1,2], [3,4] ]; - - a[1] = [-1,-2,3]; - - c = a[1][1]; - - d = a[0]; - - b = [ 1, 2 ]; - - b[0] = [2,2]; - e = b[0]; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch982_T02_Collection_Assignment_Associative() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -b; -c; -d; -e; -[Associative] -{ - a = [ [1,2], [3,4] ]; - - a[1] = [-1,-2,3]; - - c = a[1][1]; - - d = a[0]; - - b = [ 1, 2 ]; - - b[0] = [2,2]; - e = b[0]; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch983_T03_Collection_Assignment_Nested_Block() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -d; -e; -[Associative] -{ - a = [ [1,2,3],[4,5,6] ]; - - [Imperative] - { - c = a[0]; - d = a[1][2]; - } - - e = c; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch984_T04_Collection_Assignment_Using_Indexed_Values() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -d; -e; -[Associative] -{ - a = [ [1,2,3],[4,5,6] ]; - - b = [ a[0], 4 ]; - - c = b[0]; - - d = b[1]; - - e = [ a[0][0], a[0][1], a[1][0] ]; - -} - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch987_T07_Collection_Assignment_In_Function_Scope() - { - Dictionary> map = new Dictionary>(); - string src = @"def collection :int[] ( a :int[] , b:int , c:int ) -{ - a[1] = b; - a[2] = c; - return= a; -} - a = [ 1,0,0 ]; - [Imperative] - { - a = collection( a, 2, 3 ); - } -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch988_T08_Collection_Assignment_In_Function_Scope_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( a ) -{ - return= a; -} - a = [ 1, foo( 2 ) , 3 ]; - b; - [Imperative] - { - b = [ foo( 4 ), 5, 6 ]; - } -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch990_T10_2D_Collection_Assignment_In_Function_Scope() - { - Dictionary> map = new Dictionary>(); - string src = @" def foo( a:int[] ) - { - a[0][0] = 1; - return= a; - } - b = [ [0,2,3], [4,5,6] ]; - d = foo( b ); - c = d[0]; - - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch991_T11_2D_Collection_Assignment_Heterogeneous() - { - Dictionary> map = new Dictionary>(); - string src = @"b; -c; -d; -[Imperative] -{ - a = [ [1,2,3], [4], [5,6] ]; - b = a[1]; - a[1] = 2; - a[1] = a[1] + 1; - a[2] = [7,8]; - c = a[1]; - d = a[2][1]; -} "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch992_T12_Collection_Assignment_Block_Return_Statement() - { - Dictionary> map = new Dictionary>(); - string src = @"c1; -c2; -[Associative] -{ - a = 3; - - b = [Imperative] - { - c = [ 1,2,3 ]; - if( c[1] <= 3 ) - return= c; - } - - b[2] = 4; - a = b; - c1 = a[1]; - c2 = a[2]; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch993_T13_2D_Collection_Assignment_Block_Return_Statement() - { - Dictionary> map = new Dictionary>(); - string src = @"c1; -c2; -[Associative] -{ - a = 3; - - b = [Imperative] - { - c = [ [ 1,2,3 ] , [ 4,5,6 ] ] ; - return= c; - } - - b[0][0] = 0; - a = b; - c1 = a[0]; - c2 = a[1][2]; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch994_T14_2D_Collection_Assignment_Using_For_Loop() - { - Dictionary> map = new Dictionary>(); - string src = @"pts = [[0,1,2],[0,1,2]]; -x = [1,2]; -y = [1,2,3]; -[Imperative] -{ - c1 = 0; - for ( i in x ) - { - c2 = 0; - for ( j in y ) - { - pts[c1][c2] = i+j; - c2 = c2+1; - } - c1 = c1 + 1; - } - -} -p1 = pts[1][1]; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch995_T15_2D_Collection_Assignment_Using_While_Loop() - { - Dictionary> map = new Dictionary>(); - string src = @"p1; -[Imperative] -{ - pts = [[0,1,2],[0,1,2]]; - x = [1,2,3]; - y = [1,2,3]; - i = 0; - while ( i < 2 ) - { - j = 0; - while ( j < 3 ) - { - pts[i][j] = i+j; - j = j + 1; - } - i = i + 1; - } - p1 = pts[1][1]; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch997_T17_Assigning_Collection_And_Updating() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [1, 2, 3]; -b = a; -b[0] = 100; -t = a[0]; // t = 100, as expected - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch998_T18_Assigning_Collection_In_Function_And_Updating() - { - Dictionary> map = new Dictionary>(); - string src = @"def A (a: int []) -{ - return = a; -} -val = [1,2,3]; -b = A(val); -t = b; -t[0] = 100; // -y = b[0]; -z = val[0]; // val[0] is still 1 - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch999_T19_Assigning_Collection_In_Function_And_Updating() - { - Dictionary> map = new Dictionary>(); - string src = @"def A (a: int []) -{ - return = a; -} -val = [1,2,3]; -b = A(val); -b[0] = 100; -z = val[0]; - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1000_T20_Defect_1458567() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 1; -b = a[1];"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1002_T21_Defect_1460891() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -c; -[Imperative] -{ - b = [ ]; - count = 0; - a = 1..5..2; - for ( i in a ) - { - b[count] = i + 1; - count = count + 1; - } - c = b ; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1003_T21_Defect_1460891_2() - { - Dictionary> map = new Dictionary>(); - string src = @" -def CreateArray ( x : var[] , i ) -{ - x[i] = i; - return = x; -} -b = [0, 1]; -count = 0..1; -b = CreateArray ( b, count ); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1004_T22_Create_Multi_Dim_Dynamic_Array() - { - Dictionary> map = new Dictionary>(); - string src = @"test; -[Imperative] -{ - d = [[]]; - r = c = 0; - a = [ 0, 1, 2 ]; - b = [ 3, 4, 5 ]; - for ( i in a ) - { - c = 0; - for ( j in b) - { - d[r][c] = i + j; - c = c + 1; - } - r = r + 1; - } - test = d; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1007_T24_Dynamic_Array_Argument_Function_1465802_1() - { - Dictionary> map = new Dictionary>(); - string src = @" - def foo : int(i:int[]) - { - return = 1; - } -b1; -[Associative] -{ -cy=[]; -cy[0]=10; -cy[1]=12; -b1=foo(cy); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1008_T24_Dynamic_Array_Argument_Function_1465802_2() - { - Dictionary> map = new Dictionary>(); - string src = @" - def foo : int(i:int[]) - { - return = 1; - } -b1; -[Associative] -{ -cy=[]; -cy[0]=10; -cy[1]=null; -b1=foo(cy); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1012_T24_Dynamic_Array_Imperative_Function_Scope() - { - Dictionary> map = new Dictionary>(); - string src = @"def createArray( p : int[] ) -{ - a = [Imperative] - { - collection = []; - lineCnt = 0; - while ( lineCnt < 2 ) - { - collection [ lineCnt ] = p [ lineCnt ] * -1; - lineCnt = lineCnt + 1; - } - return = collection; - } - return = a; -} -x = createArray ( [ 1, 2, 3, 4 ] ); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1013_T24_Dynamic_Array_Imperative_Scope() - { - Dictionary> map = new Dictionary>(); - string src = @"t = [Imperative] -{ - d = [ [ ] ]; - r = c = 0; - a = [ 0, 1, 2 ]; - b = [ 3, 4, 5 ]; - for ( i in a ) - { - c = 0; - for ( j in b) - { - d[r][c] = i + j; - c = c + 1; - } - r = r + 1; - } - test = d; - return = test; -} -// expected : test = { { 3, 4, 5 }, {4, 5, 6}, {5, 6, 7} } -// received : test = { { 3, 4, 5 }, , }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1014_T24_Dynamic_Array_Inside_Function() - { - Dictionary> map = new Dictionary>(); - string src = @" -def foo ( d : var[] ) -{ - [Imperative] - { - r = c = 0; - a = [ 0, 1, 2 ]; - b1 = [ 3, 4, 5 ]; - for ( i in a ) - { - c = 0; - for ( j in b1) - { - d[r][c] = i + j; - c = c + 1; - } - r = r + 1; - } - } - return = d; -} -b = []; -b = foo ( b ) ; -a = b; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1015_T24_Dynamic_Array_Inside_Function_2() - { - Dictionary> map = new Dictionary>(); - string src = @" -def foo ( d : var[]..[] ) -{ - [Imperative] - { - r = c = 0; - a = [ 0, 1, 2 ]; - b1 = [ 3, 4, 5 ]; - for ( i in a ) - { - c = 0; - for ( j in b1) - { - d[r][c] = i + j; - c = c + 1; - } - r = r + 1; - } - } - return = d; -} -b = [ [] ]; -b = foo ( b ) ; -a = b; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1028_T25_Adding_Elements_To_Array() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 0..2; -a[3] = 3; -b = a; -x = [ [ 0, 0 ] , [ 1, 1 ] ]; -x[1][2] = 1; -x[2] = [2,2,2,2]; -y = x; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1030_T25_Adding_Elements_To_Array_Function() - { - Dictionary> map = new Dictionary>(); - string src = @"def add ( x : var[]..[] ) -{ - x[1][2] = 1; - x[2] = [ 2, 2, 2, 2 ]; - return = x; -} -x = [ [ 0, 0 ] , [ 1, 1 ] ]; -x = add(x); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1032_T26_Defct_DNL_1459616() - { - Dictionary> map = new Dictionary>(); - string src = @"a=1; -a=[a,2];"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1033_T26_Defct_DNL_1459616_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a=[1,2]; -[Imperative] -{ - a=[a,2]; -} -b = a;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1034_T26_Defct_DNL_1459616_3() - { - Dictionary> map = new Dictionary>(); - string src = @"a=[1,2]; -[Imperative] -{ - a=[a,2]; -} -b = [ 1, 2 ]; -def foo ( ) -{ - b = [ b[1], b[1] ]; - return = null; -} -dummy = foo (); -c = b;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1037_T26_defect_1464429_DynamicArray() - { - Dictionary> map = new Dictionary>(); - string src = @" -def CreateArray ( x : var[] , i ) -{ -x[i] = i; -return = x; -} -b = [ ]; // Note : b = { 0, 0} works fine -count = 0..1; -t2 = CreateArray ( b, count ); -t1=b;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1039_T27_defect_1464429_DynamicArray() - { - Dictionary> map = new Dictionary>(); - string src = @" -def CreateArray ( x : var[] , i ) -{ -x[i] = i; -return = x; -} -b = [ ]; // Note : b = { 0, 0} works fine -count = 0..1; -t2 = CreateArray ( b, count ); -t1=b;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1044_T27_defect_1464429_DynamicArray_update() - { - Dictionary> map = new Dictionary>(); - string src = @" -def CreateArray ( x : var[] , i ) -{ -x[i] = i; -return = x; -} -b = [ ]; // Note : b = { 0, 0} works fine -count = 0..1; -t2 = CreateArray ( b, count ); -t1=b; -count = -2..-1;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1048_T27_DynamicArray_Invalid_Index_1465614_1() - { - Dictionary> map = new Dictionary>(); - string src = @"a=[]; -b=a[2]; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1055_T29_DynamicArray_Using_Out_Of_Bound_Indices() - { - Dictionary> map = new Dictionary>(); - string src = @" - basePoint = [ ]; - - basePoint [ 4 ] =3; - test = basePoint; - - a = basePoint[0] + 1; - b = basePoint[ 4] + 1; - c = basePoint [ 8 ] + 1; - - d = [ 0,1 ]; - e1 = d [ 8] + 1; - - x = [ ]; - y = [ ]; - t = [Imperative] - { - k = [ ]; - for ( i in 0..1 ) - { - x[i] = i; - } - k[0] = 0; - for ( i in x ) - { - y[i] = x[i] + x[i+1]; - k[i+1] = x[i] + x[i+1]; - - } - return = k; - } - z = y; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1060_T40_Index_usingFunction_1467064() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo() -{ -return = 0; -} -x = [ 1, 2 ]; -x[foo()] = 3; -y = x;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1071_T62_Change_Avariable_To_Dynamic_Array_OnTheFly() - { - Dictionary> map = new Dictionary>(); - string src = @" -def func(a:int) -{ -a=5; -return = a; -} -c=1; -b= func(c[0]); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1072_T62_Create_Dynamic_Array_OnTheFly() - { - Dictionary> map = new Dictionary>(); - string src = @"i; -b; -z=[Imperative] -{ -for (i in 0..7) -{ -b[i] = i; -} -return=b; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1073_T62_Create_Dynamic_Array_OnTheFly_AsFunctionArgument() - { - Dictionary> map = new Dictionary>(); - string src = @" -def func(a:int) -{ -a=5; -return = a; -} -b= func(c[0]); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1077_T62_Create_Dynamic_Array_OnTheFly_passargument_function() - { - Dictionary> map = new Dictionary>(); - string src = @" - - def test(a:int[]) - { - b=1; - return=b; - } -d[0]=5; -a=test(d); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1078_T63_Create_MultiDimension_Dynamic_Array_OnTheFly() - { - Dictionary> map = new Dictionary>(); - string src = @" -def func(a:int[]..[]) -{ -a[0][1]=5; -a[2][3]=6; -return = a; -} -c=1; -b= func(c); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1079_T63_Dynamic_array_onthefly_1467066() - { - Dictionary> map = new Dictionary>(); - string src = @"b; -z=[Imperative] -{ -b[5]=0; -for (i in 0..7) -{ -b[i] = i; -} -return=b; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1080_T63_Dynamic_array_onthefly_aliastoanother() - { - Dictionary> map = new Dictionary>(); - string src = @"a=5; -b=a; -a[2]=3; -b[2]=-5;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1082_T63_Dynamic_array_onthefly_function_1467139() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo(a:int[]) -{ -} -x[0]=5; -a = foo(x); -c = [100]; -t = x; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1084_T63_Dynamic_array_onthefly_update() - { - Dictionary> map = new Dictionary>(); - string src = @"z=true; -b=z; -z[0]=[1]; -z=5; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1085_T64_Modify_itemInAnArray_1467093() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [1, 2, 3]; -a[1] = a; -"; - // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-3988 - string defectID = "MAGN-3988 Defects with Expression Interpreter Test Framework"; - - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map, defectID: defectID); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1086_T64_Modify_itemInAnArray_1467093_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b;c; -[Imperative] -{ -a = []; -b = a; -a[0] = b; -//hangs here -c = a; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1087_T65_Array_Alias_ByVal_1467165() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [0,1,2,3]; -b=a; -a[0]=9; -b[0]=10; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1089_T65_Array_Alias_ByVal_1467165_3() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [0,1,2,3]; -b=a; -a[0]=9; -b[0]=false; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1092_T65_Array_Alias_ByVal_1467165_6() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [0,1,2,3]; -b=a; -a[0]=null; -b[0]=false; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1093_T66_Array_CannotBeUsedToIndex1467069() - { - // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-3988 - string defectID = "MAGN-3988 Defects with Expression Interpreter Test Framework"; - - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - a = [3,1,2]; - x = [10,11,12,13,14,15]; - x[a] = 2; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map, defectID: defectID); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1095_T67_Array_Remove_Item() - { - Dictionary> map = new Dictionary>(); - string src = @"a=[1,2,3,4,5,6,7]; -a=Remove(a,0);// expected :{2,3,4,5,6,7} -a=Remove(a,4);//expected {1,2,3,4,6,7} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1096_T67_Array_Remove_Item_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a=[1,2,3,4,5,6,7]; -a=Remove(a,0);// expected :{2,3,4,5,6,7} -a=Insert(a,4,6);//expected {1,2,3,4,6,7}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1097_T68_copy_byreference_1467105() - { - Dictionary> map = new Dictionary>(); - string src = @"test; -[Associative] -{ -a = [ 1, 2, 3]; -b = a; -b[0] = 10; -test = a[0]; //= 10� i.e. a change in �b� causes a change to �a� -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1098_T01_Function_In_Assoc_Scope() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Associative] -{ - def foo : int( a:int ) - { - return = a * 10; - } - - a = foo( 2 ); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1101_T04_Function_In_Nested_Scope() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b; -[Associative] -{ - def foo : int( a:int, b : int ) - { - return = a * b; - } - a = 3.5; - [Imperative] - { - a = foo( 2, 1 ); - } - b = - [Imperative] - { - a = foo( 2, 1 ); - return = a; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1102_T05_Function_outside_Any_Block() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : int( a:int, b : int ) -{ - return = a * b; -} -a = 3.5; -b = 3.5; -[Associative] -{ - a = 3.5; - [Imperative] - { - a = foo( 2, 1 ); - } - b = - [Imperative] - { - a = foo( 2, 1 ); - return = a; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1103_T06_Function_Imp_Inside_Assoc() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b; -[Associative] -{ - def foo : int( a:int, b : int ) - { - return = a * b; - } - a = 3.5; - b = 3.5; - [Imperative] - { - a = foo( 2, 1 ); - } - b = - [Imperative] - { - c = foo( 2, 1 ); - return = c; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1111_T12_Function_From_Inside_Function() - { - Dictionary> map = new Dictionary>(); - string src = @"def add_1 : double( a:double ) -{ - return = a + 1; -} -a;b; -[Associative] -{ - def add_2 : double( a:double ) - { - return = add_1( a ) + 1; - } - - a = 1.5; - b = add_2 (a ); - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1116_T17_Function_From_Parallel_Blocks() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b; -[Associative] -{ - def foo : int( n : int ) - { - return = n * n; - } - - - -} -[Associative] -{ - a = 3; - b = foo (a ); - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1119_T20_Function_From_Imperative_If_Block() - { - Dictionary> map = new Dictionary>(); - string src = @"x;y;z; -[Associative] -{ - def foo : int( n : int ) - { - return = n * n; - } - - [Imperative] - { - - a = [ 0, 1, 2, 3, 4, 5 ]; - x = 0; - for ( i in a ) - { - x = x + foo ( i ); - } - - y = 0; - j = 0; - while ( a[j] <= 4 ) - { - y = y + foo ( a[j] ); - j = j + 1; - } - - z = 0; - - if( x == 55 ) - { - x = foo (x); - } - - if ( x == 50 ) - { - x = 2; - } - elseif ( y == 30 ) - { - y = foo ( y ); - } - - if ( x == 50 ) - { - x = 2; - } - elseif ( y == 35 ) - { - x = 3; - } - else - { - z = foo (5); - } - } - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1122_T23_Function_Call_As_Function_Call_Arguments() - { - Dictionary> map = new Dictionary>(); - string src = @"c1; -[Associative] -{ - def foo : double ( a : double , b :double ) - { - return = a + b ; - } - - def foo2 : double ( a : double , b :double ) - { - return = foo ( a , b ) + foo ( a, b ); - } - - a1 = 2; - b1 = 4; - c1 = foo2( foo (a1, b1 ), foo ( a1, foo (a1, b1 ) ) ); - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1133_T34_Function_With_Mismatching_Return_Type() - { - Dictionary> map = new Dictionary>(); - string src = @"b1; -[Associative] -{ - def foo1 : double ( a : double ) - { - return = true; - } - - dummyArg = 1.5; - - b1 = foo1 ( dummyArg ); - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1134_T35_Function_With_Mismatching_Return_Type() - { - Dictionary> map = new Dictionary>(); - string src = @"b2; -[Associative] -{ - def foo2 : double ( a : double ) - { - return = 5; - } - - dummyArg = 1.5; - - b2 = foo2 ( dummyArg ); - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1135_T36_Function_With_Mismatching_Return_Type() - { - Dictionary> map = new Dictionary>(); - string src = @"b2; -[Associative] -{ - def foo3 : int ( a : double ) - { - return = 5.5; - } - - dummyArg = 1.5; - - b2 = foo3 ( dummyArg ); - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1137_T38_Function_With_Mismatching_Return_Type() - { - Dictionary> map = new Dictionary>(); - string src = @"b2; -[Associative] -{ - def foo3 : int[] ( a : double ) - { - return = a; - } - - dummyArg = 1.5; - - b2 = foo3 ( dummyArg ); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1138_T39_Function_With_Mismatching_Return_Type() - { - Dictionary> map = new Dictionary>(); - string src = @"b2; -[Associative] -{ - def foo3 : int ( a : double ) - { - return = [1, 2]; - } - - dummyArg = 1.5; - - b2 = foo3 ( dummyArg ); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1139_T40_Function_With_Mismatching_Return_Type() - { - Dictionary> map = new Dictionary>(); - string src = @"[Associative] -{ - def foo3 : int[][] ( a : double ) - { - return = [ [2.5], [3.5]]; - } - - dummyArg = 1.5; - - b2 = foo3 ( dummyArg ); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1140_T41_Function_With_Mismatching_Return_Type() - { - Dictionary> map = new Dictionary>(); - string src = @"[Associative] -{ - def foo3 : int[][] ( a : double ) - { - return = [ [2.5], 3]; - } - - dummyArg = 1.5; - - b2 = foo3 ( dummyArg ); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1141_T42_Function_With_Mismatching_Return_Type() - { - Dictionary> map = new Dictionary>(); - string src = @"b2; -[Associative] -{ - def foo3 : bool[]..[] ( a : double ) - { - return = [ [2], 3]; - } - - dummyArg = 1.5; - - b2 = foo3 ( dummyArg ); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1142_T43_Function_With_Matching_Return_Type() - { - Dictionary> map = new Dictionary>(); - string src = @"b2; -[Associative] -{ - def foo3 : int[]..[] ( a : double ) - { - return = [ [ 0, 2 ], [ 1 ] ]; - } - - dummyArg = 1.5; - - b2 = foo3 ( dummyArg )[0][0]; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1144_T45_Function_With_Mismatching_Argument_Type() - { - Dictionary> map = new Dictionary>(); - string src = @"b2; -[Associative] -{ - def foo : double ( a : double ) - { - return = 1.5; - } - - b2 = foo ( 1 ); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1146_T47_Function_With_Mismatching_Argument_Type() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -[Associative] -{ - def foo : double ( a : double ) - { - return = 1.5; - } - - b2 = foo ( true); - c = 3; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1149_T50_Function_With_Mismatching_Argument_Type() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -[Associative] -{ - def foo : double ( a : int[] ) - { - return = 1.5; - } - aa = [ ]; - b2 = foo ( aa ); - c = 3; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1150_T51_Function_With_Mismatching_Argument_Type() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -[Associative] -{ - def foo : double ( a : double[] ) - { - return = 1.5; - } - aa = [1, 2 ]; - b2 = foo ( aa ); - c = 3; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1151_T52_Function_With_Mismatching_Argument_Type() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -[Associative] -{ - def foo : double ( a : double[] ) - { - return = 1.5; - } - aa = 1.5; - b2 = foo ( aa ); - c = 3; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1152_T53_Function_Updating_Argument_Values() - { - Dictionary> map = new Dictionary>(); - string src = @"aa;b2;c; -[Associative] -{ - def foo : double ( a : double ) - { - a = 4.5; - return = a; - } - aa = 1.5; - b2 = foo ( aa ); - c = 3; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1155_T56_Function_Updating_Argument_Values() - { - Dictionary> map = new Dictionary>(); - string src = @"aa;bb;c; -[Associative] -{ - def foo : int[] ( a : int[] ) - { - a[0] = 0; - return = a; - } - aa = [ 1, 2 ]; - bb = foo ( aa ); - - c = 3; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1156_T57_Function_Using_Local_Var_As_Same_Name_As_Arg() - { - Dictionary> map = new Dictionary>(); - string src = @"aa;bb;c; -[Associative] -{ - def foo : int ( a : int ) - { - a = 3; - b = a + 1; - return = b; - } - - aa = 1; - bb = foo ( aa ); - c = 3; - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1157_T58_Function_With_No_Argument() - { - Dictionary> map = new Dictionary>(); - string src = @"c1;c2; - def foo : int ( ) - { - return = 3; - } - - [Associative] - { - c1 = foo(); - } - - [Imperative] - { - c2 = foo(); - } -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1158_T59_Function_With_No_Return_Stmt() - { - Dictionary> map = new Dictionary>(); - string src = @"c; - def foo : int ( a : int ) - { - b = a + 1; - } - - [Associative] - { - c = foo(1); - } - - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1159_T60_Function_With_No_Return_Stmt() - { - Dictionary> map = new Dictionary>(); - string src = @"c; - def foo : int ( a : int ) - { - b = a + 1; - } - - [Imperative] - { - c = foo(1); - } - - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1173_T74_Function_With_Simple_Replication_Associative() - { - Dictionary> map = new Dictionary>(); - string src = @"x;y; -[Associative] -{ - def foo : int ( a : int ) - { - return = a + 1; - } - - x = [ 1, 2, 3 ]; - y = foo(x); - -} - - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1175_T75_Function_With_Replication_In_Two_Args() - { - Dictionary> map = new Dictionary>(); - string src = @"y; -[Associative] -{ - def foo : int ( a : int, b : int ) - { - return = a + b; - } - - x1 = [ 1, 2, 3 ]; - x2 = [ 1, 2, 3 ]; - - y = foo ( x1, x2 ); - -} - - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1176_T76_Function_With_Replication_In_One_Arg() - { - Dictionary> map = new Dictionary>(); - string src = @"y; -[Associative] -{ - def foo : int ( a : int, b : int ) - { - return = a + b; - } - - x1 = [ 1, 2, 3 ]; - x2 = 1; - - y = foo ( x1, x2 ); - -} - - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1177_T77_Function_With_Simple_Replication_Guide() - { - Dictionary> map = new Dictionary>(); - string src = @"a1;a2;a3;a4; -[Associative] -{ - def foo : int ( a : int, b : int ) - { - return = a + b; - } - - x1 = [ 1, 2 ]; - x2 = [ 1, 2 ]; - y = foo( x1<1> , x2<2> ); - a1 = y[0][0]; - a2 = y[0][1]; - a3 = y[1][0]; - a4 = y[1][1]; - -} - - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1178_T78_Function_call_By_Reference() - { - Dictionary> map = new Dictionary>(); - string src = @"c;d; -[Associative] -{ - def foo : int ( a : int, b : int ) - { - a = a + b; - b = 2; - return = a + b; - } - - a = 1; - b = 2; - c = foo (a, b ); - d = a + b; - -} - - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1180_T80_Function_call_By_Reference() - { - Dictionary> map = new Dictionary>(); - string src = @"[Associative] -{ - def foo : int ( a : int, b : int ) - { - c = [Imperative] - { - d = 0; - if( a > b ) - d = 1; - return = d; - } - a = a + c; - b = b + c; - return = a + b; - } - - a = 2; - b = 1; - c = foo (a, b ); - d = a + b; - -} - - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1181_T81_Function_Calling_Imp_From_Assoc() - { - Dictionary> map = new Dictionary>(); - string src = @"b; -[Associative] -{ - def foo : int ( a : int ) - { - c = [Imperative] - { - d = 0; - if( a > 1 ) - { - d = 1; - } - return = d; - } - return = a + c; - } - - a = 2; - b = foo (a ); -} - - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1183_T83_Function_With_Null_Arg() - { - Dictionary> map = new Dictionary>(); - string src = @"b; -def foo:int ( a : int ) -{ - return = a; -} -[Associative] -{ - b = foo( null ); -} - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1187_T87_Function_Returning_From_Imp_Block_Inside_Assoc() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : int( a : int) -{ - temp = [Imperative] - { - if ( a == 0 ) - { - return = 0; - } - return = a ; - } - return = temp; -} -x = foo( 0 ); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1188_T88_Function_With_Collection_Argument() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : double (arr : double[]) -{ - return = 0; -} -arr = [1,2,3,4]; -sum = foo(arr); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1189_T89_Function_With_Replication() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : double (arr1 : double[], arr2 : double[] ) -{ - return = arr1[0] + arr2[0]; -} -arr = [ [2.5,3], [1.5,2] ]; -two = foo (arr, arr); -t1 = two[0]; -t2 = two[1]; -//arr1 = {2.5,3}; -//arr2 = {1.5,2}; -//two = foo(arr1, arr2); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1191_T91_Function_With_Default_Arg() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo:double(x:int = 2, y:double = 5.0) -{ - return = x + y; -} -a = foo(); -b = foo(1, 3.0); -c = foo(); -d;e;f; -[Imperative] -{ - d = foo(); - e = foo(1, 3.0); - f = foo(); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1192_T92_Function_With_Default_Arg_Overload() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo:double() -{ - return = 0.0; -} -def foo:double(x : int = 1, y : double = 2.0) -{ - return = x + y; -} -a = foo(); -b = foo(3); -c = foo(3.4); // not found, null -d = foo(3, 4.0); -e = foo(1, 2.0, 3); // not found, null -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1204_TV101_Indexing_IntoArray_InFunctionCall_1463234() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo() -{ -return = [1,2]; -} -t = foo()[0];"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1206_TV101_Indexing_Intoemptyarray_InFunctionCall_1463234_3() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo() -{ -return = []; -} -t = foo()[0];"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1207_TV101_Indexing_IntoNested_FunctionCall_1463234_5() - { - Dictionary> map = new Dictionary>(); - string src = @" - def foo() - { - return = [foo2()[0],foo2()[1]]; - } -def foo2() -{ -return = [1,2]; -} -a=test.test()[0]; -t = foo()[0];"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1208_TV101_Indexing_Intosingle_InFunctionCall_1463234_() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo() -{ -return = [1,2]; -} -t = foo()[0];"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1209_TV101_Indexing_Intosingle_InFunctionCall_1463234_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo() -{ -return = [1]; -} -t = foo()[0];"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1210_TV101_Indexing_Intovariablenotarray_InFunctionCall_1463234_4() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo() -{ -return = 1; -} -t = foo()[0];"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1220_TV12_Function_With_Argument_Update_Associative() - { - Dictionary> map = new Dictionary>(); - string src = @"e;f; -[Associative] -{ - def update:int( a:int, b:int ) - { - a = a + 1; - b = b + 1; - return = a + b; - } - - c = 5; - d = 5; - e = update(c,d); - e = c; - f = d; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1222_TV14_Empty_Functions_Associative() - { - Dictionary> map = new Dictionary>(); - string src = @"b; -[Associative] -{ - def foo:int ( a : int ) - { - } - - b = foo( 1 ); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1224_TV16_Function_With_No_Return_Statement() - { - Dictionary> map = new Dictionary>(); - string src = @"b; - def foo : int( a : int ) - { - a = a + 1; - } - [Imperative] - { - b = foo( 1 ); - }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1225_TV17_Function_Access_Local_Variables_Outside() - { - Dictionary> map = new Dictionary>(); - string src = @" - def foo: int ( a : int ) - { - b = a + 1; - c = a * 2; - return = a; - } -e;f; -[Imperative] -{ - d = foo( 1 ); - e = b; - f = c; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1226_TV18_Function_Access_Global_Variables_Inside() - { - Dictionary> map = new Dictionary>(); - string src = @" global = 5; - global2 = 6; - d; - - def foo: int ( a : int ) - { - b = a + global; - c = a * 2 * global2; - return = b + c; - } -[Imperative] -{ - d = foo( 1 ); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1227_TV19_Function_Modify_Global_Variables_Inside() - { - Dictionary> map = new Dictionary>(); - string src = @" global = 5; - e; - - def foo: int ( a : int ) - { - global = a + global; - - return = a; - } -[Imperative] -{ - d = foo( 1 ); - e = global; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1231_TV23_Defect_1455152() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -d; -def foo : int ( a : int ) -{ - b = a + 1; -} -[Associative] -{ - c = foo(1); -} -[Imperative] -{ - d = foo(1); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1232_TV24_Defect_1454958() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo: int( a : int , b : int) -{ - return = a + b; -} -b;c; -[Associative] -{ - b = Foo( 1,2 ); -} -[Imperative] -{ - c = foo( 1 ); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1234_TV26_Defect_1454923_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def function1: int ( a : int, b : int ) -{ - return = -1 * (a * b ); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1235_TV27_Defect_1454688() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Associative] -{ - a = function1(1,2,3); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1236_TV28_Defect_1454688_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Imperative] -{ - a = function(1,2,3); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1237_TV29_Overloading_Different_Number_Of_Parameters() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo:int ( a : int ) -{ - return = a + 1; -} -def foo:int ( a : int, b : int, c: int ) -{ - return = a + b + c ; -} -c = foo( 1 ); -d = foo( 3, 2, 0 ); -a; -[Imperative] -{ - a = foo( 1, 2, 3 ); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1238_TV30_Overloading_Different_Parameter_Types() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo:int ( a : int ) -{ - return = 2 * a; -} -def foo:int ( a : double ) -{ - return = 2; -} - b = foo( 2 ); - c = foo(3.4); -d; -[Imperative] -{ - d = foo(-2.4); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1239_TV31_Overloading_Different_Return_Types() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo: int( a: int ) -{ - return = 1; -} -// This is the same definition regardless of return type -def foo: double( a : int ) -{ - return = 2.3; -} -b = foo ( 1 );"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1240_TV32_Function_With_Default_Argument_Value() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : int ( a = 5, b = 5 ) -{ - return = a + b; -} -c1;c2;c3;c4; -[Imperative] -{ - c1 = foo ( ); - c2 = foo ( 1 ); - c3 = foo ( 1, 2 ); - c4 = foo ( 1, 2, 3 ); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1241_TV32_Function_With_Default_Argument_Value_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( a : int = 5, b : double = 5.5, c : bool = true ) -{ - return = c == true ? a : b; -} -def foo ( a : double = 5, b : double = 5.5, c : bool = true ) -{ - return = c == true ? a : b; -} -c1;c2;c3;c4; -[Imperative] -{ - c1 = foo ( ); - c2 = foo ( 1 ); - c3 = foo ( 1.5, 2 ); - c4 = foo ( 1, 2, 0 ); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1242_TV32_Function_With_Default_Argument_Value_3() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( a : int, b : double = 5, c : bool = true) -{ - return = c == true ? a : b; -} -def foo2 ( a , b = 5, c = true) -{ - return = c == true ? a : b; -} -c1;c3;c3;c4; -d1 = foo2 ( ); -d2 = foo2 ( 1 ); -d3 = foo2 ( 2, 3 ); -d4 = foo2 ( 4, 5, false ); -d5 = -[Imperative] -{ - c1 = foo ( ); - c2 = foo ( 1 ); - c3 = foo ( 2, 3 ); - c4 = foo ( 4, 5, false ); - return = [ c1, c2, c3, c4 ]; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1243_TV33_Function_Overloading() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( a : int = 5, b : double = 5.5, c : bool = true ) -{ - return = c == true ? a : b; -} -def foo ( a : double = 6, b : double = 5.5, c : bool = true ) -{ - return = c == true ? a : b; -} -c1;c2;c3;c4; -[Imperative] -{ - c1 = foo ( ); - c2 = foo ( 1 ); - c3 = foo ( 1.5, 2 ); - c4 = foo ( 1, 2, 0 ); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1244_TV33_Function_Overloading_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( a : int , b : double , c : bool ) -{ - return = a; -} -def foo ( a : double, b : double , c : int ) -{ - return = b; -} -c4;c5;c6; -[Imperative] -{ - c4 = foo ( 1, 2, 0 ); - c5 = foo ( 1.5, 2.5, 0 ); - c6 = foo ( 1.5, 2.5, true ); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1245_TV33_Overloading_Different_Order_Of_Parameters() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : int ( a :int, b : double ) -{ - return = 2; -} -def foo : int( c : double, d : int ) -{ - return = 3; -} -c = foo( 1,2.5 ); -d = foo ( 2.5, 1 ); -//e = foo ( 2.5, 2.5 ); -f = foo ( 1, 2 ); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1247_TV35_Implicit_Conversion_Int_To_Double() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : double ( a: double ) -{ - return = a + 2.5; -} - b = foo( 2 ); - c; -[Imperative] -{ - c = foo( 3 ); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1248_TV36_Implicit_Conversion_Return_Type() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo: bool ( a : double, b : double ) -{ - return = 0.5; -} -c = foo ( 2.3 , 3 );"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1249_TV37_Overloading_With_Type_Conversion() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : int ( a : double, b : double ) -{ - return = 1; -} -def foo : int ( a : int, b : int ) -{ - return = 2; -} -def foo : int ( a : int, b : double ) -{ - return = 3; -} -a = foo ( 1,2 ); -b = foo ( 2,2 ); -c = foo ( 1, 2.3 ); -d = foo ( 2.3, 2 ); - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1252_TV40_Defect_1449956_3() - { - Dictionary> map = new Dictionary>(); - string src = @"x;y; -[Associative] -{ - def recursion : int( a : int) - { - temp = [Imperative] - { - if ( a ==0 || a < 0) - { - return = 0; - } - return = a + recursion( a - 1 ); - } - return = temp; - } - x = recursion( 4 ); - y = recursion( -1 ); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1254_TV42_Defect_1454959() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b;c; -def Level1 : int (a : int) -{ - return = Level2(a+1); -} - -def Level2 : int (a : int) -{ - return = a + 1; -} -input = 3; -result = Level1(input); -[Associative] -{ - a = Level1(4); - b = foo (a); - c = [Imperative] - { - return = foo2( foo (a ) ); - } -} -def foo ( a ) -{ - return = a + foo2(a); -} -def foo2 ( a ) -{ - return = a; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1259_TV47_Defect_1456087() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : int ( a : double, b : double ) -{ - return = 2; -} -def foo : int ( a : int, b : int ) -{ - return = 1; -} -def foo : int ( a : int, b : double ) -{ - return = 3; -} -a;b;c;d; -[Imperative] -{ - a = foo ( 1, 2 ); - b = foo ( 2.5, 2.5 ); - c = foo ( 1, 2.3 ); - d = foo ( 2.3, 2 ); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1260_TV48_Defect_1456110() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo : int( a : int) -{ - temp = [Imperative] - { - if ( a == 0 ) - { - return = 0; - } - return = a ; - } - return = temp; -} -x = foo( 0 ); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1261_TV49_Defect_1456110() - { - Dictionary> map = new Dictionary>(); - string src = @" -def recursion : int(a : int) -{ - loc = [Imperative] - { - if (a <= 0) - { - return = 0; - } - return = a + recursion(a - 1); - } - return = loc; -} -a = 10; -[Imperative] -{ - x = recursion(a); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1262_TV49_Defect_1456110_2() - { - Dictionary> map = new Dictionary>(); - string src = @" -def recursion : int(a : int) -{ - loc = [Imperative] - { - if (a <= 0) - { - return = 0; - } - return = a + recursion(a - 1); - } - return = loc; -} -a = 10; -[Imperative] -{ - x = recursion(a); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1271_TV55_Defect_1456571() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo(arr) -{ - retArr = 3; - [Imperative] - { - retArr = 5; - } - return = retArr; -} - x = 0.5; - x = foo(x);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1272_TV56_Defect_1456571_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo(arr) -{ - retArr = 3; - [Associative] - { - retArr = 5; - } - return = retArr; -} -x; - [Imperative] - { - x = 0.5; - x = foo(x); - }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1275_TV58_Defect_1455090() - { - Dictionary> map = new Dictionary>(); - string src = @" def foo( a:int[] ) - { - a[0][0] = 1; - return = a; - } - b = [ [0,2,3], [4,5,6] ]; - d = foo( b ); - c = d[0];"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1278_TV59_Defect_1455278_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def multiply : double[] (a : double[]) -{ - temp = [Imperative] - { - b = [0, 10]; - counter = 0; - - for( y in a ) - { - b[counter] = y * y; - counter = counter + 1; - } - - return = b; - } - return = temp; -} - - x = [2.5,10.0]; - x_squared = multiply( x );"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1279_TV60_Defect_1455278_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def multiply : double[] (a : double[]) -{ - temp = [Imperative] - { - b = [0, 10]; - counter = 0; - - for( y in a ) - { - b[counter] = y * y; - counter = counter + 1; - } - - return = b; - } - return = temp; -} - - x = [2.5,10]; - x_squared = multiply( x );"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1280_TV60_Defect_1455278_3() - { - Dictionary> map = new Dictionary>(); - string src = @" - def power(num : double, exponent : int) - { - temp = [Imperative] - { - result = 1.0; - counter = 0; - while(counter < exponent ) - { - result = result * num; - counter = counter + 1; - } - return = result; - } - return = temp; - } - - x = power(3.0, 2); - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1281_TV61_Defect_1455278_3() - { - Dictionary> map = new Dictionary>(); - string src = @" - def power(num : double, exponent : int) - { - temp = [Imperative] - { - result = 1.0; - counter = 0; - while(counter < exponent ) - { - result = result * num; - counter = counter + 1; - } - return = result; - } - return = temp; - } - - x = power(3.0, 2); - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1282_TV61_Defect_1455278_4() - { - Dictionary> map = new Dictionary>(); - string src = @" - def power(num : double, exponent : int) - { - temp = [Imperative] - { - result = 1.0; - counter = 0; - if(num > exponent) - { - while(counter < exponent ) - { - result = result * num; - counter = counter + 1; - } - } - return = result; - } - return = temp; - } - - x = power(3.0, 2); - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1284_TV62_Defect_1455090() - { - Dictionary> map = new Dictionary>(); - string src = @" def foo:int[]..[] ( a:int[]..[] ) - { - a[0][0] = 1; - return = a; - } - b = [ [0,2,3], [4,5,6] ]; - d = foo( b ); - c = d[0];"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1286_TV63_Defect_1455090_2() - { - Dictionary> map = new Dictionary>(); - string src = @" - def foo ( a : double[]..[] ) - { - a[0][0] = 2.5; - return = a; - } - - a = [ [2.3,3.5],[4.5,5.5] ]; - - a = foo( a ); - c = a[0]; - d; - [Imperative] - { - b = [ [2.3], [2.5] ]; - b = foo( b ); - d = b[0]; - } - - - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1297_TV71_Defect_1456108_2() - { - Dictionary> map = new Dictionary>(); - string src = @" def collectioninc: int[]( a : int[] ) - { - j = 0; - a = [Imperative] - { - for( i in a ) - { - a[j] = a[j] + 1; - j = j + 1; - } - return = a; - } - return = a; - } - d = [ 1,2,3 ]; - c = collectioninc( d ); - b; - [Imperative] - { - b = collectioninc( d ); - } -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1301_TV73_Defect_1451831() - { - Dictionary> map = new Dictionary>(); - string src = @"y; -[Associative] -{ - - a = 1; - b = 1; - - def test:int( a:int, b:int, c : int, d : int ) - { - - y = [Imperative] - { - if( a == b ) - { - return = 1; - } - else - { - return = 0; - } - } - - return = y + c + d; - } - - c = 1; - d = 1; - - y = test ( a , b, c, d); - - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1303_TV75_Defect_1456870() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo1 ( b ) -{ - return = b == 0 ? 0 : b+1; - -} -def foo2 ( x ) -{ - y = [Imperative] - { - if(x > 0) - { - return = x >=foo1(x) ? x : foo1(x); - } - return = x >=2 ? x : 2; - } - x1 = y == 0 ? 0 : y; - return = x1 + y; -} -a1 = foo1(4); -a2 = foo2(3); -//thisTest.Verification(mirror, ""a1"", 5, 0); // fails"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1304_TV76_Defect_1456112() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo1 : double (arr : double[]) -{ - return = 0; -} -arr = [1,2,3,4]; -sum = foo1(arr); -def foo2 : double (arr : double) -{ - return = 0; -} -arr1 = [1.0,2.0,3.0,4.0]; -sum1 = foo2(arr1); -sum2 = foo1(arr); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1305_TV76_Defect_1456112_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo1 : double (arr : double[][]) -{ - return = arr[0][0]; -} -sum1;sum2; -[Imperative] -{ - arr1 = [ [1, 2.0], [true, 4] ]; - sum1 = foo1(arr); - x = 1; - arr2 = [ [1, 2.0], [x, 4] ]; - sum2 = foo1(arr2); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1314_TV81_Defect_1458187() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( a ) -{ - x = [Imperative] - { - if ( a == 0 ) - return = a; - else - return = a + 1; - } - return = x; -} -a = foo( 2 ); -b = foo(false); -c = foo(true);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1315_TV81_Defect_1458187_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( a ) -{ - x = (a == 1)?a:0; - return = x + a; -} -a = foo( 2 ); -b = foo(false); -c = foo(true);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1316_TV82_Defect_1460892() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( a : int ) -{ - return = a + 1; -} -def foo2 ( b : int, f1 : function ) -{ - return = f1( b ); -} -a = foo2 ( 10, foo ); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1317_TV83_Function_Pointer() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( a : bool ) -{ - return = a ; -} -def foo2 ( b : int, f1 : function ) -{ - return = f1( b ); -} -a = foo2 ( 0, foo ); -def poo ( a : int ) -{ - return = a ; -} -def poo2 ( b : bool, f1 : function ) -{ - return = f1( b ); -} -a2 = poo2 ( false, poo ); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1318_TV83_Function_Pointer_Collection() - { - Dictionary> map = new Dictionary>(); - string src = @"def count ( a : bool[]..[] ) -{ - c = 0; - c = [Imperative] - { - for ( i in a ) - { - c = c + 1; - } - return = c; - } - return = c ; -} -def foo ( b : bool[]..[], f1 : function ) -{ - return = count( b ); -} -a = foo ( [ true, false, [ true, true ] ], count ); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1319_TV84_Function_Pointer_Implicit_Conversion() - { - Dictionary> map = new Dictionary>(); - string src = @"def count ( a : int[] ) -{ - c = 0; - x = [Imperative] - { - for ( i in a ) - { - c = c + 1; - } - return = c; - } - return = x ; -} -def foo ( b : double[], f1 : function ) -{ - return = count( b ); -} -a = foo ( [ 1.0, 2.6 ], count ); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1320_TV84_Function_Pointer_Implicit_Conversion_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def count ( a : double[]..[] ) -{ - c = 0; - x = [Imperative] - { - for ( i in a ) - { - c = c + 1; - } - return = c; - } - return = x ; -} -def foo ( b : int[]..[], f1 : function ) -{ - return = count( b ); -} -a = foo ( [ 1, 2 , [3, 4] ], count ); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1321_TV84_Function_Pointer_Implicit_Conversion_3() - { - Dictionary> map = new Dictionary>(); - string src = @"def count ( a : double[] ) -{ - c = 0; - x = [Imperative] - { - for ( i in a ) - { - c = c + 1; - } - return = c; - } - return = x ; -} -def foo ( b : int[], f1 : function ) -{ - return = count( b ); -} -a = foo ( [ 1, 2, [ 3, 4 ] ], count ); -d = foo ( [ 2, 2.5, [ 1, 1.5 ], 1 , false], count ); -// boolean can't be converted to double, so the following statement -// will generate a method resultion fail exception -// b = foo ( { true, false }, count ); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1322_TV84_Function_Pointer_Implicit_Conversion_4() - { - Dictionary> map = new Dictionary>(); - string src = @"def count ( a : double[] ) -{ - c = 0; - x = [Imperative] - { - for ( i in a ) - { - c = c + 1; - } - return = c; - } - return = x ; -} -def foo ( b : int[], f1 : function ) -{ - return = count( b ); -} -[Imperative] -{ - a = foo ( [ 1, 2, [ 3, 4 ] ], count ); - d = foo ( [ 2, 2.5, [ 1, 1.5 ], 1 , false], count ); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1323_TV84_Function_Pointer_Negative() - { - Dictionary> map = new Dictionary>(); - string src = @"def greater ( a , b ) -{ - c = [Imperative] - { - if ( a > b ) - return = a; - else - return = b; - } - return = c ; -} -def greatest ( a : double[], f : function ) -{ - c = a[0]; - [Imperative] - { - for ( i in a ) - { - c = f( i, c ); - } - } - return = c ; -} -a; -[Imperative] -{ - a = greatest ( [ 1.5, 6, 3, -1, 0 ], greater2 ); - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1324_TV84_Function_Pointer_Using_2_Functions() - { - Dictionary> map = new Dictionary>(); - string src = @"def greater ( a , b ) -{ - c = [Imperative] - { - if ( a > b ) - return = a; - else - return = b; - } - return = c ; -} -def greatest ( a : double[], greater : function ) -{ - c = a[0]; - [Imperative] - { - for ( i in a ) - { - c = greater( i, c ); - } - } - return = c ; -} -def foo ( a : double[], greatest : function , greater : function) -{ - return = greatest ( a, greater ); -} -a; -[Imperative] -{ - a = foo ( [ 1.5, 6, 3, -1, 0 ], greatest, greater ); - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1326_TV86_Defect_1456728() - { - Dictionary> map = new Dictionary>(); - string src = @"def f1 (arr : double[] ) -{ - return = arr; -} -def f2 (arr : double[] ) -{ - return = [ arr[0], arr[1] ]; -} -a = f1( [ null, null ] ); -b = f2( [ null, null ] ); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1332_TV88_Defect_1463489() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo: bool ( ) -{ - return = 0.24; -} -c = foo ( ); //expected true, received -d = [Imperative] -{ - return = foo(); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1333_TV88_Defect_1463489_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo: bool ( x : bool ) -{ - return = x && true; -} -c = foo ( 0.6 ); -c1 = foo ( 0.0 ); -d = [Imperative] -{ - return = foo(-3.5); -} -d1 = [Imperative] -{ - return = foo(0.0); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1336_TV89_typeConversion_FunctionArguments_1467060() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( x : double[]) -{ - return = x; -} -a2 = [ 2, 4, 3.5 ]; -b2 = foo (a2);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1337_TV89_typeConversion_FunctionArguments_1467060_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( x : double[]) -{ - return = x; -} -a2 = [ 2, 4, 3]; -b2 = foo ( a2 );"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1338_TV89_typeConversion_FunctionArguments_1467060_3() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( x : int[]) -{ - return = x; -} -a1 = [ 2, 4.1, 3.5]; -b1 = foo ( a1 );"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1339_TV89_typeConversion_FunctionArguments_1467060_4() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( x : int) -{ - return = x; -} -a1 = [ 2, 4.1, false]; -b1 = foo ( a1 );"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1340_TV89_typeConversion_FunctionArguments_1467060_5() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( x : int[]) -{ - return = x; -} -a1 = [ 2, 4.1, [1,2]]; -b1 = foo ( a1 );"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1341_TV89_typeConversion_FunctionArguments_1467060_6() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( x : int[]) -{ - return = x; -} -a1 = [ null, 5, 6.0]; -b1 = foo ( a1 );"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1342_TV89_typeConversion_FunctionArguments_1467060_7() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( x : int[]) -{ - return = x; -} -a1 = [ null, null, null]; -b1 = foo ( a1 );"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1343_TV89_typeConversion_FunctionArguments_1467060_8() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo:int[]( x : int[]) -{ - return = x; -} -a1 = [1.1,2.0,3]; -b1 = foo ( a1 );"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1344_TV89_typeConversion_FunctionArguments_1467060_9() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( x : int[]) -{ - return = x; -} -a1 = [ 1, null, 6.0]; -b1 = foo ( a1 );"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1346_TV90_Defect_1463474_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 3; -def foo : void ( ) -{ - a = 2; -} -foo(); -b1 = a; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1347_TV90_Defect_1463474_3() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 3; -def foo : void ( ) -{ - a = 2; - return = -3; -} -c1 = foo(); -b1 = a; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1365_TV97_Heterogenous_Objects_As_Function_Arguments_With_Replication() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( x : double) -{ - return = x; -} -a1 = [ 2.5, 4 ]; -b1 = foo ( a1 ); -a2 = [ 3, 4, 2.5 ]; -b2 = foo ( a2 ); -a3 = [ 3, 4, 2 ]; -b3 = foo ( a3 ); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1367_TV98_Method_Overload_Over_Rank_Of_Array() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo(x : int[]) -{ - return = 1; -} -def foo(x : int[]..[]) -{ - return = 2; -} -def foo(x : int[][]) -{ - return = 0; -} - -x = foo ( [ [ 0,1], [2, 3] ] ); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1369_TV99_Defect_1463456_Array_By_Reference_Issue_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def A (a: int []) -{ -return = a; -} -val = [1,2,3]; -b = A(val); -b[0] = 100; -t = val[0]; //expected 100, received 1"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1370_BaseImportAssociative() - { - Dictionary> map = new Dictionary>(); - string src = @"[Associative] -{ - a = 5; - def twice : int (val: int) - { - return = val * 2; - } - b = twice(a); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1372_BaseImportWithVariableClassInstance() - { - Dictionary> map = new Dictionary>(); - string src = @"import (""T009_BasicImport_TestClassInstanceMethod.ds""); -a = 5; -b = 2*a;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1374_basicImport1() - { - Dictionary> map = new Dictionary>(); - string src = @"def Scale (arr : double[], scalingFactor : double) -{ - scaledArr = [Imperative] - { - counter = 0; - for(val in arr) - { - arr[counter] = scalingFactor * val; - counter = counter + 1; - } - return = arr; - } - return = scaledArr; -} -a = 1; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1376_basicImport3() - { - Dictionary> map = new Dictionary>(); - string src = @"def Scale (arr : double[], scalingFactor : double) -{ - scaledArr = [Imperative] - { - counter = 0; - for(val in arr) - { - arr[counter] = scalingFactor * val; - counter = counter + 1; - } - return = arr; - } - return = scaledArr * 2; -} -a = 3; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1377_T001_BasicImport_CurrentDirectory() - { - Dictionary> map = new Dictionary>(); - string src = @"import (""basicImport.ds""); -a = [1.1,2.2]; -b = 2; -c = Scale(a,b);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1378_T002_BasicImport_AbsoluteDirectory() - { - Dictionary> map = new Dictionary>(); - string src = @"import (""basicImport.ds""); -a = [1.1,2.2]; -b = 2; -c = Scale(a,b); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1379_T004_BasicImport_CurrentDirectoryWithDotAndSlash() - { - Dictionary> map = new Dictionary>(); - string src = @"import ("".\basicImport.ds""); -a = [1.1,2.2]; -b = 2; -c = Scale(a,b);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1380_T005_BasicImport_RelativePath() - { - Dictionary> map = new Dictionary>(); - string src = @"import ("".\\ExtraFolderToTestRelativePath\\basicImport.ds""); -a = [1.1,2.2]; -b = 2; -c = Scale(a,b);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1381_T006_BasicImport_TestFunction() - { - Dictionary> map = new Dictionary>(); - string src = @"import (""basicImport.ds""); -a = [1.1,2.2]; -b = 2; -c = Scale(a,b); -d = Sin(30.0); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1386_T012_BaseImportImperative() - { - Dictionary> map = new Dictionary>(); - string src = @"import (""BaseImportImperative.ds""); -a = 1; -b = a; -c; -[Associative] -{ - c = 3 * b; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1390_T016_BaseImportAssociative() - { - Dictionary> map = new Dictionary>(); - string src = @"import (""BaseImportAssociative.ds""); -a = 10; -b = 20;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1391_T017_BaseImportWithVariableClassInstance_Associativity() - { - Dictionary> map = new Dictionary>(); - string src = @"import (""BaseImportWithVariableClassInstance.ds""); -c = a + b; -a = 10;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1394_T020_MultipleImport_WithSameFunctionName() - { - Dictionary> map = new Dictionary>(); - string src = @"import (""basicImport1.ds""); -import (""basicImport3.ds""); -arr = [ 1.0, 2.0, 3.0 ]; -a1 = Scale( arr, 4.0 ); -b = a * 2;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1395_T021_Defect_1457354() - { - Dictionary> map = new Dictionary>(); - string src = @"import (""c:\\wrongPath\\test.ds""); -a = 1; -b = a * 2;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1396_T021_Defect_1457354_2() - { - Dictionary> map = new Dictionary>(); - string src = @"import (""basicImport""); -a = 1; -b = a * 2;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1397_T021_Defect_1457354_3() - { - Dictionary> map = new Dictionary>(); - string src = @"import (""basicImport12.ds""); -a = 1; -b = a * 2;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1398_T022_Defect_1457740() - { - Dictionary> map = new Dictionary>(); - string src = @"import (""basicImport1.ds""); -import (""basicImport3.ds""); -arr1 = [ 1, 3, 5 ]; -temp = Scale( arr1, a ); -a = a; -b = 2 * a;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1399_basicImport() - { - Dictionary> map = new Dictionary>(); - string src = @"def Scale (arr : double[], scalingFactor : double) -{ - scaledArr = [Imperative] - { - counter = 0; - for(val in arr) - { - arr[counter] = scalingFactor * val; - counter = counter + 1; - } - return = arr; - } - return = scaledArr; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1400_T003_BasicImport_ParentPath() - { - Dictionary> map = new Dictionary>(); - string src = @"import (""../basicImport.ds""); -a = [1.1,2.2]; -b = 2; -c = Scale(a,b);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1402_Test_4_10_contains() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 5; -b = 7; -c = 9; -d = [a, b]; -f = Contains(d, a); // true -g = Contains(d, c); // false -h = Contains([10,11],11); // true collection built �on the fly� - // with �literal� values -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1403_Test_4_11_indexOf() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 5; -b = 7; -c = 9; -d = [a, b, c]; -f = IndexOf(d, b); // 1 -g = d[f+1]; // c -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1405_Test_4_13_Transpose() - { - Dictionary> map = new Dictionary>(); - string src = @"a =[[1,2],[3,4]]; -b = a[0][0]; // b = 1 -c = a [0][1]; // c = 2 -a = Transpose(a); // b = 1; c =3 -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1406_Test_4_14_isUniformDepth() - { - Dictionary> map = new Dictionary>(); - string src = @"myNonUniformDepth2Dcollection = [[1, 2, 3], [4, 5], 6]; -individualMemberB = myNonUniformDepth2Dcollection [0][1]; // OK, = B -individualMemberD = myNonUniformDepth2Dcollection [2][0]; // would fail -individualMemberE = myNonUniformDepth2Dcollection [2]; // OK, = 6 -// Various collection manipulation functions are provided to assist with these issues, one of these functions is: -testDepthUniform = IsUniformDepth(myNonUniformDepth2Dcollection); // = false -testForDeepestDepth = Rank(myNonUniformDepth2Dcollection); // = 2; current limitation : 1 - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1408_Test_4_15_someNulls() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [ 1, null, 2, 3 ]; -b = Count(a); // 4 after updating a @ line 9 this value become 3. -c = SomeNulls(a); // true after updating a @ line 9 this value become false. -d = a[-2]; // d = 2 note: use of fixed index [-2] -a = RemoveNulls(a); // {1, 2, 3}... d = 2 -f = Count(d); // 2 -g = SomeNulls(a); // false -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1409_Test_4_17_arrayAssignment() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 0..5; -a[1] = -1; // replace a member of a collection -a[2] = a[2] + 0.5; // modify a member of a collection -a[3] = null; // make a member of a collection = null -a[4] = [ 3.4, 4.5 ]; // allowed, but not advised: subsequently altering the structure of the collection -c = a; -b = [ 0, -1, 2.5, null, [ 3.4, 4.5 ], 5 ]; // however a collection of non-uniform depth and irregular structure can be defined -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1410_Test_4_18_removeByIndex() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 1; -b = 2; -c = 3; -d = 4; -x = [ a, b, c, d ]; -u = Remove(x, 0); // remove by content.. u = {b, c, d}; -v = Remove(x, -1); // remove by index.. x = {a, b, c}; -w = Insert(x, d, 0); // insert after defined index.. x = {d,a,b,c,d};"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1411_Test_4_20_zipped_collection() - { - Dictionary> map = new Dictionary>(); - string src = @"// Current limitation : -a = [3, 4, 5]; -b = [2, 6]; -c = a + b ; // { 5, 10, null}; // Here the length of the resulting variable [c] will be based on the length of the first -//collection encountered [in this case a] -d = b + a; // { 5, 10}; // Here the length of the resulting variable [d] will be based on the length of the first -// collection encountered [in this case b] -// Workaround : -//def sum(a, b) -//{ - //return = a + b; -//} -//d = sum(a, b); // {5, 10}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1412_Test_4_22_replication_guide_with_ragged_collection() - { - Dictionary> map = new Dictionary>(); - string src = @"// The use of replication guides with ragged collections can be unpredictable results, as follows: -a = [ 1, [ 3, 4 ] ]; // initial ragged collections -b = [ [ 5, 6 ], 7 ]; -c = a + b; // c = { { 6, 7 }, { 10, 11 } } � zipped collection -//d = a<1> + b<2>; // unpredictable -/* -// Woraround : 'flattening' ragged collections and then applying replication give far more predictable results: -f = Flatten(a); // e = { 1, 3, 4 } -g = Flatten(b); // f = { 5, 6, 7 } -h = g + f; // h = { 6, 9, 11 } -i = f<1> + g<2>; // i = { { 6, 7, 8 }, { 8, 9, 10 }, { 9, 10, 11 } } -// Normalising the depth of collections has limited value, if the resulting sub collections are of different length -i = NormalizeDepth(a); // i = {{1},{3,4}}; -j = NormalizeDepth(b); // j = {{5,6},{7}}; -k = i + j; // unpredictable -l = i<1> + j<2>; // unpredictable*/"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1414_Test_4_9_count() - { - Dictionary> map = new Dictionary>(); - string src = @"count_test1=Count([1,2]); // 2 .. count of collection -a = [[1,2],3]; // define a nested/ragged collection -count_test2=Count(a); // 2 .. count of collection -count_test3=Count(a[0]); // 2 .. count of sub collection -count_test4=Count(a[0][0]); // 0 .. count of single member -m = a[0][0]; -count_test5=Count(a[1]); // 0 .. count of single member -count_test6=Count([]); // 0 .. count of an empty collection -count_test7=Count(3); // 0 .. count of single value -count_test8=Count(null); // null .. count of null -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1415_Regress_1467127() - { - Dictionary> map = new Dictionary>(); - string src = @"i = 1..6..#10;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1416_T01_SimpleRangeExpression() - { - Dictionary> map = new Dictionary>(); - string src = @"a;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13;a14;a17; -[Imperative] -{ - a = 1..-6..-2; - a1 = 2..6..~2.5; - a2 = 0.8..1..0.2; - a3 = 0.7..1..0.3; - a4 = 0.6..1..0.4; - a5 = 0.8..1..0.1; - a6 = 1..1.1..0.1; - a7 = 9..10..1; - a8 = 9..10..0.1; - a9 = 0..1..0.1; - a10 = 0.1..1..0.1; - a11 = 0.5..1..0.1; - a12 = 0.4..1..0.1; - a13 = 0.3..1..0.1; - a14 = 0.2..1..0.1; - a17 = (0.5)..(0.25)..(-0.25); - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1417_T02_SimpleRangeExpression() - { - Dictionary> map = new Dictionary>(); - string src = @"a15;a16;a18;a19;a20; -[Imperative] -{ - a15 = 1/2..1/4..-1/4; - a16 = (1/2)..(1/4)..(-1/4); - a18 = 1.0/2.0..1.0/4.0..-1.0/4.0; - a19 = (1.0/2.0)..(1.0/4.0)..(-1.0/4.0); - a20 = 1..3*2; - //a21 = 1..-6; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1418_T03_SimpleRangeExpressionUsingCollection() - { - Dictionary> map = new Dictionary>(); - string src = @"w1;w2;w3;w4;w5; -[Imperative] -{ - a = 3 ; - b = 2 ; - c = -1; - w1 = a..b..-1 ; //correct - w2 = a..b..c; //correct - e1 = 1..2 ; //correct - f = 3..4 ; //correct - w3 = e1..f; //correct - w4 = (3-2)..(w3[1][1])..(c+2) ; //correct - w5 = (w3[1][1]-2)..(w3[1][1])..(w3[0][1]-1) ; //correct -} -/* expected results : - Updated variable a = 3 - Updated variable b = 2 - Updated variable c = -1 - Updated variable w1 = { 3, 2 } - Updated variable w2 = { 3, 2 } - Updated variable e1 = { 1, 2 } - Updated variable f = { 3, 4 } - Updated variable w3 = { { 1, 2, 3 }, { 2, 3, 4 } } - Updated variable w4 = { 1, 2, 3 } - Updated variable w5 = { 1, 2, 3 } -*/ -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1420_T05_RangeExpressionWithIncrement() - { - Dictionary> map = new Dictionary>(); - string src = @"d;e1;f;g;h;i;j;k;l;m; -[Imperative] -{ - d = 0.9..1..0.1; - e1 = -0.4..-0.5..-0.1; - f = -0.4..-0.3..0.1; - g = 0.4..1..0.2; - h = 0.4..1..0.1; - i = 0.4..1; - j = 0.6..1..0.4; - k = 0.09..0.1..0.01; - l = 0.2..0.3..0.05; - m = 0.05..0.1..0.04; - n = 0.1..0.9..~0.3; - k = 0.02..0.03..#3; - l = 0.9..1..#5; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1421_T06_RangeExpressionWithIncrement() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b;c; -[Imperative] -{ - a = 0.3..0.1..-0.1; - b = 0.1..0.3..0.2; - c = 0.1..0.3..0.1; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1425_T10_RangeExpressionWithReplication() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b; -[Imperative] -{ - //step value greater than the end value - a = 1..2..3; - b = 3..4..3; - c = a..b..a[0]; // {{1,2,3}} - d = 0.5..0.9..0.1; - e1 = 0.1..0.2..0.05; - f = e1[1]..d[2]..0.5; - g = e1..d..0.2; - h = e1[2]..d[1]..0.5; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1427_T12_RangeExpressionUsingNestedRangeExpressions() - { - Dictionary> map = new Dictionary>(); - string src = @"b;c;d;e1;f;g;h;i;j; -[Imperative] -{ - x = 1..5..2; // {1,3,5} - y = 0..6..2; // {0,2,4,6} - a = (3..12..3)..(4..16..4); // {3,6,9,12} .. {4..8..12..16} - b = 3..00.6..#5; // {3.0,2.4,1.8,1.2,0.6} - //c = b[0]..7..#1; //This indexed case works - c = 5..7..#1; //Compile error here , 5 - d = 5.5..6..#3; // {5.5,5.75,6.0} - e1 = -6..-8..#3; //{-6,-7,-8} - f = 1..0.8..#2; //{1,0.8} - g = 1..-0.8..#3; // {1.0,0.1,-0.8} - h = 2.5..2.75..#4; //{2.5,2.58,2.67,2.75} - i = x[0]..y[3]..#10;//1..6..#10 - j = 1..0.9..#4;// {1.0, 0.96,.93,0.9} - k= 1..3..#0;//null -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1430_T15_SimpleRangeExpression_1() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b;d;f;g;h;i;l; -[Imperative] -{ - a = 1..2.2..#3; - b = 0.1..0.2..#4; - c = 1..3..~0.2; - d = (a[0]+1)..(c[2]+0.9)..0.1; - e1 = 6..0.5..~-0.3; - f = 0.5..1..~0.3; - g = 0.5..0.6..0.01; - h = 0.51..0.52..0.01; - i = 0.95..1..0.05; - j = 0.8..0.99..#10; - //k = 0.9..1..#1; - l = 0.9..1..0.1; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1431_T16_SimpleRangeExpression_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b;c;d;e1;f;g;h; -[Imperative] -{ - a = 1.2..1.3..0.1; - b = 2..3..0.1; - c = 1.2..1.5..0.1; - //d = 1.3..1.4..~0.5; //incorrect - d = 1.3..1.4..0.5; - e1 = 1.5..1.7..~0.2; - f = 3..3.2..~0.2; - g = 3.6..3.8..~0.2; - h = 3.8..4..~0.2; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1432_T17_SimpleRangeExpression_3() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b;c;d;e1;f;g;h;i;j;k; -[Imperative] -{ - a = 1..2.2..~0.2; - b = 1..2..#3; - c = 2.3..2..#3; - d = 1.2..1.4..~0.2; - e1 = 0.9..1..0.1; - f = 0.9..0.99..~0.01; - g = 0.8..0.9..~0.1; - h = 0.8..0.9..0.1; - i = 0.9..1.1..0.1; - j = 1..0.9..-0.05; - k = 1.2..1.3..~0.1; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1433_T18_SimpleRangeExpression_4() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b;c;d;e1;f;g;h; -[Imperative] -{ - a = 2.3..2.6..0.3; - b = 4.3..4..-0.3; - c= 3.7..4..0.3; - d = 4..4.3..0.3; - e1 = 3.2..3.3..0.3; - f = 0.4..1..0.1; - g = 0.4..0.45..0.05; - h = 0.4..0.45..~0.05; - g = 0.4..0.6..~0.05; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1434_T19_SimpleRangeExpression_5() - { - Dictionary> map = new Dictionary>(); - string src = @"b;c;d;e1;f;g;h;i; -[Imperative] -{ - //a = 0.1..0.2..#1; //giving error - b = 0.1..0.2..#2; - c = 0.1..0.2..#3; - d = 0.1..0.1..#4; - e1 = 0.9..1..#5; - f = 0.8..0.89..#3; - g = 0.9..0.8..#3; - h = 0.9..0.7..#5; - i = 0.6..1..#4; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1439_T25_RangeExpression_WithDefaultDecrement() - { - Dictionary> map = new Dictionary>(); - string src = @"a=5..1; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1440_T25_RangeExpression_WithDefaultDecrement_1467121() - { - Dictionary> map = new Dictionary>(); - string src = @"a=5..1; -b=-5..-1; -c=1..0.5; -d=1..-0.5; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1441_T25_RangeExpression_WithDefaultDecrement_nested_1467121_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a=(5..1).. (1..5); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1443_T26_RangeExpression_Function_tilda_associative_1457845_3() - { - Dictionary> map = new Dictionary>(); - string src = @"x;a;b;f;g;h;j;k;l;m; -[Associative] -{ - def square : double ( x: double ) - { - return = x * x; - } -} -[Imperative] -{ - x = 0.1; - a = 0..2..~0.5; - b = 0..0.1..~square(0.1); - f = 0..0.1..~x; - g = 0.2..0.3..~x; - h = 0.3..0.2..~-0.1; - - j = 0.8..0.5..~-0.3; - k = 0.5..0.8..~0.3; - l = 0.2..0.3..~0.0; - m = 0.2..0.3..~1/2; // division -} - -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1444_T26_RangeExpression_Function_tilda_multilanguage_1457845_2() - { - Dictionary> map = new Dictionary>(); - string src = @"x;a;b;f;g;h;j;k;l;m; -[Associative] -{ - def square : double ( x: double ) - { - return = x * x; - } -[Imperative] -{ - x = 0.1; - a = 0..2..~0.5; - b = 0..0.1..~square(0.1); - f = 0..0.1..~x; - g = 0.2..0.3..~x; - h = 0.3..0.2..~-0.1; - - j = 0.8..0.5..~-0.3; - k = 0.5..0.8..~0.3; - l = 0.2..0.3..~0.0; - m = 0.2..0.3..~1/2; // division -} - } -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1446_T27_RangeExpression_Function_Associative_1463472() - { - Dictionary> map = new Dictionary>(); - string src = @"z1; -[Associative] -{ - def twice : double( a : double ) - { - return = 2 * a; - } - z1 = 1..twice(4)..twice(1); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1447_T27_RangeExpression_Function_Associative_1463472_2() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -[Associative] -{ - def twice : int []( a : double ) - { - c=1..a; - return = c; - } -d=1..4; -c=twice(4); -// z1 = 1..twice(4)..twice(1); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1448_T27_RangeExpression_Function_Associative_replication() - { - Dictionary> map = new Dictionary>(); - string src = @"z1; -[Associative] -{ - def twice : int[]( a : int ) - { - c=2*(1..a); - return = c; - } - d=[1,2,3,4]; - z1=twice(d); -// z1 = 1..twice(4)..twice(1); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1449_T27_RangeExpression_Function_return_1463472() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -[Associative] -{ - def twice : int []( a : double ) - { - c=1..a; - return = c; - } -d=1..4; -c=twice(4); -// z1 = 1..twice(4)..twice(1); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1450_TA01_RangeExpressionWithIntegerIncrement() - { - Dictionary> map = new Dictionary>(); - string src = @"a1;a2; -[Imperative] -{ - a1 = 1..5..2; - a2 = 12.5..20..2; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1451_TA02_RangeExpressionWithDecimalIncrement() - { - Dictionary> map = new Dictionary>(); - string src = @"a1;a2; -[Imperative] -{ - a1 = 2..9..2.7; - a2 = 10..11.5..0.3; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1452_TA03_RangeExpressionWithNegativeIncrement() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b;c; -[Imperative] -{ - a = 10..-1..-2; - b = -2..-10..-1; - c = 10..3..-1.5; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1453_TA04_RangeExpressionWithNullIncrement() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b; -[Imperative] -{ - a = 1..5..null; - b = 0..6..(null); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1454_TA05_RangeExpressionWithBooleanIncrement() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b; -[Imperative] -{ - a = 2.5..6..(true); - b = 3..7..false; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1455_TA06_RangeExpressionWithIntegerTildeValue() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b; -[Imperative] -{ - a = 1..10..~4; - b = -2.5..10..~5; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1456_TA07_RangeExpressionWithDecimalTildeValue() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b; -[Imperative] -{ - a = 0.2..0.3..~0.2; //divide by zero error - b = 6..13..~1.3; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1457_TA08_RangeExpressionWithNegativeTildeValue() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b; -[Imperative] -{ - a = 3..1..~-0.5; - b = 18..13..~-1.3; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1458_TA09_RangeExpressionWithNullTildeValue() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b; -[Imperative] -{ - a = 1..5..~null; - b = 5..2..~(null); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1459_TA10_RangeExpressionWithBooleanTildeValue() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b; -[Imperative] -{ - a = 1..3..(true); - b = 2..2..false; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1460_TA11_RangeExpressionWithIntegerHashValue() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b;c; -[Imperative] -{ - a = 1..3.3..#5; - b = 3..3..#3; - c = 3..3..#1; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1461_TA12_RangeExpressionWithDecimalHashValue() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b; -[Imperative] -{ - a = 1..7..#2.5; - b = 2..10..#2.4; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1462_TA13_RangeExpressionWithNegativeHashValue() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Imperative] -{ - a = 7.5..-2..#-9; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1463_TA14_RangeExpressionWithNullHashValue() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Imperative] -{ - a = 2..10..#null; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1464_TA15_RangeExpressionWithBooleanHashValue() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b; -[Imperative] -{ - b = 12..12..#false; - a = 12..12..#(true); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1465_TA16_RangeExpressionWithIncorrectLogic_1() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Imperative] -{ - a = 5..1..2; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1466_TA17_RangeExpressionWithIncorrectLogic_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Imperative] -{ - a = 5.5..10.7..-2; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1467_TA18_RangeExpressionWithIncorrectLogic_3() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b;c; -[Imperative] -{ - a = 7..7..5; - b = 8..8..~3; - c = 9..9..#1; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1468_TA19_RangeExpressionWithIncorrectLogic_4() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Imperative] -{ - a = null..8..2; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1470_TA21_Defect_1454692() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -b; -y; -[Imperative] -{ - x = 0; - b = 0..3; //{ 0, 1, 2, 3 } - for( y in b ) - { - x = y + x; - } - -} "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1471_TA21_Defect_1454692_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def length : int (pts : double[]) -{ - numPts = [Imperative] - { - counter = 0; - for(pt in pts) - { - counter = counter + 1; - } - - return = counter; - } - return = numPts; -} - -arr = 0.0..3.0;//{0.0,1.0,2.0,3.0}; -num = length(arr); - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1473_TA21_Defect_1454692_4() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo(i : int[]) -{ - count = 0; - count = [Imperative] - { - for ( x in i ) - { - count = count + 1; - } - return = count; - } - return = count; - -} - -arr = 0.0..3.0;//{0.0,1.0,2.0,3.0}; -c;x; -[Imperative] -{ - x = 0; - b = 0..3; //{ 0, 1, 2, 3 } - for( y in arr ) - { - x = y + x; - } - x1 = 0..3; - c = foo(x1); - -} - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1474_TA22_Range_Expression_floating_point_conversion_1467127() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 1..6..#10; -b = 0.1..0.6..#10; -c = 0.01..-0.6..#10; -d= -0.1..0.06..#10; - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1475_TA22_Range_Expression_floating_point_conversion_1467127_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 0..7..~0.75; -b = 0.1..0.7..~0.075; -c = 0.01..-7..~0.75; -d= -0.1..7..~0.75; -e = 1..-7..~1; - "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1476_TA23_Defect_1466085_Update_In_Range_Expr() - { - Dictionary> map = new Dictionary>(); - string src = @"y = 1; -y1 = 0..y; -y = 2; -z1 = y1; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1477_TA23_Defect_1466085_Update_In_Range_Expr_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 0; -b = 10; -c = 2; -y1 = a..b..c; -a = 7; -b = 14; -c = 7; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1478_TA23_Defect_1466085_Update_In_Range_Expr_3() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( x : int[] ) -{ - return = Count(x); -} -a = 0; -b = 10; -c = 2; -y1 = a..b..c; -z1 = foo ( y1 ); -z2 = Count( y1 ); -c = 5; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1481_T003_LanguageBlockScope_ImperativeNestedAssociative() - { - Dictionary> map = new Dictionary>(); - string src = @"a_inner; -b_inner; -c_inner; -[Imperative] -{ - a = 10; - b = true; - c = 20.1; - [Associative] - { - a_inner = a; - b_inner = b; - c_inner = c; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1482_T004_LanguageBlockScope_AssociativeNestedImperative() - { - Dictionary> map = new Dictionary>(); - string src = @"a_inner;b_inner;c_inner; -[Associative] -{ - a = 10; - b = true; - c = 20.1; - [Imperative] - { - a_inner = a; - b_inner = b; - c_inner = c; - } - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1483_T005_LanguageBlockScope_DeepNested_IAI() - { - Dictionary> map = new Dictionary>(); - string src = @"a_inner1;a_inner2; -b_inner1;b_inner2; -c_inner1;c_inner2; -[Imperative] -{ - a = 10; - b = true; - c = 20.1; - [Associative] - { - a_inner1 = a; - b_inner1 = b; - c_inner1 = c; - - - [Imperative] - { - a_inner2 = a; - b_inner2 = b; - c_inner2 = c; - - } - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1484_T006_LanguageBlockScope_DeepNested_AIA() - { - Dictionary> map = new Dictionary>(); - string src = @"a_inner1;b_inner1;c_inner1; -a_inner2;b_inner2;c_inner2; -[Associative] -{ - a = 10; - b = true; - c = 20.1; - [Imperative] - { - a_inner1 = a; - b_inner1 = b; - c_inner1 = c; - - - [Associative] - { - a_inner2 = a; - b_inner2 = b; - c_inner2 = c; - - } - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1485_T007_LanguageBlockScope_AssociativeParallelImperative() - { - Dictionary> map = new Dictionary>(); - string src = @"aI;bI;cI; -[Associative] -{ - a = 10; - b = true; - c = 20.1; - -} -[Imperative] -{ - aI = a; - bI = b; - cI = c; - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1486_T008_LanguageBlockScope_ImperativeParallelAssociative() - { - Dictionary> map = new Dictionary>(); - string src = @"aA;bA;cA; -[Imperative] -{ - a = 10; - b = true; - c = 20.1; -} -[Associative] -{ - aA = a; - bA = b; - cA = c; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1487_T009_LanguageBlockScope_UpdateVariableInNestedLanguageBlock_IA() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b;c; -newA;newB;newC; -[Imperative] -{ - a = -10; - b = false; - c = -20.1; - [Associative] - { - a = 1.5; - b = -4; - c = false; - } - - newA = a; - newB = b; - newC = c; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1488_T010_LanguageBlockScope_UpdateVariableInNestedLanguageBlock_AI() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b;c; -newA;newB;newC; -[Associative] -{ - a = -10; - b = false; - c = -20.1; - [Imperative] - { - a = 1.5; - b = -4; - c = false; - } - - newA = a; - newB = b; - newC = c; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1489_T011_LanguageBlockScope_AssociativeParallelAssociative() - { - Dictionary> map = new Dictionary>(); - string src = @"aA;bA;cA; -[Associative] -{ - a = 10; - b = true; - c = 20.1; - -} -[Associative] -{ - aA = a; - bA = b; - cA = c; - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1490_T012_LanguageBlockScope_ImperativeParallelImperative() - { - Dictionary> map = new Dictionary>(); - string src = @"aI; bI; cI; -[Imperative] -{ - a = 10; - b = true; - c = 20.1; - -} -[Imperative] -{ - aI = a; - bI = b; - cI = c; - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1491_T013_LanguageBlockScope_MultipleParallelLanguageBlocks_AIA() - { - Dictionary> map = new Dictionary>(); - string src = @"aI;bI;cI; -aA;bA;cA; -[Associative] -{ - a = 10; - b = true; - c = 20.1; - -} -[Imperative] -{ - aI = a; - bI = b; - cI = c; - -} -[Associative] -{ - aA = a; - bA = b; - cA = c; - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1492_T014_LanguageBlockScope_MultipleParallelLanguageBlocks_IAI() - { - Dictionary> map = new Dictionary>(); - string src = @"aI;bI;cI; -aA;bA;cA; -[Imperative] -{ - a = 10; - b = true; - c = 20.1; -} -[Associative] -{ - aA = a; - bA = b; - cA = c; - -} -[Imperative] -{ - aI = a; - bI = b; - cI = c; - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1493_T015_LanguageBlockScope_ParallelInsideNestedBlock_AssociativeNested_II() - { - Dictionary> map = new Dictionary>(); - string src = @"a;aI1;aA1;aI2;aA2; -[Associative] -{ - a = 10; - - [Imperative] - { - aI1 = a; - } - aA1 = a; - - [Imperative] - { - aI2 = a; - } - - aA2 = a; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1494_T016_LanguageBlockScope_ParallelInsideNestedBlock_ImperativeNested_AA() - { - Dictionary> map = new Dictionary>(); - string src = @"a;aA1;aI1;aA2;aI2; -[Imperative] -{ - a = 10; - [Associative] - { - aA1 = a; - } - aI1 = a; - - [Associative] - { - aA2 = a; - } - aI2 = a; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1498_T020_LanguageBlockScope_AssociativeNestedImperative_Function() - { - Dictionary> map = new Dictionary>(); - string src = @"z; -[Associative] -{ - def foo : int(a : int, b : int) - { - return = a - b; - } - [Imperative] - { - x = 20; - y = 10; - z = foo (x, y); - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1500_T022_LanguageBlockScope_DeepNested_AIA_Function() - { - Dictionary> map = new Dictionary>(); - string src = @"z_1; -z_2; -[Associative] -{ - def foo : int(a : int, b : int) - { - return = a - b; - } - [Imperative] - { - x_1 = 20; - y_1 = 10; - z_1 = foo (x_1, y_1); - - - [Associative] - { - x_2 = 100; - y_2 = 100; - z_2 = foo (x_2, y_2); - - } - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1501_T023_LanguageBlockScope_AssociativeParallelImperative_Function() - { - Dictionary> map = new Dictionary>(); - string src = @"z; -[Associative] -{ - def foo : int(a : int, b : int) - { - return = a - b; - } - - a = 10; - -} -[Imperative] -{ - x = 20; - y = 0; - z = foo (x, y); - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1503_T025_LanguageBlockScope_AssociativeParallelAssociative_Function() - { - Dictionary> map = new Dictionary>(); - string src = @"z; -[Associative] -{ - def foo : int(a : int, b : int) - { - return = a - b; - } - - a = 10; - -} -[Associative] -{ - x = 20; - y = 0; - z = foo (x, y); - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1505_T027_LanguageBlockScope_MultipleParallelLanguageBlocks_AIA_Function() - { - Dictionary> map = new Dictionary>(); - string src = @"z_1; -z_2; -[Associative] -{ - def foo : int(a : int, b : int) - { - return = a - b; - } - - a = 10; - -} -[Imperative] -{ - x_1 = 20; - y_1 = 0; - z_1 = foo (x_1, y_1); - -} -[Associative] -{ - x_2 = 20; - y_2 = 0; - z_2 = foo (x_2, y_2); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1507_T029_LanguageBlockScope_ParallelInsideNestedBlock_AssociativeNested_II_Function() - { - Dictionary> map = new Dictionary>(); - string src = @"z_I1; -z_I2; -z_A1; -z_A2; -[Associative] -{ - def foo : int(a : int, b : int) - { - return = a - b; - } - - [Imperative] - { - x_I1 = 50; - y_I1 = 50; - z_I1 = foo (x_I1, y_I1); - } - - x_A1 = 30; - y_A1 = 12; - z_A1 = foo (x_A1, y_A1); - - [Imperative] - { - x_I2 = 0; - y_I2 = 12; - z_I2 = foo (x_I2, y_I2); - } - - x_A2 = 0; - y_A2 = -10; - z_A2 = foo (x_A2, y_A2); - - -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1510_T032_Cross_Language_Variables() - { - Dictionary> map = new Dictionary>(); - string src = @" -a = 5; -b = 2 * a; -sum; -[Imperative] { - sum = 0; - arr = 0..b; - for (i in arr) { - sum = sum + 1; - } -} -a = 10; -// expected: sum = 21 -// result: sum = 11"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1511_Z001_LanguageBlockScope_Defect_1453539() - { - Dictionary> map = new Dictionary>(); - string src = @"[Associative] -{ - a = 10; - b = true; - c = 20.1; -} -// [Imperative] -// { -// aI = a; -// bI = a; -// cI = a; -// }"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1512_T01_String_IfElse_1() - { - Dictionary> map = new Dictionary>(); - string src = @"a = ""word""; -b = ""word ""; -result = -[Imperative] -{ - if(a==b) - { - return = true; - } - else return = false; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1513_T01_String_IfElse_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a = ""w ord""; -b = ""word""; -result = -[Imperative] -{ - if (a ==b) return = true; - else return = false; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1514_T01_String_IfElse_3() - { - Dictionary> map = new Dictionary>(); - string src = @"a = "" ""; -b = """"; -result = -[Imperative] -{ - if (a ==b) return = true; - else return = false; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1515_T01_String_IfElse_4() - { - Dictionary> map = new Dictionary>(); - string src = @"a = ""a""; -b = ""a""; -result = -[Imperative] -{ - if (a ==b) return = true; - else return = false; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1516_T01_String_IfElse_5() - { - Dictionary> map = new Dictionary>(); - string src = @"a = "" "";//3 whiteSpace -b = "" "";//tab -result = -[Imperative] -{ - if (a ==b) return = true; - else return = false; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1517_T01_String_IfElse_6() - { - Dictionary> map = new Dictionary>(); - string src = @"a = """"; -b = "" ""; -result = -[Imperative] -{ - if (a ==null && b!=null) return = true; - else return = false; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1518_T01_String_IfElse_7() - { - Dictionary> map = new Dictionary>(); - string src = @"a = ""a""; -result = -[Imperative] -{ - if (a ==true||a == false) return = true; - else return = false; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1519_T02_String_Not() - { - Dictionary> map = new Dictionary>(); - string src = @"a = ""a""; -result = -[Imperative] -{ - if(a) - { - return = false; - }else if(!a) - { - return = false; - } -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1521_T04_Defect_1454320_String() - { - Dictionary> map = new Dictionary>(); - string src = @"str; -[Associative] -{ -str = ""hello world!""; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1522_T04_Defect_1467100_String() - { - Dictionary> map = new Dictionary>(); - string src = @"def f(s : string) -{ - return = s; -} -x = f(""hello""); -//expected : x = ""hello"" -//received : x = null -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1525_T07_String_Replication() - { - Dictionary> map = new Dictionary>(); - string src = @"a = ""a""; -bcd = [""b"",""c"",""d""]; -r = a +bcd;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1526_T07_String_Replication_1() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [""a""]; -bc = [""b"",""c""]; -str = a + bc; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1527_T07_String_Replication_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a = ""a""; -b = [[""b""],[""c""]]; -str = a +b;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1528_T08_String_Inline() - { - Dictionary> map = new Dictionary>(); - string src = @"a = ""a""; -b = ""b""; -r = a>b? a:b; -r1 = a==b? ""Equal"":""!Equal"";"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1529_T08_String_Inline_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a = ""a""; -b = ""b""; -r = a>b? a:b; -r1 = a==b? ""Equal"":""!Equal""; -b = ""a"";"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1530_T09_String_DynamicArr() - { - Dictionary> map = new Dictionary>(); - string src = @"a[1] = foo(""1"" + 1); -a[2] = foo(""2""); -a[10] = foo(""10""); -a[ - 2] = foo("" - 2"");//smart formatting -r = -[Imperative] -{ - i = 5; - while(i < 7) - { - a[i] = foo(""whileLoop""); - i = i + 1; - } - return = a; -} -def foo(x:var) -{ - return = x + ""!!""; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1532_T11_String_Imperative() - { - Dictionary> map = new Dictionary>(); - string src = @"r = -[Imperative] -{ - a = ""a""; - b = a; - -} -c = b; -b = ""b1""; -a = ""a1""; -m = ""m""; -n = m; -n = ""n""; -m = m+n; -//a =""a1"" -//b = ""b1"" -//c = ""b1""; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1536_T00001_Language_001_Variable_Expression_1() - { - Dictionary> map = new Dictionary>(); - string src = @"A = 10; // assignment of single literal value -B = 2*A; // expression involving previously defined variables -A = A + 1; // expressions modifying an existing variable; -A = 15; // redefine A, removing modifier -A = [1,2,3,4]; // redefine A as a collection -A = 1..10..2; // redefine A as a range expression (start..end..inc) -A = 1..10..~4; // redefine A as a range expression (start..end..approx_inc) -A = 1..10..#4; // redefine A as a range expression (start..end..no_of_incs) -A = A + 1; // modifying A as a range expression -A = 1..10..2; // redefine A as a range expression (start..end..inc) -B[1] = B[1] + 0.5; // modify a member of a collection [problem here] -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1537_T00002_Language_001a_array_test_4() - { - Dictionary> map = new Dictionary>(); - string src = @"a=1; -b=2; -c=4; -collection = [a,b,c]; -collection[1] = collection[1] + 0.5; -d = collection[1]; -d = d + 0.1; // updates the result of accessing the collection -b = b + 0.1; // updates the source member of the collection -t1 = collection[0]; -t2 = collection[1]; -t3 = collection[2]; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1538_T00003_Language_001b_replication_expressions() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [1,0,-1]; -b = [0, 5, 10]; -zipped_sum = a + b; // {1, 5, 9} -cartesian_sum = a<1> + b<2>; -// cartesian_sum = {{1, 6, 11}, -// {0, 5, 10}, -// {-1, 4, 9}} -cartesian_sum = a<2> + b<1>; -t1 = zipped_sum[0]; -t2 = zipped_sum[1]; -t3 = zipped_sum[2]; -t4 = cartesian_sum[0][0]; -t5 = cartesian_sum[1][0]; -t6 = cartesian_sum[2][0]; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1554_T01_Update_Variable_Across_Language_Scope() - { - Dictionary> map = new Dictionary>(); - string src = @"a;b;c;d; -[Associative] -{ - a = 0; - d = a + 1; - [Imperative] - { - b = 2 + a; - a = 1.5; - - } - c = 2; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1555_T02_Update_Function_Argument_Across_Language_Scope() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 1; -def foo ( a1 : double ) -{ - return = a1 + 1; -} -b = foo ( c ) ; -c = a + 1; -[Imperative] -{ - a = 2.5; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1556_T03_Update_Function_Argument_Across_Language_Scope() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 1; -def foo ( a1 : int ) -{ - return = a1 + 1; -} -b = foo ( c ) ; -c = a + 1; -[Imperative] -{ - a = 2.5; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1560_T07_Update_Array_Variable() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 1..3; -c = a; -b = [ Imperative ] -{ - count = 0; - for ( i in a ) - { - a[count] = i + 1; - count = count+1; - } - return = a; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1561_T08_Update_Array_Variable() - { - // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-3988 - string defectID = "MAGN-3988 Defects with Expression Interpreter Test Framework"; - - Dictionary> map = new Dictionary>(); - string src = @"a = 1..3; -c = a; -b = [ Imperative ] -{ - count = 0; - for ( i in a ) - { - if ( i > 0 ) - { - a[count] = i + 1; - } - count = count+1; - } - return = a; -} -d = [ Imperative ] -{ - count2 = 0; - while (count2 <= 2 ) - { - if ( a[count2] > 0 ) - { - a[count2] = a[count2] + 1; - } - count2 = count2+1; - } - return = a; -} -e = b; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map, defectID: defectID); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1562_T09_Update_Across_Multiple_Imperative_Blocks() - { - string defectID = "MAGN-3988 Defects with Expression Interpreter Test Framework"; - Dictionary> map = new Dictionary>(); - string src = @"a = 1; -b = a; -c = [ Imperative ] -{ - a = 2; - return = a; -} -d = [ Imperative ] -{ - a = 3; - return = a; -} -e = c; -f = d; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map, defectID: defectID); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1563_T10_Update_Array_Across_Multiple_Imperative_Blocks() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 1..3; -b = a; -c = [Imperative ] -{ - x = [ 10, a[1], a[2] ]; - a[0] = 10; - return = x; -} -d = [ Imperative ] -{ - a[1] = 20; - return = a; -} -e = c; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1564_T11_Update_Undefined_Variables() - { - Dictionary> map = new Dictionary>(); - string src = @"b = a; -[Imperative] -{ - a = 3; -} -[Associative] -{ - a = 4; -} -c = b;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1565_T12_Update_Undefined_Variables() - { - Dictionary> map = new Dictionary>(); - string src = @"b = a; -[Imperative] -{ - a = 3; -} -[Associative] -{ - a = 4; - d = b + 1; -} -c = b;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1566_T13_Update_Variables_Across_Blocks() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 3; -b = a * 3; -c = [Imperative] -{ - d = b + 3; - a = 4; - return = d; -} -f = c + 1;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1573_T15_Defect_1460935_3() - { - Dictionary> map = new Dictionary>(); - string src = @"x = 1; -y = x; -x = true; //if x = false, the update mechanism works fine -yy = y; -x = false; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1577_T16_Defect_1460623() - { - Dictionary> map = new Dictionary>(); - string src = @"a2 = 1.0; -test2 = a2; -a2 = 3.0; -a2 = 3.3; -t2 = test2; // expected : 3.3; recieved : 3.0 -a1 = [ 1.0, 2.0]; -test1 = a1[1]; -a1[1] = 3.0; -a1[1] = 3.3; -t1 = test1; // expected : 3.3; recieved : 3.0 -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1578_T16_Defect_1460623_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( a ) -{ - return = a; -} -x = 1; -y = foo (x ); -x = 2; -x = 3; -[Imperative] -{ - x = 4; -} -z = x; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1579_T16_Defect_1460623_3() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( a ) -{ - x = a; - y = x + 3; - x = a + 1; - x = a + 2; - return = y; -} -x = 1; -y = foo (x ); -[Imperative] -{ - x = 2; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1582_T17_Defect_1459759_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a1 = [ 1, 2 ]; -y = a1[1] + 1; -a1[1] = 3; -a1 = 5; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1583_T18_Update_Variables_In_Inner_Assoc() - { - Dictionary> map = new Dictionary>(); - string src = @"c = 2; -b = c * 2; -x = b; -[Imperative] -{ - c = 1; - b = c + 1; - d = b + 1; - y = 1; - [Associative] - { - b = c + 2; - c = 4; - z = 1; - } -} -b = c + 3; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1585_T20_Defect_1461391() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 1; -def foo ( a1 : double ) -{ - return = a1 + 1; -} -b = foo ( c ) ; -c = a + 1; -[Imperative] -{ - a = 2.5; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1586_T20_Defect_1461391_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 1; -def foo ( a1 : double[] ) -{ - return = a1[0] + a1[1]; -} -b = foo ( c ) ; -c = [ a, a ]; -[Imperative] -{ - a = 2.5; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1587_T20_Defect_1461391_3() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 1; -def foo ( a1 : double ) -{ - return = a1 + 1; -} -b = foo ( a ) ; -[Imperative] -{ - a = foo(2); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1590_T20_Defect_1461391_6() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( a : int) -{ - return = a; -} -y1 = [ 1, 2 ]; -y2 = foo ( y1); -[Imperative] -{ - count = 0; - for ( i in y1) - { - y1[count] = y1[count] + 1; - count = count + 1; - } -} -t1 = y2[0]; -t2 = y2[1]; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1591_T21_Defect_1461390() - { - Dictionary> map = new Dictionary>(); - string src = @"c; -[Associative] -{ - a = 0; - d = a + 1; - [Imperative] - { - b = 2 + a; - a = 1.5; - - } - c = a + 2; // fail : runtime assertion -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1592_T21_Defect_1461390_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 1; -b = a + 1; -[Imperative] -{ - a = 2; - c = b + 1; - b = a + 2; - [Associative] - { - a = 1.5; - d = c + 1; - b = a + 3; - a = 2.5; - } - b = a + 4; - a = 3; -} -f = a + b;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1602_T25_Defect_1459759() - { - Dictionary> map = new Dictionary>(); - string src = @"p1 = 2; -p2 = p1+2; -p1 = true;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1603_T25_Defect_1459759_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a1 = [ 1, 2 ]; -y = a1[1] + 1; -a1[1] = 3; -a1 = 5;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1604_T25_Defect_1459759_3() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [ 2 , b ,3 ]; -b = 3; -c = a[1] + 2; -d = c + 1; -b = [ 1,2 ];"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1605_T25_Defect_1459759_4() - { - Dictionary> map = new Dictionary>(); - string src = @"p2; -[Imperative] -{ - [Associative] - { - p1 = 2; - p2 = p1+2; - p1 = true; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1606_T25_Defect_1459759_5() - { - Dictionary> map = new Dictionary>(); - string src = @"a; -[Imperative] -{ - a = 2; - x = [Associative] - { - b = [ 2, 3 ]; - c = b[1] + 1; - b = 2; - return = c; - } - a = x; -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1607_T25_Defect_1459759_6() - { - Dictionary> map = new Dictionary>(); - string src = @" - def foo ( a, b ) - { - a = b + 1; - b = true; - return = [ a , b ]; - } -e; -[Imperative] -{ - c = 3; - d = 4; - e = foo( c , d ); -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1634_T28_Update_With_Inline_Condition() - { - Dictionary> map = new Dictionary>(); - string src = @"x = 3; -a1 = 1; -a2 = 2; -a = x > 2 ? a1: a2; -a1 = 3; -a2 = 4;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1635_T28_Update_With_Inline_Condition_2() - { - Dictionary> map = new Dictionary>(); - string src = @"x = 3; -a1 = [ 1, 2]; -a2 = 3; -a = x > 2 ? a2: a1; -a2 = 5; -x = 1; -a1[0] = 0;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1638_T30_Update_Global_Variables_Imperative_Scope() - { - Dictionary> map = new Dictionary>(); - string src = @"x = [0,0,0,0]; -count = 0; -i = 0; -sum = 0; -test = sum; -[Imperative] -{ - for ( i in x ) - { - x[count] = count; - count = count + 1; - } - j = 0; - while ( j < count ) - { - sum = x[j]+ sum; - j = j + 1; - } -} -y = x;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1639_T30_Update_Global_Variables_Imperative_Scope_2() - { - Dictionary> map = new Dictionary>(); - string src = @" -count = 0; -i = 0; -sum = 0; -test = sum; -[Imperative] -{ - for ( i in x ) - { - x[count] = count; - count = count + 1; - } - j = 0; - while ( j < count ) - { - sum = x[j]+ sum; - j = j + 1; - } -} -x = [0,0,0,0]; -y = x; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1649_T32_Update_With_Range_Expr() - { - Dictionary> map = new Dictionary>(); - string src = @"y = 1; -y1 = 0..y; -y = 2; -z1 = y1; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1660_T37_Modify_Collections_Referencing_Each_Other() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [1,2,3]; -b = a; -c1 = a[0]; -b[0] = 10; -c2 = a[0]; -testArray = a; -testArrayMember1 = c1; -testArrayMember2 = c2;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1674_T42_Defect_1466071_Cross_Update_2() - { - Dictionary> map = new Dictionary>(); - string src = @"i = 5; -totalLength = 6; -[Associative] -{ - x = totalLength > i ? 1 : 0; - - [Imperative] - { - for (j in 0..3) - { - i = i + 1; - } - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1675_T42_Defect_1466071_Cross_Update_3() - { - Dictionary> map = new Dictionary>(); - string src = @"y = 1; -a = 2; -x = a > y ? 1 : 0; -y = [Imperative] -{ - while (y < 2) // create a simple outer loop - { - y = y + 1; - } - return = y; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1676_T43_Defect_1463498() - { - Dictionary> map = new Dictionary>(); - string src = @"c;d; -[Associative] -{ -def foo : int ( a : int, b : int ) -{ - a = a + b; - b = 2 * b; - return = a + b; -} -a = 1; -b = 2; -c = foo (a, b ); // expected 9, received -3 -d = a + b; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1686_T001_implicit_programming_Robert() - { - Dictionary> map = new Dictionary>(); - string src = @"// no paradigm specified, so assume Associative -// some Associative code .... -a = 10; -b = a*2; -a = a +1; // expanded modifier, therefore the statement on line 7 is calculated after the statement on line 6 is excuted -c = 0; -//some Imperative code .... -[Imperative] -{ -if (a>10) // implicit switch to Imperative paradigm -{ - c = b; // so statements are treated in lexical order, therefore the statement on line 13 - b=b/2; // is executed before the statement on line 14 [as would be expected] -} -else -{ - [Associative] // explicit switch to Associative paradigm [overrides the Imperative paradigm] - { - c = b; // c references the final state of b, therefore [because we are in an Associative paradigm] - b = b*2; // the statement on line 21 is executed before the statement on line 20 - } -} -} -// some more Associative code .... -a = a + 2; // I am assuming that this statement (on line 27) is executed after the if..else has been evaluated and executed, because... - // effectively, when a Imperative block is nested within an Associative block, lexical order plays a role - // in that the execution order is: - // the part of the Associative graph before the Imperative block - // the Imperative block - // the part of the Associative graph after the Imperative block -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1687_T001_implicit_programming_Robert_2() - { - Dictionary> map = new Dictionary>(); - string src = @"// no paradigm specified, so assume Associative -// some Associative code .... -a = 10; -b = a*2; -a = a +1; // expanded modifier, therefore the statement on line 7 is calculated after the statement on line 6 is excuted -c = 0; -//some Imperative code .... -[Imperative] -{ - if (a>10) // explicit switch to Imperative paradigm - { - c = b; // so statements are treated in lexical order, therefore the statement on line 13 - b=b/2; // is executed before the statement on line 14 [as would be expected] - } - else - { - [Associative] // explicit switch to Associative paradigm [overrides the Imperative paradigm] - { - c = b; // c references the final state of b, therefore [because we are in an Associative paradigm] - b = b*2; // the statement on line 21 is executed before the statement on line 20 - } - } -} -// some more Associative code .... -a = a + 2; // I am assuming that this statement (on line 27) is executed after the if..else has been evaluated and executed, because... - // effectively, when a Imperative block is nested within an Associative block, lexical order plays a role - // in that the execution order is: - // the part of the Associative graph before the Imperative block - // the Imperative block - // the part of the Associative graph after the Imperative block -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1688_T002_limits_to_replication_1_Robert() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 0..10..2; -b = a>5? 0:1; -[Imperative] -{ - c = a * 2; // replication within an Imperative block [OK?] - d = a > 5 ? 0:1; // in-line conditional.. operates on a collection [inside an Imperative block, OK?] - if( c[2] > 4 ) x = 10; // if statement evaluates a single term [OK] - - if( c > 4 ) // but... replication within a regular 'if..else' any support for this? - { - y = 1; - } - else - { - y = -1; - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1690_T004_simple_order_1_Robert() - { - Dictionary> map = new Dictionary>(); - string src = @"a1 = 10; // =1 -b1 = 20; // =1 -a2 = a1 + b1; // =3 -b2 = b1 + a2; // =3 -b = b2 + 2; // 5 -a = a2 + b; // 6"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1692_T006_grouped_1_Robert() - { - Dictionary> map = new Dictionary>(); - string src = @"a1 = 10; // =1 -a2 = a1 + b1; // =3 -a = a2 + b; // 6 - -b1 = 20; // =1 -b2 = b1 + a2; // =3 -b = b2 + 2; // 5"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1696_T010_imperative_if_inside_for_loop_1_Robert() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - x = 0; - - for ( i in 1..10..2) - { - x = i; - if(i>5) x = i*2; // tis is ignored - // if(i<5) x = i*2; // this causes a crash - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1700_Comments_1467117() - { - Dictionary> map = new Dictionary>(); - string src = @"/* -/* -*/ -a=5;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1713_error_LineNumber_2() - { - Dictionary> map = new Dictionary>(); - string src = @"a=b;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1715_FunctionCall_With_Default_Arg() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo:int(t : int = 4) - { - return = t; - } - // Type is recognized as A, actual type is B -testFoo1 = foo(6); // foo1 does not exist in A, function not found warning; testFoo1 =6; -testFoo2 = foo();"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1720_Use_Keyword_Array_1463672() - { - Dictionary> map = new Dictionary>(); - string src = @"def Create2DArray( col : int) -{ - result = [Imperative] - { - array = [ 1, 2 ]; - counter = 0; - while( counter < col) - { - array[counter] = [ 1, 2]; - counter = counter + 1; - } - return = array; - } - return = result; -} -x = Create2DArray( 2) ;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1721_Regress_1452951() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Associative] -{ - a = [ 4,5 ]; - - [Imperative] - { - //a = { 4,5 }; // works fine - x = 0; - for( y in a ) - { - x = x + y; - } - } -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1722_Regress_1454511() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -[Imperative] -{ - x = 0; - - for ( i in b ) - { - x = x + 1; - } -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1723_Regress_1454692() - { - Dictionary> map = new Dictionary>(); - string src = @"x; -y; -[Imperative] -{ - x = 0; - b = 0..3; //{ 0, 1, 2, 3 } - for( y in b ) - { - x = y + x; - } - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1724_Regress_1454692_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def length : int (pts : double[]) -{ - numPts = [Imperative] - { - counter = 0; - for(pt in pts) - { - counter = counter + 1; - } - - return = counter; - } - return = numPts; -} - -arr = 0.0..3.0;//{0.0,1.0,2.0,3.0}; -num = length(arr);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1725_Regress_1454918_1() - { - Dictionary> map = new Dictionary>(); - string src = @"d; -[Associative] // expected 2.5 -{ - def Divide : double (a:int, b:int) - { - return = a/b; - } - d = Divide (5,2); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1726_Regress_1454918_2() - { - Dictionary> map = new Dictionary>(); - string src = @"d; -[Associative] // expected error -{ - def foo : int (a:double) - { - return = a; - } - d = foo (5.5); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1727_Regress_1454918_3() - { - Dictionary> map = new Dictionary>(); - string src = @"d; -[Associative] // expected d = 5.0 -{ - def foo : double (a:double) - { - return = a; - } - d = foo (5.0); -} "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1728_Regress_1454918_4() - { - Dictionary> map = new Dictionary>(); - string src = @"d; -[Associative] // expected error -{ - def foo : double (a:bool) - { - return = a; - } - d = foo (true); -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1730_Regress_1454918_6() - { - Dictionary> map = new Dictionary>(); - string src = @" def foo : double () - { - return = 5; - } - d = foo (); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1731_Regress_1454926() - { - Dictionary> map = new Dictionary>(); - string src = @"result; -result2; -[Imperative] -{ - d1 = null; - d2 = 0.5; - result = d1 * d2; - result2 = d1 + d2; - -}"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1754_Regress_1455738() - { - Dictionary> map = new Dictionary>(); - string src = @"b; -[Associative] -{ - a = 3; - b = a * 2; - a = 4; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1765_Regress_1456713() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 2.3; -b = a * 3; -c = 2.32; -d = c * 3; -e1=0.31; -f=3*e1; -g=1.1; -h=g*a; -i=0.99999; -j=2*i;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1766_Regress_1456758() - { - Dictionary> map = new Dictionary>(); - string src = @"a = true && true ? -1 : 1;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1775_Regress_1457179() - { - Dictionary> map = new Dictionary>(); - string src = @"import (""TestImport.ds""); -def Sin : double (val : double) -{ - return = dc_sin(val); -} -result1 = Sin(90); -result2 = Sin(90.0);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1777_Regress_1457885() - { - Dictionary> map = new Dictionary>(); - string src = @"c = 5..7..#1; -a = 0.2..0.3..~0.2;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1778_Regress_1457903() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 1..7..#2.5; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1779_Regress_1458187() - { - Dictionary> map = new Dictionary>(); - string src = @"//b=true; - // x = (b == 0) ? b : b+1; -def foo1 ( b ) -{ - x = (b == 0) ? b : b+1; - return = x; -} -a=foo1(5.0); -b=foo1(5); -c=foo1(0); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1780_Regress_1458187_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo1 ( b ) -{ -x = (b == 0) ? b : b+1; -return = x; -} -a=foo1(true); "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1781_Regress_1458187_3() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo1 ( b ) -{ -x = (b == 0) ? b : b+1; -return = x; -} -a=foo1(null); "; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1782_Regress_1458475() - { - Dictionary> map = new Dictionary>(); - string src = @"a = [ 1,2 ]; -b1 = a[-1];//b1=2"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1785_Regress_1458567() - { - Dictionary> map = new Dictionary>(); - string src = @"a = 1; -b = a[1]; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1787_Regress_1458785_2() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo ( i:int[]) -{ -return = i; -} -x = 1; -a1 = foo(x); -a2 = 3;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1800_Regress_1459372() - { - Dictionary> map = new Dictionary>(); - string src = @"collection = [ 2, 2, 2 ]; -collection[1] = 3; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1801_Regress_1459512() - { - Dictionary> map = new Dictionary>(); - string src = @"def length : int (pts : int[]) -{ - numPts = [Imperative] - { - counter = 0; - for(pt in pts) - { - counter = counter + 1; - } - return = counter; - } - return = numPts; -} -z=length([1,2]);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1815_Regress_1462308() - { - Dictionary> map = new Dictionary>(); - string src = @"import(TestData from ""FFITarget.dll""); -f = TestData.IncrementByte(101); -F = TestData.ToUpper(f); -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1816_Regress_1467091() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo(x:int) -{ - return = x + 1; -} -y1 = test.foo(2); -y2 = ding().foo(3);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1817_Regress_1467094_1() - { - Dictionary> map = new Dictionary>(); - string src = @"t = []; -x = t[3]; -t[2] = 1; -y = t[3]; -z = t[-1]; -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1820_Regress_1467107() - { - Dictionary> map = new Dictionary>(); - string src = @"def foo(x:int) -{ - return = x + 1; -} -m=null; -y = m.foo(2);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1821_Regress_1467117() - { - Dictionary> map = new Dictionary>(); - string src = @"/* -/* -*/ -a = 1;"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1822_test() - { - Dictionary> map = new Dictionary>(); - string src = @"def length : int (pts : int[]) -{ - numPts = [Imperative] - { - counter = 0; - for(pt in pts) - { - counter = counter + 1; - } - return = counter; - } - return = numPts; -} -z=length([1,2]);"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - - [Test] - [Category("WatchFx Tests")] - public void DebugWatch1823_TestImport() - { - Dictionary> map = new Dictionary>(); - string src = @"def dc_sqrt : double (val : double ) -{ - return = val/2.0; -} -def dc_factorial : int (val : int ) -{ - return = val * val ; -} -def dc_sin : double (val : double) -{ - return = val + val; -} -"; - WatchTestFx.GeneratePrintStatements(src, ref map); - WatchTestFx fx = new WatchTestFx(); fx.CompareRunAndWatchResults(null, src, map); - } - } -} diff --git a/test/Engine/ProtoTest/TD/Associative/Update.cs b/test/Engine/ProtoTest/TD/Associative/Update.cs index 18282a11624..3a0441b7591 100644 --- a/test/Engine/ProtoTest/TD/Associative/Update.cs +++ b/test/Engine/ProtoTest/TD/Associative/Update.cs @@ -8,14 +8,12 @@ namespace ProtoTest.TD.Associative { class Update : ProtoTestBase { - ProtoScript.Runners.DebugRunner fsr; string importPath = "..\\..\\..\\test\\Engine\\ProtoTest\\ImportFiles\\"; public override void Setup() { base.Setup(); - fsr = new DebugRunner(core); DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); DLLFFIHandler.Register(FFILanguage.CPlusPlus, new ProtoFFI.PInvokeModuleHelper()); CLRModuleType.ClearTypes(); @@ -24,7 +22,6 @@ public override void Setup() public override void TearDown() { base.TearDown(); - fsr = null; } [Test] diff --git a/test/Engine/ProtoTest/TD/Debugger.cs b/test/Engine/ProtoTest/TD/Debugger.cs deleted file mode 100644 index 9fb1e6ff981..00000000000 --- a/test/Engine/ProtoTest/TD/Debugger.cs +++ /dev/null @@ -1,61 +0,0 @@ -using NUnit.Framework; -using ProtoTestFx; -namespace ProtoTest.TD -{ - class Debugger : ProtoTestBase - { - string testCasePath = "..\\..\\..\\test\\Engine\\ProtoTest\\ImportFiles\\"; - ProtoScript.Runners.DebugRunner fsr; - - public override void Setup() - { - base.Setup(); - fsr = new ProtoScript.Runners.DebugRunner(core); - } - - public override void TearDown() - { - base.TearDown(); - fsr = null; - } - - [Test] - public void T004_Defect_IDE_963_Crash_On_Debugging() - { - string defectID = "MAGN-4005 GC issue with globally declared objects used in update loop inside Associative language block"; - - string src = @" -import(""FFITarget.dll""); - -a : DummyPoint = null; -b : DummyLine = null; -[Associative] -{ - a = DummyPoint.ByCoordinates(10, 0, 0); - b = DummyLine.ByStartPointEndPoint(a, DummyPoint.ByCoordinates(10, 5, 0)); - a = DummyPoint.ByCoordinates(15, 0, 0); -} -c = b; -"; - DebugTestFx.CompareDebugAndRunResults(src, defectID); - } - - [Test] - public void T005_Defect_IDE_963_Crash_On_Debugging() - { - string src = @" -import(""FFITarget.dll""); -a : DummyPoint = null; -b : DummyLine = null; -[Imperative] -{ - a = DummyPoint.ByCoordinates(10, 0, 0); - b = DummyLine.ByStartPointEndPoint(a, DummyPoint.ByCoordinates(10, 5, 0)); - a = DummyPoint.ByCoordinates(15, 0, 0); -} -c = b; -"; - DebugTestFx.CompareDebugAndRunResults(src); - } - } -} diff --git a/test/Engine/ProtoTest/TD/MultiLangTests/StringTest.cs b/test/Engine/ProtoTest/TD/MultiLangTests/StringTest.cs index ae2bc905365..87b9b05408a 100644 --- a/test/Engine/ProtoTest/TD/MultiLangTests/StringTest.cs +++ b/test/Engine/ProtoTest/TD/MultiLangTests/StringTest.cs @@ -6,18 +6,14 @@ namespace ProtoTest.TD.MultiLangTests { class StringTest : ProtoTestBase { - ProtoScript.Runners.DebugRunner fsr; - public override void Setup() { base.Setup(); - fsr = new ProtoScript.Runners.DebugRunner(core); } public override void TearDown() { base.TearDown(); - fsr = null; } [Test] diff --git a/test/Engine/ProtoTest/TD/MultiLangTests/TestFunction.cs b/test/Engine/ProtoTest/TD/MultiLangTests/TestFunction.cs index e0bfd825c35..5155b3d06f8 100644 --- a/test/Engine/ProtoTest/TD/MultiLangTests/TestFunction.cs +++ b/test/Engine/ProtoTest/TD/MultiLangTests/TestFunction.cs @@ -8,18 +8,15 @@ namespace ProtoTest.TD.MultiLangTests class TestFunction : ProtoTestBase { string testPath = "..\\..\\..\\test\\Engine\\ProtoTest\\ImportFiles\\"; - ProtoScript.Runners.DebugRunner fsr; public override void Setup() { base.Setup(); - fsr = new ProtoScript.Runners.DebugRunner(core); } public override void TearDown() { base.TearDown(); - fsr = null; } [Test] @@ -5264,37 +5261,6 @@ public void TV88_Defect_1463489_2() thisTest.Verify("d1", false); } - [Test] - [Category("Design Issue")] - [Category("Update")] - [Category("Failure")] - public void TV88_Defect_1463489_3() - { - // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-1510 - string src = string.Format("{0}{1}", testPath, "TV88_Defect_1463489_3.ds"); - fsr.LoadAndPreStart(src); - ProtoCore.CodeModel.CodePoint cp = new ProtoCore.CodeModel.CodePoint - { - CharNo = 8, - LineNo = 35, - SourceLocation = new ProtoCore.CodeModel.CodeFile - { - FilePath = Path.GetFullPath(src) - } - }; - fsr.ToggleBreakpoint(cp); - ProtoScript.Runners.DebugRunner.VMState vms = fsr.Run(); - Assert.AreEqual((bool)vms.mirror.GetDebugValue("y1").Payload, true); - Assert.AreEqual((bool)vms.mirror.GetDebugValue("y3").Payload, true); - Assert.AreEqual((bool)vms.mirror.GetDebugValue("y2").Payload, false); - Assert.AreEqual((bool)vms.mirror.GetDebugValue("y4").Payload, false); - fsr.Run(); - Assert.AreEqual((bool)vms.mirror.GetDebugValue("y1").Payload, false); - Assert.AreEqual((bool)vms.mirror.GetDebugValue("y3").Payload, false); - Assert.AreEqual((bool)vms.mirror.GetDebugValue("y2").Payload, true); - Assert.AreEqual((bool)vms.mirror.GetDebugValue("y4").Payload, true); - } - [Test] [Category("DSDefinedClass_Ported")] [Category("SmokeTest")] diff --git a/test/Engine/ProtoTest/TD/MultiLangTests/TestUpdate.cs b/test/Engine/ProtoTest/TD/MultiLangTests/TestUpdate.cs index f1a14e5be7c..97dfb88ddc4 100644 --- a/test/Engine/ProtoTest/TD/MultiLangTests/TestUpdate.cs +++ b/test/Engine/ProtoTest/TD/MultiLangTests/TestUpdate.cs @@ -6,18 +6,15 @@ namespace ProtoTest.TD.MultiLangTests class TestUpdate : ProtoTestBase { string testPath = "..\\..\\..\\test\\Engine\\ProtoTest\\ImportFiles\\"; - ProtoScript.Runners.DebugRunner fsr; public override void Setup() { base.Setup(); - fsr = new ProtoScript.Runners.DebugRunner(core); } public override void TearDown() { base.TearDown(); - fsr = null; } diff --git a/test/Engine/ProtoTestFx/DebugTestFx.cs b/test/Engine/ProtoTestFx/DebugTestFx.cs deleted file mode 100644 index 9311a215b54..00000000000 --- a/test/Engine/ProtoTestFx/DebugTestFx.cs +++ /dev/null @@ -1,253 +0,0 @@ -using System; -using NUnit.Framework; -using ProtoCore; -using ProtoCore.DSASM; -using ProtoCore.DSASM.Mirror; -using ProtoFFI; -using ProtoScript.Runners; - -namespace ProtoTestFx -{ - public class DebugTestFx - { - public static void CompareDebugAndRunResults(string code, string defectID = "") - { - Core runCore = null; - RuntimeCore runtimeCore = null; - try - { - runCore = TestRunnerRunOnly(code, out runtimeCore); - } - catch (Exception e) - { - Assert.Ignore("Ignored due to Exception from run: " + e.ToString()); - } - - { - RuntimeCore debugRuntimeCore = null; - Core debugRunCore = DebugRunnerRunOnly(code, out debugRuntimeCore); - CompareCores(runtimeCore, debugRuntimeCore, defectID); - debugRuntimeCore.Cleanup(); - } - - { - RuntimeCore stepOverRuntimeCore = null; - Core stepOverCore = DebugRunnerStepOver(code, out stepOverRuntimeCore); - CompareCores(runtimeCore, stepOverRuntimeCore, defectID); - stepOverRuntimeCore.Cleanup(); - } - - { - RuntimeCore stepInRuntimeCore = null; - Core stepInCore = DebugRunerStepIn(code, out stepInRuntimeCore); - CompareCores(runtimeCore, stepInRuntimeCore, defectID); - stepInRuntimeCore.Cleanup(); - } - - runtimeCore.Cleanup(); - - } - - internal static ProtoCore.Core TestRunnerRunOnly(string code, out RuntimeCore runtimeCore) - { - ProtoCore.Core core; - ProtoScript.Runners.ProtoScriptRunner fsr = new ProtoScriptRunner(); - - // Specify some of the requirements of IDE. - var options = new ProtoCore.Options(); - options.ExecutionMode = ProtoCore.ExecutionMode.Serial; - - string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\"; - options.IncludeDirectories.Add(testPath); - - core = new ProtoCore.Core(options); - core.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(core)); - core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core)); - - fsr = new ProtoScriptRunner(); - - DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); - CLRModuleType.ClearTypes(); - - //Run - - runtimeCore = fsr.Execute(code, core); - - return core; - } - - internal static ProtoCore.Core DebugRunnerRunOnly(string code, out RuntimeCore runtimeCore) - { - ProtoCore.Core core; - DebugRunner fsr; - - // Specify some of the requirements of IDE. - var options = new ProtoCore.Options(); - options.ExecutionMode = ProtoCore.ExecutionMode.Serial; - options.GCTempVarsOnDebug = false; - - string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\"; - options.IncludeDirectories.Add(testPath); - - core = new ProtoCore.Core(options); - core.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(core)); - core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core)); - - fsr = new DebugRunner(core); - - DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); - CLRModuleType.ClearTypes(); - - //Run - - fsr.PreStart(code); - DebugRunner.VMState vms = null; - - vms = fsr.Run(); - runtimeCore = fsr.runtimeCore; - return core; - } - - internal static ProtoCore.Core DebugRunnerStepOver(string code, out RuntimeCore runtimeCore) - { - //Internal setup - - ProtoCore.Core core; - DebugRunner fsr; - - // Specify some of the requirements of IDE. - var options = new ProtoCore.Options(); - options.ExecutionMode = ProtoCore.ExecutionMode.Serial; - options.GCTempVarsOnDebug = false; - - string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\"; - options.IncludeDirectories.Add(testPath); - - core = new ProtoCore.Core(options); - core.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(core)); - core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core)); - - - fsr = new DebugRunner(core); - - DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); - CLRModuleType.ClearTypes(); - - //Run - - fsr.PreStart(code); - DebugRunner.VMState vms = null; - - while (!fsr.isEnded) - vms = fsr.StepOver(); - - runtimeCore = fsr.runtimeCore; - return core; - - } - - internal static ProtoCore.Core DebugRunerStepIn(string code, out RuntimeCore runtimeCore) - { - //Internal setup - - ProtoCore.Core core; - DebugRunner fsr; - - // Specify some of the requirements of IDE. - var options = new ProtoCore.Options(); - options.ExecutionMode = ProtoCore.ExecutionMode.Serial; - options.GCTempVarsOnDebug = false; - - string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\"; - options.IncludeDirectories.Add(testPath); - - core = new ProtoCore.Core(options); - core.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(core)); - core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core)); - - fsr = new DebugRunner(core); - - DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); - CLRModuleType.ClearTypes(); - - //Run - - fsr.PreStart(code); - DebugRunner.VMState vms = null; - - while (!fsr.isEnded) - vms = fsr.Step(); - - runtimeCore = fsr.runtimeCore; - return core; - - } - - internal static void CompareCores(RuntimeCore rtcore1, RuntimeCore rtcore2, string defectID = "") - { - Assert.AreEqual(rtcore1.DSExecutable.runtimeSymbols.Length, rtcore1.DSExecutable.runtimeSymbols.Length, defectID); - - - for (int symTableIndex = 0; symTableIndex < rtcore1.DSExecutable.runtimeSymbols.Length; symTableIndex++) - { - var rtc1Symbols = rtcore1.DSExecutable.runtimeSymbols[symTableIndex]; - if (rtc1Symbols == null) - { - continue; - } - foreach (SymbolNode symNode in rtc1Symbols.symbolList.Values) - { - - ExecutionMirror runExecMirror = new ExecutionMirror(rtcore1.CurrentExecutive.CurrentDSASMExec, rtcore1); - ExecutionMirror debugExecMirror = new ExecutionMirror(rtcore2.CurrentExecutive.CurrentDSASMExec, rtcore2); - - bool lookupOk = false; - StackValue runValue = StackValue.Null; - - if (symNode.name.StartsWith("%") || symNode.functionIndex != Constants.kInvalidIndex) - continue; //Don't care about internal variables - - try - { - runValue = runExecMirror.GetValue(symNode.name); - lookupOk = true; - - } - catch (NotImplementedException) - { - } - catch (SymbolNotFoundException) - { - } - catch (Exception ex) - { - if ((ex is ArgumentOutOfRangeException || ex is IndexOutOfRangeException) && - (rtcore1.RunningBlock != symNode.runtimeTableIndex)) - { - // Quite possible that variables defined in the inner - // language block have been garbage collected and - // stack frame pointer has been adjusted when return - // to the outer block. - } - else - { -#pragma warning disable CA2200 // Rethrow to preserve stack details - throw ex; -#pragma warning restore CA2200 // Rethrow to preserve stack details - } - } - - if (lookupOk) - { - StackValue debugValue = debugExecMirror.GetValue(symNode.name); - if (!StackUtils.CompareStackValues(debugValue, runValue, rtcore2, rtcore1)) - { - Assert.Fail(string.Format("\tThe value of variable \"{0}\" doesn't match in run mode and in debug mode.\nTracked by {1}", symNode.name, defectID)); - } - } - } - } - - } - } -} diff --git a/test/Engine/ProtoTestFx/TestFrameWork.cs b/test/Engine/ProtoTestFx/TestFrameWork.cs index caf5e6467c3..334990e5bc4 100644 --- a/test/Engine/ProtoTestFx/TestFrameWork.cs +++ b/test/Engine/ProtoTestFx/TestFrameWork.cs @@ -32,11 +32,9 @@ public enum VerificationFormat private readonly ProtoScriptRunner runner; private static string mErrorMessage = ""; bool testImport; - bool testDebug; bool dumpDS=false; bool cfgImport = Convert.ToBoolean(Environment.GetEnvironmentVariable("Import")); bool cfgDebug = Convert.ToBoolean(Environment.GetEnvironmentVariable("Debug")); - bool executeInDebugMode = true; public TestFrameWork() { @@ -97,38 +95,6 @@ private void RunAndVerify(string code, Dictionary verification) { Verify(pair.Key, pair.Value); } - - if (executeInDebugMode) - { - RunDebugWatch(code); - RunDebugEqualityTest(code); - } - } - - - /// - /// Generates a list of variables to watch. Runs the code and verifies the results against the generated watch list - /// Verifies the results against a list - /// - /// - /// - private void RunDebugWatch(string code) - { - Dictionary> map = new Dictionary>(); - WatchTestFx.GeneratePrintStatements(code, ref map); - WatchTestFx fx = new WatchTestFx(); - fx.CompareRunAndWatchResults(null, code, map); - } - - - /// - /// Runs the code in Normal Execution, Debug StepOver, Debug StepIn - /// Verifies that all 3 runs produce the same output - /// - /// - private void RunDebugEqualityTest(string code) - { - DebugTestFx.CompareDebugAndRunResults(code); } /// @@ -290,11 +256,6 @@ public ProtoCore.Core SetupTestCore() { testImport = cfgDebug; } - else - { - testDebug = false; - - } return testCore; } @@ -331,25 +292,6 @@ public ExecutionMirror RunScriptFile(string directory, string filename) createDSFile(fileToRun, directory, importCode); errorString = "tested as import file"; - } - else if (testDebug) - { - Dictionary> map = new Dictionary>(); - string fname = Path.Combine(directory, filename); - TextReader file = new StreamReader(fname); - WatchTestFx.GeneratePrintStatements(file, ref map); - file = new StreamReader(fname); - String src = file.ReadToEnd(); - file.Close(); - - WatchTestFx fx = new WatchTestFx(); - testCore = fx.TestCore; - - fx.CompareRunAndWatchResults(Path.GetFullPath(filename), src, map); - testMirror = fx.Mirror; - - return testMirror; - } string dsFullPathName = directory + currentFile; @@ -431,31 +373,6 @@ public virtual ExecutionMirror RunScriptSource(string sourceCode, string errorst } - if (testDebug) - { - Dictionary> map = new Dictionary>(); - if (!String.IsNullOrEmpty(includePath)) - { - if (System.IO.Directory.Exists(includePath)) - { - testCore.Options.IncludeDirectories.Add(includePath); - } - else - { - Console.WriteLine(String.Format("Path: {0} does not exist.", includePath)); - } - } - StringReader file = new StringReader(sourceCode); - WatchTestFx.GeneratePrintStatements(file, ref map); - - WatchTestFx fx = new WatchTestFx(); - testCore = fx.TestCore; - fx.CompareRunAndWatchResults("", sourceCode, map); - testMirror = fx.Mirror; - - return testMirror; - } - SetupTestCore(); if (!String.IsNullOrEmpty(includePath)) { diff --git a/test/Engine/ProtoTestFx/WatchTestFx.cs b/test/Engine/ProtoTestFx/WatchTestFx.cs deleted file mode 100644 index cd451722eaa..00000000000 --- a/test/Engine/ProtoTestFx/WatchTestFx.cs +++ /dev/null @@ -1,649 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text.RegularExpressions; -using NUnit.Framework; -using ProtoCore; -using ProtoCore.DSASM; -using ProtoCore.Lang; -using ProtoFFI; -using ProtoScript.Runners; - -namespace ProtoTestFx -{ - public class InjectionExecutiveProvider : IExecutiveProvider - { - public ProtoCore.DSASM.Executive CreateExecutive(RuntimeCore runtimeCore, bool isFep) - { - return new InjectionExecutive(runtimeCore, isFep); - } - } - - public struct Expression - { - public int LineNo; - public string Expr; - public int ClassIndex; - - public Expression(int lineNo, string expr, int ci = Constants.kInvalidIndex) - { - LineNo = lineNo; - Expr = expr; - ClassIndex = ci; - } - } - - // overrides POP_handler - public class InjectionExecutive : ProtoCore.DSASM.Executive - { - - public InjectionExecutive(RuntimeCore runtimeCore, bool isFep = false) : base(runtimeCore, isFep) { } - - public static int callrLineNo { get; private set; } - public static bool IsPopToPropertyArray { get; set; } - protected static StackValue propSV { get; private set; } - public static Dictionary> ExpressionMap { get; set; } - - static InjectionExecutive() - { - IsPopToPropertyArray = false; - callrLineNo = Constants.kInvalidIndex; - ExpressionMap = new Dictionary>(); - } - - internal void Print(StackValue sv, int lineNo, string symbolName, int ci = Constants.kInvalidIndex) - { - //TODO: Change Execution mirror class to have static methods, so that an instance does not have to be created - ProtoCore.DSASM.Mirror.ExecutionMirror mirror = new ProtoCore.DSASM.Mirror.ExecutionMirror(this, RuntimeCore); - string result = mirror.GetStringValue(sv, RuntimeCore.RuntimeMemory.Heap, 0, true); - - TextOutputStream tStream = RuntimeCore.RuntimeStatus.MessageHandler as TextOutputStream; - if (tStream != null) - { - Dictionary> map = tStream.Map; - - //foreach(var kv in tStream.Map) - - if (!map.ContainsKey(lineNo)) - return; - - List expressions = map[lineNo]; - - foreach (var exp in expressions) - { - // Get lhs symbol name - string lhsName = null; - int index = exp.IndexOf('.'); - if (index != -1) - { - string[] parts = exp.Split('.'); - lhsName = parts[parts.Length - 1]; - } - else - { - Match m = Regex.Match(exp, @"(\w+)"); - if (m.Success) - { - lhsName = m.Groups[1].Value; - } - } - - if (lhsName.Equals(symbolName)) - { - // Add to map - Expression expStruct = new Expression(lineNo, exp, ci); - - if (ExpressionMap.ContainsKey(expStruct)) - { - List values = ExpressionMap[expStruct]; - values.Add(result); - } - else - { - List values = new List(); - values.Add(result); - - ExpressionMap.Add(expStruct, values); - } - } - } - } - } - - protected override void POP_Handler(Instruction instruction) - { - int blockId = 0; - int dimensions = 0; - - StackValue svData = POP_helper(instruction, out blockId, out dimensions); - - if (instruction.op1.IsRegister) - return; - - SymbolNode symbolNode = GetSymbolNode(blockId, instruction.op2.ClassIndex, instruction.op1.SymbolIndex); - string symbolName = symbolNode.name; - - bool isTemp = ProtoCore.Utils.CoreUtils.IsPropertyTemp(symbolName); - - // if symbol is a temporary for a property array (true in associative block only) - // we cache the stackvalue here and not in POPM (as in POPM we will retrieve the whole array) - if (isTemp && dimensions > 0) - { - IsPopToPropertyArray = true; - propSV = svData; - } - - - if (instruction.debug != null) - { - int lineNo = instruction.debug.Location.StartInclusive.LineNo; - - if (RuntimeCore.Options.IDEDebugMode && RuntimeCore.Options.RunMode != ProtoCore.DSASM.InterpreterMode.Expression) - { - RuntimeCore.DebugProps.IsPopmCall = false; - RuntimeCore.DebugProps.CurrentSymbolName = symbolName; - } - - // Add stackvalue against lineNo and variable name - if (!RuntimeCore.Options.IDEDebugMode) - { - Print(svData, lineNo, symbolName); - } - } - return; - } - - protected override void POPM_Handler(Instruction instruction) - { - int blockId; - int ci = Constants.kInvalidIndex; - StackValue svData = POPM_Helper(instruction, out blockId, out ci); - - //if (callrLineNo != Constants.kInvalidIndex) - { - SymbolNode symbolNode = null; - if (instruction.op1.IsStaticVariableIndex) - { - symbolNode = exe.runtimeSymbols[blockId].symbolList[instruction.op1.StaticVariableIndex]; - } - else - { - symbolNode = exe.classTable.ClassNodes[ci].Symbols.symbolList[instruction.op1.MemberVariableIndex]; - } - string symbolName = symbolNode.name; - - if (RuntimeCore.Options.IDEDebugMode && RuntimeCore.Options.RunMode != ProtoCore.DSASM.InterpreterMode.Expression) - { - if (!RuntimeCore.DebugProps.DebugStackFrameContains(DebugProperties.StackFrameFlagOptions.IsReplicating)) - { - RuntimeCore.DebugProps.CurrentSymbolName = symbolName; - RuntimeCore.DebugProps.IsPopmCall = true; - } - } - - // Add stackvalue against lineNo and variable name - if (!RuntimeCore.Options.IDEDebugMode) - { - int lineNo = -1; - if (instruction.debug == null) - { - lineNo = callrLineNo; - } - // In Imperative block, POPM instruction has debug info so in this case we get the correct line no. from debug info - else - { - lineNo = instruction.debug.Location.StartInclusive.LineNo; - } - - if (IsPopToPropertyArray) - { - svData = propSV; - IsPopToPropertyArray = false; - } - Print(svData, lineNo, symbolName, ci); - } - } - } - - protected override void CALLR_Handler(Instruction instruction) - { - //callrLineNo = Constants.kInvalidIndex; - - if (instruction.debug != null) - { - if (RuntimeCore.Options.IDEDebugMode && RuntimeCore.Options.RunMode != ProtoCore.DSASM.InterpreterMode.Expression) - { - RuntimeCore.DebugProps.IsPopmCall = false; - } - - callrLineNo = instruction.debug.Location.StartInclusive.LineNo; - } - - base.CALLR_Handler(instruction); - } - } - - public class WatchTestFx - { - public WatchTestFx() - { - var options = new ProtoCore.Options(); - core = new ProtoCore.Core(options); - } - - private ProtoCore.Core core; - public ProtoCore.Core TestCore - { - get - { - return core; - } - } - - public ProtoCore.DSASM.Mirror.ExecutionMirror Mirror { get; private set; } - - public static void GeneratePrintStatements(TextReader file, ref Dictionary> map) - { - string line; - - int lineNo = 0; - - // split code into program statements and loop thro' them - while ((line = file.ReadLine()) != null) - { - lineNo++; - line = line.Trim(); - - if (line.Equals(String.Empty)) - continue; - - // TODO: implement strategy to skip commented code block - // skip commented lines - if (line.StartsWith("//")) - continue; - - List identifiers = null; - int equalIndex = line.IndexOf('='); - if (equalIndex != -1) - { - identifiers = ProtoCore.Utils.ParserUtils.GetLHSatAssignment(line, equalIndex); - if (identifiers.Count == 0) - continue; - - map.Add(lineNo, identifiers); - } - - } - file.Close(); - - } - - public static void GeneratePrintStatements(string fileContent, ref Dictionary> map) - { - string line; - - int lineNo = 0; - - string[] lines = fileContent.Split('\n'); - - // split code into program statements and loop thro' them - foreach (string contentLine in lines) - { - line = contentLine; - lineNo++; - line = line.Trim(); - - if (line.Equals(String.Empty)) - continue; - - // TODO: implement strategy to skip commented code block - // skip commented lines - if (line.StartsWith("//")) - continue; - - List identifiers = null; - int equalIndex = line.IndexOf('='); - if (equalIndex != -1) - { - identifiers = ProtoCore.Utils.ParserUtils.GetLHSatAssignment(line, equalIndex); - if (identifiers.Count == 0) - continue; - - map.Add(lineNo, identifiers); - } - - } - } - - public void CompareRunAndWatchResults(string includePath, string code, Dictionary> map, bool watchNestedMode = false, string defectID = "") - { - try - { - InjectionExecutive.ExpressionMap.Clear(); - InjectionExecutive.IsPopToPropertyArray = false; - - TestRunnerRunOnly(includePath, code, map); - } - catch (Exception e) - { - Assert.Ignore("Ignored due to Exception from run: " + e.ToString()); - } - - DebugRunnerStepIn(includePath, code, map, watchNestedMode, defectID); - } - - - - internal void TestRunnerRunOnly(string includePath, string code, Dictionary> map /*, string executionLogFilePath*/) - { - ProtoScript.Runners.ProtoScriptRunner fsr = new ProtoScriptRunner(); - - // Specify some of the requirements of IDE. - - core.Options.ExecutionMode = ProtoCore.ExecutionMode.Serial; - core.Options.WatchTestMode = true; - core.Options.GCTempVarsOnDebug = false; - - // Cyclic dependency threshold is lowered from the default (2000) - // as this causes the test framework to be painfully slow - core.Options.kDynamicCycleThreshold = 5; - - // Pass the absolute path so that imported filepaths can be resolved - // in "FileUtils.GetDSFullPathName()" - if (!String.IsNullOrEmpty(includePath)) - { - includePath = Path.GetDirectoryName(includePath); - core.Options.IncludeDirectories.Add(includePath); - } - - //StreamWriter sw = File.CreateText(executionLogFilePath); - TextOutputStream fs = new TextOutputStream(map); - - // By specifying this option we inject a mock Executive ('InjectionExecutive') - // that prints stackvalues at every assignment statement - // by overriding the POP_handler instruction - pratapa - -// core.ExecutiveProvider = new InjectionExecutiveProvider(); - - core.BuildStatus.MessageHandler = fs; - core.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(core)); - core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core)); - - DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); - - //Run - RuntimeCore runtimeCore = fsr.Execute(code, core); - Mirror = runtimeCore.Mirror; - - //sw.Close(); - runtimeCore.Cleanup(); - } - - internal static void DebugRunnerStepIn(string includePath, string code, /*string logFile*/Dictionary> map, - bool watchNestedMode = false, string defectID = "") - { - //Internal setup - ProtoCore.Core core; - DebugRunner fsr; - - // Specify some of the requirements of IDE. - var options = new ProtoCore.Options(); - options.ExecutionMode = ProtoCore.ExecutionMode.Serial; - options.GCTempVarsOnDebug = false; - - // Cyclic dependency threshold is lowered from the default (2000) - // as this causes the test framework to be painfully slow - options.kDynamicCycleThreshold = 5; - - // Pass the absolute path so that imported filepaths can be resolved - // in "FileUtils.GetDSFullPathName()" - if (!String.IsNullOrEmpty(includePath)) - { - includePath = Path.GetDirectoryName(includePath); - options.IncludeDirectories.Add(includePath); - } - - - core = new ProtoCore.Core(options); - - - core.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(core)); - core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core)); - - fsr = new DebugRunner(core); - - DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); - - //Run - fsr.PreStart(code); - - - RuntimeCore runtimeCore = fsr.runtimeCore; - - //StreamReader log = new StreamReader(logFile); - - //bool isPrevBreakAtPop = false; - int lineAtPrevBreak = -1; - DebugRunner.VMState vms = null; - - while (!fsr.isEnded) - { - vms = fsr.LastState; - - OpCode opCode = OpCode.NONE; - DebugInfo debug = null; - if (vms != null) - { - // check if previous break is a POP - // if so, get the line no. and LHS - opCode = fsr.CurrentInstruction.opCode; - debug = fsr.CurrentInstruction.debug; - - if (opCode == ProtoCore.DSASM.OpCode.POP) - { - //isPrevBreakAtPop = true; - lineAtPrevBreak = vms.ExecutionCursor.StartInclusive.LineNo; - } - } - - DebugRunner.VMState currentVms = fsr.Step(); - - //if (isPrevBreakAtPop) - - if (debug != null) - { - // Do not do the verification for imported DS files, for which the FilePath is non null - if (debug.Location.StartInclusive.SourceLocation.FilePath == null) - { - if (opCode == ProtoCore.DSASM.OpCode.POP) - { - VerifyWatch_Run(lineAtPrevBreak, runtimeCore.DebugProps.CurrentSymbolName, core, runtimeCore, map, watchNestedMode, defectID: defectID); - } - // if previous breakpoint was at a CALLR - else if (opCode == ProtoCore.DSASM.OpCode.CALLR) - { - if (runtimeCore.DebugProps.IsPopmCall) - { - int ci = currentVms.mirror.MirrorTarget.rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.FrameIndexClassIndex).ClassIndex; - VerifyWatch_Run(InjectionExecutive.callrLineNo, runtimeCore.DebugProps.CurrentSymbolName, core, runtimeCore, map, watchNestedMode, ci, defectID); - } - } - } - } - //isPrevBreakAtPop = false; - } - runtimeCore.Cleanup(); - } - - /*internal static void VerifyWatch_Run(int lineAtPrevBreak, string symbolName, Core core, StreamReader log, - bool watchNestedMode = false) - { - //bool check = true; - - // search for the line and LHS string in the log file - // verify that the LHS identifier name equals 'symbolName' - // pass the LHS string to GetWatchValue() and inspect it - // verify the watch values with the log output - string line = null; - while ((line = log.ReadLine()) != null) - { - // Get line no. - Match m = Regex.Match(line, @"At line, (\d+)"); - if (m.Success) - { - int lineNo = int.Parse(m.Groups[1].Value); - if (lineNo == lineAtPrevBreak) - { - // Get lhs string - // m = Regex.Match(line, @"(\d+), (\w+)"); - m = Regex.Match(line, @"(\d+), (.*)([^\s]+)"); - if (m.Success) - { - string lhsString = m.Groups[2].Value; - - // Get lhs symbol name - m = Regex.Match(lhsString, @"(\w+)"); - if (m.Success) - { - string lhsName = m.Groups[1].Value; - if (lhsName.Equals(symbolName)) - { - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core); - ProtoCore.DSASM.Mirror.ExecutionMirror mirror = watchRunner.Execute(lhsString); - Obj obj = mirror.GetWatchValue(); - - if (!watchNestedMode) - { - // Cheat by peeking into heap etc. to dump output string - // match string with log output to verify - string result = mirror.GetStringValue(obj.DsasmValue, core.Heap, 0, true); - line = log.ReadLine(); - - m = Regex.Match(line, @"Info: (.*)"); - if (m.Success) - { - string output = m.Groups[1].Value; - if (!output.Equals(result)) - { - Assert.Fail(string.Format("\tThe value of expression \"{0}\" doesn't match in run mode and in watch.\n", lhsString)); - return; - } - } - } - else - { - // TODO: Implement this - pratapa - // if obj is a class pointer, handle separately - // if obj is an array pointer, handle separately - // if obj is a literal, verify watch value with log output directly - GetStringValue(obj, mirror); - } - break; - } - } - } - } - } - } - }*/ - - internal static void VerifyWatch_Run(int lineAtPrevBreak, string symbolName, Core core, RuntimeCore runtimeCore, - Dictionary> map, bool watchNestedMode = false, int ci = Constants.kInvalidIndex, string defectID = "") - { - //bool check = true; - - // search for the line and LHS string in the map - // verify that the LHS identifier name equals 'symbolName' - // pass the LHS string to GetWatchValue() and inspect it - // verify the watch values with the log output - if (!map.ContainsKey(lineAtPrevBreak)) - return; - - List expressions = map[lineAtPrevBreak]; - foreach(string exp in expressions) - { - // Get line no. - // Get lhs symbol name - string lhsName = null; - int index = exp.IndexOf('.'); - if (index != -1) - { - string[] parts = exp.Split('.'); - lhsName = parts[parts.Length - 1]; - } - else - { - Match m = Regex.Match(exp, @"(\w+)"); - if (m.Success) - { - lhsName = m.Groups[1].Value; - } - } - if (lhsName.Equals(symbolName)) - { - ExpressionInterpreterRunner watchRunner = new ExpressionInterpreterRunner(core, runtimeCore); - ProtoCore.DSASM.Mirror.ExecutionMirror mirror = watchRunner.Execute(exp); - Obj obj = mirror.GetWatchValue(); - - if (!watchNestedMode) - { - // Cheat by peeking into heap etc. to dump output string - // match string with map output to verify - string result = mirror.GetStringValue(obj.DsasmValue, runtimeCore.RuntimeMemory.Heap, 0, true); - - Expression expr = new Expression(lineAtPrevBreak, exp, ci); - if (!InjectionExecutive.ExpressionMap.ContainsKey(expr)) - return; - - List values = InjectionExecutive.ExpressionMap[expr]; - - if (!values.Contains(result)) - { - Assert.Fail(string.Format("\tThe value of expression \"{0}\" doesn't match in run mode and in watch.\nTracked by Defect: {1}", exp, defectID)); - return; - } - } - else - { - // TODO: Implement this! - pratapa - // if obj is a class pointer, handle separately - // if obj is an array pointer, handle separately - // if obj is a literal, verify watch value with log output directly - GetStringValue(obj, mirror); - } - //break; - } - } - } - - // TODO: Implement this to recurse through expressions in watch window and running expression interpreter for each of their sub-types - pratapa - internal static void GetStringValue(Obj obj, ProtoCore.DSASM.Mirror.ExecutionMirror mirror) - { - switch (obj.DsasmValue.optype) - { - case AddressType.ArrayPointer: - { - List ol = mirror.GetArrayElements(obj); - - foreach (Obj o in ol) - { - GetStringValue(o, mirror); - } - return; - } - case AddressType.Pointer: - { - Dictionary os = mirror.GetProperties(obj); - for (int i = 0; i < os.Count; ++i) - { - - } - return; - } - default: - return; - } - } - } -} -