2022-10-21 16:03:06 +00:00
|
|
|
package actions
|
|
|
|
|
|
|
|
import (
|
|
|
|
// "fmt"
|
|
|
|
"testing"
|
|
|
|
engine "github.com/tgckpg/mmqlengine/mmql/engine"
|
|
|
|
stmtd "github.com/tgckpg/mmqlengine/mmql/statements"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestBuyStatement( t *testing.T ) {
|
|
|
|
lexer := engine.Lexer{}
|
|
|
|
supportedStmts := map[string] func( *engine.Lexer ) ( stmtd.IStatement, error ) {
|
|
|
|
"BUY": BuyStatement,
|
|
|
|
"AMOUNT": AmountStatement,
|
2022-10-21 16:35:24 +00:00
|
|
|
"PRODUCT": ProductStatement,
|
2022-10-21 16:03:06 +00:00
|
|
|
}
|
|
|
|
lexer.SupportedStmts = &supportedStmts
|
|
|
|
|
|
|
|
_, err := lexer.Parse( `
|
|
|
|
BUY 1 SHARES OF BTC_ETF
|
|
|
|
FOR 10 USD
|
|
|
|
FROM "MyBrokerAccount"
|
|
|
|
WITH LIMIT OF PURCHASING_POWER( "MyBrokerAccount", "QQQ" )
|
|
|
|
FOR EVERY
|
|
|
|
1 BTC OF USD_BTC SOLD
|
|
|
|
FROM "CoinBase"
|
|
|
|
` )
|
|
|
|
if err != nil {
|
|
|
|
t.Error( err )
|
|
|
|
}
|
|
|
|
}
|