Created
July 19, 2010 08:25
-
-
Save jschementi/481156 to your computer and use it in GitHub Desktop.
MIX10, Part 2.2 & 3
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
foo_module = IronRuby.require 'foo' | |
foo_module.Foo.new.bar |
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
class Foo(object): | |
def bar(self): | |
print 'Look ma, white-space-sensitivity!' |
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
var runtime = ScriptRuntime.CreateFromConfiguration(); | |
var engine = runtime.GetEngine("IronPython"); | |
dynamic scope = engine.CreateScope(); | |
scope.page = this; | |
engine.Execute("page.Message.Text = 'Hello from Python!'", scope); |
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
describe '.NET Stack instantiation' do | |
it 'can create an empty stack' do | |
stack = Stack.new | |
stack.should.be_kind_of Stack | |
stack.count.should == 0 | |
end | |
it 'can create a stack from an array' do | |
stack = Stack.new [1,2,3] | |
stack.should.be_kind_of Stack | |
stack.count.should == 3 | |
end | |
end |
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
require 'IronPython' | |
require 'Microsoft.Scripting' | |
include Microsoft::Scripting::Hosting | |
include IronPython::Hosting | |
python = Python.create_engine | |
scope = python.create_scope | |
python.execute " | |
class Foo(object): | |
def bar(self): | |
print 'Look ma, white-space-sensitivity!' | |
", scope | |
python.execute "Foo().bar()", scope |
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
<script type="text/ruby" src="foo.rb"></script> |
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
def describe string | |
puts string | |
yield | |
end | |
def it string | |
puts " #{string} " | |
yield | |
end | |
class Object | |
def should | |
PositiveAssertion.new(self) | |
end | |
end | |
class PositiveAssertion | |
def initialize lhs | |
@lhs = lhs | |
end | |
def == rhs | |
print @lhs == rhs ? '.' : 'F' | |
end | |
def be_kind_of type | |
self.class.new(@lhs.class) == type | |
end | |
end |
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
class DotNetStackInstantiation < Test::Unit::TestCase | |
def test_creating_empty_stack | |
stack = Stack.new | |
assert(stack.kind_of? Stack) | |
assert(stack.count == 0) | |
end | |
def test_creating_stack_from_array | |
stack = Stack.new [1,2,3] | |
assert(stack.kind_of? Stack) | |
assert(stack.count == 3) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment