variables.rs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // SPDX-License-Identifier: Apache-2.0
  2. use crate::build_solidity;
  3. use parity_scale_codec::Encode;
  4. #[test]
  5. fn global_constants() {
  6. // test that error is allowed as a variable name/contract name
  7. let mut runtime = build_solidity(
  8. r##"
  9. int32 constant error = 102 + 104;
  10. contract a {
  11. function test() public payable {
  12. assert(error == 206);
  13. }
  14. }"##,
  15. );
  16. runtime.constructor(0, Vec::new());
  17. runtime.function("test", Vec::new());
  18. let mut runtime = build_solidity(
  19. r##"
  20. string constant foo = "FOO";
  21. contract error {
  22. function test() public payable {
  23. assert(foo == "FOO");
  24. }
  25. }"##,
  26. );
  27. runtime.constructor(0, Vec::new());
  28. runtime.function("test", Vec::new());
  29. let mut runtime = build_solidity(
  30. r##"
  31. string constant foo = "FOO";
  32. contract a {
  33. function test(uint64 error) public payable {
  34. assert(error == 0);
  35. assert(foo == "FOO");
  36. }
  37. }"##,
  38. );
  39. runtime.constructor(0, Vec::new());
  40. runtime.function("test", 0u64.encode());
  41. }