-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
57 lines (57 loc) · 1.37 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
describe("test", function() {
var n = ''
afterEach(function(){
console.log('测试' + n+'的结果:')
n = ''
});
it("string",function(){
expect("ABCD").toEqual(copy("ABCD"));
expect(1).toEqual(copy(1));
n = "string"
});
it('obj',function(){
function A(){
this.name = 'a'
}
var a = new A()
var b = copy(a)
expect(a.__proto__.constructor).toEqual(b.__proto__.constructor);
n = "obj"
})
it('objcircle',function(){
var obj1 = {
foo: {
name: 'foo',
bar: {
name: 'bar',
baz: {
name: 'baz',
aChild: null
}
}
}
}
obj1.foo.bar.baz.aChild = obj1.foo
n = "objcircle"
expect(obj1.__proto__.constructor).toEqual(copy(obj1).__proto__.constructor);
expect(obj1).not.toBe(copy(obj1));
})
it('date',function(){
var d = new Date()
expect(d).not.toBe(copy(d));
n = "date"
})
it('regexp',function(){
var reg = new RegExp('a','g')
var iscorrect = reg==copy(reg)
expect(iscorrect).toEqual(false);
expect(JSON.stringify(reg)).toEqual(JSON.stringify(copy(reg)));
n = "regexp"
})
it('function',function(){
var a = function(){console.log(0)}
var b = copy(a)
expect(a).not.toBe(b);
n = "function"
})
});