<NME> check_bytestring_methods.lly
<BEF> ADDFILE
<MSG> ByteString.encode now returns Option[String], and ByteString tests.

Now that Option is baked into the core, it's hard to justify having
this method throw an exception when it could return an Option. I've
also added a file to test ByteString methods (currently method, since
ByteString.encode is it).

<DFF> @@ -0,0 +1,23 @@
+var total = 0, failed = 0
+
+define ok(b: Boolean, s: String)
+{
+    total += 1
+
+    if b == false: {
+        stderr.write($"Test ^(total) (^(s)) failed.\n")
+        failed += 1
+    }
+}
+
+ok(B"0".encode("invalidmode").is_none(),        "ByteString.encode with invalid mode fails.")
+ok(B"\000".encode("error").is_none(),           "ByteString.encode with embedded zero fails.")
+ok(B"\195\169".encode("error").unwrap() == "é", "ByteString.encode(error) allows valid utf-8.")
+ok(B"".encode("error").unwrap() == "",          "ByteString.encode(error) allows an empty string.")
+ok(B"asdf".encode("error").unwrap() == "asdf",  "ByteString.encode(error) allows plain ascii.")
+ok(B"\255\255\255".encode("error").is_none(),   "ByteString.encode(error) forbids invalid utf-8 (255 * 3).")
+
+if failed == 0:
+    print($"^(total) of ^(total) tests passed.")
+else:
+    stderr.write($"^(failed) tests have failed.\n")

{'addition_count': 23, 'commit_subject': 'ByteString.encode now returns Option[String], and ByteString tests.', 'deletion_count': 0, 'file_extension': '.lly', 'lang': 'lly', 'license': 'mit', 'repo_name': 'FascinatedBox/lily'}