Skip to content

Commit 3e04dc6

Browse files
committed
test: fix regression tests and bring back execution cursor
1 parent 227fc3b commit 3e04dc6

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { log } from './core/logging'
1111
import { saveCapture } from './core/newStorage'
1212

1313
let _executingFunctions: CapturedFunction[] = []
14-
const _executionCursor = 1
14+
let _executionCursor = 1
1515
let _functionCalls: CapturedCall[] = []
1616
let _userId: string | undefined = undefined
1717

@@ -85,12 +85,14 @@ export function uff<T extends AnyFunction>(func: T, id: string | null = null): T
8585
timestamp: Date.now()
8686
})
8787
}
88+
_executionCursor--
8889
try {
8990
const context = null
9091
const functionOutput = func.apply(context ?? this, args)
9192
if (id) {
9293
saveOutputForFunction(id, functionOutput)
9394
}
95+
_executionCursor++
9496
return functionOutput
9597
} catch (error) {
9698
/**

test/regression.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import { describe, expect, it } from 'vitest'
22
import { initTRPC } from '@trpc/server'
3+
import { removeCircularsAndNonPojos } from '../src/core/stringify'
34
// import { removeCircularDependencies } from '../src/core/stringify'
45

56
describe('Regression', () => {
6-
/* it('regression #2 > can remove circulars from non-POJOs', () => {
7+
it('regression #2 > can remove circulars from non-POJOs', () => {
78
const trpcInstance = initTRPC.create({})
8-
const withoutCirculars = removeCircularDependencies(trpcInstance)
9+
const withoutCirculars = removeCircularsAndNonPojos(trpcInstance)
910
expect(typeof withoutCirculars).toEqual('object')
1011
})
1112

12-
it.skip("regression #3 > doesn't give false positives to circular", () => {
13+
it("regression #3 > doesn't give false positives to circular", () => {
1314
const items = ['abc', 'def']
1415
const calls = [items, items]
15-
const callsWithoutCirculars = removeCircularDependencies(calls)
16+
const callsWithoutCirculars = removeCircularsAndNonPojos(calls)
1617
expect(callsWithoutCirculars).toEqual([
1718
['abc', 'def'],
1819
['abc', 'def']
1920
])
20-
}) */
21+
})
2122
})

test/transform-uff.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ describe('functions', () => {
116116
}
117117
})
118118

119-
it('callee and accessorKey are correct', () => {
119+
it.only('callee and accessorKey are correct', () => {
120120
const accessorKeyFixtures = [
121121
/* {
122122
fixture: 'parseFloat',
@@ -171,8 +171,9 @@ it('callee and accessorKey are correct', () => {
171171

172172
for (let i = 0; i < accessorKeyFixtures.length; i++) {
173173
const fixture = accessorKeyFixtures[i].fixture
174+
174175
// @ts-expect-error
175-
const node = parseCode(fixture).unwrap().data?.program?.body?.[0]?.expression
176+
const node = parseCode(fixture).unwrap().program?.body?.[0]?.expression
176177
if (node === undefined) {
177178
throw new Error(`Could not parse fixture "${fixture}"`)
178179
}

0 commit comments

Comments
 (0)