forked from CodingFu/typeof
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.coffee
49 lines (34 loc) · 1.32 KB
/
test.coffee
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
assert = require 'assert'
typeOf = require './index'
describe 'type of', ->
it 'undefined should be an "undefined"', ->
assert.equal typeOf(undefined), "undefined"
it 'null should be a "null"', ->
assert.equal typeOf(null), "null"
it 'NaN should be a "number"', ->
assert.equal typeOf(NaN), "number"
it 'Number should be a "number"', ->
assert.equal (typeOf 1), "number"
assert.equal (typeOf 1.5), "number"
it 'Boolean should be a "boolean"', ->
assert.equal (typeOf true), "boolean"
assert.equal (typeOf false), "boolean"
it 'String should be a "string"', ->
assert.equal (typeOf "abc"), "string"
it 'new String() should be a "string"', ->
assert.equal (typeOf new String()), "string"
it 'Empty Array should be an "array"', ->
assert.equal (typeOf []), "array"
it 'new Array() should be an "array"', ->
assert.equal (typeOf new Array()), "array"
it 'Object should be an "object"', ->
assert.equal (typeOf {}), "object"
it 'Function should be a "function"', ->
assert.equal (typeOf (-> false)), "function"
it 'Buffer should be a "buffer"', ->
assert.equal (typeOf new Buffer(0)), "buffer"
it 'Any "ClassName" instance should be "classname"', ->
class ClassName
constructor: ->
obj = new ClassName()
assert.equal (typeOf obj), "classname"