upper_lower_method_simple.gravity 449 B

123456789101112131415161718192021
  1. #unittest {
  2. name: "upper() and lower methods for string";
  3. error: NONE;
  4. result: true;
  5. };
  6. func main () {
  7. var s = "Hello World"
  8. var u = s.upper() == "HELLO WORLD"
  9. var l = s.lower() == "hello world"
  10. // calling the method returns the change, but should not physically change the
  11. // base string
  12. s.upper()
  13. var unchanged_u = s == "Hello World"
  14. s.lower()
  15. var unchanged_l = s == "Hello World"
  16. return u and l and unchanged_u and unchanged_l
  17. }