-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Threads] implement a toolset to work with threads #45
- Loading branch information
Showing
17 changed files
with
972 additions
and
42 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,4 +78,6 @@ require('./util/array'); | |
|
||
require('./rendering'); | ||
|
||
require('./threading'); | ||
|
||
require('./features'); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* eslint-env mocha */ | ||
|
||
const expect = require('chai').expect; | ||
const mochaVM = require('../../node/mochaVM'); | ||
|
||
module.exports = function() { | ||
const vm = mochaVM({}); | ||
|
||
mochaVM.applyNodeEnv(vm); | ||
|
||
vm.updateContext({ | ||
self: vm.getContext(), | ||
|
||
addEventListener() {}, | ||
postMessage() {}, | ||
|
||
BroadcastChannel: function(name) { // eslint-disable-line object-shorthand | ||
this.name = name; | ||
}, | ||
|
||
Worker: function(sourcePath) { // eslint-disable-line object-shorthand | ||
this.source = sourcePath; | ||
|
||
this.postMessage = function() {}; | ||
}, | ||
|
||
MessagePort: function() { // eslint-disable-line object-shorthand | ||
this.postMessage = function() {}; | ||
|
||
this.onmessage = {}; | ||
} | ||
}); | ||
|
||
vm.runModule('../../testable/threading/lib/CurrentThread.js'); | ||
|
||
it('should be able to bootstrap the current thread', () => { | ||
const { testResult } = vm.apply(() => { | ||
/* globals CurrentThread */ | ||
|
||
CurrentThread.bootstrap(); | ||
|
||
global.testResult = CurrentThread; | ||
}); | ||
|
||
expect(testResult).to.have.property('mainThread'); | ||
}); | ||
}; |
Oops, something went wrong.