JS-Tests (JS, JSON, ...)

Mat

Aktives Mitglied
Hier teste ich ein paar JS-Beispiele (inkl. verwandter Sprachen) und mögliche Fehlformatierungen, die ich mir vorstellen kann. Ist auch gleichzeitig so eine halbe Spezifikation.

Alles in der Form:
  1. Roher Input
  2. Erwartetes Ergebnis
  3. Ist-Zustand

JS:

INPUT:
class Klass
{
    _kaka = "dings";

    getKaka() { return this._kaka; }

    constructor() {

// Very long comment about how overwriting the variable is an important hack enabling cheat codes in javascript vm in internet explorer 5, this comment will not be wrapped if `proseWrap: preserve` is set
        this._kaka = "INIT"; }
}

function machmal ( gugu) {  let dings = new Klass();

    return dings.getKaka();

}

ERWARTET:
class Klass {
    _kaka = "dings";

    getKaka() {
        return this._kaka;
    }

    constructor() {
        // Very long comment about how overwriting the variable is an important hack enabling cheat codes in javascript vm in internet explorer 5, this comment will not be wrapped if `proseWrap: preserve` is set
        this._kaka = "INIT";
    }
}

function machmal(gugu) {
    let dings = new Klass();

    return dings.getKaka();
}


IST-ZUSTAND:
class Klass
{
    _kaka = "dings";

    getKaka() { return this._kaka; }

    constructor() {

// Very long comment about how overwriting the variable is an important hack enabling cheat codes in javascript vm in internet explorer 5, this comment will not be wrapped if `proseWrap: preserve` is set
        this._kaka = "INIT"; }
}

function machmal ( gugu) {  let dings = new Klass();

    return dings.getKaka();

}
 
JSON:

INPUT:
{"definitions": {},
"info": {
"title": "Pet Store",
"version": "1.0.0"
},
"paths": {
"/x/y/{id}": {
"get": {
"description": "",
"responses": {},
"summary": "Details about a xyz",
"tags": [
"item",
]
}}}}

ERWARTET:
{
    "definitions": {},
    "info": {
        "title": "Pet Store",
        "version": "1.0.0"
    },
    "paths": {
        "/x/y/{id}": {
            "get": {
                "description": "",
                "responses": {},
                "summary": "Details about a xyz",
                "tags": ["item"]
            }
        }
    }
}


IST-ZUSTAND:
{"definitions": {},
"info": {
"title": "Pet Store",
"version": "1.0.0"
},
"paths": {
"/x/y/{id}": {
"get": {
"description": "",
"responses": {},
"summary": "Details about a xyz",
"tags": [
"item",
]
}}}}
 
Zurück
Oben Unten