Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
130 lines (107 loc) · 2.92 KB

File metadata and controls

130 lines (107 loc) · 2.92 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import * as ds from "@devicescript/core"
function callIt(x: any) {
x()
}
function callNew(x: any) {
new x()
}
function getFoo(x: any) {
return x.foo
}
function setFoo(x: any) {
x.foo = 1
}
function expectExn(f: () => void, ex: Function) {
try {
f()
ds.assert(false, "missing exn")
} catch (e: any) {
ds.assert(e instanceof ex, "wrong exn")
}
}
async function expectExnAsync(f: ds.Callback, ex: Function) {
try {
await f()
ds.assert(false, "missing exn")
} catch (e: any) {
ds.assert(e instanceof ex, "wrong exn")
}
}
const airp = new ds.AirPressure()
function testTooLarge(tooLarge: number) {
expectExn(() => {
Buffer.alloc(tooLarge)
}, RangeError)
const arr = [1]
expectExn(() => {
arr[tooLarge] = 1
}, RangeError)
expectExn(() => {
arr.insert(0, tooLarge)
}, RangeError)
}
function instOf(a: any, b: any) {
return a instanceof b
}
async function testExn() {
getFoo("foo")
getFoo(true)
expectExn(() => getFoo(null), TypeError)
expectExn(() => setFoo(null), TypeError)
expectExn(() => setFoo(true), TypeError)
const b = Buffer.alloc(10)
b[1] = b[9] + 1
expectExn(() => {
b[10] = 1
}, RangeError)
ds.assert(b[10] === undefined)
const b2 = hex`001122`
expectExn(() => {
b2[0] = 1
}, TypeError)
expectExn(() => {
b2.fillAt(0, 1, 1)
}, TypeError)
expectExn(() => {
b2.blitAt(0, "a", 0, 1)
}, TypeError)
testTooLarge(1000000000)
testTooLarge(1000000)
testTooLarge(2000000000)
await expectExnAsync(async () => {
await airp.sendCommand(100000)
}, RangeError)
await expectExnAsync(async () => {
await airp.sendCommand(0x80, Buffer.alloc(300))
}, RangeError)
callIt(() => {})
callIt(Error)
callIt(TypeError)
ds.assert(Error() instanceof Error)
ds.assert(new Error() instanceof Error)
ds.assert(new Error() instanceof Error)
ds.assert(TypeError() instanceof Error)
ds.assert(TypeError() instanceof TypeError)
expectExn(() => callIt(null), TypeError)
expectExn(() => callIt(1), TypeError)
expectExn(() => callIt({}), TypeError)
expectExn(() => callIt([]), TypeError)
expectExn(() => callIt(Array.prototype), TypeError)
expectExn(() => Math.pow.start(), TypeError) // fiber started with builtin
expectExn(() => Object.keys(null), TypeError)
expectExn(() => Object.values(null), TypeError)
Object.keys("")
instOf(null, Object)
instOf(null, Array)
instOf("", Array)
expectExn(() => instOf("", {}), TypeError)
expectExn(() => instOf("", Array.prototype), TypeError)
expectExn(() => instOf("", null), TypeError)
expectExn(() => {
throw null
}, TypeError)
callNew(Error)
expectExn(() => callNew(null), TypeError)
expectExn(() => callNew(Math.pow), TypeError)
}
await testExn()
Morty Proxy This is a proxified and sanitized view of the page, visit original site.