examples/browser/1

# Application examples/browser/1

Function

    function f_1_0(x) {
        if (x == 1) {
            return 1;
        } else if (x == 2) {
            return 2;
        } else if (x == 3) {
            return 3;
        }
        return -1;
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "x": 0
        },
        {
          "x": 3
        },
        {
          "x": 2
        },
        {
          "x": 1
        }
      ],
      "results": [
        {
          "type": "number",
          "value": -1,
          "description": "-1"
        },
        {
          "type": "number",
          "value": 3,
          "description": "3"
        },
        {
          "type": "number",
          "value": 2,
          "description": "2"
        },
        {
          "type": "number",
          "value": 1,
          "description": "1"
        }
      ]
    }

Function

    function f_1_1(x) {
        if (x == 1) {
            return 1;
        } else if (x == 2) {
            return 2;
        } else if (x == 3) {
            return 3;
        }
        return -1;
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "x": 10
        },
        {
          "x": 3
        },
        {
          "x": 2
        },
        {
          "x": 1
        }
      ],
      "results": [
        {
          "type": "number",
          "value": -1,
          "description": "-1"
        },
        {
          "type": "number",
          "value": 3,
          "description": "3"
        },
        {
          "type": "number",
          "value": 2,
          "description": "2"
        },
        {
          "type": "number",
          "value": 1,
          "description": "1"
        }
      ]
    }

Function

    function f_1_2(x) {
        if (x == 1 || x == 2) {
            return '1 or 2';
        } else if (x == 3 || x > 3) {
            return '3 or > 3';
        }
        return -1;
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "x": 10
        },
        {
          "x": 0
        },
        {
          "x": 1
        }
      ],
      "results": [
        {
          "type": "string",
          "value": "3 or > 3"
        },
        {
          "type": "number",
          "value": -1,
          "description": "-1"
        },
        {
          "type": "string",
          "value": "1 or 2"
        }
      ]
    }

Function

    function f_1_3(x, y, z) {
        if (x == 1 && y == 1) {
            return 1;
        } else if (x == 2 || y == 1) {
            return 2;
        } else if (x == 3 && z == 2) {
            return 3;
        } else if (z == 190) {
            return 4;
        } else {
            return -1;
        }
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "x": 10,
          "y": 231,
          "z": 23131
        },
        {
          "x": 3,
          "y": 2,
          "z": 190
        },
        {
          "x": 3,
          "y": 2,
          "z": 2
        },
        {
          "x": 0,
          "y": 1,
          "z": 2
        },
        {
          "x": 1,
          "y": 1,
          "z": 2
        }
      ],
      "results": [
        {
          "type": "number",
          "value": -1,
          "description": "-1"
        },
        {
          "type": "number",
          "value": 4,
          "description": "4"
        },
        {
          "type": "number",
          "value": 3,
          "description": "3"
        },
        {
          "type": "number",
          "value": 2,
          "description": "2"
        },
        {
          "type": "number",
          "value": 1,
          "description": "1"
        }
      ]
    }

Function

    function f_1_4(a, b) {
        if (a > 0) {
            if (a == 19) {
                if (b == 0) {
                    return 1;
                } else {
                    return 2;
                }
            }
        } else {
            if (a == -1) {
                return 3;
            } else if (a == -90) {
                return 4;
            }
        }
        return -1;
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "a": 10,
          "b": 231
        },
        {
          "a": 19,
          "b": 231
        },
        {
          "a": 19,
          "b": 0
        },
        {
          "a": 0,
          "b": 0
        },
        {
          "a": -90,
          "b": 0
        },
        {
          "a": -1,
          "b": 0
        }
      ],
      "results": [
        {
          "type": "number",
          "value": -1,
          "description": "-1"
        },
        {
          "type": "number",
          "value": 2,
          "description": "2"
        },
        {
          "type": "number",
          "value": 1,
          "description": "1"
        },
        {
          "type": "number",
          "value": -1,
          "description": "-1"
        },
        {
          "type": "number",
          "value": 4,
          "description": "4"
        },
        {
          "type": "number",
          "value": 3,
          "description": "3"
        }
      ]
    }

Function

    function f_2_0(x, y) {
        if (x == 0) {
            if (y == 0) {
            } else if (y == 1) {
            }
        } else if (x == 1) {
        } else {
            return y == 3131 ? 10 : 11;
        }
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "x": 0,
          "y": 2
        },
        {
          "x": 0,
          "y": 1
        },
        {
          "x": 0,
          "y": 0
        },
        {
          "x": 1,
          "y": 0
        },
        {
          "x": 2,
          "y": 0
        },
        {
          "x": 2,
          "y": 3131
        }
      ],
      "results": [
        {
          "type": "undefined"
        },
        {
          "type": "undefined"
        },
        {
          "type": "undefined"
        },
        {
          "type": "undefined"
        },
        {
          "type": "number",
          "value": 11,
          "description": "11"
        },
        {
          "type": "number",
          "value": 10,
          "description": "10"
        }
      ]
    }

Function

    function f_2_1(x) {
        if (x == 1) {
            return 1;
        } else if (x == 2) {
            return 2;
        } else if (x == 3) {
            return 3;
        }
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "x": 10
        },
        {
          "x": 3
        },
        {
          "x": 2
        },
        {
          "x": 1
        }
      ],
      "results": [
        {
          "type": "undefined"
        },
        {
          "type": "number",
          "value": 3,
          "description": "3"
        },
        {
          "type": "number",
          "value": 2,
          "description": "2"
        },
        {
          "type": "number",
          "value": 1,
          "description": "1"
        }
      ]
    }

Function

    function f_2_2(x) {
        if (x == 1) {
        } else if (x == 2) {
        } else if (x == 3) {
        }
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "x": 10
        },
        {
          "x": 3
        },
        {
          "x": 2
        },
        {
          "x": 1
        }
      ],
      "results": [
        {
          "type": "undefined"
        },
        {
          "type": "undefined"
        },
        {
          "type": "undefined"
        },
        {
          "type": "undefined"
        }
      ]
    }

Function

    function f_2_3(x, y, z) {
        if (x == 1 && y == 1) {
        } else if (x == 2 || y == 1) {
        } else if (x == 3 && z == 2) {
        } else if (z == 190) {
        } else {
        }
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "x": 10,
          "y": 231,
          "z": 23131
        },
        {
          "x": 3,
          "y": 2,
          "z": 190
        },
        {
          "x": 3,
          "y": 2,
          "z": 2
        },
        {
          "x": 0,
          "y": 1,
          "z": 2
        },
        {
          "x": 1,
          "y": 1,
          "z": 2
        }
      ],
      "results": [
        {
          "type": "undefined"
        },
        {
          "type": "undefined"
        },
        {
          "type": "undefined"
        },
        {
          "type": "undefined"
        },
        {
          "type": "undefined"
        }
      ]
    }

Function

    function f_2_4(a, b) {
        if (a > 0) {
            if (a == 19) {
                if (b == 0) {
                    return 1;
                } else {
                    return 0;
                }
            }
        } else {
            if (a == -1) {
                return 0;
            } else if (a == -90) {
                return 1;
            }
        }
        return 180;
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "a": 10,
          "b": 231
        },
        {
          "a": 19,
          "b": 231
        },
        {
          "a": 19,
          "b": 0
        },
        {
          "a": 0,
          "b": 0
        },
        {
          "a": -90,
          "b": 0
        },
        {
          "a": -1,
          "b": 0
        }
      ],
      "results": [
        {
          "type": "number",
          "value": 180,
          "description": "180"
        },
        {
          "type": "number",
          "value": 0,
          "description": "0"
        },
        {
          "type": "number",
          "value": 1,
          "description": "1"
        },
        {
          "type": "number",
          "value": 180,
          "description": "180"
        },
        {
          "type": "number",
          "value": 1,
          "description": "1"
        },
        {
          "type": "number",
          "value": 0,
          "description": "0"
        }
      ]
    }

Function

    function f_3_0(x, y) {
        x = x + 1;
        y = y + 1;
        var p = x + y;
        p *= 2;
        if (p == 0) {
            return 0;
        } else {
            return 1;
        }
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "x": 0,
          "y": 0
        },
        {
          "x": -2,
          "y": 0
        }
      ],
      "results": [
        {
          "type": "number",
          "value": 1,
          "description": "1"
        },
        {
          "type": "number",
          "value": 0,
          "description": "0"
        }
      ]
    }

Function

    function f_3_1(x, y) {
        var a = x * y;
        var b = a * 2;
        if (b == 190) {
            return 'b = 190';
        } else {
            return 'b != 190';
        }
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "x": 0,
          "y": 0
        },
        {
          "x": 95,
          "y": 1
        }
      ],
      "results": [
        {
          "type": "string",
          "value": "b != 190"
        },
        {
          "type": "string",
          "value": "b = 190"
        }
      ]
    }

Function

    function f_3_2(x, y) {
        var a = x * y;
        var b = a * 2;
        return b == 800 ? 'b  = 190' : 'b != 190';
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "x": 0,
          "y": 0
        },
        {
          "x": 400,
          "y": 1
        }
      ],
      "results": [
        {
          "type": "string",
          "value": "b != 190"
        },
        {
          "type": "string",
          "value": "b  = 190"
        }
      ]
    }

Function

    function f_3_3(x) {
        var a = x + 10;
        a += 100;
        a *= 2;
        if (a == 500) {
            return 'a = 500';
        } else {
            return 'a != 500';
        }
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "x": 0
        },
        {
          "x": 140
        }
      ],
      "results": [
        {
          "type": "string",
          "value": "a != 500"
        },
        {
          "type": "string",
          "value": "a = 500"
        }
      ]
    }

Function

    function f_3_4(x, y) {
        var p = x + y;
        p *= x + y;
        p += 100;
        if (p == 100) {
            return 'p = 100';
        } else {
            return 'p != 100';
        }
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "x": 0,
          "y": 0
        },
        {
          "x": 4,
          "y": 0
        }
      ],
      "results": [
        {
          "type": "string",
          "value": "p = 100"
        },
        {
          "type": "string",
          "value": "p != 100"
        }
      ]
    }

Function

    function f_4_0(x, y) {
        if (x > 0) {
            return y > 0 ? 1 : 0;
        } else if (x < 0) {
            if (y == 1) {
                return x == -1 ? -1 : 0;
            } else if (y == 2) {
                return x == -2 ? -1 : 0;
            } else {
                return x == -3 ? -1 : 0;
            }
        }
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "x": 0,
          "y": 0
        },
        {
          "x": -1,
          "y": 0
        },
        {
          "x": -3,
          "y": 3
        },
        {
          "x": -1,
          "y": 2
        },
        {
          "x": -2,
          "y": 2
        },
        {
          "x": -1,
          "y": 1
        },
        {
          "x": -2,
          "y": 1
        },
        {
          "x": 1,
          "y": 1
        },
        {
          "x": 1,
          "y": 0
        }
      ],
      "results": [
        {
          "type": "undefined"
        },
        {
          "type": "number",
          "value": 0,
          "description": "0"
        },
        {
          "type": "number",
          "value": -1,
          "description": "-1"
        },
        {
          "type": "number",
          "value": 0,
          "description": "0"
        },
        {
          "type": "number",
          "value": -1,
          "description": "-1"
        },
        {
          "type": "number",
          "value": -1,
          "description": "-1"
        },
        {
          "type": "number",
          "value": 0,
          "description": "0"
        },
        {
          "type": "number",
          "value": 1,
          "description": "1"
        },
        {
          "type": "number",
          "value": 0,
          "description": "0"
        }
      ]
    }

Function

    function f_4_1(a) {
        var b = a + 1;
        b -= 100;
        if (b == 1) {
            return 'b = 1';
        } else {
            return 'b != 1';
        }
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "a": 0
        },
        {
          "a": 100
        }
      ],
      "results": [
        {
          "type": "string",
          "value": "b != 1"
        },
        {
          "type": "string",
          "value": "b = 1"
        }
      ]
    }

Function

    function f_4_2(a, b) {
        var b = a + 1;
        return b == 1 ? 'b = 1' : 'b != 1';
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "a": 10,
          "b": 10
        },
        {
          "a": 0,
          "b": 10
        }
      ],
      "results": [
        {
          "type": "string",
          "value": "b != 1"
        },
        {
          "type": "string",
          "value": "b = 1"
        }
      ]
    }

Function

    function f_4_3(a, b) {
        return a == b * 100 ? 1 : 0;
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "a": 0,
          "b": 0
        },
        {
          "a": 1,
          "b": 0
        }
      ],
      "results": [
        {
          "type": "number",
          "value": 1,
          "description": "1"
        },
        {
          "type": "number",
          "value": 0,
          "description": "0"
        }
      ]
    }

Function

    function f_4_4(a, b) {
        return a == b * 56 - 45 ? 1 : 0;
    }

Leena response object

    {
      "errors": [],
      "testCases": [
        {
          "a": 0,
          "b": 0
        },
        {
          "a": -45,
          "b": 0
        }
      ],
      "results": [
        {
          "type": "number",
          "value": 0,
          "description": "0"
        },
        {
          "type": "number",
          "value": 1,
          "description": "1"
        }
      ]
    }