Skip to content

Commit

Permalink
sync with java
Browse files Browse the repository at this point in the history
  • Loading branch information
dhowe committed Oct 22, 2020
1 parent e99f12b commit 85f2ea1
Showing 1 changed file with 77 additions and 79 deletions.
156 changes: 77 additions & 79 deletions issues/known-issues.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,82 @@
const expect = require('chai').expect;
const RiTa = require('../src/rita');
const RiScript = require('../src/riscript');

describe('RiScript.KnownIssues', () => { // TODO:

it('Should resolve transforms on phrases', () => {
let res = RiTa.evaluate("($a dog).pluralize()\n$a=the", null, opts("trace", true));
assertEquals("the dogs", res);
});

it('Should use phones for articlize', () => {
expect(RiTa.articlize("honor")).eq('an honor');
});

it('Should throw on infinite recursions', () => {
console.log(RiTa.evaluate('$s', { s: '$a', a: '$s' }));
expect(() => RiTa.evaluate('$s', { s: '$a', a: '$s' })).to.throw();
});

it('Should throw on bad transforms', () => {
expect(() => RiTa.evaluate('a.toUpperCase()', 0, { silent: 1, trace: 1 })).to.throw();
});

it('Should handle RiTa function transforms with args', () => {
expect(RiTa.evaluate('Is $RiTa.presentParticiple("lie") wrong?',
{}, { trace: 1, singlePass: 1 })).eq("Is lying wrong?");
});

it('1: pluralize or singularize fails', () => {
let testPairs = []; // SS FAILING ITEMS HERE
let res1, res2, res3, i = 0, dbug = true;
if (!testPairs.length) return;
dbug && console.log(testPairs[i] + '/' + testPairs[i + 1]);

res1 = RiTa.singularize(testPairs[i], { dbug: dbug });
res2 = RiTa.pluralize(testPairs[i + 1], { dbug: dbug });
res3 = RiTa.inflector.isPlural(testPairs[i], { dbug: dbug });

eq(res1, testPairs[i + 1], 'FAIL: singularize(' + testPairs[i]
+ ') was ' + res1 + ', but expected ' + testPairs[i + 1] + '\n '
+ 'pluralize(' + testPairs[i + 1] + ') was ' + res2 + '\n\n');

// pluralize
eq(res2, testPairs[i], 'FAIL: pluralize(' + testPairs[i + 1]
+ ') was ' + res2 + ', but expected ' + testPairs[i] + '\n '
+ 'singularize(' + testPairs[i] + ') was ' + res1 + '\n\n');

ok(res3, 'FAIL: isPlural(' + testPairs[i] + ') was false\n\n');
});

0 && it('simple evaluations', function () {
// should this throw? maybe yes: can do foo˙bar - need better error
expect(RiTa.evaluate('foo.bar', {}, 1)).eq('foo.bar');
});

it('Should allow transforms on assignments', () => { // TODO
let ctx = {};
expect(RiTa.evaluate('[$a=a].toUpperCase()', ctx, 0)).eq('');
expect(ctx.a).eq('A')
});

it('Should eval simple expressions', () => {
// NOT SURE WHAT THIS TEST IS ABOUT
expect(RiTa.evaluate('$foo=bar \\nbaz\n$foo', {}, TT)).eq('bar baz'); ``
});

///////////////////////////////////#///////////////////////////////////////////

it('Should pluralize phrases', () => { // failing
expect(RiTa.evaluate('These ($state feeling).pluralize().',
{ state: '(bad | bad)' }, TT)).eq('These bad feelings.');
});

it('Should evaluate inline assigns to vars', () => { // failing
let rs = RiTa.evaluate('[$chosen=$person] talks to $chosen.', { person: '(Dave | Jill | Pete)' });
expect(rs).to.be.oneOf(["Dave talks to Dave.", "Jill talks to Jill.", "Pete talks to Pete."])
});
;
});

describe('RiTa.KnownIssues', () => {

Expand All @@ -11,10 +87,8 @@ describe('RiTa.KnownIssues', () => {
"universes", "universe",
"toothbrushes", "toothbrush",
"clashes", "clash",
"verves", "verve",
"addresses", "address",
"flashes", "flash",
"morasses", "morass",
"conclaves", "conclave",
"promises", "promise",
"spouses", "spouse",
Expand All @@ -31,7 +105,6 @@ describe('RiTa.KnownIssues', () => {
"fetuses", "fetus",
"alumni", "alumnus",
"lighthouses", "lighthouse",
"onyxes", "onyx",
"genuses", "genus",
"zombies", "zombie",
"hearses", "hearse",
Expand All @@ -48,7 +121,6 @@ describe('RiTa.KnownIssues', () => {
"duplexes", "duplex",
"missives", "missive",
"madhouses", "madhouse",
"washes", "wash",
"pauses", "pause",
"heroes", "hero",
"sketches", "sketch",
Expand All @@ -63,13 +135,10 @@ describe('RiTa.KnownIssues', () => {
"abysses", "abyss",
"lighthouses", "lighthouse",
"gashes", "gash",
"dynamoes", "dynamo",
"lurches", "lurch",
"directives", "directive",
"calories", "calorie",
"moves", "move",
"expanses", "expanse",
"chaises", "chaise",
"briefcases", "briefcase",
];

Expand Down Expand Up @@ -98,77 +167,6 @@ describe('RiTa.KnownIssues', () => {
}
});
});
describe('RiScript.KnownIssues', () => {

it('Should use phones for articlize', () => {
expect(RiTa.articlize("honor")).eq('an honor');
});

it('Should throw on infinite recursions', () => {
console.log(RiTa.evaluate('$s', { s: '$a', a: '$s' }));
expect(() => RiTa.evaluate('$s', { s: '$a', a: '$s' })).to.throw();
});

it('Should throw on bad transforms', () => {
expect(() => RiTa.evaluate('a.toUpperCase()', 0, { silent: 1, trace: 1 })).to.throw();
});

it('Should handle RiTa function transforms with args', () => {
expect(RiTa.evaluate('Is $RiTa.presentParticiple("lie") wrong?',
{}, { trace: 1, singlePass: 1 })).eq("Is lying wrong?");
});

it('1: pluralize or singularize fails', () => {
let testPairs = []; // SS FAILING ITEMS HERE
let res1, res2, res3, i = 0, dbug = true;
if (!testPairs.length) return;
dbug && console.log(testPairs[i] + '/' + testPairs[i + 1]);

res1 = RiTa.singularize(testPairs[i], { dbug: dbug });
res2 = RiTa.pluralize(testPairs[i + 1], { dbug: dbug });
res3 = RiTa.inflector.isPlural(testPairs[i], { dbug: dbug });

eq(res1, testPairs[i + 1], 'FAIL: singularize(' + testPairs[i]
+ ') was ' + res1 + ', but expected ' + testPairs[i + 1] + '\n '
+ 'pluralize(' + testPairs[i + 1] + ') was ' + res2 + '\n\n');

// pluralize
eq(res2, testPairs[i], 'FAIL: pluralize(' + testPairs[i + 1]
+ ') was ' + res2 + ', but expected ' + testPairs[i] + '\n '
+ 'singularize(' + testPairs[i] + ') was ' + res1 + '\n\n');

ok(res3, 'FAIL: isPlural(' + testPairs[i] + ') was false\n\n');
});

0 && it('simple evaluations', function () {
// should this throw? maybe yes: can do foo˙bar - need better error
expect(RiTa.evaluate('foo.bar', {}, 1)).eq('foo.bar');
});

it('Should allow transforms on assignments', () => { // TODO
let ctx = {};
expect(RiTa.evaluate('[$a=a].toUpperCase()', ctx, 0)).eq('');
expect(ctx.a).eq('A')
});

it('Should eval simple expressions', () => {
// NOT SURE WHAT THIS TEST IS ABOUT
expect(RiTa.evaluate('$foo=bar \\nbaz\n$foo', {}, TT)).eq('bar baz'); ``
});

///////////////////////////////////#///////////////////////////////////////////

it('Should pluralize phrases', () => { // failing
expect(RiTa.evaluate('These ($state feeling).pluralize().',
{ state: '(bad | bad)' }, TT)).eq('These bad feelings.');
});

it('Should evaluate inline assigns to vars', () => { // failing
let rs = RiTa.evaluate('[$chosen=$person] talks to $chosen.', { person: '(Dave | Jill | Pete)' });
expect(rs).to.be.oneOf(["Dave talks to Dave.", "Jill talks to Jill.", "Pete talks to Pete."])
});
;
});

function eql(output, expected, msg) { expect(output).eql(expected, msg); }
function ok(res, msg) { expect(res).eq(true, msg); }
Expand Down

0 comments on commit 85f2ea1

Please sign in to comment.