Documentation

FT117 (micro failure)

Back to documentation index
{
  "@context": "https://nxdlang.org/schema",
  "doc_id": "PT117",
  "title": "PT117 - Intentional Failures",
  "description": "Intentional Test Failures",
  "layer": "Passed Tests",
  "category": "Passed Tests - Nim",
  "keywords": [Nim, Pass, Test],
  "doc_version": "1.0",
  "status": "active"
}

# FT117 (micro failure)

### NXD Sample:

```nxd
MODULE TEST

FUNC MAIN()
    LET X SET 2

    MATCH X:
        CASE 1:
            PRINTLN(ONE)

        CASE 2:
            PRINTLN("TWO")

        OTHERWISE:
            PRINTLN("OTHER")
```

### Result:

PASS

### Expected Output:

FAIL -

### Expected Rejection Stage:

[ ] Lexer
[ ] Parser
[ ] AST
[ ] IR
[ ] Semantics
[ ] Backend

### Actual Output:

```json
{
  "module": {
    "name": "TEST",
    "imports": []
  },
  "types": [],
  "traits": [],
  "impls": [],
  "functions": [
    {
      "name": "MAIN",
      "params": [],
      "return_type": null,
      "body": [
        {
          "Let": {
            "name": "X",
            "value": {
              "Literal": {
                "Int": 2
              }
            }
          }
        },
        {
          "Match": {
            "scrutinee": {
              "Var": "X"
            },
            "arms": [
              {
                "pattern": 1,
                "body": [
                  {
                    "Expr": {
                      "Call": {
                        "func": "PRINTLN",
                        "args": [
                          {
                            "Var": "ONE"
                          }
                        ]
                      }
                    }
                  }
                ]
              },
              {
                "pattern": 2,
                "body": [
                  {
                    "Expr": {
                      "Call": {
                        "func": "PRINTLN",
                        "args": [
                          {
                            "Literal": {
                              "String": "TWO"
                            }
                          }
                        ]
                      }
                    }
                  }
                ]
              }
            ],
            "otherwise": [
              {
                "Expr": {
                  "Call": {
                    "func": "PRINTLN",
                    "args": [
                      {
                        "Literal": {
                          "String": "OTHER"
                        }
                      }
                    ]
                  }
                }
              }
            ]
          }
        }
      ]
    }
  ],
  "statements": []
}
```

```nim
# test


proc main() =
  var x = 2
case x:
  of 1:
    println("ONE")
  of 2:
    println("TWO")
  else:
    println("OTHER")

```

### Notes: