Skip to content

Commit 8491afc

Browse files
committed
Adjust Process::Tms and define keyword_init? and members methods
1 parent 1d7f642 commit 8491afc

File tree

9 files changed

+123
-0
lines changed

9 files changed

+123
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require_relative '../../../spec_helper'
2+
3+
describe "Process::Tms#cstime" do
4+
it "returns cstime attribute" do
5+
cstime = Object.new
6+
Process::Tms.new(nil, nil, nil, cstime).cstime.should == cstime
7+
end
8+
end
9+
10+
describe "Process::Tms#cstime=" do
11+
it "assigns a value to the cstime attribute" do
12+
cstime = Object.new
13+
tms = Process::Tms.new
14+
tms.cstime = cstime
15+
tms.cstime.should == cstime
16+
end
17+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require_relative '../../../spec_helper'
2+
3+
describe "Process::Tms#cutime" do
4+
it "returns cutime attribute" do
5+
cutime = Object.new
6+
Process::Tms.new(nil, nil, cutime, nil).cutime.should == cutime
7+
end
8+
end
9+
10+
describe "Process::Tms#cutime=" do
11+
it "assigns a value to the cutime attribute" do
12+
cutime = Object.new
13+
tms = Process::Tms.new
14+
tms.cutime = cutime
15+
tms.cutime.should == cutime
16+
end
17+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require_relative '../../../spec_helper'
2+
3+
describe "Process::Tms#stime" do
4+
it "returns stime attribute" do
5+
stime = Object.new
6+
Process::Tms.new(nil, stime, nil, nil).stime.should == stime
7+
end
8+
end
9+
10+
describe "Process::Tms#stime=" do
11+
it "assigns a value to the stime attribute" do
12+
stime = Object.new
13+
tms = Process::Tms.new
14+
tms.stime = stime
15+
tms.stime.should == stime
16+
end
17+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require_relative '../../../spec_helper'
2+
3+
describe "Process::Tms#utime" do
4+
it "returns utime attribute" do
5+
utime = Object.new
6+
Process::Tms.new(utime, nil, nil, nil).utime.should == utime
7+
end
8+
end
9+
10+
describe "Process::Tms#utime=" do
11+
it "assigns a value to the ctime attribute" do
12+
utime = Object.new
13+
tms = Process::Tms.new
14+
tms.utime = utime
15+
tms.utime.should == utime
16+
end
17+
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2025 Oracle and/or its affiliates. All rights reserved. This
2+
# code is released under a tri EPL/GPL/LGPL license. You can use it,
3+
# redistribute it and/or modify it under the terms of the:
4+
#
5+
# Eclipse Public License version 2.0, or
6+
# GNU General Public License version 2, or
7+
# GNU Lesser General Public License version 2.1.
8+
9+
require_relative '../../../ruby/spec_helper'
10+
11+
describe "Process::Tms.keyword_init?" do
12+
it "returns nil" do
13+
Process::Tms.keyword_init?.should == nil
14+
end
15+
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2025 Oracle and/or its affiliates. All rights reserved. This
2+
# code is released under a tri EPL/GPL/LGPL license. You can use it,
3+
# redistribute it and/or modify it under the terms of the:
4+
#
5+
# Eclipse Public License version 2.0, or
6+
# GNU General Public License version 2, or
7+
# GNU Lesser General Public License version 2.1.
8+
9+
require_relative '../../../ruby/spec_helper'
10+
11+
describe "Process::Tms.members" do
12+
it "returns attributes" do
13+
Process::Tms.members.should == [:utime, :stime, :cutime, :cstime]
14+
end
15+
end

spec/truffle/process/tms/tms_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2025 Oracle and/or its affiliates. All rights reserved. This
2+
# code is released under a tri EPL/GPL/LGPL license. You can use it,
3+
# redistribute it and/or modify it under the terms of the:
4+
#
5+
# Eclipse Public License version 2.0, or
6+
# GNU General Public License version 2, or
7+
# GNU Lesser General Public License version 2.1.
8+
9+
require_relative '../../../ruby/spec_helper'
10+
11+
describe "Process::Tms" do
12+
it "inherits Struct" do
13+
Process::Tms.superclass.should == Struct
14+
end
15+
end

src/main/ruby/truffleruby/core/struct.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class << self
3333
alias_method :subclass_new, :new
3434
end
3535

36+
# Process:Tms (tms.rb) is duplicating some of this logic and must be kept in sync.
37+
3638
def self.new(*attrs, keyword_init: nil, &block)
3739
klass_name = nil
3840

src/main/ruby/truffleruby/core/tms.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ class Tms < Struct
3434
STRUCT_ATTRS = [:utime, :stime, :cutime, :cstime]
3535
attr_accessor :utime, :stime, :cutime, :cstime
3636

37+
def self.keyword_init?
38+
nil
39+
end
40+
41+
def self.members
42+
STRUCT_ATTRS.dup
43+
end
44+
3745
def self.new(*args, &block)
3846
subclass_new(*args, &block)
3947
end

0 commit comments

Comments
 (0)