File tree Expand file tree Collapse file tree 8 files changed +76
-17
lines changed Expand file tree Collapse file tree 8 files changed +76
-17
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ Cases len: 1
2+ First case dir: 3
File renamed without changes.
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import "reflect"
4+
5+ func main () {
6+ // Test creating reflect.SelectCase struct literals
7+ cases := []reflect.SelectCase {
8+ {Dir : reflect .SelectDefault },
9+ }
10+ println ("Cases len:" , len (cases ))
11+ println ("First case dir:" , cases [0 ].Dir )
12+ }
Original file line number Diff line number Diff line change 1+ // Generated file based on struct_literal_interface.go
2+ // Updated when compliance tests are re-run, DO NOT EDIT!
3+
4+ import * as $ from "@goscript/builtin/index.js"
5+
6+ import * as reflect from "@goscript/reflect/index.js"
7+
8+ export async function main ( ) : Promise < void > {
9+ // Test creating reflect.SelectCase struct literals
10+ let cases = $ . arrayToSlice < reflect . SelectCase > ( [ $ . markAsStructValue ( new reflect . SelectCase ( { Dir : reflect . SelectDefault } ) ) ] )
11+ console . log ( "Cases len:" , $ . len ( cases ) )
12+ console . log ( "First case dir:" , cases ! [ 0 ] . Dir )
13+ }
14+
Original file line number Diff line number Diff line change 1+ {
2+ "compilerOptions" : {
3+ "allowImportingTsExtensions" : true ,
4+ "lib" : [
5+ " es2022" ,
6+ " esnext.disposable" ,
7+ " dom"
8+ ],
9+ "module" : " nodenext" ,
10+ "moduleResolution" : " nodenext" ,
11+ "noEmit" : true ,
12+ "paths" : {
13+ "*" : [
14+ " ./*"
15+ ],
16+ "@goscript/*" : [
17+ " ../../../gs/*" ,
18+ " ../../../compliance/deps/*"
19+ ],
20+ "@goscript/github.com/aperturerobotics/goscript/compliance/tests/struct_literal_interface/*" : [
21+ " ./*"
22+ ]
23+ },
24+ "sourceMap" : true ,
25+ "target" : " es2022"
26+ },
27+ "extends" : " ../../../tsconfig.json" ,
28+ "include" : [
29+ " index.ts" ,
30+ " struct_literal_interface.gs.ts"
31+ ]
32+ }
Original file line number Diff line number Diff line change @@ -37,17 +37,17 @@ export {
3737 StructTag ,
3838 StructField ,
3939 ValueError ,
40- SelectDir ,
4140 SelectSend ,
4241 SelectRecv ,
4342 SelectDefault ,
43+ SelectCase ,
4444 bitVector ,
4545} from './types.js'
4646export type {
4747 uintptr ,
4848 Pointer ,
4949 Method ,
50- SelectCase ,
50+ SelectDir ,
5151 SliceHeader ,
5252 StringHeader ,
5353 MapIter ,
Original file line number Diff line number Diff line change @@ -106,24 +106,24 @@ export interface Channel<T = unknown> {
106106}
107107
108108// Select case for channel operations
109- export interface SelectCase {
110- Dir : SelectDir
111- Chan ?: Value // Value representing a channel - optional since default cases don't need it
112- Send ?: Value // Value to send (if Dir is SendDir) - optional since only needed for send cases
113- }
114-
115- // Select direction constants
116- export class SelectDir {
117- constructor ( private _value : number ) { }
109+ export class SelectCase {
110+ public Dir ! : SelectDir
111+ public Chan ?: Value // Value representing a channel - optional since default cases don't need it
112+ public Send ?: Value // Value to send (if Dir is SendDir) - optional since only needed for send cases
118113
119- valueOf ( ) : number {
120- return this . _value
114+ constructor ( init ?: Partial < SelectCase > ) {
115+ if ( init ) {
116+ Object . assign ( this , init )
117+ }
121118 }
122119}
123120
124- export const SelectSend = new SelectDir ( 1 )
125- export const SelectRecv = new SelectDir ( 2 )
126- export const SelectDefault = new SelectDir ( 3 )
121+ // Select direction constants - SelectDir is just an int in Go
122+ export type SelectDir = number
123+
124+ export const SelectSend : SelectDir = 1
125+ export const SelectRecv : SelectDir = 2
126+ export const SelectDefault : SelectDir = 3
127127
128128// Slice header (internal representation)
129129export interface SliceHeader {
You can’t perform that action at this time.
0 commit comments