Skip to content

Instantly share code, notes, and snippets.

@stepancheg
Created July 1, 2019 00:47
Show Gist options
  • Save stepancheg/c68a83f8a0e5309ad8cec8ad4283658a to your computer and use it in GitHub Desktop.
Save stepancheg/c68a83f8a0e5309ad8cec8ad4283658a to your computer and use it in GitHub Desktop.
#[test]
fn test_bool_1() {
do_conformance_test("tests/rust-testcases/bool.sky", "# Boolean tests\n\nTrue + 9223372036854775807 ### Type of parameters mismatch\n")
}
#[test]
fn test_struct_1() {
do_conformance_test("tests/rust-testcases/struct.sky", "# Struct tests\n\n# Comparison\nassert_(struct() == struct())\nassert_(struct(a=1) == struct(a=1))\nassert_(struct(a=1, b=False) == struct(a=1, b=False))\n\n# Order of fields is not important for comparison\nassert_(struct(a=1, b=2) == struct(b=2, a=1))\n\n# Inequality\nassert_(struct(a=2) != struct())\nassert_(struct() != struct(a=2))\nassert_(struct(a=2) != struct(a=1))\nassert_(struct(a=2) != struct(b=1))\nassert_(struct(a=1, b=2) != struct(a=1, b=\"2\"))\n")
}
#[test]
fn test_regression_1() {
do_conformance_test("tests/rust-testcases/regression.sky", "# Regression for https://github.com/google/starlark-rust/issues/10\n\"abc\" * True ### Type of parameters mismatch")
}
#[test]
fn test_regression_4() {
do_conformance_test("tests/rust-testcases/regression.sky", "\n\n\n# Make sure int * string works as well as string * int\nassert_eq(3 * \"abc\", \"abcabcabc1\")\nassert_eq(\"abc\" * 3, \"abcabcabc\")\n")
}
#[test]
fn test_josharian_fuzzing_1() {
do_conformance_test("tests/rust-testcases/josharian_fuzzing.sky", "# This file contains the list of example reported by https://github.com/josharian\n# as part of his fuzzing of starlark-rust\n\n# https://github.com/google/starlark-rust/issues/44: whitespace isn\'t required between some tokens\nassert_eq(6or(), 6)\n# 6burgle still generates a parse error.\n6burgle ### [CP01]")
}
#[test]
fn test_josharian_fuzzing_9() {
do_conformance_test("tests/rust-testcases/josharian_fuzzing.sky", "\n\n\n\n\n\n\n\n# https://github.com/google/starlark-rust/issues/56: Non whitespace after 0 should be allowed.\nassert_eq(0in[1,2,3], False)")
}
#[test]
fn test_josharian_fuzzing_12() {
do_conformance_test("tests/rust-testcases/josharian_fuzzing.sky", "\n\n\n\n\n\n\n\n\n\n\n# https://github.com/google/starlark-rust/issues/61: panic on bad range using string.index\nassert_eq(\'a\'.find(\'\', 1, 0), -1)\nassert_eq(\'a\'.rfind(\'\', 1, 0), -1)\n\'a\'.index(\'\', 1, 0) ### [UF00]\n\'a\'.rindex(\'\', 1, 0) ### [UF00]")
}
#[test]
fn test_josharian_fuzzing_18() {
do_conformance_test("tests/rust-testcases/josharian_fuzzing.sky", "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# https://github.com/google/starlark-rust/issues/64: alphabetize dir entries\nassert_eq(dir(\"\"), sorted(dir(\"\")))")
}
#[test]
fn test_josharian_fuzzing_21() {
do_conformance_test("tests/rust-testcases/josharian_fuzzing.sky", "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# https://github.com/google/starlark-rust/issues/66: / is only for floats (which we don\'t support)\n1 / 1 ### [CV00]\n")
}
#[test]
fn test_dict_1() {
do_conformance_test("tests/rust-testcases/dict.sky", "# Dict tests\n\n{[]: 1 for x in [1]} ### Value is not hashable\n")
}
#[test]
fn test_string_1() {
do_conformance_test("tests/rust-testcases/string.sky", "# String tests\n\n\n# From Starlark spec\n\n# The conversion\'s operand is the next element of args, which must be a tuple\n# with exactly one component per conversion,\n\nassert_eq(\"ab1cd2ef\", \"ab%scd%sef\" % [1, 2])\n\n# ... unless the format string contains\n# only a single conversion, in which case args itself is its operand.\nassert_eq(\"ab[1]cd\", \"ab%scd\" % [1])\n\n\n# Issue #43\n\'\'%(0) ### The type \'int\' is not iterable")
}
#[test]
fn test_string_19() {
do_conformance_test("tests/rust-testcases/string.sky", "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\'\'%(0,) ### Too many arguments for format string\n")
}
#[test]
fn test_int_1() {
do_conformance_test("tests/rust-testcases/int.sky", "# Integer tests\n\n9223372036854775807 + 1 ### Integer overflow")
}
#[test]
fn test_int_5() {
do_conformance_test("tests/rust-testcases/int.sky", "\n\n\n\n-9223372036854775807 - 2 ### Integer overflow")
}
#[test]
fn test_int_7() {
do_conformance_test("tests/rust-testcases/int.sky", "\n\n\n\n\n\n9223372036854775807 * 2 ### Integer overflow")
}
#[test]
fn test_int_9() {
do_conformance_test("tests/rust-testcases/int.sky", "\n\n\n\n\n\n\n\nint_min = -9223372036854775807 - 1\n-int_min ### Integer overflow")
}
#[test]
fn test_int_12() {
do_conformance_test("tests/rust-testcases/int.sky", "\n\n\n\n\n\n\n\n\n\n\nint_min = -9223372036854775807 - 1\nint_min // -1 ### Integer overflow")
}
#[test]
fn test_int_15() {
do_conformance_test("tests/rust-testcases/int.sky", "\n\n\n\n\n\n\n\n\n\n\n\n\n\nint_min = -9223372036854775807 - 1\nassert_eq(0, int_min % -1)\nassert_eq(0, int_min % int_min)\nassert_eq(9223372036854775806, int_min % 9223372036854775807)\nassert_eq(-1, 9223372036854775807 % int_min)\n\n\n# Issue #98\nassert_eq(4, 7 - 2 - 1)\n\n# Issue 152\nassert_eq(0, int(\"0\", 8))\nassert_eq(0, int(\"-0\", 8))\nassert_eq(0, int(\"+0\", 8))\n")
}
#[test]
fn test_mutation_during_iteration_1() {
do_conformance_test("tests/rust-testcases/mutation_during_iteration.sky", "# Test for disallowing mutation during iteration.\n# https://github.com/bazelbuild/starlark/blob/815aed90b552fa70adca4dc18d73082fae83b538/design.md#no-mutation-during-iteration\na = [1, 2, 3]\ndef fun():\n for x in a:\n a.append(1)\n\nfun() ### Cannot mutate an iterable while iterating")
}
#[test]
fn test_mutation_during_iteration_10() {
do_conformance_test("tests/rust-testcases/mutation_during_iteration.sky", "\n\n\n\n\n\n\n\n\ndef increment_values(dict):\n for k in dict:\n dict[k] += 1\n\ndict = {\"one\": 1, \"two\": 2}\nincrement_values(dict) ### Cannot mutate an iterable while iterating")
}
#[test]
fn test_mutation_during_iteration_17() {
do_conformance_test("tests/rust-testcases/mutation_during_iteration.sky", "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# modifying deep content is allowed\ndef modify_deep_content():\n list = [[0], [1], [2]]\n for x in list:\n list[x[0]][0] = 2 * x[0]\n return list\nassert_eq(modify_deep_content(), [[0], [2], [4]])")
}
#[test]
fn test_mutation_during_iteration_25() {
do_conformance_test("tests/rust-testcases/mutation_during_iteration.sky", "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment