Comments (1)
// 仅仅下面的不等断言会失败
assert.ok(ob.sum !== val);
// 而相等断言
let sum = 0;
let val = 0;
sum+=val;
assert.ok(sum === val);
// 这个断言并不会失败。
// 只是对于我们这个测试用例的目的:
// 期待俩个不相等的值sum 和 val 作为测试条件
// 通过执行下面代码
ob.subscribe('add', (val) => sum += val);
ob.publish('add', val);
// 之后, 修改sum的值(0 + val)后在与val的值作比较,然后我们断言 0 + val === val 。
// 用以说明ob的add方法没问题。
// 此时,我们的条件如果 sum 和 val 起初都为 0, 断言 (0 + 0) === 0没有意义了
// 所以测试的结果也将不准确了。
from exercise17.
Related Issues (2)
- 目前对观察订阅者模式的一些体会和应用场景 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from exercise17.