Skip to content

Commit

Permalink
language/vimscript: add new function primula
Browse files Browse the repository at this point in the history
  • Loading branch information
hattya committed Apr 1, 2024
1 parent fbe51fc commit 8820f3b
Show file tree
Hide file tree
Showing 5 changed files with 248 additions and 3 deletions.
12 changes: 12 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ Version 0.5
* Add ``coverage.json`` function.
* Add ``coverage.lcov`` function.

* Improve ``language/vimscript`` module.

* Add ``primula.annotate`` function.
* Add ``primula.combine`` function.
* Add ``primula.erase`` function.
* Add ``primula.html`` function.
* Add ``primula.json`` function.
* Add ``primula.lcov`` function.
* Add ``primula.report`` function.
* Add ``primula.run`` function.
* Add ``primula.xml`` function.


Version 0.4
-----------
Expand Down
64 changes: 64 additions & 0 deletions doc/language/vimscript.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,70 @@ covimerage.xml(...args)
``covimerage.xml`` represents ``covimerage xml``.


vimscript.primula(...args)
--------------------------

``vimscript.primula`` represents ``primula``, and its commands are defined as
properties of this function.

Requirements
- `Primula <https://github.com/hattya/primula>`_


primula.annotate(...args)
~~~~~~~~~~~~~~~~~~~~~~~~~

``primula.annotate`` represents ``primula annotate``.


primula.combine(...args)
~~~~~~~~~~~~~~~~~~~~~~~~

``primula.combine`` represents ``primula combine``.


primula.erase(...args)
~~~~~~~~~~~~~~~~~~~~~~

``primula.erase`` represents ``primula erase``.


primula.html(...args)
~~~~~~~~~~~~~~~~~~~~~

``primula.html`` represents ``primula html``.


primula.json(...args)
~~~~~~~~~~~~~~~~~~~~~

``primula.json`` represents ``primula json``.


primula.lcov(...args)
~~~~~~~~~~~~~~~~~~~~~

``primula.lcov`` represents ``primula lcov``.


primula.report(...args)
~~~~~~~~~~~~~~~~~~~~~~~

``primula.report`` represents ``primula report``.


primula.run(...args)
~~~~~~~~~~~~~~~~~~~~

``primula.run`` represents ``primula run``.


primula.xml(...args)
~~~~~~~~~~~~~~~~~~~~

``primula.xml`` represents ``primula xml``.


vimscript.themis(...args)
-------------------------

Expand Down
52 changes: 51 additions & 1 deletion lib/language/vimscript.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// aster :: language/vimscript.js
//
// Copyright (c) 2017-2020 Akinori Hattori <hattya@gmail.com>
// Copyright (c) 2017-2024 Akinori Hattori <hattya@gmail.com>
//
// SPDX-License-Identifier: MIT
//
Expand Down Expand Up @@ -42,6 +42,56 @@ covimerage.xml = function() {
return covimerage.apply(null, ['xml'].concat(Array.prototype.slice.call(arguments)));
};

var primula = exports.primula = function primula() {
if (!os.whence('primula')) {
aster.notify('failure', language.prefix + 'primula', 'primula not found!');
return true;
}

return language.system({
args: ['primula'].concat(Array.prototype.slice.call(arguments)),
title: 'primula',
success: arguments[0] + ' passed',
failure: arguments[0] + ' failed',
});
};

primula.annotate = function annotate() {
return primula.apply(null, ['annotate'].concat(Array.prototype.slice.call(arguments)));
};

primula.combine = function combine() {
return primula.apply(null, ['combine'].concat(Array.prototype.slice.call(arguments)));
};

primula.erase = function erase() {
return primula.apply(null, ['erase'].concat(Array.prototype.slice.call(arguments)));
};

primula.html = function html() {
return primula.apply(null, ['html'].concat(Array.prototype.slice.call(arguments)));
};

primula.json = function json() {
return primula.apply(null, ['json'].concat(Array.prototype.slice.call(arguments)));
};

primula.lcov = function lcov() {
return primula.apply(null, ['lcov'].concat(Array.prototype.slice.call(arguments)));
};

primula.report = function report() {
return primula.apply(null, ['report'].concat(Array.prototype.slice.call(arguments)));
};

primula.run = function run() {
return primula.apply(null, ['run'].concat(Array.prototype.slice.call(arguments)));
};

primula.xml = function xml() {
return primula.apply(null, ['xml'].concat(Array.prototype.slice.call(arguments)));
};

exports.themis = function themis() {
var script = 'themis';
if (!os.whence(script)) {
Expand Down
52 changes: 51 additions & 1 deletion std.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 70 additions & 1 deletion test/language/vimscript.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// aster :: language/vimscript.spec.js
//
// Copyright (c) 2020-2021 Akinori Hattori <hattya@gmail.com>
// Copyright (c) 2020-2024 Akinori Hattori <hattya@gmail.com>
//
// SPDX-License-Identifier: MIT
//
Expand Down Expand Up @@ -100,6 +100,75 @@ describe('language', () => {
});
});

describe('.primula()', () => {
it('should notify "primula not found"', () => {
os.whence.mockReturnValueOnce(false);

expect(vimscript.primula('--version')).toBe(true);
expect(os.whence).lastCalledWith('primula');
expect(aster.notify).lastCalledWith('failure', 'aster: primula', 'primula not found!');
});

it('should execute `primula --version`', () => {
os.whence.mockReturnValueOnce(true);
language.system.mockReturnValueOnce(false);

expect(vimscript.primula('--version')).toBe(false);
expect(language.system).lastCalledWith({
args: ['primula', '--version'],
options: undefined,
title: 'primula',
success: '--version passed',
failure: '--version failed',
});
});
});

describe('.primula', () => {
describe.each([
['annotate'],
['combine'],
['erase'],
['html'],
['json'],
['lcov'],
['report'],
['xml'],
])('.%s()', (cmd) => {
it(`should execute \`primula ${cmd}\``, () => {
os.whence.mockReturnValueOnce(true);
language.system.mockReturnValueOnce(false);

expect(vimscript.primula[cmd]()).toBe(false);
expect(os.whence).lastCalledWith('primula');
expect(language.system).lastCalledWith({
args: ['primula', cmd],
options: undefined,
title: 'primula',
success: `${cmd} passed`,
failure: `${cmd} failed`,
});
});
});

describe('.run()', () => {
it('should execute `primula run themis --reporter dot`', () => {
os.whence.mockReturnValueOnce(true);
language.system.mockReturnValueOnce(false);

expect(vimscript.primula.run('themis', '--reporter', 'dot')).toBe(false);
expect(os.whence).lastCalledWith('primula');
expect(language.system).lastCalledWith({
args: ['primula', 'run', 'themis', '--reporter', 'dot'],
options: undefined,
title: 'primula',
success: 'run passed',
failure: 'run failed',
});
});
});
});

describe('.themis()', () => {
it('should notify "themis not found"', () => {
os.whence.mockClear().mockReturnValue(false);
Expand Down

0 comments on commit 8820f3b

Please sign in to comment.