diff --git a/index.html b/index.html
index 1321942..92e36f4 100644
--- a/index.html
+++ b/index.html
@@ -107,7 +107,7 @@
C Declarations & printf/scanf ➔ Prose
Function with empty parameter list takes unspecified number of parameters
- Constexpr adds an implicit const in this case
+ constexpr adds an implicit const in this case
diff --git a/js/prose-decl.js b/js/prose-decl.js
index 78cddcf..074a6fa 100644
--- a/js/prose-decl.js
+++ b/js/prose-decl.js
@@ -182,7 +182,6 @@ export class Explainer {
}
}
- // TODO: add regression testing
if (histo.has('constexpr')
&& !Explainer.isExplicitlyConst(declarator, histo.has('const'))) {
this.showDiagnostic('constexpr-implicit-const');
@@ -223,8 +222,8 @@ export class Explainer {
/**
* Returns copy with all consecutive trailing elements that satisfy
* a given predicate removed.
- * @param {Array} arr
- * @param {any} predicate
+ * @param {Array} arr the array
+ * @param {any} predicate the predicate
* @returns {Array}
*/
static withoutTrailing(arr, predicate) {
diff --git a/test/test.js b/test/test.js
index dbeebf0..b05f7f9 100644
--- a/test/test.js
+++ b/test/test.js
@@ -181,18 +181,69 @@ describe('Examples', function () {
code = 'signed bool';
describe(code, function () {
+ const codeCopy = code;
it('throws because "signed" and "bool" conflict', function () {
- assert.throws(() => codeToProse(code),
+ assert.throws(() => codeToProse(codeCopy),
{message: 'Conflicting specifiers signed and bool'});
});
});
code = 'constexpr const int *x';
describe(code, function () {
- const {paragraphs, _} = codeToProse(code);
+ const {paragraphs} = codeToProse(code);
it('has correct prose', function () {
const expected = ['Declare x as constexpr pointer to const int'];
assert.deepEqual(paragraphs, expected);
});
});
+
+ code = 'constexpr int x';
+ describe(code, function () {
+ const {paragraphs, diagnostics} = codeToProse(code);
+ it('has correct prose', function () {
+ const expected = ['Declare x as constexpr int'];
+ assert.deepEqual(paragraphs, expected);
+ });
+ it('has constexpr-implicit-const diagnostic', function() {
+ assert.deepEqual(diagnostics, ['constexpr-implicit-const']);
+ });
+ });
+
+ code = 'constexpr const int x';
+ describe(code, function () {
+ const {paragraphs, diagnostics} = codeToProse(code);
+ it('has correct prose', function () {
+ const expected = ['Declare x as constexpr const int'];
+ assert.deepEqual(paragraphs, expected);
+ });
+ it('has no diagnostics', function() {
+ assert.equal(diagnostics.length, 0);
+ });
+ });
+
+ code = 'constexpr const int * const x';
+ describe(code, function () {
+ const {paragraphs, diagnostics} = codeToProse(code);
+ it('has correct prose', function () {
+ const expected = ['Declare x as constexpr const ' +
+ 'pointer to const int'];
+ assert.deepEqual(paragraphs, expected);
+ });
+ it('has no diagnostics', function() {
+ assert.equal(diagnostics.length, 0);
+ });
+ });
+
+ code = 'constexpr const int * x[][]';
+ describe(code, function () {
+ const {paragraphs, diagnostics} = codeToProse(code);
+ it('has correct prose', function () {
+ const expected = ['Declare x as constexpr array of arrays ' +
+ 'of pointers to const int'];
+ assert.deepEqual(paragraphs, expected);
+ });
+ it('has constexpr-implicit-const diagnostic', function() {
+ assert.deepEqual(diagnostics, ['constexpr-implicit-const']);
+ });
+ });
});