File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
com.oracle.graal.python.test/src/com/oracle/graal/python/test/interop
com.oracle.graal.python/src/com/oracle/graal/python/nodes/util Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -182,6 +182,18 @@ public void javaArraySet() {
182
182
assertPrints ("42\n " , source );
183
183
}
184
184
185
+ @ Test
186
+ public void javaArrayBytes () {
187
+ String source = "import java\n " +
188
+ "array = java.type(\" short[]\" )(4)\n " +
189
+ "array[0] = 1\n " +
190
+ "array[1] = 2\n " +
191
+ "array[2] = 3\n " +
192
+ "array[3] = 4\n " +
193
+ "print(bytes(array))\n \n " ;
194
+ assertPrints ("b'\\ x01\\ x02\\ x03\\ x04'\n " , source );
195
+ }
196
+
185
197
@ Test
186
198
public void testPassingFloats () throws UnsupportedEncodingException {
187
199
String source = "import polyglot\n " +
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* The Universal Permissive License (UPL), Version 1.0
@@ -87,6 +87,20 @@ protected byte doByte(byte value) {
87
87
return value ;
88
88
}
89
89
90
+ @ Specialization (rewriteOn = ArithmeticException .class )
91
+ protected byte doShort (short value ) {
92
+ return PInt .byteValueExact (value );
93
+ }
94
+
95
+ @ Specialization (replaces = "doShort" )
96
+ protected byte doShortOvf (short value ) {
97
+ try {
98
+ return PInt .byteValueExact (value );
99
+ } catch (ArithmeticException e ) {
100
+ return handleRangeError (value );
101
+ }
102
+ }
103
+
90
104
@ Specialization (rewriteOn = ArithmeticException .class )
91
105
protected byte doInt (int value ) {
92
106
return PInt .byteValueExact (value );
You can’t perform that action at this time.
0 commit comments