madlib icon indicating copy to clipboard operation
madlib copied to clipboard

Mutating list values in Node mode

Open brekk opened this issue 1 year ago • 0 comments

Given a file like this:

import List from "List"



export type Metal = Gold | Silver | Bronze | Tin
export type Mixed = Numeric(Metal, Short) | Word(Metal, String)

nums :: Metal -> List Mixed
export nums = (m) => pipe(
  List.range(0),
  map(Numeric(m)),
)(3)

words :: Metal -> List Mixed
export words = (m) => map(Word(m), ["hey", "there", "spreadable", "butter"])

NUMBERS_AND_WORDS :: List Mixed
export NUMBERS_AND_WORDS = [
  ...nums(Gold),
  ...nums(Silver),
  ...nums(Bronze),
  ...words(Gold),
  ...words(Silver),
  ...words(Bronze),
]

FAILURE_CASE :: List Mixed
export FAILURE_CASE = [...NUMBERS_AND_WORDS, Word(Tin, "shit"), Word(Tin, "storm")]

The NUMBERS_AND_WORDS value is mutating in a test case downstream, but only in target: node mode.

Example repo here:

https://github.com/brekk/mad-abend/blob/main/src/ButterLists.spec.mad#L16-L44

brekk avatar May 14 '24 01:05 brekk