Skip to content

Commit b0092eb

Browse files
Merge pull request #5 from crewdevio/development
add: more matchers and migrate to trex imports
2 parents 7efbfd4 + e6cc9db commit b0092eb

File tree

12 files changed

+199
-86
lines changed

12 files changed

+199
-86
lines changed

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"deno.enable": true,
3+
"deno.import_map": "./import_map.json",
4+
"deno.unstable": true
5+
}

README.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
<a href="https://nest.land/package/merlin">
2222
<img src="https://nest.land/badge.svg" />
2323
</a>
24+
<a href="https://deno.land/x/merlin">
25+
<img src="https://img.shields.io/badge/available%20on-deno.land/x-blue.svg?style=flat&logo=deno"/>
26+
</a>
2427
</p>
2528

2629
## Merlin
@@ -59,6 +62,8 @@ Merlin is a [Jest](https://jestjs.io/en/)-inspired testing framework for deno.
5962
- `isFunction(label: string, config)` evaluates if a data is a function
6063
- `isSymbol(label: string, config)` evaluates if a data is a symbol
6164
- `isUndefined(label: string, config)` evaluates if a data is undefined
65+
- `isString(label: string, config)` evaluates if a data is string
66+
- `isNumber(label: string, config)` evaluates if a data is number
6267
- `testSame(label: string, config)` evaluates if two values are strictly the same
6368
- `testGreaterOrEqual(label: string, config)` evaluates whether the expected data is greater than or equal to another
6469
- `testGreater(label: string, config)` evaluates whether the expected data is greater than another
@@ -68,19 +73,20 @@ Merlin is a [Jest](https://jestjs.io/en/)-inspired testing framework for deno.
6873
- `testFloat(label: string, config)` evaluates if two decimal numbers are equal
6974
- `testThrows(label: string, config)` expect it throws an error
7075
- `testThrowsSync(label: string, config)` expect it throws an async error
76+
- `haveProperty(label: string, config)` expect an object to contain the properties in its value
7177

72-
### Install Merlin
78+
#### Statics
7379

74-
install merlin-cli (optional)
80+
- `Merlin.Error(msg?: string)` force to throw an error
81+
- `Merlin.Unimplemented(msg?: string)` Use this to throw a method not implemented error
82+
- `Merlin.Unreachable()` Use this to throw an Unreachable method error
7583

76-
```sh
77-
$ deno install --allow-run -n merlin http://denopkg.com/crewdevio/merlin/cli.ts
78-
```
84+
### Install Merlin
7985

80-
or using [Trex](https://github.com/crewdevio/Trex) package manager.
86+
install merlin-cli (optional)
8187

8288
```sh
83-
$ trex getTool merlin-cli
89+
deno install --allow-run -n merlin https://deno.land/x/merlin/cli.ts
8490
```
8591

8692
### Mirrors
@@ -126,10 +132,16 @@ test.testEqual("two plus two is four", {
126132
});
127133
```
128134

129-
run this test in deno
135+
run this test in deno.
136+
137+
```sh
138+
merlin start
139+
```
140+
141+
or
130142

131143
```sh
132-
$ deno test
144+
deno test
133145
```
134146

135147
you should see this output on the console.
@@ -184,7 +196,7 @@ test.testEqual("Leak resources test", {
184196
```
185197

186198
```sh
187-
deno test
199+
merlin start
188200

189201
test Leak resources test ... ok (5ms)
190202

@@ -224,7 +236,7 @@ test.evalEquals([
224236
output
225237

226238
```sh
227-
$ deno test
239+
merlin start
228240

229241
running 2 tests
230242
test object assignment ... ok (10ms)
@@ -251,7 +263,7 @@ test.testNotEqual("two plus two not is five", {
251263
output
252264

253265
```sh
254-
$ deno test
266+
merlin start
255267

256268
running 1 tests
257269
test two plus two not is five ... FAILED (2ms)
@@ -286,7 +298,7 @@ test.stringContains("hello world contains orld", {
286298
```
287299

288300
```sh
289-
deno test
301+
merlin start
290302

291303
test hello world contains orld ... ok (8ms)
292304

@@ -306,7 +318,7 @@ test.fetchEqual("fetch data", {
306318
```
307319

308320
```sh
309-
deno test
321+
merlin start
310322

311323
test fetch data ... ok (1440ms)
312324

@@ -323,7 +335,7 @@ test.testRegExp("regEx match", {
323335
```
324336

325337
```sh
326-
deno test
338+
merlin start
327339

328340
test regEx match ... ok (6ms)
329341

@@ -415,7 +427,7 @@ It has a table with the detailed values
415427
▒▒▒▒▒▒▒▒ Benchmarking finished
416428

417429
┌───────────────────────────────────────────────────────────────────────────────────────────┐
418-
🧪 Benchmark name: Sorting arrays │
430+
🚀 Benchmark name: Sorting arrays │
419431
├───────────────────────┬──────────────────────────────┬────────────────────────────────────┤
420432
│ Total runs: 1000 │ Total time: 1099.6591 ms │ Avg time: 1.0997 ms │
421433
├───────────────────────┼────────────────────┬─────────┴───────────┬────────────────────────┤

cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*/
88

9-
import { colors } from "./deps.ts";
9+
import { colors } from "./imports/fmt.ts";
1010

1111
async function main() {
1212
const [command, ...args] = Deno.args;
@@ -25,7 +25,7 @@ async function main() {
2525
}
2626
} else if (command === "help") {
2727
const info = [
28-
colors.green("merlin test runner v1.0.0 🧪\n"),
28+
colors.green("merlin test runner v1.0.2 🧪\n"),
2929
colors.green("usage:"),
3030
`merlin ${colors.yellow("test")} ...allow-flags\n`,
3131
colors.green("example:"),

deps.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

egg.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "merlin",
33
"description": "Testing and Benchmarking framework for deno 🧙‍♂️",
4-
"version": "1.0.0",
4+
"version": "1.0.2",
55
"entry": "./mod.ts",
66
"stable": true,
77
"unlisted": false,
@@ -10,9 +10,9 @@
1010
"files": [
1111
"./cli.ts",
1212
"./src/**/*",
13+
"./imports/**/*",
1314
"./README.md",
1415
"./mod.ts",
15-
"./deps.ts",
1616
"./LICENSE"
1717
]
1818
}

imports/deps.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"meta": {
3+
"fmt": "http://denopkg.com/crewdevio/Trex@proxy/proxy/files/fmt.ts",
4+
"testing": "http://denopkg.com/crewdevio/Trex@proxy/proxy/files/testing.ts",
5+
"pretty_benching": "https://deno.land/x/pretty_benching/mod.ts"
6+
}
7+
}

imports/fmt.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "http://denopkg.com/crewdevio/Trex@proxy/proxy/files/fmt.ts";

imports/pretty_benching.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "https://deno.land/x/pretty_benching/mod.ts";

imports/testing.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "http://denopkg.com/crewdevio/Trex@proxy/proxy/files/testing.ts";

src/maven.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,29 @@
77
*/
88

99
import {
10-
bench,
11-
runBenchmarks,
12-
BenchmarkRunOptions,
1310
prettyBenchmarkProgress,
1411
prettyBenchmarkResult,
15-
colors,
16-
} from "../deps.ts";
17-
12+
} from "../imports/pretty_benching.ts";
13+
import { colors } from "../imports/fmt.ts";
14+
import { bench } from "../imports/testing.ts";
1815
import { Thresholds, Bench } from "./types.ts";
1916

2017
export class Maven {
21-
private bench = bench;
18+
private bench = bench.bench;
2219

2320
private thresholds: Thresholds = {};
2421

25-
private config: BenchmarkRunOptions = {};
22+
private config: bench.BenchmarkRunOptions = {};
2623

2724
private indicators = [
2825
{
2926
benches: /./,
3027
tableColor: colors.cyan,
31-
modFn: () => "🧪",
28+
modFn: () => "🚀",
3229
},
3330
];
3431

35-
private runIndicator = [{ benches: /./, modFn: () => colors.green(" ==> ") }];
32+
private runIndicator = [{ benches: /./, modFn: () => "==> " }];
3633

3734
private addThreasholds(name: string) {
3835
this.thresholds[name] = { green: 70, yellow: 90 };
@@ -51,9 +48,9 @@ export class Maven {
5148
});
5249
}
5350

54-
public async runBench(config?: BenchmarkRunOptions) {
55-
this.config = config as BenchmarkRunOptions;
56-
return runBenchmarks(
51+
public async runBench(config?: bench.BenchmarkRunOptions) {
52+
this.config = config as bench.BenchmarkRunOptions;
53+
return bench.runBenchmarks(
5754
{ silent: true, ...config },
5855
prettyBenchmarkProgress({
5956
indicators: this.runIndicator,

0 commit comments

Comments
 (0)