caolan / caolan/nodeunit

test.deepEqual may print incorrect property values for subsequently modified properties SERIOUS ISSUE

Đang mở
#176 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
1.9k
Fork
359
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

test.deepEqual does not examine failing objects immediately, so incorrect values are printed
## Reproduction printout

```
$ nodeunit ../nodejs3/snippets/modules/nodeunit/nodeunit-changedobject.js

nodeunit-changedobject.js
Expected printout: AssertionError: { property: 'object1' } deepEqual { property: 'object2' }
✖ f

AssertionError: { property: 'overwite' } deepEqual { property: 'object2' }
at Object.assertWrapper [as deepEqual] (/usr/local/lib/node_modules/nodeunit/lib/types.js:83:39)
at Object.module.exports.f (/home/foxyboy/Desktop/c505/node/nodejs3/snippets/modules/nodeunit/nodeunit-changedobject.js:13:7)
at Object.wrapTest (/usr/local/lib/node_modules/nodeunit/lib/core.js:235:16)
at wrapTest (/usr/local/lib/node_modules/nodeunit/lib/core.js:235:16)
at Object.exports.runTest (/usr/local/lib/node_modules/nodeunit/lib/core.js:69:9)
at exports.runSuite (/usr/local/lib/node_modules/nodeunit/lib/core.js:117:25)
at _concat (/usr/local/lib/node_modules/nodeunit/deps/async.js:508:13)
at async.forEachSeries.iterate (/usr/local/lib/node_modules/nodeunit/deps/async.js:118:13)
at async.forEachSeries (/usr/local/lib/node_modules/nodeunit/deps/async.js:134:9)
at _concat (/usr/local/lib/node_modules/nodeunit/deps/async.js:507:9)
```
## Reproduction code

``` js
// nodeunit-changedobject.js

module.exports.f = function (test) {

var object1 = {
property: 'object1'
}
var object2 = {
property: 'object2'
}

test.deepEqual(object1, object2)
object1.property = 'overwite'

console.log('Expected printout: AssertionError: { property: \'object1\' } deepEqual { property: \'object2\' }')
test.done()
}
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu với test.deepEqual trong lib/types.js, sử dụng stack trace và bản tái hiện nodeunit-changedobject.js làm các điểm bắt đầu. Chạy ví dụ nodeunit được cung cấp và so sánh đầu ra lỗi với phần in ra mong đợi; được xem là hoàn tất khi các giá trị được báo cáo vẫn là những giá trị hiện diện tại thời điểm deepEqual được gọi, thay vì các giá trị sau những lần đột biến tiếp theo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript
Lĩnh vực
testing-qa
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.