MMQLEngine/mmql/statements/actions/buy_test.go

31 lines
704 B
Go
Raw Normal View History

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,
}
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 )
}
}