Example #1
0
        public void PartitionInteger2Strand1()
        {
            AType expected = Helpers.BuildStrand(
                new AType[] {
                Helpers.BuildStrand(
                    new AType[] {
                    AArray.Create(ATypes.ANull),
                    AInteger.Create(8)
                }
                    ),
                Helpers.BuildStrand(
                    new AType[] {
                    AInteger.Create(5),
                    AInteger.Create(4),
                    AInteger.Create(3)
                }
                    )
            }
                );

            AType result = this.engine.Execute <AType>("3 bag (3;4;5;8;)");

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);
        }
Example #2
0
        public void BracketIndexingWithNullMappedIntegerArray()
        {
            AType expected = AArray.Create(
                ATypes.AInteger,
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(5),
                    AInteger.Create(6),
                    AInteger.Create(7)
                ),
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(9),
                    AInteger.Create(12),
                    AInteger.Create(2)
                )
            );

            ScriptScope scope = this.engine.CreateScope();
            string executable = string.Format("a := 1 beam `{0}", MappedFiles.IntegerMatrix.GetFileName());

            this.engine.Execute<AType>(executable, scope);
            this.engine.Execute<AType>("b := a[]", scope);

            this.engine.Execute<AType>("b[1;1] := 12", scope);

            AType result = this.engine.Execute<AType>("a", scope);

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);
        }
Example #3
0
        public void RestrucutreNegativeInteger2Strand()
        {
            AType expected = AArray.Create(
                ATypes.ABox,
                AArray.Create(
                    ATypes.AInteger,
                    ABox.Create(AInteger.Create(4)),
                    ABox.Create(AInteger.Create(5))
                    ),
                AArray.Create(
                    ATypes.ABox,
                    ABox.Create(AInteger.Create(5)),
                    ABox.Create(AInteger.Create(1))
                    ),
                AArray.Create(
                    ATypes.ABox,
                    ABox.Create(AInteger.Create(1)),
                    ABox.Create(AInteger.Create(4))
                    )
                );
            AType result = this.engine.Execute <AType>("-2 ! (4;5;1;4)");

            Assert.AreEqual(expected, result);
            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
        }
Example #4
0
        public void RazeNestedMappedIntegerArray()
        {
            AType expected = AArray.Create(
                ATypes.AInteger,
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(4),
                    AInteger.Create(4),
                    AInteger.Create(4)
                ),
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(9),
                    AInteger.Create(8),
                    AInteger.Create(2)
                )
            );

            ScriptScope scope = this.engine.CreateScope();
            string executable = string.Format("a := 1 beam `{0}", MappedFiles.IntegerMatrix.GetFileName());

            this.engine.Execute<AType>(executable, scope);
            this.engine.Execute<AType>("b := < a", scope);
            this.engine.Execute<AType>("c := pick b", scope);

            this.engine.Execute<AType>("(1 take c) := 4", scope);

            AType result = this.engine.Execute<AType>("a", scope);

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);
        }
Example #5
0
        public void RightEnclosedMappedIntegerArray()
        {
            AType expected = AArray.Create(
                ATypes.AInteger,
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(8),
                    AInteger.Create(2),
                    AInteger.Create(1)
                ),
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(5),
                    AInteger.Create(4),
                    AInteger.Create(2)
                )
            );

            ScriptScope scope = this.engine.CreateScope();
            string executable = string.Format("a := 1 beam `{0}", MappedFiles.IntegerMatrix.GetFileName());

            this.engine.Execute<AType>(executable, scope);
            this.engine.Execute<AType>("b := rtack < a", scope);
            this.engine.Execute<AType>("c := > b", scope);

            this.engine.Execute<AType>("(!c) := 8 2 1 5 4 2", scope);

            AType result = this.engine.Execute<AType>("a", scope);

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);
        }
Example #6
0
        public void ItemRavelIntegerMatrixWithFrame()
        {
            AType expected = AArray.Create(
                ATypes.AInteger,
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(0),
                    AInteger.Create(1),
                    AInteger.Create(2)
                    ),
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(3),
                    AInteger.Create(4),
                    AInteger.Create(5)
                    ),
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(6),
                    AInteger.Create(7),
                    AInteger.Create(8)
                    ),
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(9),
                    AInteger.Create(10),
                    AInteger.Create(11)
                    )
                );
            AType result = this.engine.Execute <AType>("! iota 2 2 3");

            Assert.AreEqual(expected, result);
            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
        }
Example #7
0
        public void StrandWithMappedIntegerArray1()
        {
            AType expected = AArray.Create(
                ATypes.AInteger,
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(5),
                    AInteger.Create(6),
                    AInteger.Create(7)
                ),
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(9),
                    AInteger.Create(8),
                    AInteger.Create(56)
                )
            );

            ScriptScope scope = this.engine.CreateScope();
            string value = string.Format(" 1 beam `{0}", MappedFiles.IntegerMatrix.GetFileName());

            this.engine.Execute<AType>(string.Format("a := {0}", value), scope);
            this.engine.Execute<AType>(string.Format("b := {0}", value), scope);

            this.engine.Execute<AType>("c := (a; iota 2 3; b)", scope);
            this.engine.Execute<AType>("d := > c[2]", scope);
            this.engine.Execute<AType>("d[1;2] := 56", scope);

            AType result = this.engine.Execute<AType>("a", scope);

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);
        }
Example #8
0
        public void MapCharArray2CharArray()
        {
            AType expected = AArray.Create(
                ATypes.AChar,
                Helpers.BuildString("Welcome"),
                Helpers.BuildString("Szeged!")
                );

            ScriptScope scope = this.engine.CreateScope();

            this.engine.Execute <AType>("(2 4 rho 'CharAray') beam 2 7 rho 'WelcomeSzeged!'");
            this.engine.Execute <AType>("t := 0 beam 'CharAray.m'", scope);

            AType result = scope.GetVariable <AType>(".t");

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);

            scope.RemoveVariable(".");

            result = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();

            File.Delete("CharAray.m");
        }
Example #9
0
        public void LaminateBoxArray2SymbolConstant()
        {
            AType expected = AArray.Create(
                ATypes.ABox,
                Helpers.BuildStrand(
                    new AType[]
            {
                AInteger.Create(1),
                AInteger.Create(4),
                AInteger.Create(3)
            }
                    ),
                AArray.Create(
                    ATypes.ASymbol,
                    ASymbol.Create("b"),
                    ASymbol.Create("b"),
                    ASymbol.Create("b")
                    )
                );

            AType result = this.engine.Execute <AType>("(3;4;1) ~ `b");

            Assert.AreEqual(expected, result);
            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
        }
Example #10
0
        public void ReadAndWriteIntegerArray()
        {
            AType expected = AArray.Create(
                ATypes.AInteger,
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(5),
                    AInteger.Create(6),
                    AInteger.Create(7)
                    ),
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(9),
                    AInteger.Create(8),
                    AInteger.Create(55)
                    )
                );

            ScriptScope scope = this.engine.CreateScope();
            string      value = string.Format("1 beam `{0}", MappedFiles.IntegerMatrix.GetFileName());

            this.engine.Execute <AType>(string.Format("a := {0}", value), scope);
            this.engine.Execute <AType>(string.Format("b := {0}", value), scope);

            this.engine.Execute <AType>("a[1;2] := 55", scope);
            AType result = this.engine.Execute <AType>("b", scope);

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);
        }
Example #11
0
        public void ReadAndWriteFloatArray()
        {
            AType expected = AArray.Create(
                ATypes.AFloat,
                AArray.Create(
                    ATypes.AFloat,
                    AFloat.Create(3.4),
                    AFloat.Create(8)
                    ),
                AArray.Create(
                    ATypes.AFloat,
                    AFloat.Create(7.6),
                    AFloat.Create(1.1)
                    )
                );

            ScriptScope scope = this.engine.CreateScope();
            string      value = string.Format("1 beam `{0}", MappedFiles.FloatMatrix.GetFileName());

            this.engine.Execute <AType>(string.Format("a := {0}", value), scope);
            this.engine.Execute <AType>(string.Format("b := {0}", value), scope);

            this.engine.Execute <AType>("((0;1) # b) := 8", scope);
            AType result = this.engine.Execute <AType>("a", scope);

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);
        }
Example #12
0
        public void ReadFloatScalarUseAPATH()
        {
            AType expected = AFloat.Create(3.4);

            string path = Path.Combine(Directory.GetCurrentDirectory(), "Temp");

            Directory.CreateDirectory(path);

            string pathWithFileName = "'" + Path.Combine(path, "FloatTest") + "'";

            this.engine.Execute <AType>(pathWithFileName + " beam 3.4");

            string apath = Environment.GetEnvironmentVariable("APATH", EnvironmentVariableTarget.User);

            Environment.SetEnvironmentVariable("APATH", path, EnvironmentVariableTarget.User);

            AType result = this.engine.Execute <AType>("0 beam `FloatTest.m");

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);

            Environment.SetEnvironmentVariable("APATH", apath, EnvironmentVariableTarget.User);

            result = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();

            Directory.Delete(path, true);
        }
Example #13
0
        public void CastChar2SymbolMatrix()
        {
            AType expected = AArray.Create(
                ATypes.AChar,
                AArray.Create(
                    ATypes.AChar,
                    Helpers.BuildString("a   "),
                    Helpers.BuildString("abcd"),
                    Helpers.BuildString("t   ")
                    ),
                AArray.Create(
                    ATypes.AChar,
                    Helpers.BuildString("dfg "),
                    Helpers.BuildString("a   "),
                    Helpers.BuildString("abcd")
                    ),
                AArray.Create(
                    ATypes.AChar,
                    Helpers.BuildString("t   "),
                    Helpers.BuildString("dfg "),
                    Helpers.BuildString("a   ")
                    )
                );

            AType result = this.engine.Execute <AType>("`char ? 3 3 rho `a `abcd `t `dfg");

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);
        }
Example #14
0
        public void ReadIntegerArray()
        {
            AType expected = AArray.Create(
                ATypes.AInteger,
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(5),
                    AInteger.Create(6),
                    AInteger.Create(7)
                    ),
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(9),
                    AInteger.Create(8),
                    AInteger.Create(2)
                    )
                );

            ScriptScope scope      = this.engine.CreateScope();
            string      executable = string.Format("a := beam '{0}'", MappedFiles.IntegerMatrix.GetFileName());

            this.engine.Execute <AType>(executable, scope);
            this.engine.Execute <AType>("(1 take a) := 1 3 rho 9 2 4", scope);

            executable = string.Format("beam '{0}'", MappedFiles.IntegerMatrix.GetFileName());
            AType result = this.engine.Execute <AType>(executable, scope);

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);
        }
Example #15
0
        public void SimpleIndexAssignCallback()
        {
            AType expected =
                Helpers.BuildStrand(
                    new AType[]
            {
                ASymbol.Create("b"),
                ASymbol.Create(""),
                Utils.ANull(),
                AInteger.Create(1),
                AInteger.Create(200),
                Helpers.BuildString("static")
            }
                    );

            ScriptScope scope = this.engine.CreateScope();

            this.engine.Execute("b := 10 20 30 40", scope);
            this.engine.Execute("cbf{a;b;c;d;e;f}:{.result := (a;b;c;d;e;f)}", scope);
            this.engine.Execute("_scb{`b;(cbf;'static')}", scope);
            this.engine.Execute("b[1] := 200", scope);

            AType result = scope.GetVariable <AType>(".result");

            Assert.AreEqual(expected.CompareInfos(result), InfoResult.OK);
            Assert.AreEqual(expected, scope.GetVariable <AType>(".result"));
        }
Example #16
0
        public void DiscloseNestedUniformFloatVector2()
        {
            AType expected = AArray.Create(
                ATypes.AFloat,
                AArray.Create(
                    ATypes.AFloat,
                    AFloat.Create(4),
                    AFloat.Create(7)
                    ),
                AArray.Create(
                    ATypes.AFloat,
                    AFloat.Create(4),
                    AFloat.Create(6)
                    ),
                AArray.Create(
                    ATypes.AFloat,
                    AFloat.Create(4.3),
                    AFloat.Create(0)
                    )
                );

            AType result = this.engine.Execute <AType>(">(4 7; 4 6; 4.3 0)");

            Assert.AreEqual <AType>(expected, result);
            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
        }
Example #17
0
        public void SelectiveAssignment()
        {
            AType expected =
                Helpers.BuildStrand(
                    new AType[]
            {
                ASymbol.Create("b"),
                ASymbol.Create("ctx"),
                Utils.ANull(),
                AInteger.Create(0),
                ABox.Create(AArray.Create(ATypes.ASymbol, ASymbol.Create("Scalar"), ASymbol.Create("Vector"), ASymbol.Create("Matrix"))),
                Helpers.BuildString("static")
            }
                    );

            ScriptScope scope = this.engine.CreateScope();

            this.engine.Execute("$cx ctx", scope);
            this.engine.Execute("b := (`scalar `vector `matrix; (3.14; 'abcdef'; iota 3 2))", scope);
            this.engine.Execute("cbf{a;b;c;d;e;f}:{.result := (a;b;c;d;e;f)}", scope);
            this.engine.Execute("_scb{`b;(cbf;'static')}", scope);
            this.engine.Execute("(1 0 /b) := <`Scalar `Vector `Matrix", scope);

            Assert.AreEqual(expected.CompareInfos(scope.GetVariable <AType>(".result")), InfoResult.OK);
            Assert.AreEqual(expected, scope.GetVariable <AType>(".result"));
        }
Example #18
0
        public void EachUseUserDefinedFunctionScalard2IntegerMatrix()
        {
            AType expected = AArray.Create(
                ATypes.ABox,
                Helpers.BuildStrand(
                    new AType[] {
                AFloat.Create(3),
                AFloat.Create(2.5),
                AFloat.Create(2)
            }
                    ),
                Helpers.BuildStrand(
                    new AType[] {
                AFloat.Create(4.5),
                AFloat.Create(4),
                AFloat.Create(3.5)
            }
                    )
                );

            ScriptScope scope = this.engine.CreateScope();

            this.engine.Execute <AType>("a{b;c} : (b+c)%2", scope);
            AType result = this.engine.Execute <AType>("4 a each iota 2 3", scope);

            Assert.AreEqual(expected, result);
            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
        }
Example #19
0
        public void DecodeFloatList2IntegerArray()
        {
            AType expected = AArray.Create(
                ATypes.AFloat,
                AArray.Create(
                    ATypes.AFloat,
                    AArray.Create(ATypes.AFloat, AFloat.Create(64), AFloat.Create(76)),
                    AArray.Create(ATypes.AFloat, AFloat.Create(88), AFloat.Create(100)),
                    AArray.Create(ATypes.AFloat, AFloat.Create(112), AFloat.Create(124)),
                    AArray.Create(ATypes.AFloat, AFloat.Create(136), AFloat.Create(148))
                    ),
                AArray.Create(
                    ATypes.AFloat,
                    AArray.Create(ATypes.AFloat, AFloat.Create(160), AFloat.Create(172)),
                    AArray.Create(ATypes.AFloat, AFloat.Create(184), AFloat.Create(196)),
                    AArray.Create(ATypes.AFloat, AFloat.Create(208), AFloat.Create(220)),
                    AArray.Create(ATypes.AFloat, AFloat.Create(232), AFloat.Create(244))
                    )
                );

            AType result = this.engine.Execute <AType>("3 4.5 2 pack iota 3 2 4 2");

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);
        }
Example #20
0
        public void EachUseDyadicNonScalarFunctionStrand2Strand()
        {
            AType expected = AArray.Create(
                ATypes.ABox,
                ABox.Create(
                    AArray.Create(ATypes.AInteger, AInteger.Create(0), AInteger.Create(1))
                    ),
                ABox.Create(
                    AArray.Create(
                        ATypes.AInteger,
                        AArray.Create(
                            ATypes.AInteger,
                            AInteger.Create(8),
                            AInteger.Create(9),
                            AInteger.Create(10),
                            AInteger.Create(11)
                            )
                        )
                    )
                );

            AType result = this.engine.Execute <AType>("(2;-1) take each (iota 4; iota 3 4)");

            Assert.AreEqual(expected, result);
            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
        }
Example #21
0
        public void RakeMappedIntegerArray()
        {
            AType expected = AArray.Create(
                ATypes.AInteger,
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(5),
                    AInteger.Create(6),
                    AInteger.Create(7)
                ),
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(4),
                    AInteger.Create(2),
                    AInteger.Create(8)
                )
            );

            ScriptScope scope = this.engine.CreateScope();
            string executable = string.Format("a := 1 beam `{0}", MappedFiles.IntegerMatrix.GetFileName());

            this.engine.Execute<AType>(executable, scope);
            this.engine.Execute<AType>("b := in a", scope);

            this.engine.Execute<AType>("c := > b[0]", scope);

            this.engine.Execute<AType>("(0 1 / c) := 1 3 rho 4 2 8", scope);

            AType result = this.engine.Execute<AType>("a", scope);

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);
        }
Example #22
0
        public void UnpackSymbolConstantMatrix()
        {
            AType expected = AArray.Create(
                ATypes.AChar,
                AArray.Create(
                    ATypes.AChar,
                    AArray.Create(ATypes.AChar, AChar.Create('a'), AChar.Create(' '), AChar.Create(' '), AChar.Create(' ')),
                    AArray.Create(ATypes.AChar, AChar.Create('a'), AChar.Create('b'), AChar.Create('c'), AChar.Create('d')),
                    AArray.Create(ATypes.AChar, AChar.Create('t'), AChar.Create(' '), AChar.Create(' '), AChar.Create(' '))
                    ),
                AArray.Create(
                    ATypes.AChar,
                    AArray.Create(ATypes.AChar, AChar.Create('d'), AChar.Create('f'), AChar.Create('g'), AChar.Create(' ')),
                    AArray.Create(ATypes.AChar, AChar.Create('a'), AChar.Create(' '), AChar.Create(' '), AChar.Create(' ')),
                    AArray.Create(ATypes.AChar, AChar.Create('a'), AChar.Create('b'), AChar.Create('c'), AChar.Create('d'))
                    ),
                AArray.Create(
                    ATypes.AChar,
                    AArray.Create(ATypes.AChar, AChar.Create('t'), AChar.Create(' '), AChar.Create(' '), AChar.Create(' ')),
                    AArray.Create(ATypes.AChar, AChar.Create('d'), AChar.Create('f'), AChar.Create('g'), AChar.Create(' ')),
                    AArray.Create(ATypes.AChar, AChar.Create('a'), AChar.Create(' '), AChar.Create(' '), AChar.Create(' '))
                    )
                );

            AType result = this.engine.Execute <AType>("unpack 3 3 rho `a `abcd `t `dfg");

            Assert.AreEqual(expected, result);
            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
        }
Example #23
0
        public void RazeBoxVectorWithMappedIntegerArray()
        {
            AType expected = AArray.Create(
                ATypes.AInteger,
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(5),
                    AInteger.Create(6),
                    AInteger.Create(7)
                ),
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(9),
                    AInteger.Create(8),
                    AInteger.Create(2)
                )
            );

            ScriptScope scope = this.engine.CreateScope();
            string executable = string.Format("a := 1 beam `{0}", MappedFiles.IntegerMatrix.GetFileName());

            this.engine.Execute<AType>(executable, scope);
            this.engine.Execute<AType>("b := (a;iota 2 3)", scope);
            this.engine.Execute<AType>("c := pick b", scope);

            this.engine.Execute<AType>("c[1;0] := 14", scope);

            AType result = this.engine.Execute<AType>("a", scope);

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);
        }
Example #24
0
        public void RankComplexTest()
        {
            AType expected = AArray.Create(
                ATypes.ABox,
                Helpers.BuildStrand(
                    new AType[] {
                AArray.Create(ATypes.AInteger, AInteger.Create(2)),
                AArray.Create(ATypes.AInteger, AInteger.Create(0)),
            }
                    ),
                Helpers.BuildStrand(
                    new AType[] {
                AArray.Create(ATypes.AInteger, AInteger.Create(1)),
                AArray.Create(ATypes.AInteger, AInteger.Create(0)),
            }
                    ),
                Helpers.BuildStrand(
                    new AType[] {
                AArray.Create(ATypes.AInteger, AInteger.Create(3)),
                AArray.Create(ATypes.AInteger, AInteger.Create(0)),
            }
                    )
                );

            AType result = this.engine.Execute <AType>("rho each (rho each) @ -2 rtack 3 2 rho (4; iota 2 3; 2; iota 5; 7; iota 2 3 4)");

            Assert.AreEqual(expected, result);
            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
        }
Example #25
0
        public void DiscloseMappedIntegerArray()
        {
            AType expected = AArray.Create(
                ATypes.AInteger,
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(1),
                    AInteger.Create(6),
                    AInteger.Create(7)
                ),
                AArray.Create(
                    ATypes.AInteger,
                    AInteger.Create(9),
                    AInteger.Create(3),
                    AInteger.Create(2)
                )
            );

            ScriptScope scope = this.engine.CreateScope();
            string executable = string.Format("a := 1 beam `{0}", MappedFiles.IntegerMatrix.GetFileName());

            this.engine.Execute<AType>(executable, scope);
            this.engine.Execute<AType>("b := > a", scope);

            this.engine.Execute<AType>("(0 0 flip b) := 1 3", scope);

            AType result = this.engine.Execute<AType>("a", scope);

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);
        }
Example #26
0
        public void RestructureIntegerList2NestedArray()
        {
            ScriptScope scope = this.engine.CreateScope();
            AType       f     = this.engine.Execute <AType>("f := {+}", scope);

            AType expected = AArray.Create(
                ATypes.ASymbol,
                AArray.Create(
                    ATypes.ASymbol,
                    ASymbol.Create("a"),
                    ASymbol.Create("b")
                    ),
                AArray.Create(
                    ATypes.ABox,
                    ABox.Create(AInteger.Create(3)),
                    ABox.Create(AInteger.Create(4))
                    ),
                AArray.Create(
                    ATypes.AFunc,
                    ABox.Create(f),
                    ABox.Create(AInteger.Create(6))
                    )
                );
            AType result = this.engine.Execute <AType>("2 ! (`a`b , (3;4)) , (f;6)", scope);

            Assert.AreEqual(expected, result);
            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
        }
Example #27
0
        public void PartitionIntegerList2MixedNestedArray()
        {
            ScriptScope scope = this.engine.CreateScope();
            AType       f     = this.engine.Execute <AType>("f := <{+}", scope);

            AType expected = AArray.Create(
                ATypes.ABox,
                ABox.Create(
                    AArray.Create(
                        ATypes.ASymbol,
                        ASymbol.Create("a"),
                        ABox.Create(AInteger.Create(4))
                        )
                    ),
                ABox.Create(
                    AArray.Create(
                        ATypes.AFunc,
                        f
                        )
                    ),
                ABox.Create(Utils.ANull())
                );

            AType result = this.engine.Execute <AType>("2 2 1 bag `a , (< 4) , f", scope);

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);
        }
Example #28
0
        public void FloatvectorTest()
        {
            AType result   = SysImp.Instance.Import(TestUtils.FileToByteArray("floatvector.dat"));
            AType expected = this.engine.Execute <AType>("5 rho 1.1");

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);
        }
Example #29
0
        public void ScalarInNullMember()
        {
            AType expected = AInteger.Create(0);
            AType result   = this.engine.Execute <AType>("1 in ()");

            Assert.AreEqual <AType>(expected, result, "Invalid value produced");
            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
        }
Example #30
0
        public void NullmatrixTest()
        {
            AType result   = SysImp.Instance.Import(TestUtils.FileToByteArray("nullmatrix.dat"));
            AType expected = this.engine.Execute <AType>("5 5 5 rho ()");

            Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected));
            Assert.AreEqual(expected, result);
        }