mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 16:49:18 -05:00
621 lines
11 KiB
Text
621 lines
11 KiB
Text
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"attachments": {},
|
||
|
"cell_type": "markdown",
|
||
|
"id": "182aef1d",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Integration Tests for Deno Jupyter\n",
|
||
|
"This notebook contains a number of tests to ensure that Jupyter is working as expected. You should be able to select \"Kernel -> Restart Kernel and Run All\" in Jupyter's notebook UI to run the tests."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"attachments": {},
|
||
|
"cell_type": "markdown",
|
||
|
"id": "d7705d88",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Passing Tests"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"attachments": {},
|
||
|
"cell_type": "markdown",
|
||
|
"id": "669f972e",
|
||
|
"metadata": {
|
||
|
"heading_collapsed": true
|
||
|
},
|
||
|
"source": [
|
||
|
"### Simple Tests"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"attachments": {},
|
||
|
"cell_type": "markdown",
|
||
|
"id": "e7e8a512",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"source": [
|
||
|
"#### This test should print \"hi\".\n",
|
||
|
"If this doesn't work, everything else will probably fail :)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"id": "a5d38758",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {},
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"hi\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"console.log(\"hi\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"attachments": {},
|
||
|
"cell_type": "markdown",
|
||
|
"id": "bc5ce8e3",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"source": [
|
||
|
"#### Top-level await"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"id": "f7fa885a",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {},
|
||
|
"execution_count": 2,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"x is \u001b[33m42\u001b[39m\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"let x = await Promise.resolve(42);\n",
|
||
|
"console.log(\"x is\", x);"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"attachments": {},
|
||
|
"cell_type": "markdown",
|
||
|
"id": "c21455ae",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"source": [
|
||
|
"#### TypeScript transpiling\n",
|
||
|
"Credit to [typescriptlang.org](https://www.typescriptlang.org/docs/handbook/interfaces.html) for this code"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"id": "08a17340",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"{ color: \u001b[32m\"red\"\u001b[39m, area: \u001b[33m10000\u001b[39m }"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"interface SquareConfig {\n",
|
||
|
" color?: string;\n",
|
||
|
" width?: number;\n",
|
||
|
"}\n",
|
||
|
" \n",
|
||
|
"function createSquare(config: SquareConfig): { color: string; area: number } {\n",
|
||
|
" return {\n",
|
||
|
" color: config.color || \"red\",\n",
|
||
|
" area: config.width ? config.width * config.width : 20,\n",
|
||
|
" };\n",
|
||
|
"}\n",
|
||
|
" \n",
|
||
|
"createSquare({ colour: \"red\", width: 100 });"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"attachments": {},
|
||
|
"cell_type": "markdown",
|
||
|
"id": "eaa0ebc0",
|
||
|
"metadata": {
|
||
|
"heading_collapsed": true
|
||
|
},
|
||
|
"source": [
|
||
|
"### Return Values"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"attachments": {},
|
||
|
"cell_type": "markdown",
|
||
|
"id": "52876276",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"source": [
|
||
|
"#### undefined should not return a value"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"id": "bbf2c09b",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {},
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"undefined"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"attachments": {},
|
||
|
"cell_type": "markdown",
|
||
|
"id": "e175c803",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"source": [
|
||
|
"#### null should return \"null\""
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"id": "d9801d80",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"\u001b[1mnull\u001b[22m"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 5,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"null"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"attachments": {},
|
||
|
"cell_type": "markdown",
|
||
|
"id": "a2a716dc",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"source": [
|
||
|
"#### boolean should return the boolean"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"id": "cfaac330",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"\u001b[33mtrue\u001b[39m"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 6,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"true"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"attachments": {},
|
||
|
"cell_type": "markdown",
|
||
|
"id": "8d9f1aba",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"source": [
|
||
|
"#### number should return the number"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"id": "ec3be2da",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"\u001b[33m42\u001b[39m"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 7,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"42"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"attachments": {},
|
||
|
"cell_type": "markdown",
|
||
|
"id": "60965915",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"source": [
|
||
|
"#### string should return the string"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"id": "997cf2d7",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"\u001b[32m\"this is a test of the emergency broadcast system\"\u001b[39m"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"\"this is a test of the emergency broadcast system\""
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"attachments": {},
|
||
|
"cell_type": "markdown",
|
||
|
"id": "fe38dc27",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"source": [
|
||
|
"#### bigint should return the bigint in literal format"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 9,
|
||
|
"id": "44b63807",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"\u001b[33m31337n\u001b[39m"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 9,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"31337n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"attachments": {},
|
||
|
"cell_type": "markdown",
|
||
|
"id": "843ccb6c",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"source": [
|
||
|
"#### symbol should return a string describing the symbol"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 10,
|
||
|
"id": "e10c0d31",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"\u001b[32mSymbol(foo)\u001b[39m"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 10,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"Symbol(\"foo\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"attachments": {},
|
||
|
"cell_type": "markdown",
|
||
|
"id": "171b817f",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"source": [
|
||
|
"#### object should describe the object inspection"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"id": "81c99233",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"{ foo: \u001b[32m\"bar\"\u001b[39m }"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 11,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"{foo: \"bar\"}"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"attachments": {},
|
||
|
"cell_type": "markdown",
|
||
|
"id": "6caeb583",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"source": [
|
||
|
"#### resolve returned promise"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 13,
|
||
|
"id": "43c1581b",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"Promise { \u001b[32m\"it worked!\"\u001b[39m }"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 13,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"Promise.resolve(\"it worked!\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 14,
|
||
|
"id": "9a34b725",
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"Promise {\n",
|
||
|
" \u001b[36m<rejected>\u001b[39m Error: it failed!\n",
|
||
|
" at <anonymous>:2:16\n",
|
||
|
"}"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 14,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"Promise.reject(new Error(\"it failed!\"));"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 15,
|
||
|
"id": "b5c7b819",
|
||
|
"metadata": {
|
||
|
"scrolled": true
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"ename": "Error: this is a test\n at foo (<anonymous>:3:9)\n at <anonymous>:4:3",
|
||
|
"evalue": "",
|
||
|
"output_type": "error",
|
||
|
"traceback": []
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"(function foo() {\n",
|
||
|
" throw new Error(\"this is a test\")\n",
|
||
|
"})()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 16,
|
||
|
"id": "72d01fdd",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"Promise {\n",
|
||
|
" \u001b[36m<rejected>\u001b[39m TypeError: Expected string at position 0\n",
|
||
|
" at Object.readFile (ext:deno_fs/30_fs.js:716:29)\n",
|
||
|
" at <anonymous>:2:6\n",
|
||
|
"}"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 16,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"Deno.readFile(1)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"id": "28cf59d0-6908-4edc-bb10-c325beeee362",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"console.log(\"Hello from Deno!\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"id": "8d5485c3-0da3-43fe-8ef5-a61e672f5e81",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"console.log(\"%c Hello Deno \", \"background-color: #15803d; color: white;\");"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"id": "1401d9d5-6994-4c7b-b55a-db3c16a1e2dc",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"\"Cool 🫡\""
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"id": "7afdaa0a-a2a0-4f52-8c7d-b6c5f237aa0d",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"console.table([1, 2, 3])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"id": "8e93df23-06eb-414b-98d4-51fbebb53d1f",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Deno",
|
||
|
"language": "typescript",
|
||
|
"name": "deno"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"file_extension": ".ts",
|
||
|
"mimetype": "text/x.typescript",
|
||
|
"name": "typescript",
|
||
|
"nb_converter": "script",
|
||
|
"pygments_lexer": "typescript",
|
||
|
"version": "5.2.2"
|
||
|
},
|
||
|
"toc": {
|
||
|
"base_numbering": 1,
|
||
|
"nav_menu": {},
|
||
|
"number_sections": true,
|
||
|
"sideBar": true,
|
||
|
"skip_h1_title": false,
|
||
|
"title_cell": "Table of Contents",
|
||
|
"title_sidebar": "Contents",
|
||
|
"toc_cell": false,
|
||
|
"toc_position": {},
|
||
|
"toc_section_display": true,
|
||
|
"toc_window_display": true
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 5
|
||
|
}
|