本文整理匯總了TypeScript中logtrap.stderrTrap函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript stderrTrap函數的具體用法?TypeScript stderrTrap怎麽用?TypeScript stderrTrap使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了stderrTrap函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it("should alert if column lengths are inconsistent", () => {
set_log_level("info")
const r0 = new ColumnDataSource({data: {foo: [1], bar: [1,2]}})
const out0 = stderrTrap(() => r0.get_length())
expect(out0).to.be.equal("[bokeh] data source has columns of inconsistent lengths\n")
const r1 = new ColumnDataSource({data: {foo: [1], bar: [1,2], baz: [1]}})
const out1 = stderrTrap(() => r1.get_length())
expect(out1).to.be.equal("[bokeh] data source has columns of inconsistent lengths\n")
})
示例2: it
it("checks for versions matching", () => {
const d = new Document()
expect(d.roots().length).to.equal(0)
const root1 = new SomeModel()
d.add_root(root1)
expect(d.roots().length).to.equal(1)
d.set_title("Foo")
const old_log_level = logging.logger.level.name
logging.set_log_level("warn")
const json = d.to_json_string()
const parsed = JSON.parse(json)
parsed.version = `${js_version}`
const out0 = stderrTrap(() => Document.from_json_string(JSON.stringify(parsed)))
expect(out0).to.be.equal("")
parsed.version = "0.0.1"
const out1 = stderrTrap(() => Document.from_json_string(JSON.stringify(parsed)))
expect(out1).to.be.equal(`[bokeh] JS/Python version mismatch\n[bokeh] Library versions: JS (${js_version}) / Python (${parsed.version})\n`)
parsed.version = `${js_version}rc123`
const out2 = stderrTrap(() => Document.from_json_string(JSON.stringify(parsed)))
expect(out2).to.be.equal(`[bokeh] JS/Python version mismatch\n[bokeh] Library versions: JS (${js_version}) / Python (${parsed.version})\n`)
parsed.version = `${js_version}dev123`
const out3 = stderrTrap(() => Document.from_json_string(JSON.stringify(parsed)))
expect(out3).to.be.equal(`[bokeh] JS/Python version mismatch\n[bokeh] Library versions: JS (${js_version}) / Python (${parsed.version})\n`)
parsed.version = `${js_version}-foo`
const out4 = stderrTrap(() => Document.from_json_string(JSON.stringify(parsed)))
expect(out4).to.be.equal("")
parsed.version = `${js_version}rc123-foo`
const out5 = stderrTrap(() => Document.from_json_string(JSON.stringify(parsed)))
expect(out5).to.be.equal("")
parsed.version = `${js_version}dev123-bar`
const out6 = stderrTrap(() => Document.from_json_string(JSON.stringify(parsed)))
expect(out6).to.be.equal("")
// need to reset old log level
logging.set_log_level(old_log_level)
})