copy to mac clipboard
:w !pbcopy
paste from mac clibpoard
console.log("hello") |
var assert = require('assert'); | |
var contracts = require('contracts'); // our home-built contract testing library | |
var echo = require('./echo_consumer'); | |
// test the echo consumer | |
var stubConnection = contracts.connection(); | |
echo(stubConnection, 'echo', function(response) { | |
assert.equal(response, 'echo'); | |
}); | |
stubConnection.testContract("echo-contract.json", { as: "consumer" }); |
package echo | |
import ( | |
"testing" | |
"contracts" // our home-built contract testing library | |
) | |
// test the echo provider | |
func TestEchoProvider(t *testing.T) { | |
stubConnection := contracts.NewStubConnection() |
package echo | |
type Connection interface { | |
Subscribe(string, func(string)) | |
Publish(string, string) | |
} | |
// echo back any message sent to the "/echo" topic | |
func StartEchoProvider(connection Connection) { | |
connection.Subscribe("/echo", func(message string) { |
// publish `message` to the "/echo" topic, and call `callback` on response | |
module.exports = function echo(connection, message, callback) { | |
connection.subscribe('/echo', callback); | |
connection.publish('/echo', message); | |
}; |
[ | |
{ | |
"source": "consumer", | |
"topic": "/echo", | |
"payload": "echo" | |
}, | |
{ | |
"source": "provider", | |
"topic": "/echo", | |
"payload": "echo" |
[ | |
{ | |
"source": "consumer", | |
"topic": "/echo", | |
"payload": "echo" | |
}, | |
{ | |
"source": "provider", | |
"topic": "/echo", | |
"payload": "echo" |
class ObjSpaceTree | |
def initialize(object_id) | |
@root = Node.new(object_id) | |
expand | |
end | |
def expand | |
depth = 0 | |
begin | |
nodes_at_depth(depth).each do |node| |
// force dom element redraws to work around chrome bugs | |
$.fn.redraw = function() { | |
return $(this).each(function() { | |
var n = document.createTextNode(' '); | |
$(this).append(n); | |
setTimeout(function() { n.parentNode.removeChild(n); }, 0); | |
}); | |
} |