{"size": 2502, "ext": "js", "max_stars_repo_path": "test/expressions/arithmeticSpec.js", "max_stars_repo_name": "ilinsky/xpath.js", "max_stars_repo_stars_event_min_datetime": "2015-01-13T08:22:08.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-24T04:30:13.000Z", "max_issues_repo_path": "test/expressions/arithmeticSpec.js", "max_issues_repo_name": "ilinsky/xpath2.js", "max_issues_repo_issues_event_min_datetime": "2015-10-26T11:41:33.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-01T14:54:51.000Z", "max_forks_repo_path": "test/expressions/arithmeticSpec.js", "max_forks_repo_name": "ilinsky/xpath.js", "max_forks_repo_forks_event_min_datetime": "2015-03-03T00:00:12.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-19T08:24:16.000Z"}
{"max_stars_count": 60, "max_issues_count": 7, "max_forks_count": 10, "avg_line_length": 25.5306122449, "max_line_length": 55, "alphanum_fraction": 0.3725019984}
var xpath = require('./../../lib');
var expect = require('chai').expect;

describe("arithmetics", function() {
    describe("+", function() {
        it('', function() {
            expect(xpath.evaluate("3 + 2")[0])
                .to.equal(5);
        });
    });

    describe("-", function() {
        it('', function() {
            expect(xpath.evaluate("2 - 3")[0])
                .to.equal(-1);
        });
    });

    describe("unary", function() {
        it('', function() {
            expect(xpath.evaluate("-2")[0])
                .to.equal(-2);
        });
        it('', function() {
            expect(xpath.evaluate("+2")[0])
                .to.equal(2);
        });
    });

    describe("*", function() {
        it('', function() {
            expect(xpath.evaluate("2 * 3")[0])
                .to.equal(6);
        });
        it('', function() {
            expect(xpath.evaluate("2 * 3 * 4")[0])
                .to.equal(24);
        });
        it('', function() {
            expect(xpath.evaluate("2 *-3")[0])
                .to.equal(-6);
        });
    });

    describe("div", function() {
        it('', function() {
            expect(xpath.evaluate("6 div 3")[0])
                .to.equal(2);
        });
        it('', function() {
            expect(xpath.evaluate("6 div 3 div 2")[0])
                .to.equal(1);
        });
        it('', function() {
            expect(xpath.evaluate("1 div 2")[0])
                .to.equal(0.5);
        });
    });

    describe("idiv", function() {
        it('', function() {
            expect(xpath.evaluate("5 idiv 3")[0])
                .to.equal(1);
        });
    });

    describe("mod", function() {
        it('', function() {
            expect(xpath.evaluate("5 mod 3")[0])
                .to.equal(2);
        });
    });

    // Test evaluation order
    it('', function() {
        expect(xpath.evaluate("3 + 2 - 4")[0])
            .to.equal(1);
    });

    it('', function() {
        expect(xpath.evaluate("3 * 4 + 2")[0])
            .to.equal(14);
    });
    it('', function() {
        expect(xpath.evaluate("3 * (4 + 2)")[0])
            .to.equal(18);
    });
    it('', function() {
        expect(xpath.evaluate("3 + 2 * 4")[0])
            .to.equal(11);
    });
    // Misc
    it('', function() {
        expect(xpath.evaluate("0.1 + 0.2")[0])
            .to.equal(0.3);
    });
});
