Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 840243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:35:33+00:00 2026-05-15T05:35:33+00:00

I have been working on an ECMAScript implementation and I am currently working on

  • 0

I have been working on an ECMAScript implementation and I am currently working on polishing up the project. As a part of this, I have been writing tests like the following:

[TestMethod]
public void ArrayReduceTest()
{
    var engine = new Engine();
    var request = new ExecScriptRequest(@"
        var a = [1, 2, 3, 4, 5];
        a.reduce(function(p, c, i, o) {
            return p + c;
        });
    ");
    var response = (ExecScriptResponse)engine.PostWithReply(request);
    Assert.AreEqual((double)response.Data, 15D);
} 

The problem is that there are so many points of failure in this test and similar tests that it almost doesn’t seem worth it. It almost seems like my effort would be better spent reducing coupling between modules. To write a true unit test I would have to assume something like this:

[TestMethod]
public void CommentTest()
{
    const string toParse = "/*First Line\r\nSecond Line*/";
    var analyzer = new LexicalAnalyzer(toParse);
    {
        Assert.IsInstanceOfType(analyzer.Next(), typeof(MultiLineComment));
        Assert.AreEqual(analyzer.Current.Value, "First Line\r\nSecond Line");
    }
}

Doing this would require me to write thousands of tests which once again does not seem worth it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T05:35:34+00:00Added an answer on May 15, 2026 at 5:35 am

    Just spitballing here, but what if you stored your tests in a file/database/etc… (as Doug points out – the ability to store in version control makes files the best choice!) Each entry could have a Name, a Script, and the Expected Output.

    Then you could just write a small app that executes each script using your engine and compares the output to the expected output, and notifies you of success/failure based on the result.

    This wouldn’t save you from needing to test the pain points in the script engine itself, but it might be easier to maintain something like this than to write a unit test for each way that you can envision using the scripting runtime.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.