-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse model values of the form 5e1 (no decimal) (#861)
Previously, models that contained real literals with no decimal point (e.g., 5e1) would lead to an exception in the model parser. This PR adapts Boogie to recognize such values. Ensuring that Z3 will emit one of these values in a model is tricky, and a test for it would be fragile. But I've seen it appear in practice.
- Loading branch information
Showing
2 changed files
with
52 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using Microsoft.Boogie; | ||
using NUnit.Framework; | ||
|
||
namespace ModelTests | ||
{ | ||
[TestFixture()] | ||
public class ModelTests | ||
{ | ||
[Test] | ||
public void ParseRealModelElements() | ||
{ | ||
var m = new Model(); | ||
var e1 = m.ConstructElement("1e2"); | ||
Assert.AreEqual(e1.Kind, Model.ElementKind.Real); | ||
Assert.AreEqual(e1.ToString(), "1e2"); | ||
var e2 = m.ConstructElement("-3e5"); | ||
Assert.AreEqual(e2.Kind, Model.ElementKind.Real); | ||
Assert.AreEqual(e2.ToString(), "-3e5"); | ||
var e3 = m.ConstructElement("1.2e3"); | ||
Assert.AreEqual(e3.Kind, Model.ElementKind.Real); | ||
Assert.AreEqual(e3.ToString(), "1.2e3"); | ||
var e4 = m.ConstructElement("-3.1e6"); | ||
Assert.AreEqual(e4.Kind, Model.ElementKind.Real); | ||
Assert.AreEqual(e4.ToString(), "-3.1e6"); | ||
} | ||
|
||
[Test] | ||
public void ParseBoolModelElements() | ||
{ | ||
var m = new Model(); | ||
var e1 = m.ConstructElement("true"); | ||
Assert.AreEqual(e1, m.True); | ||
var e2 = m.ConstructElement("false"); | ||
Assert.AreEqual(e2, m.False); | ||
} | ||
|
||
[Test] | ||
public void ParseIntModelElements() | ||
{ | ||
var m = new Model(); | ||
var e1 = m.ConstructElement("3289"); | ||
Assert.AreEqual(e1.Kind, Model.ElementKind.Integer); | ||
Assert.AreEqual(e1.ToString(), "3289"); | ||
var e2 = m.ConstructElement("-12389"); | ||
Assert.AreEqual(e2.Kind, Model.ElementKind.Integer); | ||
Assert.AreEqual(e2.ToString(), "-12389"); | ||
} | ||
} | ||
} |