Skip to content

Commit

Permalink
fix: Fix the bug where a regex replacement error occurs when test cas…
Browse files Browse the repository at this point in the history
…es contain both .toBeUndefined() and .toBe or .toEqual.
  • Loading branch information
zrwusa committed Nov 20, 2024
1 parent f84518c commit 1b0ee60
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ All notable changes to this project will be documented in this file.
- [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
- [`auto-changelog`](https://github.com/CookPete/auto-changelog)

## [v1.53.2](https://github.com/zrwusa/data-structure-typed/compare/v1.51.5...main) (upcoming)
## [v1.53.3](https://github.com/zrwusa/data-structure-typed/compare/v1.51.5...main) (upcoming)

### Changes

Expand Down
52 changes: 26 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "data-structure-typed",
"version": "1.53.3",
"version": "1.53.4",
"description": "Javascript Data Structure. Heap, Binary Tree, Red Black Tree, Linked List, Deque, Trie, HashMap, Directed Graph, Undirected Graph, Binary Search Tree(BST), AVL Tree, Priority Queue, Graph, Queue, Tree Multiset, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue, Stack. Benchmark compared with C++ STL. API aligned with ES6 and Java.util. Usability is comparable to Python",
"main": "dist/cjs/index.js",
"module": "dist/mjs/index.js",
Expand Down Expand Up @@ -70,11 +70,11 @@
"@typescript-eslint/eslint-plugin": "^8.12.1",
"@typescript-eslint/parser": "^8.12.1",
"auto-changelog": "^2.5.0",
"avl-tree-typed": "^1.53.1",
"avl-tree-typed": "^1.53.2",
"benchmark": "^2.1.4",
"binary-tree-typed": "^1.53.1",
"bst-typed": "^1.53.1",
"data-structure-typed": "^1.53.1",
"binary-tree-typed": "^1.53.2",
"bst-typed": "^1.53.2",
"data-structure-typed": "^1.53.2",
"dependency-cruiser": "^16.5.0",
"doctoc": "^2.2.1",
"eslint": "^9.13.0",
Expand All @@ -83,7 +83,7 @@
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-import": "^2.31.0",
"fast-glob": "^3.3.2",
"heap-typed": "^1.53.1",
"heap-typed": "^1.53.2",
"istanbul-badges-readme": "^1.9.0",
"jest": "^29.7.0",
"js-sdsl": "^4.4.2",
Expand Down
16 changes: 8 additions & 8 deletions src/data-structures/linked-list/doubly-linked-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ export class DoublyLinkedListNode<E = any> {
* cache.set('c', 3);
* cache.set('d', 4); // This will eliminate 'a'
*
* console.log(cache.get('a')).toBeUndefined();
* expect(cache.get('b')); // 2
* console.log(cache.get('a')); // undefined
* console.log(cache.get('b')); // 2
* console.log(cache.get('c')); // 3
* console.log(cache.get('d')); // 4
*
Expand All @@ -368,8 +368,8 @@ export class DoublyLinkedListNode<E = any> {
* cache.set('d', 4); // This will eliminate 'b'
*
* console.log(cache.get('a')); // 1
* console.log(cache.get('b')).toBeUndefined();
* expect(cache.get('c')); // 3
* console.log(cache.get('b')); // undefined
* console.log(cache.get('c')); // 3
* console.log(cache.get('d')); // 4
*
* // Should support updating existing keys
Expand All @@ -385,8 +385,8 @@ export class DoublyLinkedListNode<E = any> {
* cache.set('b', 2);
*
* console.log(cache.delete('a')); // true
* console.log(cache.get('a')).toBeUndefined();
* expect(cache.size); // 1
* console.log(cache.get('a')); // undefined
* console.log(cache.size); // 1
*
* // Should support clearing cache
* cache.clear();
Expand Down Expand Up @@ -431,11 +431,11 @@ export class DoublyLinkedListNode<E = any> {
*
* // 3. Find first lyric when timestamp is less than first entry
* const earlyTimeLyric = lyricsList.findBackward(lyric => lyric.time <= -1000);
* console.log(earlyTimeLyric).toBeUndefined();
* console.log(earlyTimeLyric); // undefined
*
* // 4. Find last lyric when timestamp is after last entry
* const lateTimeLyric = lyricsList.findBackward(lyric => lyric.time <= 50000);
* expect(lateTimeLyric?.text); // 'And I will try to fix you'
* console.log(lateTimeLyric?.text); // 'And I will try to fix you'
* @example
* // cpu process schedules
* class Process {
Expand Down
14 changes: 7 additions & 7 deletions testToExample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ function extractExamplesFromFile(filePath: string): { name: string; body: string
}

const transformedBody = exampleBody
.replace(
/expect\((.*?)\)\.(toEqual|toBe|toStrictEqual|toHaveLength|toMatchObject)\((.*?)\);/gs, // Use `s` flag for multiline
(match, actual, method, expected) => {
expected = expected.replace(/\n/g, '\n //')
return `console.log(${actual}); // ${expected}`;
}
)
.replace(
/expect\((.*?)\)\.(toBeUndefined|toBeNull)\(\);/g,
(match, actual, method) => {
const expectedValue = method === 'toBeUndefined' ? 'undefined' : 'null';
return `console.log(${actual}); // ${expectedValue}`;
}
)
.replace(
/expect\((.*?)\)\.(toEqual|toBe|toStrictEqual|toHaveLength|toMatchObject)\((.*?)\);/gs, // Use `s` flag for multiline
(match, actual, method, expected) => {
expected = expected.replace(/\n/g, '\n //')
return `console.log(${actual}); // ${expected}`;
}
)
.trim();

examples.push({ name: exampleName, body: transformedBody });
Expand Down

0 comments on commit 1b0ee60

Please sign in to comment.