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
it ( 'should calculate the proper value', function () { | |
var ds = new DataService(); | |
var x = new Foo( ds ); | |
sinon.stub( ds, "lookupMultiplier" ).returns( 2 ); | |
var rst = x.calculateValueBasedOnLookup( 5 ); | |
expect( rst ).to.equal( 10 ); |
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
package example.web; | |
import example.domain.PermissionDeniedException; | |
import example.domain.Person; | |
import example.domain.SearchUi; | |
import example.domain.Thing; | |
import example.service.ThingService; | |
import example.service.PersonService; | |
import example.service.ThingConstants; |
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 PayCalculator { | |
public static long totalPayForEmployee ( HourlyEmployee employee ) { | |
RateRepository rr = new RateRepository (); | |
long rate = rr.getRateById ( employee.id ); | |
return rate * employee.hours; | |
} | |
} | |
class RateRepository { |
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 Liskov { | |
public static int calculateArea(Rectangle x) { | |
return x.getHeight() * x.getWidth(); | |
} | |
public static int calculateArea(Square x) { | |
return x.getHeight() * x.getHeight(); | |
} | |
} |
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 Cart { | |
private List<OrderItem> items = new ArrayList<OrderItem>(); | |
public void add ( OrderItem item ) { | |
this.items.add ( item ); | |
} | |
public long calcTotal () { |
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
var Kefir = require( "kefir" ) | |
var numbers1 = Kefir.sequentially( 100, [1, 2, 3] ) | |
var numbers2 = numbers1.map( multiplyBy2 ) | |
var numbers3 = numbers2.filter( isNot4 ) | |
numbers3.onValue( print ) | |
function multiplyBy2 ( x ) | |
{ |
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
var vdom = require( "virtual-dom" ) | |
var h = vdom.h | |
var count = 0 | |
var tree = render( count ) | |
var rootNode = vdom.create(tree) | |
document.body.appendChild( rootNode ) | |
setInterval( updateDom , 500) |
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
var Kefir = require( "kefir" ) | |
var plusButton = document.getElementById( "plus-btn" ) | |
var minusButton = document.getElementById( "minus-btn" ) | |
var plusClicks = Kefir.fromEvent( plusButton , "click" ) | |
var minusClicks = Kefir.fromEvent( minusButton , "click" ) | |
var counterChanges = Kefir.merge( | |
[ plusClicks.mapTo(1) , minusClicks.mapTo(-1) ] |
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
var R = require("ramda") | |
var _ = require("underscore") | |
var tasks = [ | |
{ username: 'Scott' | |
, title: 'remember milk' | |
, dueDate: '2015-04-01' | |
, complete: false | |
, priority: 'medium' | |
} |
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
var assert = require("chai").assert | |
var R = require("ramda") | |
var UrlPattern = require("url-pattern") | |
var patterns = [ "#/foos/new" , "#/foos/:id" , "#/" ] | |
var path = routes( patterns , "#/foos/new" ) | |
assert.equal( path.pattern , "#/foos/1" ) | |
function routes( patterns , hash ) |