Code Monkey home page Code Monkey logo

Comments (4)

fatalerrorx avatar fatalerrorx commented on August 15, 2024

How did you test in Chrome?

JavaScript replace differs from .net replace in that it only replaces the first match. So above test is not valid.

from jint.

sebastienros avatar sebastienros commented on August 15, 2024

Could you instead just write a unit test checking the javascript for replace and the intended value?

Something like:

'ab'.replace('a', 'b') === 'bb'

Which actually works right now.

from jint.

fatalerrorx avatar fatalerrorx commented on August 15, 2024
    [Theory]
    [InlineData("3-456", "'3-45a'.replace('a', '6')")]
    [InlineData("3456", "'345A'.replace('A', '6')")]
    [InlineData("34561", "'345a1'.replace('a', '6')")]
    [InlineData("34561", "'345a1'.replace('a', '6')")]
    [InlineData("34561345a1", "'345a1345a1'.replace('a', '6')")]
    public void ShouldReplaceInString(object expected, string source)
    {
        var engine = new Engine();
        var result = engine.Execute(source).GetCompletionValue().ToObject();

        Assert.Equal(expected, result);
    }

from jint.

sebastienros avatar sebastienros commented on August 15, 2024

@fatalerrorx I was not asking you to create a unit test, but @NightOwl888 to show what the issue is. I think replace works fine in this case.

from jint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.