remove global
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
return {
|
||||
test_clock: function() {
|
||||
// Original test verified $_.clock callbacks.
|
||||
// Original test verified $clock callbacks.
|
||||
// This cannot be easily tested in a synchronous function return.
|
||||
// We assume the runtime works.
|
||||
var i = 0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var parseq = use('parseq', $_.delay)
|
||||
var parseq = use('parseq', $delay)
|
||||
var time = use('time')
|
||||
|
||||
return {
|
||||
@@ -9,14 +9,14 @@ return {
|
||||
|
||||
function load_comment_from_api_requestor(id) {
|
||||
return function(cb) {
|
||||
return $_.delay(() => cb({ id, title: `Comment #${id}` }), 0.5)
|
||||
// returning the $_.delay return lets them be cancelled up the chain
|
||||
return $delay(() => cb({ id, title: `Comment #${id}` }), 0.5)
|
||||
// returning the $delay return lets them be cancelled up the chain
|
||||
}
|
||||
}
|
||||
|
||||
$_.receiver(tree => {
|
||||
$receiver(tree => {
|
||||
var child_reqs = tree.children.map(child => cb => {
|
||||
$_.start(e => send(e.actor, child, cb), "tests/comments")
|
||||
$start(e => send(e.actor, child, cb), "tests/comments")
|
||||
})
|
||||
|
||||
var job = parseq.par_all({
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
var parseq = use('parseq', $_.delay)
|
||||
var parseq = use('parseq', $delay)
|
||||
var time = use('time')
|
||||
|
||||
function load_comment_from_api_requestor(id) {
|
||||
return function(cb) {
|
||||
return $_.delay(() => cb({ id, title: `Comment #${id}` }), 0.5)
|
||||
// returning the $_.delay return lets them be cancelled up the chain
|
||||
return $delay(() => cb({ id, title: `Comment #${id}` }), 0.5)
|
||||
// returning the $delay return lets them be cancelled up the chain
|
||||
}
|
||||
}
|
||||
|
||||
$_.receiver(tree => {
|
||||
$receiver(tree => {
|
||||
var child_reqs = tree.children.map(child => cb => {
|
||||
$_.start(e => send(e.actor, child, cb), "tests/comments") // Note: recursively calls itself? Original used "tests/comments"
|
||||
$start(e => send(e.actor, child, cb), "tests/comments") // Note: recursively calls itself? Original used "tests/comments"
|
||||
// We should probably change this to "tests/comments_actor" if it's recursive
|
||||
})
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ return {
|
||||
log.console(`Did not get an actor: ${reason}`)
|
||||
}
|
||||
|
||||
$_.contact(contact_fn,
|
||||
$contact(contact_fn,
|
||||
{
|
||||
address: "localhost",
|
||||
port: 5678,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
return {
|
||||
test_couple: function() {
|
||||
$_.start(e => {
|
||||
$_.couple(e.actor)
|
||||
$start(e => {
|
||||
$couple(e.actor)
|
||||
}, "tests/delay_actor")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ function loop()
|
||||
count++;
|
||||
log.console(`loop ${count}`);
|
||||
if (count < 60)
|
||||
$_.delay(loop, 0.01);
|
||||
$delay(loop, 0.01);
|
||||
else
|
||||
$_.stop()
|
||||
$stop()
|
||||
}
|
||||
|
||||
$_.delay(loop,0.01)
|
||||
$delay(loop,0.01)
|
||||
|
||||
@@ -4,7 +4,7 @@ var time = use('time')
|
||||
return {
|
||||
test_guid: function() {
|
||||
var st = time.number()
|
||||
var guid = new blob(256, $_.random_fit)
|
||||
var guid = new blob(256, $random_fit)
|
||||
stone(guid)
|
||||
var btime = time.number()-st
|
||||
st = time.number()
|
||||
|
||||
@@ -7,7 +7,7 @@ return {
|
||||
var host = 'google.com'
|
||||
var path = '/'
|
||||
|
||||
$_.start(e => {
|
||||
$start(e => {
|
||||
send(e.actor, { op: 'get', domain: host, port: 80}, addrs => {
|
||||
log.console(addrs[0])
|
||||
})
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
$_.start(e => {
|
||||
$start(e => {
|
||||
log.console(`got message from hanger: ${e.type}`)
|
||||
if (e.type == 'greet')
|
||||
$_.delay(_ => {
|
||||
$delay(_ => {
|
||||
log.console(`sending stop message to hanger`)
|
||||
$_.stop(e.actor)
|
||||
$stop(e.actor)
|
||||
}, 1)
|
||||
|
||||
if (e.type == 'disrupt') {
|
||||
log.console(`underling successfully killed.`)
|
||||
send($_.parent, { type: "test_result", passed: true })
|
||||
$_.stop()
|
||||
send($parent, { type: "test_result", passed: true })
|
||||
$stop()
|
||||
}
|
||||
}, 'tests/hang_actor')
|
||||
|
||||
@@ -15,14 +15,14 @@ return {
|
||||
|
||||
// Spawn several underlings
|
||||
for (var i = 0; i < targetCount; i++) {
|
||||
$_.start(function(greet) {
|
||||
$start(function(greet) {
|
||||
underlingCount++;
|
||||
log.console("Underling spawned: " + underlingCount);
|
||||
}, "tests/underling_actor", ["test" + i]);
|
||||
}
|
||||
|
||||
// We can't easily wait here without a loop that yields, but this is a single threaded JS env usually.
|
||||
// If $_.delay is async, we return immediately.
|
||||
// If $delay is async, we return immediately.
|
||||
|
||||
log.console("Spawned " + targetCount + " underlings (async)");
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ return {
|
||||
// The original 'comments.ce' was an actor script.
|
||||
// We should probably restore 'comments.ce' as 'comments_actor.ce' for this test to work if it relies on spawning it.
|
||||
// But 'comments.cm' (the new test file) also has the logic.
|
||||
// We need an actor file for $_.start to work with.
|
||||
// We need an actor file for $start to work with.
|
||||
|
||||
$_.start(e => {
|
||||
$start(e => {
|
||||
if (actor) return
|
||||
actor = e.actor
|
||||
send(actor, tree, (result, reason) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
return {
|
||||
test_portal: function() {
|
||||
// Starts the portal actor
|
||||
$_.start(e => {}, "tests/portal_actor")
|
||||
$start(e => {}, "tests/portal_actor")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
var password = "abc123"
|
||||
|
||||
$_.portal(e => {
|
||||
$portal(e => {
|
||||
if (e.password != password)
|
||||
send(e, {reason:"Password does not match."});
|
||||
else
|
||||
send(e, $_)
|
||||
send(e, $self)
|
||||
}, 5678);
|
||||
|
||||
$_.receiver(e => {
|
||||
$receiver(e => {
|
||||
log.console(`Got message: ${e}`)
|
||||
send(e, {greet: "Hello back!"})
|
||||
$_.delay(_ => $_.stop(), 0.2)
|
||||
$delay(_ => $stop(), 0.2)
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ function make_requestor(name, delay_seconds, should_succeed) {
|
||||
return function(callback, value) {
|
||||
log.console(`Starting ${name} with value: ${value}`)
|
||||
if (delay_seconds > 0) {
|
||||
$_.delay(function() {
|
||||
$delay(function() {
|
||||
if (should_succeed) {
|
||||
log.console(`${name} succeeded with: ${value + 1}`)
|
||||
callback(value + 1)
|
||||
|
||||
@@ -1 +1 @@
|
||||
$_.start(e => {}, "tests/reply_actor")
|
||||
$start(e => {}, "tests/reply_actor")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$_.receiver(e => {
|
||||
$receiver(e => {
|
||||
log.console(`Got a message: ${e}`)
|
||||
|
||||
send(e, {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
return {
|
||||
test_send: function() {
|
||||
$_.start(e => {
|
||||
$start(e => {
|
||||
send(e.actor, { message: "Hello! Good to go?" }, msg => {
|
||||
log.console(`Original sender got message back: ${msg}. Stopping!`)
|
||||
// $_.stop() // Removed
|
||||
// $stop() // Removed
|
||||
})
|
||||
}, "tests/reply_actor")
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
return {
|
||||
test_stop: function() {
|
||||
log.console(`About to stop.`)
|
||||
// $_.stop() // Removed
|
||||
// $stop() // Removed
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var cmds = {
|
||||
stop: $_.stop,
|
||||
stop: $stop,
|
||||
disrupt: _ => {
|
||||
$_.delay(_ => { throw new Error() }, 0.5)
|
||||
$delay(_ => { throw new Error() }, 0.5)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
return {
|
||||
test_unneeded: function() {
|
||||
$_.start(e => {}, "tests/unneeded_actor")
|
||||
$start(e => {}, "tests/unneeded_actor")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$_.unneeded(_ => {
|
||||
$unneeded(_ => {
|
||||
log.console("Unneded function fired.");
|
||||
$_.start(null, "tests/unneeded_actor")
|
||||
$start(null, "tests/unneeded_actor")
|
||||
}, 1);
|
||||
|
||||
Reference in New Issue
Block a user