(allowedStates)
| 418 | } |
| 419 | |
| 420 | _checkState(allowedStates) { |
| 421 | if (allowedStates && !allowedStates.includes(this.state)) { |
| 422 | const allowedStatesList = '[' + _.map(allowedStates, String).join(',') + ']'; |
| 423 | return this._logError('Expected PythonCaller states ' + allowedStatesList + ' but actually have state ' + String(this.state)); |
| 424 | } |
| 425 | |
| 426 | let childNull, callbackNull, timeoutIDNull; |
| 427 | if (this.state == CREATED) { |
| 428 | childNull = true; |
| 429 | callbackNull = true; |
| 430 | timeoutIDNull = true; |
| 431 | } else if (this.state == WAITING) { |
| 432 | childNull = false; |
| 433 | callbackNull = true; |
| 434 | timeoutIDNull = true; |
| 435 | } else if (this.state == IN_CALL) { |
| 436 | childNull = false; |
| 437 | callbackNull = false; |
| 438 | timeoutIDNull = false; |
| 439 | } else if (this.state == EXITING) { |
| 440 | childNull = false; |
| 441 | callbackNull = true; |
| 442 | timeoutIDNull = true; |
| 443 | } else if (this.state == EXITED) { |
| 444 | childNull = true; |
| 445 | callbackNull = true; |
| 446 | timeoutIDNull = true; |
| 447 | } else { |
| 448 | return this._logError('Invalid PythonCaller state: ' + String(this.state)); |
| 449 | } |
| 450 | |
| 451 | if (childNull != null) { |
| 452 | if (childNull && this.child != null) return this._logError('PythonCaller state "' + String(this.state) + '": child should be null'); |
| 453 | if (!childNull && this.child == null) return this._logError('PythonCaller state "' + String(this.state) + '": child should not be null'); |
| 454 | } |
| 455 | if (callbackNull != null) { |
| 456 | if (callbackNull && this.callback != null) return this._logError('PythonCaller state "' + String(this.state) + '": callback should be null'); |
| 457 | if (!callbackNull && this.callback == null) return this._logError('PythonCaller state "' + String(this.state) + '": callback should not be null'); |
| 458 | } |
| 459 | if (timeoutIDNull != null) { |
| 460 | if (timeoutIDNull && this.timeoutID != null) return this._logError('PythonCaller state "' + String(this.state) + '": timeoutID should be null'); |
| 461 | if (!timeoutIDNull && this.timeoutID == null) return this._logError('PythonCaller state "' + String(this.state) + '": timeoutID should not be null'); |
| 462 | } |
| 463 | |
| 464 | return true; |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | module.exports.FunctionMissingError = FunctionMissingError; |
no test coverage detected