Load the tests files from the JSON input

Property definitions

markdown2 $ TestGenerator :: load_tests
	# Load the tests files from the JSON input
	fun load_tests: Map[String, Array[TestCase]] do
		var json = json_file.to_path.read_all.parse_json
		var tests = new HashMap[String, Array[TestCase]]

		for obj in json.as(JsonArray) do
			if not obj isa JsonObject then continue

			var number = obj["example"].as(Int)
			if ignored_tests.has(number) then continue

			var name = "test{number}"

			var section = obj["section"].as(String)
			if not tests.has_key(section) then
				tests[section] = new Array[TestCase]
			end

			var markdown = obj["markdown"].as(String)
			markdown = markdown.replace("\\", "\\\\")
			markdown = markdown.replace("\n", "\\n")
			markdown = markdown.replace("\t", "\\t")

			# fix missing chars in some tests
			if number == 162 then
				markdown = markdown.replace("my url", "my%20url")
			else if number == 467 then
				markdown = markdown.replace("my uri", "my%20uri")
			end

			var html = obj["html"].as(String)
			html = html.replace("\\", "\\\\")
			html = html.replace("\n", "\\n")
			html = html.replace("\t", "\\t")

			tests[section].add(new TestCase(name, markdown, html))
		end

		return tests
	end
lib/markdown2/tests/commonmark_gen.nit:51,2--90,4