(t *testing.T)
| 187 | } |
| 188 | |
| 189 | func TestReflectionMethodCalls(t *testing.T) { |
| 190 | rt := NewRuntime() |
| 191 | defer rt.Close() |
| 192 | ctx := rt.NewContext() |
| 193 | defer ctx.Close() |
| 194 | |
| 195 | constructor, _ := ctx.BindClass(&Person{}) |
| 196 | require.False(t, constructor.IsException()) |
| 197 | |
| 198 | ctx.Globals().Set("Person", constructor) |
| 199 | |
| 200 | // Test method calls and private method accessibility |
| 201 | result := ctx.Eval(` |
| 202 | let person = new Person(); |
| 203 | person.firstName = "Alice"; |
| 204 | person.lastName = "Johnson"; |
| 205 | person.age = 25; |
| 206 | person.isActive = true; |
| 207 | |
| 208 | [ |
| 209 | person.GetFullName(), |
| 210 | person.IncrementAge(5), |
| 211 | person.age, |
| 212 | typeof person.getSecret // Should be undefined (private method) |
| 213 | ]; |
| 214 | `) |
| 215 | defer result.Free() |
| 216 | |
| 217 | require.False(t, result.IsException()) |
| 218 | |
| 219 | require.Equal(t, "Alice Johnson", result.GetIdx(0).ToString()) // Changed: String() → ToString() |
| 220 | require.Equal(t, int32(30), result.GetIdx(1).ToInt32()) // Changed: Int32() → ToInt32() |
| 221 | require.Equal(t, int32(30), result.GetIdx(2).ToInt32()) // Changed: Int32() → ToInt32() |
| 222 | require.Equal(t, "undefined", result.GetIdx(3).ToString()) // Changed: String() → ToString() |
| 223 | } |
| 224 | |
| 225 | func TestReflectionMultipleReturnValues(t *testing.T) { |
| 226 | rt := NewRuntime() |
nothing calls this directly
no test coverage detected