Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not(true) seems not to work #33

Open
thorek opened this issue Jan 3, 2023 · 1 comment
Open

not(true) seems not to work #33

thorek opened this issue Jan 3, 2023 · 1 comment

Comments

@thorek
Copy link

thorek commented Jan 3, 2023

In the following test suite, the tests 'evaluates true = true' and 'evaluates true = false' are evaluated correctly, showing the js-feel implementation seems to work properly, however the tests 'not(true)' and 'not(false)' evaluate to a Function (not to a boolean). If I try to call the function it throws an error "TypeError: Cannot read properties of undefined (reading 'isDate')".

Any help is appreciated.

const feel = require('js-feel/dist/feel');

describe( 'inbuild "not" function', () => {

  it( 'evaluates not(true)', async () => {
    const notTrue = 'not(true)'    
    const ast = await feel.parse( notTrue );
    const result = await ast.build({});
    expect( result ).toBe( false );   // -> Function
  });

  it( 'evaluates not(false)', async () => {
    const notFalse = 'not(false)'    
    const ast = await feel.parse( notFalse );
    const result = await ast.build({});
    expect( result ).toBe( true );   // -> Function
  });

  it( 'evaluates not(true) - with function', async () => {
    const notTrue = 'not(true)'    
    const ast = await feel.parse( notTrue);
    let result = await ast.build({});
    if( typeof result === 'function' ) result = result();
    expect( result ).toBe( false );   // -> "TypeError: Cannot read properties of undefined (reading 'isDate')"
  });

  it( 'evaluates true = true', async () => {
    const notTrue = 'true = true'    
    const ast = await feel.parse( notTrue);
    const result = await ast.build({});
    expect( result ).toBe( true );   // -> ok
  });

  it( 'evaluates true = false', async () => {
    const notTrue = 'true = false'    
    const ast = await feel.parse( notTrue);
    const result = await ast.build({});
    expect( result ).toBe( false );   // -> ok
  });

});
@thorek
Copy link
Author

thorek commented Jan 4, 2024

Anyone? I can't believe I'm the only one having an issue with such a basic feature. Am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant