-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
363 changed files
with
39,628 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Sockets; | ||
using System.Text; | ||
using MoonSharp.Interpreter; | ||
using MoonSharp.VsCodeDebugger; | ||
using MoonSharp.VsCodeDebugger.SDK; | ||
|
||
namespace VsCodeDebugger_Testbed | ||
{ | ||
class Program | ||
{ | ||
const int DEFAULT_PORT = 41912; | ||
|
||
public static void Main(string[] argv) | ||
{ | ||
Script script = new Script(); | ||
MoonSharpVsCodeDebugServer server = new MoonSharpVsCodeDebugServer(script, DEFAULT_PORT); | ||
|
||
script.AttachDebugger(server.GetDebugger()); | ||
|
||
script.DoFile(@"Z:/HDD/temp/lua/fact.lua"); | ||
|
||
Closure func = script.Globals.Get("run").Function; | ||
|
||
server.Start(); | ||
|
||
Console.WriteLine("READY."); | ||
|
||
while (true)//(Console.ReadKey().Key != ConsoleKey.Escape) | ||
{ | ||
try | ||
{ | ||
var val = func.Call(5); | ||
Console.ForegroundColor = ConsoleColor.Magenta; | ||
Console.WriteLine(val.Number); | ||
System.Threading.Thread.Sleep(5000); | ||
} | ||
catch (InterpreterException ex) | ||
{ | ||
Console.ForegroundColor = ConsoleColor.Red; | ||
Console.Write(ex.DecoratedMessage); | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/DevTools/VsCodeDebugger_Testbed/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("VsCodeDebugger_Testbed")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("VsCodeDebugger_Testbed")] | ||
[assembly: AssemblyCopyright("Copyright © 2016")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("d17dd647-76cf-4d87-bdf7-75e1704e8783")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
64 changes: 64 additions & 0 deletions
64
src/DevTools/VsCodeDebugger_Testbed/VsCodeDebugger_Testbed.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{D17DD647-76CF-4D87-BDF7-75E1704E8783}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>VsCodeDebugger_Testbed</RootNamespace> | ||
<AssemblyName>VsCodeDebugger_Testbed</AssemblyName> | ||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\MoonSharp.Interpreter\MoonSharp.Interpreter.net35-client.csproj"> | ||
<Project>{91ea9b9d-fe03-4273-bdaf-8ad42ede1e59}</Project> | ||
<Name>MoonSharp.Interpreter.net35-client</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\..\MoonSharp.VsCodeDebugger\MoonSharp.VsCodeDebugger.net35-client.csproj"> | ||
<Project>{eb7d4595-299f-489b-90ac-55066a4675f9}</Project> | ||
<Name>MoonSharp.VsCodeDebugger.net35-client</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
136 changes: 136 additions & 0 deletions
136
src/MoonSharp.Interpreter.Tests/EndToEnd/JsonSerializationTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using MoonSharp.Interpreter; | ||
using MoonSharp.Interpreter.Serialization.Json; | ||
using NUnit.Framework; | ||
|
||
|
||
namespace MoonSharp.Interpreter.Tests.EndToEnd | ||
{ | ||
[TestFixture] | ||
public class JsonSerializationTests | ||
{ | ||
void AssertTableValues(Table t) | ||
{ | ||
Assert.AreEqual(DataType.Number, t.Get("aNumber").Type); | ||
Assert.AreEqual(1, t.Get("aNumber").Number); | ||
|
||
Assert.AreEqual(DataType.String, t.Get("aString").Type); | ||
Assert.AreEqual("2", t.Get("aString").String); | ||
|
||
Assert.AreEqual(DataType.Table, t.Get("anObject").Type); | ||
Assert.AreEqual(DataType.Table, t.Get("anArray").Type); | ||
|
||
Table o = t.Get("anObject").Table; | ||
|
||
Assert.AreEqual(DataType.Number, o.Get("aNumber").Type); | ||
Assert.AreEqual(3, o.Get("aNumber").Number); | ||
|
||
Assert.AreEqual(DataType.String, o.Get("aString").Type); | ||
Assert.AreEqual("4", o.Get("aString").String); | ||
|
||
Table a = t.Get("anArray").Table; | ||
|
||
// 'anArray' : [ 5, '6', true, null, { 'aNumber' : 7, 'aString' : '8' } ] | ||
|
||
Assert.AreEqual(DataType.Number, a.Get(1).Type); | ||
Assert.AreEqual(5, a.Get(1).Number); | ||
|
||
Assert.AreEqual(DataType.String, a.Get(2).Type); | ||
Assert.AreEqual("6", a.Get(2).String); | ||
|
||
Assert.AreEqual(DataType.Boolean, a.Get(3).Type); | ||
Assert.IsTrue(a.Get(3).Boolean); | ||
|
||
Assert.AreEqual(DataType.Boolean, a.Get(3).Type); | ||
Assert.IsTrue(a.Get(3).Boolean); | ||
|
||
Assert.AreEqual(DataType.UserData, a.Get(4).Type); | ||
Assert.IsTrue(JsonNull.IsJsonNull(a.Get(4))); | ||
|
||
Assert.AreEqual(DataType.Table, a.Get(5).Type); | ||
Table s = a.Get(5).Table; | ||
|
||
Assert.AreEqual(DataType.Number, s.Get("aNumber").Type); | ||
Assert.AreEqual(7, s.Get("aNumber").Number); | ||
|
||
Assert.AreEqual(DataType.String, s.Get("aString").Type); | ||
Assert.AreEqual("8", s.Get("aString").String); | ||
} | ||
|
||
|
||
[Test] | ||
public void JsonDeserialization() | ||
{ | ||
string json = @"{ | ||
'aNumber' : 1, | ||
'aString' : '2', | ||
'anObject' : { 'aNumber' : 3, 'aString' : '4' }, | ||
'anArray' : [ 5, '6', true, null, { 'aNumber' : 7, 'aString' : '8' } ] | ||
} | ||
".Replace('\'', '\"'); | ||
|
||
Table t = JsonTableConverter.JsonToTable(json); | ||
AssertTableValues(t); | ||
} | ||
|
||
[Test] | ||
public void JsonSerialization() | ||
{ | ||
string json = @"{ | ||
'aNumber' : 1, | ||
'aString' : '2', | ||
'anObject' : { 'aNumber' : 3, 'aString' : '4' }, | ||
'anArray' : [ 5, '6', true, null, { 'aNumber' : 7, 'aString' : '8' } ] | ||
} | ||
".Replace('\'', '\"'); | ||
|
||
Table t1 = JsonTableConverter.JsonToTable(json); | ||
|
||
string json2 = JsonTableConverter.TableToJson(t1); | ||
|
||
Table t = JsonTableConverter.JsonToTable(json2); | ||
|
||
AssertTableValues(t); | ||
} | ||
|
||
|
||
[Test] | ||
public void JsonObjectSerialization() | ||
{ | ||
object o = new | ||
{ | ||
aNumber = 1, | ||
aString = "2", | ||
anObject = new | ||
{ | ||
aNumber = 3, | ||
aString = "4" | ||
}, | ||
anArray = new object[] | ||
{ | ||
5, | ||
"6", | ||
true, | ||
null, | ||
new | ||
{ | ||
aNumber = 7, | ||
aString = "8" | ||
} | ||
} | ||
}; | ||
|
||
|
||
string json = JsonTableConverter.ObjectToJson(o); | ||
|
||
Table t = JsonTableConverter.JsonToTable(json); | ||
|
||
AssertTableValues(t); | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.