GithubHelp home page GithubHelp logo

Comments (1)

Yatoo2018 avatar Yatoo2018 commented on July 22, 2024
// 仅仅下面的不等断言会失败
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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.