273 lines
10 KiB
Plaintext
273 lines
10 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"id": "13e0b4fc-3ea3-4fc8-9293-7d9f58eb82fb",
|
|
"metadata": {
|
|
"editable": true,
|
|
"jupyter": {
|
|
"source_hidden": true
|
|
},
|
|
"slideshow": {
|
|
"slide_type": ""
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import { assertEquals } from \"jsr:@std/assert\""
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "12998cb3-fe6b-4be9-83de-4d725210c5b1",
|
|
"metadata": {
|
|
"editable": true,
|
|
"slideshow": {
|
|
"slide_type": ""
|
|
},
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"# Aufgabe 01.02.4\n",
|
|
"Schreibe eine Funktion `echo`, die ebenfalls den übergebenen Parameter wieder zurückgibt."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "3bc621d3-8101-4588-9a9a-73480f296a5d",
|
|
"metadata": {
|
|
"editable": true,
|
|
"slideshow": {
|
|
"slide_type": ""
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"id": "288a67d3-1aab-4f24-ac41-ab24c2d098eb",
|
|
"metadata": {
|
|
"collapsed": true,
|
|
"editable": true,
|
|
"jupyter": {
|
|
"outputs_hidden": true,
|
|
"source_hidden": true
|
|
},
|
|
"slideshow": {
|
|
"slide_type": ""
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"01.02.4: echo ... \u001b[0m\u001b[31mFAILED\u001b[0m \u001b[0m\u001b[38;5;245m(2ms)\u001b[0m\n",
|
|
"01.02.4: Parameter ... \u001b[0m\u001b[31mFAILED\u001b[0m \u001b[0m\u001b[38;5;245m(0ms)\u001b[0m\n",
|
|
"01.02.4: Greta ... \u001b[0m\u001b[31mFAILED\u001b[0m \u001b[0m\u001b[38;5;245m(0ms)\u001b[0m\n",
|
|
"01.02.4: CO2 ... \u001b[0m\u001b[31mFAILED\u001b[0m \u001b[0m\u001b[38;5;245m(0ms)\u001b[0m\n",
|
|
"\n",
|
|
"\u001b[0m\u001b[1m\u001b[37m\u001b[41m ERRORS \u001b[0m\n",
|
|
"\n",
|
|
"01.02.4: echo \u001b[0m\u001b[38;5;245m=> <anonymous>:1:27\u001b[0m\n",
|
|
"\u001b[0m\u001b[1m\u001b[31merror\u001b[0m: AssertionError: Values are not equal.\n",
|
|
"\n",
|
|
"\n",
|
|
" \u001b[90m\u001b[1m[Diff]\u001b[22m\u001b[39m \u001b[31m\u001b[1mActual\u001b[22m\u001b[39m / \u001b[32m\u001b[1mExpected\u001b[22m\u001b[39m\n",
|
|
"\n",
|
|
"\n",
|
|
"\u001b[31m\u001b[1m- \u001b[41m\u001b[37mundefined\u001b[31m\u001b[49m\n",
|
|
"\u001b[22m\u001b[39m\u001b[32m\u001b[1m+ \u001b[42m\u001b[37mfunction\u001b[32m\u001b[49m\n",
|
|
"\u001b[22m\u001b[39m\n",
|
|
"\n",
|
|
" throw new AssertionError(message);\n",
|
|
"\u001b[0m\u001b[31m ^\u001b[0m\n",
|
|
" at \u001b[0m\u001b[1m\u001b[3massertEquals\u001b[0m (\u001b[0m\u001b[36mhttps://jsr.io/@std/assert/1.0.13/equals.ts\u001b[0m:\u001b[0m\u001b[33m64\u001b[0m:\u001b[0m\u001b[33m9\u001b[0m)\n",
|
|
" at \u001b[0m\u001b[36m<anonymous>\u001b[0m:\u001b[0m\u001b[33m2\u001b[0m:\u001b[0m\u001b[33m3\u001b[0m\n",
|
|
"\n",
|
|
"01.02.4: Parameter \u001b[0m\u001b[38;5;245m=> <anonymous>:4:6\u001b[0m\n",
|
|
"\u001b[0m\u001b[1m\u001b[31merror\u001b[0m: ReferenceError: echo is not defined\n",
|
|
" at \u001b[0m\u001b[36m<anonymous>\u001b[0m:\u001b[0m\u001b[33m5\u001b[0m:\u001b[0m\u001b[33m16\u001b[0m\n",
|
|
"\n",
|
|
"01.02.4: Greta \u001b[0m\u001b[38;5;245m=> <anonymous>:7:6\u001b[0m\n",
|
|
"\u001b[0m\u001b[1m\u001b[31merror\u001b[0m: ReferenceError: echo is not defined\n",
|
|
" at \u001b[0m\u001b[36m<anonymous>\u001b[0m:\u001b[0m\u001b[33m8\u001b[0m:\u001b[0m\u001b[33m3\u001b[0m\n",
|
|
"\n",
|
|
"01.02.4: CO2 \u001b[0m\u001b[38;5;245m=> <anonymous>:10:6\u001b[0m\n",
|
|
"\u001b[0m\u001b[1m\u001b[31merror\u001b[0m: ReferenceError: echo is not defined\n",
|
|
" at \u001b[0m\u001b[36m<anonymous>\u001b[0m:\u001b[0m\u001b[33m11\u001b[0m:\u001b[0m\u001b[33m3\u001b[0m\n",
|
|
"\n",
|
|
"\u001b[0m\u001b[1m\u001b[37m\u001b[41m FAILURES \u001b[0m\n",
|
|
"\n",
|
|
"01.02.4: echo \u001b[0m\u001b[38;5;245m=> <anonymous>:1:27\u001b[0m\n",
|
|
"01.02.4: Parameter \u001b[0m\u001b[38;5;245m=> <anonymous>:4:6\u001b[0m\n",
|
|
"01.02.4: Greta \u001b[0m\u001b[38;5;245m=> <anonymous>:7:6\u001b[0m\n",
|
|
"01.02.4: CO2 \u001b[0m\u001b[38;5;245m=> <anonymous>:10:6\u001b[0m\n",
|
|
"\n",
|
|
"\u001b[0m\u001b[31mFAILED\u001b[0m | 0 passed | 4 failed \u001b[0m\u001b[38;5;245m(3ms)\u001b[0m\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"Deno.test(\"01.02.4: echo\", () => {\n",
|
|
" assertEquals(typeof echo, 'function')\n",
|
|
"})\n",
|
|
"Deno.test(\"01.02.4: Parameter\", () => {\n",
|
|
" assertEquals(echo.length, 1)\n",
|
|
"})\n",
|
|
"Deno.test(\"01.02.4: Greta\", () => {\n",
|
|
" assertEquals(echo('Greta'), 'Greta')\n",
|
|
"})\n",
|
|
"Deno.test(\"01.02.4: CO2\", () => {\n",
|
|
" assertEquals(echo('CO2'), 'CO2')\n",
|
|
"})"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "f80f8e2f-f8e0-48d4-9ffb-21a17b14b473",
|
|
"metadata": {
|
|
"editable": true,
|
|
"slideshow": {
|
|
"slide_type": ""
|
|
},
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"# Aufgabe 01.02.5\n",
|
|
"Schreibe eine Funktion `welcome`, die einen Parameter entgegennimmt und die `'Hallo <Parameter>!'` zurückgibt.\n",
|
|
"\n",
|
|
"Beispiel: Übergibt man der Funktion `welcome` den Wert `'Ada'`, so sollte die Funktion `'Hallo Ada!'` zurückgeben."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "8fd18a65-713b-48af-a6ad-ade656a3f7dd",
|
|
"metadata": {
|
|
"editable": true,
|
|
"slideshow": {
|
|
"slide_type": ""
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"id": "21b1f649-6e1f-4c1a-a8f3-f3653dd4eb89",
|
|
"metadata": {
|
|
"editable": true,
|
|
"jupyter": {
|
|
"source_hidden": true
|
|
},
|
|
"slideshow": {
|
|
"slide_type": ""
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"01.02.5: welcome ... \u001b[0m\u001b[31mFAILED\u001b[0m \u001b[0m\u001b[38;5;245m(0ms)\u001b[0m\n",
|
|
"01.02.5: Parameter ... \u001b[0m\u001b[31mFAILED\u001b[0m \u001b[0m\u001b[38;5;245m(0ms)\u001b[0m\n",
|
|
"01.02.5: Ada ... \u001b[0m\u001b[31mFAILED\u001b[0m \u001b[0m\u001b[38;5;245m(0ms)\u001b[0m\n",
|
|
"01.02.5: Marianne ... \u001b[0m\u001b[31mFAILED\u001b[0m \u001b[0m\u001b[38;5;245m(16ms)\u001b[0m\n",
|
|
"01.02.5: Mitchell ... \u001b[0m\u001b[31mFAILED\u001b[0m \u001b[0m\u001b[38;5;245m(0ms)\u001b[0m\n",
|
|
"\n",
|
|
"\u001b[0m\u001b[1m\u001b[37m\u001b[41m ERRORS \u001b[0m\n",
|
|
"\n",
|
|
"01.02.5: welcome \u001b[0m\u001b[38;5;245m=> <anonymous>:1:27\u001b[0m\n",
|
|
"\u001b[0m\u001b[1m\u001b[31merror\u001b[0m: AssertionError: Values are not equal.\n",
|
|
"\n",
|
|
"\n",
|
|
" \u001b[90m\u001b[1m[Diff]\u001b[22m\u001b[39m \u001b[31m\u001b[1mActual\u001b[22m\u001b[39m / \u001b[32m\u001b[1mExpected\u001b[22m\u001b[39m\n",
|
|
"\n",
|
|
"\n",
|
|
"\u001b[31m\u001b[1m- \u001b[41m\u001b[37mundefined\u001b[31m\u001b[49m\n",
|
|
"\u001b[22m\u001b[39m\u001b[32m\u001b[1m+ \u001b[42m\u001b[37mfunction\u001b[32m\u001b[49m\n",
|
|
"\u001b[22m\u001b[39m\n",
|
|
"\n",
|
|
" throw new AssertionError(message);\n",
|
|
"\u001b[0m\u001b[31m ^\u001b[0m\n",
|
|
" at \u001b[0m\u001b[1m\u001b[3massertEquals\u001b[0m (\u001b[0m\u001b[36mhttps://jsr.io/@std/assert/1.0.13/equals.ts\u001b[0m:\u001b[0m\u001b[33m64\u001b[0m:\u001b[0m\u001b[33m9\u001b[0m)\n",
|
|
" at \u001b[0m\u001b[36m<anonymous>\u001b[0m:\u001b[0m\u001b[33m2\u001b[0m:\u001b[0m\u001b[33m3\u001b[0m\n",
|
|
"\n",
|
|
"01.02.5: Parameter \u001b[0m\u001b[38;5;245m=> <anonymous>:4:6\u001b[0m\n",
|
|
"\u001b[0m\u001b[1m\u001b[31merror\u001b[0m: ReferenceError: welcome is not defined\n",
|
|
" at \u001b[0m\u001b[36m<anonymous>\u001b[0m:\u001b[0m\u001b[33m5\u001b[0m:\u001b[0m\u001b[33m16\u001b[0m\n",
|
|
"\n",
|
|
"01.02.5: Ada \u001b[0m\u001b[38;5;245m=> <anonymous>:7:6\u001b[0m\n",
|
|
"\u001b[0m\u001b[1m\u001b[31merror\u001b[0m: ReferenceError: welcome is not defined\n",
|
|
" at \u001b[0m\u001b[36m<anonymous>\u001b[0m:\u001b[0m\u001b[33m8\u001b[0m:\u001b[0m\u001b[33m3\u001b[0m\n",
|
|
"\n",
|
|
"01.02.5: Marianne \u001b[0m\u001b[38;5;245m=> <anonymous>:10:6\u001b[0m\n",
|
|
"\u001b[0m\u001b[1m\u001b[31merror\u001b[0m: ReferenceError: welcome is not defined\n",
|
|
" at \u001b[0m\u001b[36m<anonymous>\u001b[0m:\u001b[0m\u001b[33m11\u001b[0m:\u001b[0m\u001b[33m3\u001b[0m\n",
|
|
"\n",
|
|
"01.02.5: Mitchell \u001b[0m\u001b[38;5;245m=> <anonymous>:13:6\u001b[0m\n",
|
|
"\u001b[0m\u001b[1m\u001b[31merror\u001b[0m: ReferenceError: welcome is not defined\n",
|
|
" at \u001b[0m\u001b[36m<anonymous>\u001b[0m:\u001b[0m\u001b[33m14\u001b[0m:\u001b[0m\u001b[33m3\u001b[0m\n",
|
|
"\n",
|
|
"\u001b[0m\u001b[1m\u001b[37m\u001b[41m FAILURES \u001b[0m\n",
|
|
"\n",
|
|
"01.02.5: welcome \u001b[0m\u001b[38;5;245m=> <anonymous>:1:27\u001b[0m\n",
|
|
"01.02.5: Parameter \u001b[0m\u001b[38;5;245m=> <anonymous>:4:6\u001b[0m\n",
|
|
"01.02.5: Ada \u001b[0m\u001b[38;5;245m=> <anonymous>:7:6\u001b[0m\n",
|
|
"01.02.5: Marianne \u001b[0m\u001b[38;5;245m=> <anonymous>:10:6\u001b[0m\n",
|
|
"01.02.5: Mitchell \u001b[0m\u001b[38;5;245m=> <anonymous>:13:6\u001b[0m\n",
|
|
"\n",
|
|
"\u001b[0m\u001b[31mFAILED\u001b[0m | 0 passed | 5 failed \u001b[0m\u001b[38;5;245m(18ms)\u001b[0m\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"Deno.test(\"01.02.5: welcome\", () => {\n",
|
|
" assertEquals(typeof welcome, 'function')\n",
|
|
"})\n",
|
|
"Deno.test(\"01.02.5: Parameter\", () => {\n",
|
|
" assertEquals(welcome.length, 1)\n",
|
|
"})\n",
|
|
"Deno.test(\"01.02.5: Ada\", () => {\n",
|
|
" assertEquals(welcome('Ada'), 'Hallo Ada!')\n",
|
|
"})\n",
|
|
"Deno.test(\"01.02.5: Marianne\", () => {\n",
|
|
" assertEquals(welcome('Marianne'), 'Hallo Marianne!')\n",
|
|
"})\n",
|
|
"Deno.test(\"01.02.5: Mitchell\", () => {\n",
|
|
" assertEquals(welcome('Mitchell'), 'Hallo Mitchell!')\n",
|
|
"})"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Deno",
|
|
"language": "typescript",
|
|
"name": "deno"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": "typescript",
|
|
"file_extension": ".ts",
|
|
"mimetype": "text/x.typescript",
|
|
"name": "typescript",
|
|
"nbconvert_exporter": "script",
|
|
"pygments_lexer": "typescript",
|
|
"version": "5.8.3"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|