···323323 result = new PValue(pvht, this);
324324 break;
325325326326- case "createFromArgs":
327327- if (args.Length%2 != 0)
328328- break;
326326+ case "createfromargs":
329327 pvht = new PValueHashtable(args.Length/2);
330330- for (var i = 0; i < args.Length; i += 2)
328328+ for (var i = 0; i + 1 < args.Length; i += 2)
331329 pvht.AddOverride(args[i], args[i + 1]);
332330 result = new PValue(pvht, this);
333331 break;
+81
PrexoniteTests/Tests/BuiltInTypesTest.cs
···11+// Prexonite
22+//
33+// Copyright (c) 2014, Christian Klauser
44+// All rights reserved.
55+//
66+// Redistribution and use in source and binary forms, with or without modification,
77+// are permitted provided that the following conditions are met:
88+//
99+// Redistributions of source code must retain the above copyright notice,
1010+// this list of conditions and the following disclaimer.
1111+// Redistributions in binary form must reproduce the above copyright notice,
1212+// this list of conditions and the following disclaimer in the
1313+// documentation and/or other materials provided with the distribution.
1414+// The names of the contributors may be used to endorse or
1515+// promote products derived from this software without specific prior written permission.
1616+//
1717+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1818+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1919+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2020+// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
2121+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
2222+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2323+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2424+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
2525+// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626+2727+using System.Collections.Generic;
2828+using System.IO;
2929+using System.Linq;
3030+using JetBrains.Annotations;
3131+using Moq;
3232+using NUnit.Framework;
3333+using Prexonite;
3434+using Prexonite.Commands;
3535+using Prexonite.Compiler;
3636+using Prexonite.Compiler.Ast;
3737+using Prexonite.Compiler.Build;
3838+using Prexonite.Compiler.Symbolic;
3939+using Prexonite.Modular;
4040+using Prexonite.Types;
4141+4242+namespace PrexoniteTests.Tests;
4343+4444+public class BuiltInTypeTests : VMTestsBase
4545+{
4646+ [Test]
4747+ public void HashStaticMethodCreate()
4848+ {
4949+ Compile(@"
5050+function main(x,y) {
5151+ var h = ~Hash.Create(""x"": x, ""y"": y);
5252+ return ""x=$(h[""x""]), y=$(h[""y""]), c=$(h.Count)"";
5353+}
5454+");
5555+ Expect("x=5, y=7, c=2", 5, 7);
5656+ }
5757+5858+ [Test]
5959+ public void HashStaticMethodCreateFromArgs()
6060+ {
6161+ Compile(@"
6262+function main(x,y) {
6363+ var h = ~Hash.CreateFromArgs(""x"", x, ""y"", y);
6464+ return ""x=$(h[""x""]), y=$(h[""y""]), c=$(h.Count)"";
6565+}
6666+");
6767+ Expect("x=3, y=8, c=2", 3, 8);
6868+ }
6969+7070+ [Test]
7171+ public void HashStaticMethodCreateFromArgsIgnoresExcessArg()
7272+ {
7373+ Compile(@"
7474+function main(x,y) {
7575+ var h = ~Hash.CreateFromArgs(""x"", x, ""y"", y, ""z"");
7676+ return ""x=$(h[""x""]), y=$(h[""y""]), c=$(h.Count)"";
7777+}
7878+");
7979+ Expect("x=6, y=9, c=2", 6,9);
8080+ }
8181+}