File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
spec/ruby/core/file/shared
src/main/ruby/truffleruby/core Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ Compatibility:
43
43
* Implement negative line numbers for eval (#1482 ).
44
44
* Support refinements for ` #to_s ` called by string interpolation (#2110 , @ssnickolay )
45
45
* Module#using raises error in method scope (#2112 , @ssnickolay )
46
+ * ` File#path ` now returns a new mutable String on every call like MRI (#2115 ).
46
47
47
48
Performance:
48
49
Original file line number Diff line number Diff line change 15
15
@file . send ( @method ) . should be_an_instance_of ( String )
16
16
end
17
17
18
+ it "returns a different String on every call" do
19
+ @file = File . new @path
20
+ path1 = @file . send ( @method )
21
+ path2 = @file . send ( @method )
22
+ path1 . should == path2
23
+ path1 . should_not . equal? ( path2 )
24
+ end
25
+
26
+ it "returns a mutable String" do
27
+ @file = File . new @path . dup . freeze
28
+ path = @file . send ( @method )
29
+ path . should == @path
30
+ path . should_not . frozen?
31
+ path << "test"
32
+ @file . send ( @method ) . should == @path
33
+ end
34
+
18
35
it "calls to_str on argument and returns exact value" do
19
36
path = mock ( 'path' )
20
37
path . should_receive ( :to_str ) . and_return ( @path )
Original file line number Diff line number Diff line change @@ -108,8 +108,6 @@ module Constants
108
108
PATH_SEPARATOR = ':'
109
109
POSIX = Truffle ::POSIX
110
110
111
- attr_reader :path
112
-
113
111
# The mode_t type is 2 bytes (ushort). Instead of getting whatever
114
112
# value happens to be in the least significant 16 bits, just set
115
113
# the value to 0 if it is greater than 0xffff. Also, negative values
@@ -1238,6 +1236,9 @@ def stat
1238
1236
Stat . fstat Primitive . io_fd ( self )
1239
1237
end
1240
1238
1239
+ def path
1240
+ @path . dup
1241
+ end
1241
1242
alias_method :to_path , :path
1242
1243
1243
1244
def truncate ( length )
You can’t perform that action at this time.
0 commit comments