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
// Tiniest BDD DSL/framework around? | |
// Licensed under MSPL/FreeBSD/ISC or any other OSS license you want | |
// Original idea from http://blog.kjempekjekt.com/2009/08/13/ultra-tiny-given-when-then-dsl-snippet/, | |
// turned into generic base class by Jonas Follesø. | |
public abstract class BDD<T> where T : BDD<T> | |
{ | |
protected T Given { get { return (T)this; } } | |
protected T And { get { return (T)this; } } | |
protected T When { get { return (T)this; } } |
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
module RomanNumerals | |
// Define function | |
let convertToRoman n = | |
let steps = [ | |
(1, 3, "I") | |
(4, 4, "IV") | |
(5, 8, "V") | |
(9, 9, "IX") |
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 'test/unit' | |
class Conway | |
def self.map_new_world(world) | |
interstitial_world = {} | |
world.each do |location| | |
(location[0]-1).upto(location[0]+1) do |x| | |
(location[1]-1).upto(location[1]+1) do |y| | |
interstitial_world[[x, y]] ||= {} | |
interstitial_world[[x, y]][:alive] = true and next if location[0] == x and location[1] == y |
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
module Test | |
module Unit | |
TestCase = RSpec::Core::ExampleGroup | |
end | |
end | |
class Test::Unit::TestCase | |
def self.inherited(host) | |
host.set_it_up host.name.gsub(/(Spec|Test)/,'') | |
def host.method_added(name) |