Kristian Kristensen’s Blog


Iron Languages Talk at Community Day 2010

Posted in Code,IronPython,IronRuby by Kristian Kristensen on the May 30th, 2010

On Thursday I held a talk on Iron Languages at Community Day 2010. It’s a free one day conference that tries to bridge different technology stacks and encourage discussion. My talk was an updated and shortened version of the Tech Talk I did at Microsofts office some time ago.

The slides are up on Slideshare – IronSprog Community Day 2010.

I demoed a Ruby Testing Framework originally done by John Lam, and also used by Harry Pierson in his Pumping Iron talk. The code is pasted below.
I demoed the CTP of IronPython Tools for Visual Studio.  To showcase some of the features I used BeautifulSoup.
I demoed BadPaint, which is a sample that comes with IronPython. Get it here including the example code I used.

It appears my talk was video taped. I should get a copy of that, and I ‘m quite sure it’ll find its way to the Internet as well. I’ll post a link when and where it goes online.

Ruby Test Framework and unit testing the .NET stack demo code:

#testharness.rb
$examples = 0
$messages = []

class PositiveExpectation

  def initialize(obj)
    @obj = obj
  end

  def ==(other)
    $examples += 1
    if @obj != other
      $messages << "Want #{@obj.inspect} got #{other.inspect}"
      print "E"
    else
      print "OK"
    end
  end

end

class Object
  def should
    PositiveExpectation.new(self)
  end
end

def it(description)
  print "\n it #{description}: "
  yield
end

def describe(description)
  print "#{description}"
  yield
  puts "\nend\n"
end

at_exit do
  puts "#{$messages.length} / #{$examples} failed"
  if $messages.length > 0
    puts "Failures: "
    $messages.each { |m| puts "- #{m}"}
  end
end
#stack.rb
require 'testharness'
require 'System'

include System::Collections

describe ".NET Stack Operations" do
  it "should create an instance with zero elements" do
    Stack.new.count.should == 0
  end

  it "should let us peek at the element pushed" do
    s = Stack.new
    s.push "bob"
    s.peek.should == "bob"
    s.count.should == 1
  end

  it "should let us pop the element we pushed" do
    s = Stack.new
    s.push "bob"
    s.pop.should == "bob"
    s.count.should == 0
  end
end</pre>
<div>
$examples = 0
$messages = []
class PositiveExpectation
def initialize(obj)
@obj = obj
end
def ==(other)
$examples += 1
if @obj != other
$messages << “Want #{@obj.inspect} got #{other.inspect}”
print “E”
else
print “OK”
end
end
end
class Object
def should
PositiveExpectation.new(self)
end
end
def it(description)
print “\n it #{description}: “
yield
end
def describe(description)
print “#{description}”
yield
puts “\nend\n”
end
at_exit do
puts “#{$messages.length} / #{$examples} failed”
if $messages.length > 0
puts “Failures: “
$messages.each { |m| puts “- #{m}”}
end
ende]
  • If you like my writing you should subscribe to my RSS feed.