Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
vars {
account $a = @src
}
send [USD/2 10] (
source = @world
destination = @dest:$a
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-account-interpolation"
],
"testCases": [
{
"it": "interpolates the name of an account var whose origin is another account",
"expect.postings": [
{
"source": "world",
"destination": "dest:src",
"amount": 10,
"asset": "USD/2"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
vars {
number $n = 42
}
send [USD/2 10] (
source = @world
destination = @account:$n
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-account-interpolation"
],
"testCases": [
{
"it": "interpolates a number var",
"expect.postings": [
{
"source": "world",
"destination": "account:42",
"amount": 10,
"asset": "USD/2"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
vars {
string $id = "alice"
}
send [USD/2 10] (
source = @world
destination = @users:$id:wallet
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-account-interpolation"
],
"testCases": [
{
"it": "interpolates a string var",
"expect.postings": [
{
"source": "world",
"destination": "users:alice:wallet",
"amount": 10,
"asset": "USD/2"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
vars {
account $acc = @src
}
send [USD/2 10] (
source = $acc
destination = @dest
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"testCases": [
{
"it": "uses an account var initialized from a literal",
"balances": [
{
"account": "src",
"asset": "USD/2",
"amount": 100
}
],
"expect.postings": [
{
"source": "src",
"destination": "dest",
"amount": 10,
"asset": "USD/2"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
send [USD/2 1000000000000000000000000001] (
source = @world
destination = {
1/2 to @a
remaining to @b
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"testCases": [
{
"it": "splits an amount beyond int64",
"expect.postings": [
{
"source": "world",
"destination": "a",
"amount": 500000000000000000000000001,
"asset": "USD/2"
},
{
"source": "world",
"destination": "b",
"amount": 500000000000000000000000000,
"asset": "USD/2"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
send [USD/2 100] (
source = @world
destination = {
1/4 to @a
3/4 to @b
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"testCases": [
{
"it": "portions summing to exactly 1 need no remaining",
"expect.postings": [
{
"source": "world",
"destination": "a",
"amount": 25,
"asset": "USD/2"
},
{
"source": "world",
"destination": "b",
"amount": 75,
"asset": "USD/2"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
send [USD/2 7] (
source = @world
destination = {
1/2 to @a
remaining to @b
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"testCases": [
{
"it": "the odd unit goes to the earliest share",
"expect.postings": [
{
"source": "world",
"destination": "a",
"amount": 4,
"asset": "USD/2"
},
{
"source": "world",
"destination": "b",
"amount": 3,
"asset": "USD/2"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
send [USD/2 100] (
source = @world
destination = {
1/6 to @a
1/6 to @b
remaining to @c
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"testCases": [
{
"it": "each of the first shares gets one leftover unit",
"expect.postings": [
{
"source": "world",
"destination": "a",
"amount": 17,
"asset": "USD/2"
},
{
"source": "world",
"destination": "b",
"amount": 17,
"asset": "USD/2"
},
{
"source": "world",
"destination": "c",
"amount": 66,
"asset": "USD/2"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
send [USD/2 10000] (
source = @world
destination = {
19/100 to @a
remaining to @b
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"testCases": [
{
"it": "no share is adjusted when the split is exact",
"expect.postings": [
{
"source": "world",
"destination": "a",
"amount": 1900,
"asset": "USD/2"
},
{
"source": "world",
"destination": "b",
"amount": 8100,
"asset": "USD/2"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
send [USD/2 100] (
source = @world
destination = {
remaining to @dest
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"testCases": [
{
"it": "a lone remaining clause takes everything",
"expect.postings": [
{
"source": "world",
"destination": "dest",
"amount": 100,
"asset": "USD/2"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
send [USD/2 1001] (
source = @world
destination = {
1/7 to @a
2/7 to @b
remaining to @c
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"testCases": [
{
"it": "the shares sum back to the amount",
"expect.postings": [
{
"source": "world",
"destination": "a",
"amount": 143,
"asset": "USD/2"
},
{
"source": "world",
"destination": "b",
"amount": 286,
"asset": "USD/2"
},
{
"source": "world",
"destination": "c",
"amount": 572,
"asset": "USD/2"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
vars {
monetary $bal = balance(@src, USD/2)
}
send $bal (
source = @src
destination = @dest
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"testCases": [
{
"it": "sends the balance read into a var",
"balances": [
{
"account": "src",
"asset": "USD/2",
"amount": 100
}
],
"expect.postings": [
{
"source": "src",
"destination": "dest",
"amount": 100,
"asset": "USD/2"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
send [USD/2 42] (
source = @a allowing overdraft up to [USD/2 5]
destination = @dest
)
Loading
Loading