Skip to content

Commit

Permalink
Check for nulls.
Browse files Browse the repository at this point in the history
  • Loading branch information
izrik committed Nov 12, 2021
1 parent e0b1357 commit cc56d6b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public void ResultIsScalar()
Assert.IsFalse(result.IsMatrix(env));
Assert.AreEqual(0, result.GetTensorRank(env));
Assert.IsFalse(result.IsString(env));
Assert.IsNull(result.GetDimension(env, 0));
Assert.IsNull(result.GetDimensions(env));
Assert.IsNull(result.GetVectorLength(env));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,24 @@ public void ResultMatchesExpr3()
Assert.AreEqual(0, result.GetTensorRank(env));
Assert.IsTrue(result.IsString(env));
}

[Test]
public void MissingVariableYieldsNull()
{
// given
var expr = new VariableAccess("a");
var env = new SolusEnvironment(); // no "a"
// when
var result = expr.Result;
// then
Assert.IsNull(result.IsScalar(env));
Assert.IsNull(result.IsVector(env));
Assert.IsNull(result.IsMatrix(env));
Assert.IsNull(result.GetTensorRank(env));
Assert.IsNull(result.IsString(env));
Assert.IsNull(result.GetDimension(env, 0));
Assert.IsNull(result.GetDimensions(env));
Assert.IsNull(result.GetVectorLength(env));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public void ResultIsVector()
Assert.IsFalse(result.IsMatrix(env));
Assert.AreEqual(1, result.GetTensorRank(env));
Assert.IsFalse(result.IsString(env));
Assert.IsNull(result.GetDimension(env, -1));
Assert.AreEqual(4, result.GetDimension(env, 0));
Assert.IsNull(result.GetDimension(env, 1));
Assert.AreEqual(new int[] { 4 },
result.GetDimensions(env));
Assert.AreEqual(4, result.GetVectorLength(env));
Expand Down

0 comments on commit cc56d6b

Please sign in to comment.