liveBook · Manning

Edge case

As explained in Functional Programming in JavaScript

An edge case is an unusual or boundary input or condition that may produce behavior unlike typical cases or expose a system’s limitations.

An edge case is an unusual, extreme, or boundary input or condition that may expose unexpected behavior or failure. Unit tests use these cases to check whether code meets its specification. section 6.0

Use edge cases to:

  • Test invalid or unusual inputs, such as passing null to a function. section 6.5
  • Find error-handling paths and other code that ordinary tests never execute. section 6.5
  • Measure whether imperative and functional implementations handle boundary conditions consistently. section 6.5

Testing a null input

A QUnit test calls showStudent(null). The imperative version skips much of its execution path and reaches only 40% coverage, while the functional version returns a Nothing-like result and continues to produce strong coverage for invalid input. section 6.5

QUnit.test('Imperative Show Student with null', function (assert) {
    const result = showStudent(null);
    assert.equal(result, null);
});

View the compact QUnit test that exercises the null-input edge case. section 6.5

How Functional Programming in JavaScript covers it

How deep it goes
Explains boundary conditions through unit tests, control-flow paths, coverage, and invalid-input behavior.
Examples
Uses null input with showStudent and compares imperative and functional coverage results.
What it assumes
Assumes familiarity with unit tests and JavaScript test runners rather than teaching testing from zero.
What you can do after
Diagnose/debug with unit tests and coverage analysis to find untested boundary conditions and add tests.
How it connects
Connects edge cases to unit testing, code coverage, error handling, and functional programming.

Also explained in

Compare how 7 books explain edge case →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Programming in JavaScript. The section links point to the parts of the book it draws on.