aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/getter-setter.js
blob: fe0481b36c797c6f30717ddd81daa55855b75b9e (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
var UglifyJS = require("../node");
var assert = require("assert");

describe("Getters and setters", function() {
    it("Should not accept operator symbols as getter/setter name", function() {
        var illegalOperators = [
            "++",
            "--",
            "+",
            "-",
            "!",
            "~",
            "&",
            "|",
            "^",
            "*",
            "/",
            "%",
            ">>",
            "<<",
            ">>>",
            "<",
            ">",
            "<=",
            ">=",
            "==",
            "===",
            "!=",
            "!==",
            "?",
            "=",
            "+=",
            "-=",
            "/=",
            "*=",
            "%=",
            ">>=",
            "<<=",
            ">>>=",
            "|=",
            "^=",
            "&=",
            "&&",
            "||"
        ];
        var generator = function() {
            var results = [];

            for (var i in illegalOperators) {
                results.push({
                    code: "var obj = { get " + illegalOperators[i] + "() { return test; }};",
                    operator: illegalOperators[i],
                    method: "get"
                });
                results.push({
                    code: "var obj = { set " + illegalOperators[i] + "(value) { test = value}};",
                    operator: illegalOperators[i],
                    method: "set"
                });
            }

            return results;
        };

        var testCase = function(data) {
            return function() {
                UglifyJS.parse(data.code);
            };
        };

        var fail = function(data) {
            return function (e) {
                return e instanceof UglifyJS.JS_Parse_Error &&
                    e.message === "Unexpected token: operator (" + data.operator + ")";
            };
        };

        var errorMessage = function(data) {
            return "Expected but didn't get a syntax error while parsing following line:\n" + data.code;
        };

        var tests = generator();
        for (var i = 0; i < tests.length; i++) {
            var test = tests[i];
            assert.throws(testCase(test), fail(test), errorMessage(test));
        }
    });

});
ebook-bootloader): New exported variable. * gnu/system/install.scm (pinebook-installation-os): New exported variable. Vagrant Cascadian 2018-11-18bootloader: De-monadify configuration file generators....* gnu/bootloader/extlinux.scm: Remove unneeded imports. (extlinux-configuration-file): Use 'computed-file' instead of 'gexp->derivation'. * gnu/bootloader/grub.scm (svg->png): Likewise. (grub-background-image, eye-candy): Adjust accordingly, return non-monadically. (grub-configuration-file): Likewise, and use 'computed-file' instead of 'gexp->derivation'. * gnu/bootloader/u-boot.scm: Remove unneeded imports. * gnu/system.scm: Add 'lower-object' call. Ludovic Courtès 2018-09-14gnu: Rename "banana-pi" to "bananapi"....* gnu/bootloader/u-boot.scm (u-boot-banana-pi-m2-ultra-bootloader): Rename to... (u-boot-bananapi-m2-ultra-bootloader): ...this. * gnu/packages/bootloaders.scm (u-boot-banana-pi-m2-ultra): Rename to... (u-boot-bananapi-m2-ultra): ...this. * gnu/system/install.scm (banana-pi-m2-ultra-installation-os): Rename to... (bananapi-m2-ultra-installation-os): ...this. Danny Milosavljevic 2018-06-26bootloader: grub-efi: Identify as "GuixSD" instead of "grub"....* gnu/bootloader/grub.scm (install-grub-efi): Pass "--bootloader-id" to grub-install. Marius Bakke 2018-06-26bootloader: grub-efi: Support EFI directories relative to MOUNT-POINT....* gnu/bootloader/grub.scm (install-grub-efi): When MOUNT-POINT/EFI-DIR exists, install there rather than EFI-DIR directly. Marius Bakke