| 1 | public class Main { |
| 2 | public static void main(String[] args) { |
| 3 | inner_classes.TrafficLight red = new inner_classes.TrafficLight.Red(); |
| 4 | inner_classes.TrafficLight yellow = new inner_classes.TrafficLight.Yellow(); |
| 5 | inner_classes.TrafficLight green = new inner_classes.TrafficLight.Green(); |
| 6 | |
| 7 | String redAction = org.rustlang.runtime.Utf8View.toJavaString( |
| 8 | inner_classes.inner_classes.get_light_action(red)); |
| 9 | if (!redAction.equals("Stop")) { |
| 10 | throw new AssertionError("Test failed for Red: expected 'Stop' but got '" + redAction + "'"); |
| 11 | } |
| 12 | |
| 13 | String yellowAction = org.rustlang.runtime.Utf8View.toJavaString( |
| 14 | inner_classes.inner_classes.get_light_action(yellow)); |
| 15 | if (!yellowAction.equals("Caution")) { |
| 16 | throw new AssertionError("Test failed for Yellow: expected 'Caution' but got '" + yellowAction + "'"); |
| 17 | } |
| 18 | |
| 19 | String greenAction = org.rustlang.runtime.Utf8View.toJavaString( |
| 20 | inner_classes.inner_classes.get_light_action(green)); |
| 21 | if (!greenAction.equals("Go")) { |
| 22 | throw new AssertionError("Test failed for Green: expected 'Go' but got '" + greenAction + "'"); |
| 23 | } |
| 24 | |
| 25 | inner_classes.MaybeNumber seven = inner_classes.inner_classes.make_some(7); |
| 26 | inner_classes.MaybeNumber anotherSeven = inner_classes.inner_classes.make_some(7); |
| 27 | inner_classes.MaybeNumber eight = inner_classes.inner_classes.make_some(8); |
| 28 | inner_classes.MaybeNumber.Some someSeven = (inner_classes.MaybeNumber.Some) seven; |
| 29 | if (someSeven.value != 7 || someSeven.component1() != 7) { |
| 30 | throw new AssertionError("Single enum payload should use value and component1()"); |
| 31 | } |
| 32 | |
| 33 | if (!inner_classes.MaybeNumber.eq(seven, anotherSeven)) { |
| 34 | throw new AssertionError("Enum equality should accept matching payload fields"); |
| 35 | } |
| 36 | if (inner_classes.MaybeNumber.eq(seven, eight)) { |
| 37 | throw new AssertionError("Enum equality should reject different payload fields"); |
| 38 | } |
| 39 | |
| 40 | inner_classes.MaybeNumber pairTrue = inner_classes.inner_classes.make_pair(7, true); |
| 41 | inner_classes.MaybeNumber pairFalse = inner_classes.inner_classes.make_pair(7, false); |
| 42 | inner_classes.MaybeNumber.Pair pair = (inner_classes.MaybeNumber.Pair) pairTrue; |
| 43 | if (pair._0 != 7 || !pair._1 || pair.component1() != 7 || !pair.component2()) { |
| 44 | throw new AssertionError("Tuple enum payload should use _0/_1 and component methods"); |
| 45 | } |
| 46 | |
| 47 | inner_classes.MaybeNumber.WithUnit withUnit = (inner_classes.MaybeNumber.WithUnit) |
| 48 | inner_classes.inner_classes.make_with_unit(9); |
| 49 | if (withUnit._1 != 9 || withUnit.component1() != 9 |
| 50 | || inner_classes.inner_classes.read_with_unit(withUnit) != 9) { |
| 51 | throw new AssertionError("Enum field names should retain Rust indexes across ZSTs"); |
| 52 | } |
| 53 | |
| 54 | inner_classes.MaybeNumber.Stats stats = (inner_classes.MaybeNumber.Stats) |
| 55 | inner_classes.inner_classes.make_stats(12, true); |
| 56 | if (stats.count != 12 || !stats.enabled |
| 57 | || stats.component1() != 12 || !stats.component2()) { |
| 58 | throw new AssertionError("Struct-like enum payload should retain source field names"); |
| 59 | } |
| 60 | |