Permalink
Browse files

sync to head of tfs for rc4

  • Loading branch information...
1 parent c2a69ce commit a148cafcd7de30296cca66da4c059faca9bfbc05 @jredville jredville committed Mar 24, 2010
Showing with 2,777 additions and 257 deletions.
  1. +2 −0 ...ernal.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/fixtures/autoload_script_lines.rb
  2. +36 −0 Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/fixtures/classes.rb
  3. +1 −0 Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/fixtures/empty.rb
  4. +1 −0 Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/fixtures/raise.rb
  5. +122 −0 Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/language/predefined_spec.rb
  6. +10 −2 Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/library/timeout/timeout_spec.rb
  7. +0 −1 Merlin/External.LCA_RESTRICTED/Languages/IronRuby/tests/RailsTests-3.0.pre/actionpack/tmp/.gitignore
  8. +16 −4 Merlin/External.LCA_RESTRICTED/Languages/Ruby/redist-libs/ruby/1.8/timeout.rb
  9. +5 −3 Merlin/External.LCA_RESTRICTED/Languages/Ruby/redist-libs/ruby/site_ruby/1.8/rubygems/dependency.rb
  10. +1 −1 Merlin/Main/Languages/IronPython/IronPython/Compiler/Ast/BinaryExpression.cs
  11. +4 −4 Merlin/Main/Languages/IronPython/IronPython/Runtime/Exceptions/PythonExceptions.cs
  12. +1 −0 Merlin/Main/Languages/IronPython/IronPython/Runtime/FunctionCode.cs
  13. +14 −0 Merlin/Main/Languages/IronPython/IronPython/Runtime/Operations/InstanceOps.cs
  14. +10 −0 Merlin/Main/Languages/IronPython/IronPython/Runtime/Operations/PythonOps.cs
  15. +1 −1 Merlin/Main/Languages/IronPython/IronPython/Runtime/Operations/PythonTypeOps.cs
  16. +3 −23 Merlin/Main/Languages/IronPython/IronPython/Runtime/PythonDocumentationProvider.cs
  17. +3 −10 Merlin/Main/Languages/IronPython/IronPython/Runtime/Types/BuiltinFunction.cs
  18. +131 −62 Merlin/Main/Languages/IronPython/IronPython/Runtime/Types/DocBuilder.cs
  19. +8 −0 Merlin/Main/Languages/IronPython/IronPython/Runtime/Types/TypeInfo.cs
  20. +1 −2 Merlin/Main/Languages/IronPython/IronPythonTest/EngineTest.cs
  21. +2 −0 Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/BacktraceTests.cs
  22. +0 −1 Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/MutableStringOps.cs
  23. +0 −1 Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/RubyTime.cs
  24. +2,197 −83 Merlin/Main/Languages/Ruby/Public/CHANGELOG.txt
  25. +1 −1 Merlin/Main/Languages/Ruby/Ruby/Builtins/LibraryInitializer.cs
  26. +1 −1 Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyBufferedStream.cs
  27. +3 −1 Merlin/Main/Languages/Ruby/Ruby/Compiler/AstGenerator.cs
  28. +0 −1 Merlin/Main/Languages/Ruby/Ruby/Compiler/Generation/ClsTypeEmitter.cs
  29. +1 −2 Merlin/Main/Languages/Ruby/Ruby/Compiler/Generation/RubyTypeBuilder.cs
  30. +1 −1 Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyAccessorInfo.cs
  31. +0 −5 Merlin/Main/Languages/Ruby/Ruby/Runtime/Conversions/ProtocolConversionAction.cs
  32. +44 −0 Merlin/Main/Languages/Ruby/Ruby/Runtime/Loader.cs
  33. +4 −1 Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyExceptionData.cs
  34. +3 −0 Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyScope.cs
  35. +16 −10 Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyScriptCode.cs
  36. +26 −12 Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyStackTraceBuilder.cs
  37. +1 −0 Merlin/Main/Languages/Ruby/Ruby4.sln
  38. +2 −2 Merlin/Main/Languages/Ruby/Scripts/Wix/config.wxi
  39. +11 −3 Merlin/Main/Languages/Ruby/Scripts/irtests.rb
  40. +1 −1 Merlin/Main/Languages/Ruby/Scripts/powershell/update-version.ps1
  41. +5 −1 Merlin/Main/Languages/Ruby/Tests/Interop/net/spec_helper.rb
  42. +8 −3 Merlin/Main/Runtime/Microsoft.Dynamic/Actions/Calls/MethodCandidate.cs
  43. +1 −1 Merlin/Main/Runtime/Microsoft.Dynamic/Actions/DefaultBinder.Invoke.cs
  44. +15 −1 Merlin/Main/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs
  45. +27 −3 Merlin/Main/Runtime/Microsoft.Dynamic/Utils/ThreadLocal.cs
  46. +19 −5 Merlin/Main/Runtime/Microsoft.Scripting/Hosting/ParameterDoc.cs
  47. +5 −0 Merlin/Main/Runtime/Microsoft.Scripting/PlatformAdaptationLayer.cs
  48. +9 −3 Merlin/Main/Runtime/Microsoft.Scripting/Runtime/DlrConfiguration.cs
  49. +3 −0 Merlin/Main/Runtime/Microsoft.Scripting/Utils/NativeMethods.cs
  50. +1 −1 ndp/fx/src/Core/Microsoft/Scripting/Microsoft.Scripting.Core.csproj
@@ -0,0 +1,2 @@
+ScratchPad.record :autoload_script_lines
+SCRIPT_LINES__ = {}
@@ -17,6 +17,42 @@ class ClassWithout_to_s
undef :to_s
end
+ ruby_version_is("" ... "1.9") { SCRIPT_LINES_NAME = 'SCRIPT_LINES__' }
+ ruby_version_is("1.9") { SCRIPT_LINES_NAME = :SCRIPT_LINES__ }
+
+ def self.script_lines_target_file
+ File.dirname(__FILE__) + '/empty.rb'
+ end
+
+ def self.preserving_script_lines()
+ old_script_lines = if Object.constants.include? SCRIPT_LINES_NAME
+ Object.const_get SCRIPT_LINES_NAME
+ else
+ :undefined
+ end
+
+ begin
+ yield
+ ensure
+ if old_script_lines == :undefined
+ Object.class_eval { remove_const SCRIPT_LINES_NAME if Object.constants.include? SCRIPT_LINES_NAME }
+ else
+ Object.const_set SCRIPT_LINES_NAME, old_script_lines
+ end
+ end
+ end
+
+ def self.get_script_lines(filename)
+ preserving_script_lines do
+ Object.const_set :SCRIPT_LINES__, {}
+ load filename
+ SCRIPT_LINES__
+ end
+ end
+
+ class MyHash < Hash
+ end
+
#############################################################################
# Regexp support
#############################################################################
@@ -0,0 +1 @@
+raise "raise.rb raising exception"
@@ -1,4 +1,5 @@
require File.dirname(__FILE__) + '/../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
require 'stringio'
# The following tables are excerpted from Programming Ruby: The Pragmatic Programmer's Guide'
@@ -567,3 +568,124 @@ def obj.foo2; yield; end
Object.const_defined?(:TOPLEVEL_BINDING).should == true
end
end
+
+describe "SCRIPT_LINES__" do
+ it "can be set" do
+ LanguageSpecs.preserving_script_lines do
+ SCRIPT_LINES__ = {}
+ Object.constants.include?(LanguageSpecs::SCRIPT_LINES_NAME).should be_true
+ end
+ end
+
+ it "records file name" do
+ filename = LanguageSpecs.script_lines_target_file
+ LanguageSpecs.get_script_lines(filename).keys[0].should == filename
+ end
+
+ it "records the contents of the file" do
+ filename = LanguageSpecs.script_lines_target_file
+ script_lines = LanguageSpecs.get_script_lines filename
+ script_lines.values[0].class.should == Array
+ script_lines.values[0][0].should == File.open(filename) {|f| f.readline }
+ end
+
+ ruby_version_is "" ... "1.9" do
+ it "records reloads" do
+ LanguageSpecs.preserving_script_lines do
+ SCRIPT_LINES__ = {}
+ filename = LanguageSpecs.script_lines_target_file
+ load filename
+ SCRIPT_LINES__.clear
+ load filename
+ SCRIPT_LINES__.size.should == 1
+ end
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "does not record reloads" do
+ LanguageSpecs.preserving_script_lines do
+ SCRIPT_LINES__ = {}
+ filename = LanguageSpecs.script_lines_target_file
+ load filename
+ SCRIPT_LINES__.clear
+ load filename
+ SCRIPT_LINES__.size.should == 0
+ end
+ end
+ end
+
+ ruby_version_is "" ... "1.9" do
+ it "records the module load even if the module load fails" do
+ LanguageSpecs.preserving_script_lines do
+ SCRIPT_LINES__ = {}
+ lambda { load fixture(__FILE__, 'raise.rb') }.should raise_error
+ SCRIPT_LINES__.size.should == 1
+ end
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "does not record the module load if the module load fails" do
+ LanguageSpecs.preserving_script_lines do
+ SCRIPT_LINES__ = {}
+ lambda { load fixture(__FILE__, 'raise.rb') }.should raise_error
+ SCRIPT_LINES__.size.should == 0
+ end
+ end
+ end
+
+ it "can be set on a module mixed in to Object" do
+ defined?(SCRIPT_LINES__).should be_nil
+ begin
+ Kernel.const_set :SCRIPT_LINES__, {}
+ load LanguageSpecs.script_lines_target_file
+ Kernel.const_get(:SCRIPT_LINES__).size.should > 0
+ ensure
+ Kernel.module_eval { remove_const :SCRIPT_LINES__ if Kernel.constants.include? LanguageSpecs::SCRIPT_LINES_NAME }
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "is not honored as an autoload constant" do
+ begin
+ ScratchPad.clear
+ Object.autoload :SCRIPT_LINES__, fixture(__FILE__, 'autoload_script_lines.rb')
+ ScratchPad.recorded.should be_nil
+ load LanguageSpecs.script_lines_target_file
+ ScratchPad.recorded.should be_nil
+ SCRIPT_LINES__.size.should == 0
+ ensure
+ Object.class_eval { remove_const :SCRIPT_LINES__ }
+ end
+ end
+ end
+
+ ruby_version_is "" ... "1.9" do
+ it "can be set to a Hash subclass" do
+ LanguageSpecs.preserving_script_lines do
+ SCRIPT_LINES__ = LanguageSpecs::MyHash.new
+ load LanguageSpecs.script_lines_target_file
+ SCRIPT_LINES__.size.should == 1
+ end
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "cannot be set to a Hash subclass" do
+ LanguageSpecs.preserving_script_lines do
+ SCRIPT_LINES__ = LanguageSpecs::MyHash.new
+ load LanguageSpecs.script_lines_target_file
+ SCRIPT_LINES__.size.should == 0
+ end
+ end
+ end
+
+ it "can be set to any type" do
+ LanguageSpecs.preserving_script_lines do
+ SCRIPT_LINES__ = mock("mock")
+ load LanguageSpecs.script_lines_target_file
+ SCRIPT_LINES__.class.should == MockObject
+ end
+ end
+end
@@ -27,7 +27,7 @@
rescue Timeout::Error
(Time.now - before_time).should < 1.2
else
- 1.should == 0 # I can't think of a better way to say "shouldn't get here"
+ flunk
end
end
@@ -40,7 +40,7 @@
rescue Timeout::Error
(Time.now - before_time).should > 1.9
else
- 1.should == 0 # I can't think of a better way to say "shouldn't get here"
+ flunk
end
end
@@ -49,4 +49,12 @@
42
end.should == 42
end
+
+ it "cancels the timeout if an exception is raised" do
+ lambda { Timeout::timeout(2) { 1/0 } }.should raise_error(ZeroDivisionError)
+ end
+
+ it "accepts Float arguments" do
+ Timeout::timeout(123.456) { 42 }.should == 42
+ end
end
@@ -55,10 +55,21 @@ def timeout(sec, klass = nil)
exception = klass || Class.new(ExitException)
begin
x = Thread.current
- y = Thread.start {
- sleep sec
- x.raise exception, "execution expired" if x.alive?
- }
+
+ if defined?(RUBY_ENGINE) and RUBY_ENGINE == "ironruby"
+ # Creating a thread is expensive. So we use a timer instead
+ include System::Threading
+ callback = TimerCallback.new {
+ x.raise exception, "execution expired" if x.alive?
+ }
+ timer = Timer.new(callback, nil, System::Int64.new(sec * 1000), Timeout.Infinite)
+ else
+ y = Thread.start {
+ sleep sec
+ x.raise exception, "execution expired" if x.alive?
+ }
+ end
+
yield sec
# return true
rescue exception => e
@@ -73,6 +84,7 @@ def timeout(sec, klass = nil)
# would be expected outside.
raise Error, e.message, e.backtrace
ensure
+ timer.dispose if timer
y.kill if y and y.alive?
end
end
@@ -116,10 +116,12 @@ def =~(other)
Gem::Dependency.new other.name, other.version
end
- pattern = @name
- pattern = /\A#{Regexp.escape @name}\Z/ unless Regexp === pattern
+ if not @pattern
+ @pattern = @name
+ @pattern = /\A#{Regexp.escape @name}\Z/ unless Regexp === @pattern
+ end
- return false unless pattern =~ other.name
+ return false unless @pattern =~ other.name
reqs = other.version_requirements.requirements
@@ -171,7 +171,7 @@ out tmp
method,
Parent.LocalContext,
_left,
- _right
+ AstUtils.Convert(_right, typeof(object))
);
}
@@ -113,19 +113,19 @@ public class BaseException : ICodeFormattable, IPythonObject, IDynamicMetaObject
_type = type;
}
- public static object __new__(PythonType/*!*/ cls, params object[] args) {
+ public static object __new__(PythonType/*!*/ cls, params object[] args\u00F8) {
return Activator.CreateInstance(cls.UnderlyingSystemType, cls);
}
- public static object __new__(PythonType/*!*/ cls, [ParamDictionary]IDictionary<object, object> kwArgs, params object[] args) {
+ public static object __new__(PythonType/*!*/ cls, [ParamDictionary]IDictionary<object, object> kwArgs\u00F8, params object[] args\u00F8) {
return Activator.CreateInstance(cls.UnderlyingSystemType, cls);
}
/// <summary>
/// Initializes the Exception object with an unlimited number of arguments
/// </summary>
- public virtual void __init__(params object[] args) {
- _args = PythonTuple.MakeTuple(args ?? new object[] { null });
+ public virtual void __init__(params object[] args\u00F8) {
+ _args = PythonTuple.MakeTuple(args\u00F8 ?? new object[] { null });
if (_args.__len__() == 1) {
_message = _args[0];
}
@@ -76,6 +76,7 @@ public class FunctionCode : IExpressionSerializable {
_normalDelegate = code;
_lambda = scope;
_argCount = CalculateArgumentCount();
+ _initialDoc = documentation;
// need to take this lock to ensure sys.settrace/sys.setprofile is not actively changing
lock (_CodeCreateAndUpdateDelegateLock) {
@@ -381,6 +381,20 @@ public static object ValueNotEqualsMethod<T>(object y, [NotNull]T x)
return !x.Equals(y);
}
+#if CLR2
+ public static bool TypeNotEqualsMethod(Type x, object y) {
+ ContractUtils.RequiresNotNull(x, "x");
+
+ PythonType pythonType = y as PythonType;
+ if (pythonType != null) {
+ return !x.Equals((Type)pythonType);
+ }
+
+ Type type = y as Type;
+ return y == null || !x.Equals(type);
+ }
+#endif
+
// Structural Equality and Hashing Helpers
public static int StructuralHashMethod(CodeContext/*!*/ context, IStructuralEquatable x) {
@@ -847,6 +847,16 @@ public static partial class PythonOps {
}
public static int Length(object o) {
+ string s = o as string;
+ if (s != null) {
+ return s.Length;
+ }
+
+ object[] os = o as object[];
+ if (os != null) {
+ return os.Length;
+ }
+
object len = PythonContext.InvokeUnaryOperator(DefaultContext.Default, UnaryOperators.Length, o, "len() of unsized object");
int res;
@@ -741,7 +741,7 @@ internal struct BuiltinFunctionKey {
// Simple generated helpbased on ctor, if available.
ConstructorInfo[] cis = type.GetConstructors();
foreach (ConstructorInfo ci in cis) {
- autoDoc += FixCtorDoc(type, DocBuilder.CreateAutoDoc(ci)) + Environment.NewLine;
+ autoDoc += FixCtorDoc(type, DocBuilder.CreateAutoDoc(ci, DynamicHelpers.GetPythonTypeFromType(type).Name, 0)) + Environment.NewLine;
}
return autoDoc;
Oops, something went wrong.

0 comments on commit a148caf

Please sign in to comment.