Skip to content

not(true) seems not to work #33

@thorek

Description

@thorek

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
  });

});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions