helper_test.go 822 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * ECAL
  3. *
  4. * Copyright 2020 Matthias Ladkau. All rights reserved.
  5. *
  6. * This Source Code Form is subject to the terms of the MIT
  7. * License, If a copy of the MIT License was not distributed with this
  8. * file, You can obtain one at https://opensource.org/licenses/MIT.
  9. */
  10. package scope
  11. import (
  12. "testing"
  13. "devt.de/krotik/ecal/parser"
  14. )
  15. func TestNameFromASTNode(t *testing.T) {
  16. n, _ := parser.Parse("", "foo")
  17. if res := NameFromASTNode(n); res != "block: identifier (Line:1 Pos:1)" {
  18. t.Error("Unexpected result:", res)
  19. return
  20. }
  21. }
  22. func TestScopeConversion(t *testing.T) {
  23. vs := NewScope("foo")
  24. vs.SetValue("a", 1)
  25. vs.SetValue("b", 2)
  26. vs.SetValue("c", 3)
  27. vs2 := ToScope("foo", ToObject(vs))
  28. if vs.String() != vs2.String() {
  29. t.Error("Unexpected result:", vs.String(), vs2.String())
  30. return
  31. }
  32. }