0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-31 09:14:20 -04:00
denoland-deno/std/examples
Bartek Iwańczuk 6e2df8c64f
feat: Deno.test() sanitizes ops and resources (#4399)
This PR brings assertOps and assertResources sanitizers to Deno.test() API.

assertOps checks that test doesn't leak async ops, ie. there are no unresolved
promises originating from Deno APIs. Enabled by default, can be disabled using 
Deno.TestDefinition.disableOpSanitizer.

assertResources checks that test doesn't leak resources, ie. all resources used
in test are closed. For example; if a file is opened during a test case it must be
explicitly closed before test case finishes. It's most useful for asynchronous
generators. Enabled by default, can be disabled using 
Deno.TestDefinition.disableResourceSanitizer.

We've used those sanitizers in internal runtime tests and it proved very useful in
surfacing incorrect tests which resulted in interference between the tests.

All tests have been sanitized.

Closes #4208
2020-03-18 19:25:55 -04:00
..
chat feat: Deno.test() sanitizes ops and resources (#4399) 2020-03-18 19:25:55 -04:00
testdata fix(std/examples): add tests for examples (#4094) 2020-02-24 08:31:40 -05:00
tests feat: Deno.test() sanitizes ops and resources (#4399) 2020-03-18 19:25:55 -04:00
cat.ts feat: Deno.args now does not include script (#3628) 2020-01-09 11:37:01 -07:00
catj.ts refactor(std): Uncomment disabled tests, use skip option (#4378) 2020-03-15 13:03:25 +01:00
colors.ts reduce unnecessary output on tests (#4148) 2020-02-27 15:12:04 -05:00
curl.ts fix curl.ts (#3677) 2020-01-15 08:05:22 -06:00
echo_server.ts Happy new year! (#3578) 2020-01-02 15:13:47 -05:00
gist.ts reorg: move JS ops implementations to cli/js/ops/, part 1 (#4264) 2020-03-08 13:09:22 +01:00
README.md Added browser chat example (#4022) 2020-02-22 18:51:04 -05:00
test.ts feat: Deno.test() sanitizes ops and resources (#4399) 2020-03-18 19:25:55 -04:00
welcome.ts Add std/examples/welcome.ts (#3181) 2019-10-23 09:57:08 -07:00
xeval.ts feat(std/io): Export readDelim(), readStringDelim() and readLines() from bufio.ts (#4019) 2020-02-17 19:51:13 -05:00

Deno example programs

This module contains small scripts that demonstrate use of Deno and its standard module.

You can run these examples using just their URL or install the example as an executable script which references the URL. (Think of installing as creating a bookmark to a program.)

A TCP echo server

deno  --allow-net https://deno.land/std/examples/echo_server.ts

Or

deno install --allow-net echo_server https://deno.land/std/examples/echo_server.ts

cat - print file to standard output

deno install --allow-read deno_cat https://deno.land/std/examples/cat.ts
deno_cat file.txt

catj - print flattened JSON to standard output

A very useful command by Soheil Rashidi ported to Deno.

deno install --allow-read catj https://deno.land/std/examples/catj.ts
catj example.json
catj file1.json file2.json
echo example.json | catj -

curl - print the contents of a url to standard output

deno --allow-net=deno.land https://deno.land/std/examples/curl.ts https://deno.land/

gist - easily create and upload Gists

export GIST_TOKEN=ABC # Generate at https://github.com/settings/tokens
deno install --allow-net --allow-env gist https://deno.land/std/examples/gist.ts
gist --title "Example gist 1" script.ts
gist --t "Example gist 2" script2.ts

chat - WebSocket chat server and browser client

deno --allow-net --allow-read https://deno.land/std/examples/chat/server.ts

Open http://localhost:8080 on the browser.