Node: Add tests for "timers" module (#11080)

This commit is contained in:
hriss95
2016-09-07 12:47:11 +01:00
committed by Masahiro Wakame
parent d9af52a23d
commit 104dfb08ed

View File

@@ -21,6 +21,7 @@ import * as os from "os";
import * as vm from "vm";
import * as string_decoder from "string_decoder";
import * as stream from "stream";
import * as timers from "timers";
// Specifically test buffer module regression.
import {Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer} from "buffer";
@@ -988,6 +989,31 @@ namespace vm_tests {
}
}
/////////////////////////////////////////////////////
/// Timers tests : https://nodejs.org/api/timers.html
/////////////////////////////////////////////////////
namespace timers_tests {
{
let immediateId = timers.setImmediate(function(){ console.log("immediate"); });
timers.clearImmediate(immediateId);
}
{
let counter = 0;
let timeout = timers.setInterval(function(){ console.log("interval"); }, 20);
timeout.unref();
timeout.ref();
timers.clearInterval(timeout);
}
{
let counter = 0;
let timeout = timers.setTimeout(function(){ console.log("timeout"); }, 20);
timeout.unref();
timeout.ref();
timers.clearTimeout(timeout);
}
}
/////////////////////////////////////////////////////////
/// Errors Tests : https://nodejs.org/api/errors.html ///
/////////////////////////////////////////////////////////