This file contains hidden or 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
# accessing named child elements | |
### normal | |
w.find_name("msg").text = "Hello" | |
### wpf.rb | |
w.msg.text = "Hello" | |
# showing, hiding, and collapsing elements | |
### normal | |
include System::Windows | |
e.visibility = Visibility.hidden |
This file contains hidden or 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
# make sure we put "Lib" on the path -- this contains only | |
# libs required to load unittest ... | |
import sys | |
sys.path.append("Lib") | |
# stop the SL loading animation by setting the rootvisual | |
from System.Windows import Application | |
from System.Windows.Controls import UserControl | |
Application.Current.RootVisual = UserControl() |
This file contains hidden or 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
require 'benchmark' | |
Benchmark.bm { |x| x.report { require 'rubygems' } } | |
# | |
# user system total real | |
# eager transformation | |
# 1.622410 0.031200 1.653611 ( 1.581316) | |
# lazy transformation | |
# 1.170008 0.031200 1.201208 ( 1.099220) | |
# |
This file contains hidden or 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
System::Byte.instance_methods(false) | |
#=> ["-", "%", "&", "*", "**", "/", "-@", "[]", "^", "|", "~", "+", "<", "<<", "<=", "<=>", "==", ">", ">=", ">>", "abs", "div", "divmod", "modulo", "quo", "to_f", "to_s", "zero?", "size", 'compare_to', 'equals', 'get_hash_code', 'to_string', 'get_type_code'] | |
l = System::Byte.instance_methods(false).last | |
#=> 'get_type_code' | |
l.ruby_name | |
#=> "get_type_code" | |
l.clr_name | |
#=> "GetTypeCode" |
This file contains hidden or 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
class System::Decimal | |
instance_methods(false).each do |name| | |
mangled = '__' + name | |
alias_method(mangled, name) | |
private mangled | |
define_method(name) do |*args| | |
puts "method called: #{name}" | |
send mangled, *args | |
end | |
end |
This file contains hidden or 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
require 'c' | |
C.new.foo(1) | |
# System.Int32 | |
C.new.foo("x") | |
# IronRuby.Builtins.MutableString | |
C.new.foo(1.0) | |
# System.Double |
This file contains hidden or 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
// c.dll | |
public class C { | |
public void Foo<T>(T x) { Console.WriteLine(typeof(T)); } | |
} |
This file contains hidden or 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
Feature: Addition | |
In order to avoid silly mistakes | |
As a math idiot | |
I want to be told the sum of two numbers | |
Scenario Outline: Add two numbers | |
Given I have entered <input_1> into the calculator | |
And I have entered <input_2> into the calculator | |
When I press add | |
Then the result should be <output> on the screen |
This file contains hidden or 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
require 'spec/expectations' | |
require 'Calculator' # Calculator.dll | |
Before do | |
@calc = Demo::Calculator.new # A .NET class in Calculator.dll | |
end | |
Given "I have entered $n into the calculator" do |n| | |
@calc.push n.to_i | |
end |
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
namespace Demo { | |
public class Calculator { | |
private List<int>args = new List<int>(); | |
public void Push(int n) { | |
args.Add(n); | |
} |