tests: update tests
This commit is contained in:
@@ -13,6 +13,20 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"message": "Cannot assign str to variable 'c' of type int"
|
"message": "Cannot assign str to variable 'c' of type int"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Error",
|
||||||
|
"location": {
|
||||||
|
"start": [
|
||||||
|
9,
|
||||||
|
4
|
||||||
|
],
|
||||||
|
"end": [
|
||||||
|
9,
|
||||||
|
9
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"message": "Undefined operation __add__ between bool and bool"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"judgments": [
|
"judgments": [
|
||||||
@@ -158,9 +172,7 @@
|
|||||||
"name": "d"
|
"name": "d"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {}
|
||||||
"name": "int"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"location": {
|
"location": {
|
||||||
|
|||||||
@@ -264,7 +264,6 @@
|
|||||||
"name": "foo"
|
"name": "foo"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"name": "foo",
|
|
||||||
"pos_args": [
|
"pos_args": [
|
||||||
{
|
{
|
||||||
"pos": 0,
|
"pos": 0,
|
||||||
@@ -328,7 +327,6 @@
|
|||||||
"name": "foo"
|
"name": "foo"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"name": "foo",
|
|
||||||
"pos_args": [
|
"pos_args": [
|
||||||
{
|
{
|
||||||
"pos": 0,
|
"pos": 0,
|
||||||
@@ -410,7 +408,6 @@
|
|||||||
"name": "foo"
|
"name": "foo"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"name": "foo",
|
|
||||||
"pos_args": [
|
"pos_args": [
|
||||||
{
|
{
|
||||||
"pos": 0,
|
"pos": 0,
|
||||||
@@ -509,7 +506,6 @@
|
|||||||
"name": "foo"
|
"name": "foo"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"name": "foo",
|
|
||||||
"pos_args": [
|
"pos_args": [
|
||||||
{
|
{
|
||||||
"pos": 0,
|
"pos": 0,
|
||||||
@@ -609,7 +605,6 @@
|
|||||||
"name": "foo"
|
"name": "foo"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"name": "foo",
|
|
||||||
"pos_args": [
|
"pos_args": [
|
||||||
{
|
{
|
||||||
"pos": 0,
|
"pos": 0,
|
||||||
@@ -725,7 +720,6 @@
|
|||||||
"name": "foo"
|
"name": "foo"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"name": "foo",
|
|
||||||
"pos_args": [
|
"pos_args": [
|
||||||
{
|
{
|
||||||
"pos": 0,
|
"pos": 0,
|
||||||
@@ -842,7 +836,6 @@
|
|||||||
"name": "foo"
|
"name": "foo"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"name": "foo",
|
|
||||||
"pos_args": [
|
"pos_args": [
|
||||||
{
|
{
|
||||||
"pos": 0,
|
"pos": 0,
|
||||||
@@ -924,7 +917,6 @@
|
|||||||
"name": "foo"
|
"name": "foo"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"name": "foo",
|
|
||||||
"pos_args": [
|
"pos_args": [
|
||||||
{
|
{
|
||||||
"pos": 0,
|
"pos": 0,
|
||||||
@@ -1006,7 +998,6 @@
|
|||||||
"name": "foo"
|
"name": "foo"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"name": "foo",
|
|
||||||
"pos_args": [
|
"pos_args": [
|
||||||
{
|
{
|
||||||
"pos": 0,
|
"pos": 0,
|
||||||
@@ -1123,7 +1114,6 @@
|
|||||||
"name": "foo"
|
"name": "foo"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"name": "foo",
|
|
||||||
"pos_args": [
|
"pos_args": [
|
||||||
{
|
{
|
||||||
"pos": 0,
|
"pos": 0,
|
||||||
@@ -1240,7 +1230,6 @@
|
|||||||
"name": "foo"
|
"name": "foo"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"name": "foo",
|
|
||||||
"pos_args": [
|
"pos_args": [
|
||||||
{
|
{
|
||||||
"pos": 0,
|
"pos": 0,
|
||||||
@@ -1357,7 +1346,6 @@
|
|||||||
"name": "foo"
|
"name": "foo"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"name": "foo",
|
|
||||||
"pos_args": [
|
"pos_args": [
|
||||||
{
|
{
|
||||||
"pos": 0,
|
"pos": 0,
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ type Second = float
|
|||||||
type MeterPerSecond = float
|
type MeterPerSecond = float
|
||||||
|
|
||||||
extend Meter {
|
extend Meter {
|
||||||
op __add__(Meter) -> Meter
|
def __add__: fn(Meter, /) -> Meter
|
||||||
op __sub__(Meter) -> Meter
|
def __sub__: fn(Meter, /) -> Meter
|
||||||
op __truediv__(Second) -> MeterPerSecond
|
def __truediv__: fn(Second, /) -> MeterPerSecond
|
||||||
}
|
}
|
||||||
|
|
||||||
extend Second {
|
extend Second {
|
||||||
op __add__(Second) -> Second
|
def __add__: fn(Second, /) -> Second
|
||||||
op __sub__(Second) -> Second
|
def __sub__: fn(Second, /) -> Second
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ def maximum(a: float, b: float):
|
|||||||
|
|
||||||
|
|
||||||
v3 = maximum(v1, v2)
|
v3 = maximum(v1, v2)
|
||||||
v3 = v1 + v2
|
v3 = v2 + v1
|
||||||
|
|||||||
@@ -63,7 +63,6 @@
|
|||||||
"name": "maximum"
|
"name": "maximum"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"name": "maximum",
|
|
||||||
"pos_args": [],
|
"pos_args": [],
|
||||||
"args": [
|
"args": [
|
||||||
{
|
{
|
||||||
@@ -149,10 +148,10 @@
|
|||||||
},
|
},
|
||||||
"expr": {
|
"expr": {
|
||||||
"_type": "VariableExpr",
|
"_type": "VariableExpr",
|
||||||
"name": "v1"
|
"name": "v2"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"name": "int"
|
"name": "float"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -162,10 +161,10 @@
|
|||||||
},
|
},
|
||||||
"expr": {
|
"expr": {
|
||||||
"_type": "VariableExpr",
|
"_type": "VariableExpr",
|
||||||
"name": "v2"
|
"name": "v1"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"name": "float"
|
"name": "int"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -177,12 +176,12 @@
|
|||||||
"_type": "BinaryExpr",
|
"_type": "BinaryExpr",
|
||||||
"left": {
|
"left": {
|
||||||
"_type": "VariableExpr",
|
"_type": "VariableExpr",
|
||||||
"name": "v1"
|
"name": "v2"
|
||||||
},
|
},
|
||||||
"operator": "+",
|
"operator": "+",
|
||||||
"right": {
|
"right": {
|
||||||
"_type": "VariableExpr",
|
"_type": "VariableExpr",
|
||||||
"name": "v2"
|
"name": "v1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ type Difference[T] = T
|
|||||||
|
|
||||||
// Complex custom type, containing two values accessible through properties
|
// Complex custom type, containing two values accessible through properties
|
||||||
type GeoLocation = {
|
type GeoLocation = {
|
||||||
lat: Latitude
|
prop lat: Latitude
|
||||||
lon: Longitude
|
prop lon: Longitude
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define operations on our custom type
|
// Define operations on our custom type
|
||||||
@@ -19,23 +19,23 @@ extend GeoLocation {
|
|||||||
// This type is compatible with the `-` operation with another GeoLocation
|
// This type is compatible with the `-` operation with another GeoLocation
|
||||||
// i.e. you can subtract a GeoLocation from another GeoLocation, resulting
|
// i.e. you can subtract a GeoLocation from another GeoLocation, resulting
|
||||||
// in a Difference of GeoLocations
|
// in a Difference of GeoLocations
|
||||||
op __sub__(GeoLocation) -> Difference[GeoLocation]
|
def __sub__: fn(GeoLocation, /) -> Difference[GeoLocation]
|
||||||
}
|
}
|
||||||
|
|
||||||
// For complex generics, you need to specify how the genericity the properties
|
// For complex generics, you need to specify how the genericity the properties
|
||||||
// are handled
|
// are handled
|
||||||
type Difference[GeoLocation] = {
|
type Difference[GeoLocation] = {
|
||||||
lat: Difference[Latitude]
|
prop lat: Difference[Latitude]
|
||||||
lon: Difference[Longitude]
|
prop lon: Difference[Longitude]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple operation defined on our custom types
|
// Simple operation defined on our custom types
|
||||||
extend Latitude {
|
extend Latitude {
|
||||||
op __sub__(Latitude) -> Difference[Latitude]
|
def __sub__: fn(Latitude, /) -> Difference[Latitude]
|
||||||
}
|
}
|
||||||
|
|
||||||
extend Longitude {
|
extend Longitude {
|
||||||
op __sub__(Longitude) -> Difference[Longitude]
|
def __sub__: fn(Longitude, /) -> Difference[Longitude]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Predefined custom predicates that can be referenced in other definitions
|
// Predefined custom predicates that can be referenced in other definitions
|
||||||
@@ -45,13 +45,13 @@ predicate Equatorial(loc: GeoLocation) = (-10 <= loc.lat <= 10)
|
|||||||
predicate Arctic(loc: GeoLocation) = (loc.lat >= 66)
|
predicate Arctic(loc: GeoLocation) = (loc.lat >= 66)
|
||||||
|
|
||||||
type Person = {
|
type Person = {
|
||||||
name: str
|
prop name: str
|
||||||
|
|
||||||
// Property with an inline constraint
|
// Property with an inline constraint
|
||||||
age: Optional[int where (0 <= _ < 150)]
|
prop age: Optional[int where (0 <= _ < 150)]
|
||||||
|
|
||||||
// Property referencing a predicate
|
// Property referencing a predicate
|
||||||
height: float where StrictlyPositive
|
prop height: float where StrictlyPositive
|
||||||
|
|
||||||
home: GeoLocation
|
prop home: GeoLocation
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user