Permalink
Browse files

More Win8 fixes

  • Loading branch information...
1 parent 93e6aff commit 18cd5b92ff0b415d474f2f4d8807bf2c9c3f67c9 @tmat tmat committed Aug 12, 2012
Showing with 1,260 additions and 850 deletions.
  1. +2 −2 Languages/IronPython/Tests/test_help.py
  2. +117 −0 Languages/Ruby/IronRuby.Tests/DLR/PlatformAdaptationLayerTests.cs
  3. +68 −19 Languages/Ruby/IronRuby.Tests/Driver.cs
  4. +6 −5 Languages/Ruby/IronRuby.Tests/Helpers.cs
  5. +1 −0 Languages/Ruby/IronRuby.Tests/IronRuby.Tests.csproj
  6. +14 −8 Languages/Ruby/IronRuby.Tests/Parser/ParserTests.cs
  7. +31 −12 Languages/Ruby/IronRuby.Tests/RubyTests.cs
  8. +13 −14 Languages/Ruby/IronRuby.Tests/Runtime/ClrTests.cs
  9. +1 −1 Languages/Ruby/IronRuby.Tests/Runtime/ConstantTests.cs
  10. +8 −9 Languages/Ruby/IronRuby.Tests/Runtime/DlrInteropTests.cs
  11. +2 −0 Languages/Ruby/IronRuby.Tests/Runtime/HostingTests.cs
  12. +240 −240 Languages/Ruby/IronRuby.Tests/Runtime/LoaderTests.cs
  13. +41 −13 Languages/Ruby/IronRuby.Tests/Runtime/MutableStringTests.cs
  14. +307 −297 Languages/Ruby/IronRuby.Tests/Runtime/OverloadResolutionTests.cs
  15. +33 −50 Languages/Ruby/Libraries/Builtins/RubyEncodingOps.cs
  16. +28 −32 Languages/Ruby/Libraries/Initializers.Generated.cs
  17. +2 −2 Languages/Ruby/Ruby/Builtins/RubyClass.cs
  18. +183 −114 Languages/Ruby/Ruby/Builtins/RubyEncoding.cs
  19. +1 −1 Languages/Ruby/Ruby/Builtins/RubyModule.cs
  20. +1 −0 Languages/Ruby/Ruby/Ruby.csproj
  21. +101 −0 Languages/Ruby/Ruby/Runtime/AsciiEncoding.cs
  22. +2 −0 Languages/Ruby/Ruby/Runtime/RubyContext.cs
  23. +13 −3 Runtime/Microsoft.Dynamic/MutableTuple.cs
  24. +16 −16 Runtime/Microsoft.Dynamic/Utils/ReflectionUtils.cs
  25. +29 −12 Runtime/Microsoft.Scripting/PlatformAdaptationLayer.cs
@@ -460,8 +460,8 @@ def test_paramrefs():
# by paramnames.
import System
x = run_help(System.DateTime.Parse)
-
- Assert(x.find("A System.DateTime equivalent to the date and time contained in s") != -1)
+
+ Assert(x.find("equivalent to the date and time contained in s") != -1)
@skip("silverlight") #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=20236#
def test_type():
@@ -0,0 +1,117 @@
+/* ****************************************************************************
+ *
+ * Copyright (c) Microsoft Corporation.
+ *
+ * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
+ * copy of the license can be found in the License.html file at the root of this distribution. If
+ * you cannot locate the Apache License, Version 2.0, please send an email to
+ * ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
+ * by the terms of the Apache License, Version 2.0.
+ *
+ * You must not remove this notice, or any other, from this software.
+ *
+ *
+ * ***************************************************************************/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using Microsoft.Scripting.Runtime;
+using Microsoft.Scripting.Utils;
+using Microsoft.Scripting;
+
+namespace IronRuby.Tests {
+ public partial class Tests {
+ private class WinPAL : PlatformAdaptationLayer {
+ public override bool IsSingleRootFileSystem {
+ get { return false; }
+ }
+ }
+
+ public void IsAbsolutePath_Windows() {
+ var pal = new WinPAL();
+
+ Assert(!pal.IsAbsolutePath(null));
+ Assert(!pal.IsAbsolutePath(""));
+ Assert(!pal.IsAbsolutePath("C"));
+ Assert(!pal.IsAbsolutePath(@"\"));
+ Assert(!pal.IsAbsolutePath(@"/"));
+ Assert(!pal.IsAbsolutePath(@":"));
+ Assert(!pal.IsAbsolutePath(@"\:"));
+ Assert(!pal.IsAbsolutePath(@"/:"));
+ Assert(!pal.IsAbsolutePath(@"XX:"));
+
+ // current working directory relative
+ Assert(!pal.IsAbsolutePath(@"."));
+ Assert(!pal.IsAbsolutePath(@".\"));
+ Assert(!pal.IsAbsolutePath(@"./"));
+ Assert(!pal.IsAbsolutePath(@".."));
+ Assert(!pal.IsAbsolutePath(@"..\"));
+ Assert(!pal.IsAbsolutePath(@"../"));
+
+ // Drive relative
+ Assert(!pal.IsAbsolutePath(@"C:"));
+
+ // Drive
+ Assert(pal.IsAbsolutePath(@"C:\"));
+ Assert(pal.IsAbsolutePath(@"C:/"));
+ Assert(pal.IsAbsolutePath(@"C:\path"));
+
+ // UNC
+ Assert(pal.IsAbsolutePath(@"\/"));
+ Assert(pal.IsAbsolutePath(@"\\"));
+ Assert(pal.IsAbsolutePath(@"/\"));
+ Assert(pal.IsAbsolutePath(@"//"));
+
+ // relative to the current user:
+ Assert(!pal.IsAbsolutePath(@"~\path"));
+ }
+
+ private class UnixPAL : PlatformAdaptationLayer {
+ public override bool IsSingleRootFileSystem {
+ get { return true; }
+ }
+ }
+
+ public void IsAbsolutePath_Unix()
+ {
+ var pal = new UnixPAL();
+
+ Assert(!pal.IsAbsolutePath(null));
+ Assert(!pal.IsAbsolutePath(""));
+ Assert(!pal.IsAbsolutePath("C"));
+ Assert(!pal.IsAbsolutePath(@":"));
+ Assert(!pal.IsAbsolutePath(@"XX:"));
+
+ // root
+ Assert(pal.IsAbsolutePath(@"\"));
+ Assert(pal.IsAbsolutePath(@"/"));
+ Assert(pal.IsAbsolutePath(@"\:"));
+ Assert(pal.IsAbsolutePath(@"/:"));
+ Assert(pal.IsAbsolutePath(@"\/"));
+ Assert(pal.IsAbsolutePath(@"\\"));
+ Assert(pal.IsAbsolutePath(@"/\"));
+ Assert(pal.IsAbsolutePath(@"//"));
+
+ // current working directory relative
+ Assert(!pal.IsAbsolutePath(@"."));
+ Assert(!pal.IsAbsolutePath(@".\"));
+ Assert(!pal.IsAbsolutePath(@"./"));
+ Assert(!pal.IsAbsolutePath(@".."));
+ Assert(!pal.IsAbsolutePath(@"..\"));
+ Assert(!pal.IsAbsolutePath(@"../"));
+
+ // Drive relative
+ Assert(!pal.IsAbsolutePath(@"C:"));
+
+ // Drive
+ Assert(!pal.IsAbsolutePath(@"C:\"));
+ Assert(!pal.IsAbsolutePath(@"C:/"));
+ Assert(!pal.IsAbsolutePath(@"C:\path"));
+
+ // relative to the current user:
+ Assert(!pal.IsAbsolutePath(@"~\path"));
+ }
+ }
+}
@@ -30,6 +30,7 @@
using System.Globalization;
using System.Threading;
using Microsoft.Scripting.Hosting.Providers;
+using System.Runtime.InteropServices;
#if WIN8
using System.Runtime.InteropServices.WindowsRuntime;
@@ -79,21 +80,8 @@ public class TestRuntime {
Environment.SetEnvironmentVariable("DLR_AssembliesFileName", _testName);
}
#endif
- var runtimeSetup = ScriptRuntimeSetup.ReadConfiguration();
- var languageSetup = runtimeSetup.AddRubySetup();
-
- runtimeSetup.DebugMode = _driver.IsDebug;
- runtimeSetup.PrivateBinding = testCase.Options.PrivateBinding;
- runtimeSetup.HostType = typeof(TestHost);
- runtimeSetup.HostArguments = new object[] { testCase.Options };
-
- languageSetup.Options["ApplicationBase"] = _driver.BaseDirectory;
- languageSetup.Options["NoAdaptiveCompilation"] = _driver.NoAdaptiveCompilation;
- languageSetup.Options["CompilationThreshold"] = _driver.CompilationThreshold;
- languageSetup.Options["Verbosity"] = 2;
-
- _runtime = Ruby.CreateRuntime(runtimeSetup);
- _engine = Ruby.GetEngine(_runtime);
+ _engine = _driver.CreateRubyEngine(testCase.Options.PrivateBinding, testCase.Options);
+ _runtime = _engine.Runtime;
_context = (RubyContext)HostingHelpers.GetLanguageContext(_engine);
}
}
@@ -115,19 +103,50 @@ public class TestHost : ScriptHost {
public class Win8PAL : PlatformAdaptationLayer
{
+ private string cwd;
+
+ public Win8PAL()
+ {
+ StringBuilder buffer = new StringBuilder(300);
+ if (GetCurrentDirectory(buffer.Capacity, buffer) == 0) {
+ throw new IOException();
+ }
+
+ cwd = buffer.ToString();
+ }
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
+ internal static extern int GetCurrentDirectory(int nBufferLength, [Out] StringBuilder lpBuffer);
+
public override Assembly LoadAssembly(string name)
{
- if (name == "IronRuby, Version=1.1.4.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1")
- {
+ if (name.StartsWith("mscorlib")) {
+ return typeof(object).GetTypeInfo().Assembly;
+ }
+
+ if (name == "IronRuby, Version=1.1.4.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1") {
return typeof(Ruby).GetTypeInfo().Assembly;
}
- else if (name == "IronRuby.Libraries, Version=1.1.4.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1")
- {
+
+ if (name == "IronRuby.Libraries, Version=1.1.4.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1") {
return typeof(IronRuby.Builtins.Integer).GetTypeInfo().Assembly;
}
return base.LoadAssembly(name);
}
+
+ public override string CurrentDirectory {
+ get { return cwd; }
+ set { cwd = value; }
+ }
+
+ public override bool FileExists(string path) {
+ return false;
+ }
+
+ public override bool DirectoryExists(string path) {
+ return false;
+ }
}
}
@@ -163,13 +182,24 @@ public int GetFileLineNumber()
private static bool _partialTrust;
private static bool _noAdaptiveCompilation;
private static int _compilationThreshold;
+#if WIN8
+ // TODO: enable when IronPython is ported to WIN8
+ private static bool _runPython = false;
+#else
private static bool _runPython = true;
+#endif
private readonly string _baseDirectory;
public Driver(string baseDirectory) {
_baseDirectory = baseDirectory;
}
+#if FEATURE_REFEMIT
+ public const bool FeatureRefEmit = true;
+#else
+ public const bool FeatureRefEmit = false;
+#endif
+
public TestRuntime TestRuntime {
get { return _testRuntime; }
}
@@ -214,6 +244,25 @@ public int GetFileLineNumber()
get { return _baseDirectory; }
}
+ public ScriptEngine CreateRubyEngine(bool privateBinding = false, OptionsAttribute options = null)
+ {
+ var runtimeSetup = ScriptRuntimeSetup.ReadConfiguration();
+ var languageSetup = runtimeSetup.AddRubySetup();
+
+ runtimeSetup.DebugMode = IsDebug;
+ runtimeSetup.PrivateBinding = privateBinding;
+ runtimeSetup.HostType = typeof(TestHost);
+ runtimeSetup.HostArguments = new object[] { options ?? new OptionsAttribute() };
+
+ languageSetup.Options["ApplicationBase"] = BaseDirectory;
+ languageSetup.Options["NoAdaptiveCompilation"] = NoAdaptiveCompilation;
+ languageSetup.Options["CompilationThreshold"] = CompilationThreshold;
+ languageSetup.Options["Verbosity"] = 2;
+
+ var runtime = Ruby.CreateRuntime(runtimeSetup);
+ return Ruby.GetEngine(runtime);
+ }
+
#if WIN8
private static TextWriter logWriter;
private static Stream logStream;
@@ -187,7 +187,8 @@ private void AssertEquals<T>(object actual, T expected)
}
[DebuggerHiddenAttribute]
- private void AssertOutput(Action f, string expectedOutput, OutputFlags flags) {
+ private void AssertOutput(Action f, string expectedOutput, OutputFlags flags)
+ {
var error = CompareOutput(f, expectedOutput, flags);
if (error != null) {
Assert(false, error);
@@ -339,10 +340,10 @@ private void AssertEquals<T>(object actual, T expected)
/// Asserts an condition it true
/// </summary>
[DebuggerHidden]
- public void Assert(bool condition, string msg) {
+ public void Assert(bool condition, string message) {
if (!condition) {
- AssertBreak();
- _driver.AssertionFailed(msg);
+ AssertBreak(message);
+ _driver.AssertionFailed(message);
}
}
@@ -351,7 +352,7 @@ private void AssertEquals<T>(object actual, T expected)
Assert(condition, "Assertion failed");
}
- internal void AssertBreak() {
+ internal void AssertBreak(string message) {
if (Debugger.IsAttached) {
Debugger.Break();
}
@@ -36,6 +36,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
+ <Compile Include="DLR\PlatformAdaptationLayerTests.cs" />
<Compile Include="DLR\ReflectionUtilsTests.cs" />
<Compile Include="PartialTrustDriver.cs" />
<Compile Include="Runtime\ClrTests_Globals.cs" />
@@ -1015,7 +1015,7 @@ public partial class Tests {
EOF();
}
- private void TokenizeEscapes2() {
+ public void TokenizeEscapes2() {
AssertTokenizer t = NewAssertTokenizer();
// hexa:
@@ -1038,7 +1038,7 @@ public partial class Tests {
t.Expect();
}
- private void UnicodeEscapes1() {
+ public void UnicodeEscapes1() {
AssertTokenizer t = NewAssertTokenizer();
int[] values = new[] { 0x20, 0x102020, 0x20, 0x20, 0 };
@@ -1371,11 +1371,17 @@ public partial class Tests {
Assert(tokens.ToArray().ValueEquals(expected));
}
+#if FEATURE_ENCODING
// encodings suported in preamble:
- private static readonly string[] preambleEncodingNames =
+ private static readonly string[] preambleEncodingNames =
new[] { "ASCII-8BIT", "ASCII", "BINARY", "US-ASCII", "UTF-8", "EUC-JP", "SJIS", "SHIFT_JIS", "LOCALE", "FILESYSTEM" };
+#else
+ // encodings suported in preamble:
+ private static readonly string[] preambleEncodingNames =
+ new[] { "ASCII-8BIT", "ASCII", "BINARY", "US-ASCII", "UTF-8", "LOCALE", "FILESYSTEM" };
+#endif
- private void Encoding1() {
+ public void Encoding1() {
foreach (var name in preambleEncodingNames) {
var encoding = Context.GetEncodingByRubyName(name);
Assert(encoding != null);
@@ -1384,7 +1390,7 @@ public partial class Tests {
Assert(RubyEncoding.AsciiIdentity(encoding));
}
-#if !WIN8
+#if FEATURE_ENCODING
foreach (var info in Encoding.GetEncodings()) {
var encoding = info.GetEncoding();
@@ -1396,7 +1402,7 @@ public partial class Tests {
#endif
}
- private void Encoding2() {
+ public void Encoding2() {
var source1 = Context.CreateSourceUnit(new BinaryContentProvider(BinaryEncoding.Instance.GetBytes(
@"#! foo bar
# enCoding = ascii-8BIT
@@ -1415,7 +1421,7 @@ p __ENCODING__
AssertOutput(() => source2.Execute(), @"#<Encoding:UTF-8>");
}
-#if !WIN8
+#if FEATURE_ENCODING
private void Encoding4() {
var enc = Engine.Execute<RubyEncoding>(@"eval('# encoding: SJIS
__ENCODING__
@@ -1426,7 +1432,7 @@ p __ENCODING__
private void Encoding_Host1() {
Encoding_HostHelper(Encoding.UTF8, "\u0394", true);
-#if !WIN8
+#if FEATURE_ENCODING
Encoding_HostHelper(Encoding.UTF32, "\u0394", false);
#endif
}
Oops, something went wrong.

0 comments on commit 18cd5b9

Please sign in to comment.