<commit_before>
import valueTransformer from "../value-transformer";
import { strictEqual } from "assert";

describe("Value Transformer", () => {
    const multiplier = valueTransformer(m => n => n * m);

    it("should work with property initializers in objects", () => {
        const obj = {
            @multiplier(2)
            value: 21,

            @multiplier(3)
            anotherValue: 14
        };

        strictEqual(obj.value, 42);
        strictEqual(obj.anotherValue, 42);
    });

    it("should work with property initializers in classes", () => {
        class Obj {
            @multiplier(2)
            value = 21;

            @multiplier(3)
            anotherValue = 14;

            @multiplier(2)
            computedValue = this.value;
        }

        const obj = new Obj();

        strictEqual(obj.value, 42);
        strictEqual(obj.anotherValue, 42);
        strictEqual(obj.computedValue, 84);
    });

    it("should work with static property initializers in classes", () => {
        class Obj {
            @multiplier(2)
            static value = 21;

            @multiplier(3)
            static anotherValue = 14;

            @multiplier(2)
            static computedValue = this.value;
        }

        strictEqual(Obj.value, 42);
        strictEqual(Obj.anotherValue, 42);
        strictEqual(Obj.computedValue, 84);
    });

    it("should work with property accessors in objects", () => {
        let valueFromSet1;
        let valueFromSet2;

        const obj = {
            @multiplier(2)
            get value() {
                return 21;
            },

            @multiplier(3)
            set anotherValue(n) {
                valueFromSet1 = n;
            },

            @multiplier(4)
            set computedValue(n) {
                valueFromSet2 = n;
            },
            get computedValue() {<commit_msg>Add failing tests for value descriptors<commit_after>
import valueTransformer from "../value-transformer";
import { strictEqual, deepEqual } from "assert";

describe("Value Transformer", () => {
    const multiplier = valueTransformer(m => n => n * m);
    const logger = valueTransformer(log => fn => function (...args) {
        log.push([ 'call', args ]);
        return this::fn(...args);
    });

    it("should work with property initializers in objects", () => {
        const log = [];

        const obj = {
            @multiplier(2)
            value: 21,

            @multiplier(3)
            anotherValue: 14,

            @logger(log)
            method() { return 42; }
        };

        strictEqual(obj.value, 42);
        strictEqual(obj.anotherValue, 42);
        strictEqual(obj.method(), 42);

        deepEqual(log[0], [ 'call', [] ]);
    });

    it("should work with property initializers in classes", () => {
        const log = [];

        class Obj {
            @multiplier(2)
            value = 21;

            @multiplier(3)
            anotherValue = 14;

            @multiplier(2)
            computedValue = this.value;

            @logger(log)
            method() { return 42; }
        }

        const obj = new Obj();

        strictEqual(obj.value, 42);
        strictEqual(obj.anotherValue, 42);
        strictEqual(obj.computedValue, 84);
        strictEqual(obj.method(), 42);

        deepEqual(log[0], [ 'call', [] ]);
    });

    it("should work with static property initializers in classes", () => {
        const log = [];

        class Obj {
            @multiplier(2)
            static value = 21;

            @multiplier(3)
            static anotherValue = 14;

            @multiplier(2)
            static computedValue = this.value;

            @logger(log)
            static method() { return 42; }
        }

        strictEqual(Obj.value, 42);
        strictEqual(Obj.anotherValue, 42);
        strictEqual(Obj.computedValue, 84);
        strictEqual(Obj.method(), 42);

        deepEqual(log[0], [ 'call', [] ]);
    });

    it("should work with property accessors in objects", () => {
        let valueFromSet1;
        let valueFromSet2;

        const obj = {
            @multiplier(2)
            get value() {
                return 21;
            },

            @multiplier(3)
            set anotherValue(n) {
                valueFromSet1 = n;
            },

            @multiplier(4)
            set computedValue(n) {
                valueFromSet2 = n;
            },
            get computedValue() {
{'fraction_non_alphanumeric': 0.12150993969175787, 'fraction_numerical': 0.02345320527138709, 'mean_word_length': 1.5780080598733448, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7627877', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1215, 'n_words': 292}